diff --git a/RustTools/App.config b/RustTools/App.config new file mode 100644 index 0000000..935bcd2 --- /dev/null +++ b/RustTools/App.config @@ -0,0 +1,24 @@ + + + + +
+
+ + + + + + 1 + + + + + 1 + + + + + + + \ No newline at end of file diff --git a/RustTools/App.xaml b/RustTools/App.xaml index e89d519..8ff8621 100644 --- a/RustTools/App.xaml +++ b/RustTools/App.xaml @@ -12,26 +12,64 @@ + - - + + + + + + + + + + + + + + + + + + + Width="500" + MaxLines="2" + Style="{StaticResource BodyStrongTextBlockStyle}" + Text="{Binding Description}" + TextTrimming="CharacterEllipsis" + TextWrapping="Wrap" /> + + + + + - + + diff --git a/RustTools/App.xaml.cs b/RustTools/App.xaml.cs index ebbf1d7..c3323b0 100644 --- a/RustTools/App.xaml.cs +++ b/RustTools/App.xaml.cs @@ -112,7 +112,7 @@ public partial class App : Microsoft.UI.Xaml.Application protected async override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) { - + base.OnLaunched(args); var activatedEventArgs = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs(); if (activatedEventArgs.Kind == Microsoft.Windows.AppLifecycle.ExtendedActivationKind.File) @@ -154,7 +154,7 @@ public partial class App : Microsoft.UI.Xaml.Application } else { - base.OnLaunched(args); + //MainWindow.Activate(); await App.GetService().ActivateAsync(args); } } diff --git a/RustTools/Assets/Icon.ico b/RustTools/Assets/Icon.ico new file mode 100644 index 0000000..5d06b9f Binary files /dev/null and b/RustTools/Assets/Icon.ico differ diff --git a/RustTools/Assets/LockScreenLogo.scale-200.png b/RustTools/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57a..0000000 Binary files a/RustTools/Assets/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/RustTools/Assets/SplashScreen.scale-200.png b/RustTools/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1..0000000 Binary files a/RustTools/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/RustTools/Assets/Square150x150Logo.scale-200.png b/RustTools/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec..0000000 Binary files a/RustTools/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/RustTools/Assets/Square44x44Logo.scale-200.png b/RustTools/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2..0000000 Binary files a/RustTools/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/RustTools/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/RustTools/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce..0000000 Binary files a/RustTools/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/RustTools/Assets/StoreLogo.png b/RustTools/Assets/StoreLogo.png deleted file mode 100644 index 7385b56..0000000 Binary files a/RustTools/Assets/StoreLogo.png and /dev/null differ diff --git a/RustTools/Assets/Wide310x150Logo.scale-200.png b/RustTools/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b..0000000 Binary files a/RustTools/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/RustTools/Assets/WindowIcon.ico b/RustTools/Assets/WindowIcon.ico index b6c9dd1..c89274d 100644 Binary files a/RustTools/Assets/WindowIcon.ico and b/RustTools/Assets/WindowIcon.ico differ diff --git a/RustTools/DataList/ModListResponse.cs b/RustTools/DataList/ModListResponse.cs index a0ed4de..6403bfb 100644 --- a/RustTools/DataList/ModListResponse.cs +++ b/RustTools/DataList/ModListResponse.cs @@ -2,68 +2,6 @@ using System.Collections.Generic; using Newtonsoft.Json; -public class ModData -{ - [JsonProperty("id")] - public string Id - { - get; set; - } - - [JsonProperty("name")] - public string Name - { - get; set; - } - - [JsonProperty("describe")] - public string Description - { - get; set; - } - - [JsonProperty("icon")] - public string Icon - { - get; set; - } - - [JsonProperty("developer")] - public string Developer - { - get; set; - } - - [JsonProperty("downloadNumber")] - public string DownloadNumber - { - get; set; - } - - [JsonProperty("updateTime")] - public DateTime UpdateTime - { - get; set; - } - - [JsonProperty("coinNumber")] - public string CoinNumber - { - get; set; - } - - [JsonProperty("unitNumber")] - public string UnitNumber - { - get; set; - } - - [JsonProperty("versionNumber")] - public string VersionNumber - { - get; set; - } -} public class ModListResponse { @@ -84,4 +22,66 @@ public class ModListResponse { get; set; } + public class ModData + { + [JsonProperty("id")] + public string Id + { + get; set; + } + + [JsonProperty("name")] + public string Name + { + get; set; + } + + [JsonProperty("describe")] + public string Description + { + get; set; + } + + [JsonProperty("icon")] + public string Icon + { + get; set; + } + + [JsonProperty("developer")] + public string Developer + { + get; set; + } + + [JsonProperty("downloadNumber")] + public string DownloadNumber + { + get; set; + } + + [JsonProperty("updateTime")] + public DateTime UpdateTime + { + get; set; + } + + [JsonProperty("coinNumber")] + public string CoinNumber + { + get; set; + } + + [JsonProperty("unitNumber")] + public string UnitNumber + { + get; set; + } + + [JsonProperty("versionNumber")] + public string VersionNumber + { + get; set; + } + } } \ No newline at end of file diff --git a/RustTools/MainWindow.xaml.cs b/RustTools/MainWindow.xaml.cs index 7431703..ea02836 100644 --- a/RustTools/MainWindow.xaml.cs +++ b/RustTools/MainWindow.xaml.cs @@ -1,5 +1,8 @@ -using RustTools.Helpers; +using System.Resources; +using Microsoft.UI.Xaml; +using RustTools.Helpers; using RustTools.muqing; +using Windows.Storage; using Windows.UI.ViewManagement; namespace RustTools; @@ -8,30 +11,23 @@ public sealed partial class MainWindow : WindowEx { private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue; - private readonly UISettings settings; + private readonly UISettings settings = new(); public MainWindow() { - //gj.SetBackTheme(this); + gj.SetBackTheme(this); InitializeComponent(); - //AppWindow.SetIcon("Assets/tool.png"); + //gj.sc("lujing"+ AppContext.BaseDirectory); + //Resources AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico")); + //AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico")); Content = null; Title = "AppDisplayName".GetLocalized(); // Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239 dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread(); - settings = new UISettings(); - settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event - //settings.Color - //if(wj.cz(wj.FILE.UUID)) - //{ - // gj.sc(wj.dqwb(wj.FILE.UUID)); - //} - //else - //{ - // wj.xrwb("win.uuid", gj.GetUUID()); - //} + settings.ColorValuesChanged += Settings_ColorValuesChanged; + // cannot use FrameworkElement.ActualThemeChanged event } // this handles updating the caption button colors correctly when indows system theme is changed diff --git a/RustTools/RustTools.csproj b/RustTools/RustTools.csproj index 1ccf886..06295a2 100644 --- a/RustTools/RustTools.csproj +++ b/RustTools/RustTools.csproj @@ -30,11 +30,13 @@ D:\RustTools + + @@ -42,6 +44,9 @@ + + + @@ -70,6 +75,12 @@ True \ + + MSBuild:Compile + + + MSBuild:Compile + MSBuild:Compile @@ -96,10 +107,6 @@ - - - - true diff --git a/RustTools/Styles/TitleSubtitleControl.cs b/RustTools/Styles/TitleSubtitleControl.cs new file mode 100644 index 0000000..e015e61 --- /dev/null +++ b/RustTools/Styles/TitleSubtitleControl.cs @@ -0,0 +1,54 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Documents; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.Foundation.Collections; + +namespace RustTools.Styles; +public sealed class TitleSubtitleControl : Control +{ + public TitleSubtitleControl() + { + DefaultStyleKey = typeof(TitleSubtitleControl); + } + + public string TitleText + { + get + { + return (string)GetValue(TitleTextProperty); + } + set + { + SetValue(TitleTextProperty, value); + } + } + + public static readonly DependencyProperty TitleTextProperty = + DependencyProperty.Register("TitleText", typeof(string), typeof(TitleSubtitleControl), new PropertyMetadata("")); + + public string SubtitleText + { + get + { + return (string)GetValue(SubtitleTextProperty); + } + set + { + SetValue(SubtitleTextProperty, value); + } + } + + public static readonly DependencyProperty SubtitleTextProperty = + DependencyProperty.Register("SubtitleText", typeof(string), typeof(TitleSubtitleControl), new PropertyMetadata("")); +} \ No newline at end of file diff --git a/RustTools/Styles/TitleSubtitleControlStyle.xaml b/RustTools/Styles/TitleSubtitleControlStyle.xaml new file mode 100644 index 0000000..afc325d --- /dev/null +++ b/RustTools/Styles/TitleSubtitleControlStyle.xaml @@ -0,0 +1,22 @@ + + + + diff --git a/RustTools/Themes/Generic.xaml b/RustTools/Themes/Generic.xaml new file mode 100644 index 0000000..71528c2 --- /dev/null +++ b/RustTools/Themes/Generic.xaml @@ -0,0 +1,19 @@ + + + + diff --git a/RustTools/ViewModels/HomePageViewModel.cs b/RustTools/ViewModels/HomePageViewModel.cs index 8a08719..7ab3e76 100644 --- a/RustTools/ViewModels/HomePageViewModel.cs +++ b/RustTools/ViewModels/HomePageViewModel.cs @@ -8,8 +8,8 @@ namespace RustTools.ViewModels; public partial class HomePageViewModel : ObservableRecipient { - public ObservableCollection randomList = new(); - public ObservableCollection latestTimeList = new(); + public ObservableCollection randomList = new(); + public ObservableCollection latestTimeList = new(); public HomePageViewModel() { diff --git a/RustTools/ViewModels/RankingViewModel.cs b/RustTools/ViewModels/RankingViewModel.cs index 9748fd9..19c39e9 100644 --- a/RustTools/ViewModels/RankingViewModel.cs +++ b/RustTools/ViewModels/RankingViewModel.cs @@ -1,10 +1,27 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; +using System.Net.Http.Json; +using CommunityToolkit.Mvvm.ComponentModel; +using Newtonsoft.Json; +using RustTools.muqing; namespace RustTools.ViewModels; public partial class RankingViewModel : ObservableRecipient { + public ObservableCollection RankingList { get; set; } = new(); public RankingViewModel() { + Init(); + } + private async void Init() + { + //List必须小于10才能重新加载 + var StringList = await ApiFox.mod.list("downloadNumber", "10", ""); + var modData = JsonConvert.DeserializeObject(StringList); + foreach (var item in modData.Data) + { + item.Icon = item.Icon.Equals("") ? "/Assets/image/image.svg" : item.Icon.Replace("..", "https://rust.coldmint.top"); + RankingList.Add(item); + } } } diff --git a/RustTools/ViewModels/SettingsViewModel.cs b/RustTools/ViewModels/SettingsViewModel.cs index 3318681..0d8a901 100644 --- a/RustTools/ViewModels/SettingsViewModel.cs +++ b/RustTools/ViewModels/SettingsViewModel.cs @@ -13,6 +13,7 @@ using Windows.ApplicationModel; using Windows.Storage.AccessCache; using Windows.Storage.Pickers; using Windows.Storage; +using RustTools.muqing; namespace RustTools.ViewModels; diff --git a/RustTools/Views/ConcernPage.xaml b/RustTools/Views/ConcernPage.xaml index 6a83137..6bca285 100644 --- a/RustTools/Views/ConcernPage.xaml +++ b/RustTools/Views/ConcernPage.xaml @@ -18,17 +18,19 @@ - + ScrollViewer.VerticalScrollBarVisibility="Hidden" + SelectionChanged="ListViewA_SelectionChanged" + SelectionMode="Single" /> (); InitializeComponent(); - } - - private void ItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args) - { } + private void Page_SizeChanged(object sender, SizeChangedEventArgs e) { @@ -47,7 +45,7 @@ public sealed partial class ConcernPage : Page // ǷΪЧֵ if (!double.IsNaN(height) && !double.IsInfinity(height) && height > 16) { - ListViewA.Height = height - 16; + ListViewA.Height = height - 36; ListViewB.Height = height - 16; } else @@ -56,4 +54,24 @@ public sealed partial class ConcernPage : Page ListViewB.Height = 500; // ʵĬֵ } } + + private void ItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args) + { + gj.sc("You invoked "); + } + private void ListViewA_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // ȡǰѡеĿ + var selectedItem = ListViewA.SelectedItem; + gj.sc(selectedItem); + } + + private void ListViewA_Loaded(object sender, RoutedEventArgs e) + { + // ǷĿĬѡΪһ + if (ListViewA.Items.Count > 0) + { + ListViewA.SelectedIndex = 0; + } + } } diff --git a/RustTools/Views/HomePage.xaml b/RustTools/Views/HomePage.xaml index 836fdce..0e7c69c 100644 --- a/RustTools/Views/HomePage.xaml +++ b/RustTools/Views/HomePage.xaml @@ -10,41 +10,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" SizeChanged="Page_SizeChanged" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - - @@ -81,10 +46,9 @@ diff --git a/RustTools/Views/HomePage.xaml.cs b/RustTools/Views/HomePage.xaml.cs index 0dd856e..2183f22 100644 --- a/RustTools/Views/HomePage.xaml.cs +++ b/RustTools/Views/HomePage.xaml.cs @@ -30,6 +30,8 @@ public sealed partial class HomePage : Page ViewModel.random(); ViewModel.Latest(); InitializeComponent(); + ListA.ItemClick += ListAClick; + ListB.ItemClick += ListAClick; } private void Page_SizeChanged(object sender, SizeChangedEventArgs e) @@ -41,9 +43,9 @@ public sealed partial class HomePage : Page //Banner.Height = a; } - private void ListAClick(object sender, ItemClickEventArgs e) + public static void ListAClick(object sender, ItemClickEventArgs e) { - if (e.ClickedItem is not ModData item) { return; } + if (e.ClickedItem is not ModListResponse.ModData item) { return; } // Ѵڵ ModulePage򼤻 var existingWindow = ModulePage.ModulePageList.FirstOrDefault(window => window.Mod.Id == item.Id); diff --git a/RustTools/Views/RankingPage.xaml b/RustTools/Views/RankingPage.xaml index 7cba7f8..2b4c6b2 100644 --- a/RustTools/Views/RankingPage.xaml +++ b/RustTools/Views/RankingPage.xaml @@ -1,15 +1,49 @@ - + - + SizeChanged="Page_SizeChanged" + mc:Ignorable="d"> + + + + + + + + + + + + + + + + + + + diff --git a/RustTools/Views/RankingPage.xaml.cs b/RustTools/Views/RankingPage.xaml.cs index b818610..5be4d80 100644 --- a/RustTools/Views/RankingPage.xaml.cs +++ b/RustTools/Views/RankingPage.xaml.cs @@ -13,6 +13,9 @@ using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; using RustTools.ViewModels; +using Newtonsoft.Json; +using RustTools.muqing; +using System.Collections; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -27,9 +30,18 @@ public sealed partial class RankingPage : Page { get; set; } + public RankingPage() { ViewModel=App.GetService(); InitializeComponent(); + list.ItemClick +=HomePage.ListAClick; + + } + + + private void Page_SizeChanged(object sender, SizeChangedEventArgs e) + { + list.Height = ActualHeight - 100; } } diff --git a/RustTools/Views/ShellPage.xaml.cs b/RustTools/Views/ShellPage.xaml.cs index 3403823..a717527 100644 --- a/RustTools/Views/ShellPage.xaml.cs +++ b/RustTools/Views/ShellPage.xaml.cs @@ -5,6 +5,7 @@ using Microsoft.UI.Xaml.Media; using RustTools.Contracts.Services; using RustTools.Helpers; +using RustTools.muqing; using RustTools.ViewModels; using Windows.System; @@ -41,11 +42,13 @@ public sealed partial class ShellPage : Page App.MainWindow.ExtendsContentIntoTitleBar = true; App.MainWindow.SetTitleBar(AppTitleBar); App.MainWindow.Activated += MainWindow_Activated; + App.MainWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico")); AppTitleBarText.Text = "app_name".GetLocalized() +" " +"app_version".GetLocalized(); } private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { + //gj.sc(RequestedTheme); TitleBarHelper.UpdateTitleBar(RequestedTheme); KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu)); diff --git a/RustTools/Views/UserPage.xaml b/RustTools/Views/UserPage.xaml index bb09bfa..dee02d9 100644 --- a/RustTools/Views/UserPage.xaml +++ b/RustTools/Views/UserPage.xaml @@ -1,15 +1,115 @@ - + + xmlns:styles="using:RustTools.Styles" + mc:Ignorable="d"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +