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">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RustTools/WindowUI/ImportModule.xaml b/RustTools/WindowUI/ImportModule.xaml
index f1c2a01..8986512 100644
--- a/RustTools/WindowUI/ImportModule.xaml
+++ b/RustTools/WindowUI/ImportModule.xaml
@@ -12,7 +12,6 @@
MinWidth="500"
MinHeight="500"
mc:Ignorable="d">
-
diff --git a/RustTools/WindowUI/ModulePage.xaml b/RustTools/WindowUI/ModulePage.xaml
index 99d2ed1..f3005df 100644
--- a/RustTools/WindowUI/ModulePage.xaml
+++ b/RustTools/WindowUI/ModulePage.xaml
@@ -18,8 +18,7 @@
-
-
+
ModulePageList = new();
- public ObservableCollection ScreenshotsList =new();
+ public ObservableCollection ScreenshotsList = new();
public ModInfo.Data Mod { get; set; } = new();
public ModulePage(string v)
{
- gj.SetBackTheme(this);
+
+
+ // ôڱɫ
InitializeComponent();
ExtendsContentIntoTitleBar = true;
+ gj.SetBackTheme(this);
init(v);
+ var frame = App.AppTitlebar as FrameworkElement;
+ if (frame != null)
+ {
+ gj.UpdateTitleBar(this, frame.ActualTheme);
+ grid.RequestedTheme = frame.ActualTheme;
+ }
+ }
+
+
+ static bool IsColorLight(Windows.UI.Color clr)
+ {
+ return (((5 * clr.G) + (2 * clr.R) + clr.B) > (8 * 128));
}
private async void init(string v)
{
@@ -81,7 +88,7 @@ public sealed partial class ModulePage : WindowEx
private void WindowEx_SizeChanged(object sender, WindowSizeChangedEventArgs args)
{
- DescriptionText.Width = Width-50;
+ DescriptionText.Width = Width - 50;
}
@@ -114,7 +121,7 @@ public sealed partial class ModulePage : WindowEx
break;
case "DownLoadButton":
- gj.sc("شģ:"+Mod.Link);
+ gj.sc("شģ:" + Mod.Link);
break;
}
}
diff --git a/RustTools/muqing/IniHelper.cs b/RustTools/muqing/IniHelper.cs
index 54e18ad..3cdcdb0 100644
--- a/RustTools/muqing/IniHelper.cs
+++ b/RustTools/muqing/IniHelper.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using RustTools.muqing;
+using Windows.Storage;
public class IniHelper
{
@@ -121,6 +122,37 @@ public class IniHelper
sw.WriteLine(); // Add an empty line for readability
}
}
+ ///更高级的配置保存方式 为什么不用呢,因为不可视化保存后是个TMD二进制
+ //private void Load()
+ //{
+ // ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
+
+ // // load a setting that is local to the device
+ // String localValue = localSettings.Values["test setting"] as string;
+
+ // // load a composite setting
+ // Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)localSettings.Values["FontInfo"];
+ // if (composite != null)
+ // {
+ // String fontName = composite["Font"] as string;
+ // int fontSize = (int)composite["FontSize"];
+ // gj.sc(fontName + " " + ApplicationData.Current.LocalSettings.Locality);
+ // }
+ //}
+
+ //private void save()
+ //{
+ // ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
+
+ // // Save a setting locally on the device
+ // localSettings.Values["test setting"] = "a device specific setting";
+
+ // // Save a composite setting locally on the device
+ // Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
+ // composite["Font"] = "Calibri";
+ // composite["FontSize"] = 11;
+ // localSettings.Values["FontInfo"] = composite;
+ //}
///
/// 读取配置数据
diff --git a/RustTools/muqing/gj.cs b/RustTools/muqing/gj.cs
index a0c4496..af3e06b 100644
--- a/RustTools/muqing/gj.cs
+++ b/RustTools/muqing/gj.cs
@@ -6,11 +6,15 @@ using System.Diagnostics.Tracing;
using System.Management;
using Microsoft.UI;
using Microsoft.UI.Composition.SystemBackdrops;
+using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
+using Windows.UI.ViewManagement;
+using System.Runtime.InteropServices;
+using Windows.UI;
class gj
{
- public static void sc(object obj)
+ public static void sc(object? obj)
{
obj ??= "null";
Debug.WriteLine(obj);
@@ -79,6 +83,100 @@ class gj
}
}
+ public static void SetBackColor(WindowEx windowEx)
+ {
+ UISettings uISettings = new UISettings();
+ // 获取当前的背景颜色
+ var backgroundColor = uISettings.GetColorValue(UIColorType.Background);
+
+ // 判断主题模式
+ if (backgroundColor == Colors.Black)
+ {
+ // 设置背景色为黑色
+ //uISettings.SetColorValue(UIColorType.Background, Colors.Black);
+ //uISettings.SetColorValue(UIColorType.Foreground, Colors.White);
+ }
+ else if (backgroundColor == Colors.White)
+ {
+ // 设置背景色为白色
+ //uISettings.SetColorValue(UIColorType.Background, Colors.White);
+ //uISettings.SetColorValue(UIColorType.Foreground, Colors.Black);
+ }
+ else
+ {
+ Console.WriteLine("Current theme mode is unknown.");
+ }
+ }
+
+
+ private const int WAINACTIVE = 0x00;
+ private const int WAACTIVE = 0x01;
+ private const int WMACTIVATE = 0x0006;
+ public static void UpdateTitleBar(WindowEx a,ElementTheme theme)
+ {
+ if (a.ExtendsContentIntoTitleBar)
+ {
+ if (theme == ElementTheme.Default)
+ {
+ var uiSettings = new UISettings();
+ var background = uiSettings.GetColorValue(UIColorType.Background);
+
+ theme = background == Colors.White ? ElementTheme.Light : ElementTheme.Dark;
+ }
+
+ if (theme == ElementTheme.Default)
+ {
+ theme = Application.Current.RequestedTheme == ApplicationTheme.Light ? ElementTheme.Light : ElementTheme.Dark;
+ }
+
+ a.AppWindow.TitleBar.ButtonForegroundColor = theme switch
+ {
+ ElementTheme.Dark => Colors.White,
+ ElementTheme.Light => Colors.Black,
+ _ => Colors.Transparent
+ };
+
+ a.AppWindow.TitleBar.ButtonHoverForegroundColor = theme switch
+ {
+ ElementTheme.Dark => Colors.White,
+ ElementTheme.Light => Colors.Black,
+ _ => Colors.Transparent
+ };
+
+ a.AppWindow.TitleBar.ButtonHoverBackgroundColor = theme switch
+ {
+ ElementTheme.Dark => Color.FromArgb(0x33, 0xFF, 0xFF, 0xFF),
+ ElementTheme.Light => Color.FromArgb(0x33, 0x00, 0x00, 0x00),
+ _ => Colors.Transparent
+ };
+
+ a.AppWindow.TitleBar.ButtonPressedBackgroundColor = theme switch
+ {
+ ElementTheme.Dark => Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF),
+ ElementTheme.Light => Color.FromArgb(0x66, 0x00, 0x00, 0x00),
+ _ => Colors.Transparent
+ };
+
+ a.AppWindow.TitleBar.BackgroundColor = Colors.Transparent;
+
+ var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(a);
+ if (hwnd == GetActiveWindow())
+ {
+ SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero);
+ SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero);
+ }
+ else
+ {
+ SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero);
+ SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero);
+ }
+ }
+ }
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr GetActiveWindow();
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam);
}