2024-07-28 13:33:21 +00:00
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
using Microsoft.UI.Composition.SystemBackdrops;
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
using Microsoft.UI.Xaml.Data;
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
using RustTools.muqing;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
using RustTools.ViewModels;
|
2024-07-28 13:33:21 +00:00
|
|
|
|
using Windows.Storage.AccessCache;
|
|
|
|
|
using Windows.Storage.Pickers;
|
|
|
|
|
using Windows.Storage;
|
|
|
|
|
using WinUIEx;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
|
|
|
|
|
namespace RustTools.Views;
|
|
|
|
|
|
|
|
|
|
// TODO: Set the URL for your privacy policy by updating SettingsPage_PrivacyTermsLink.NavigateUri in Resources.resw.
|
|
|
|
|
public sealed partial class SettingsPage : Page
|
|
|
|
|
{
|
|
|
|
|
public SettingsViewModel ViewModel
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
}
|
2024-07-28 13:33:21 +00:00
|
|
|
|
public enum SystemBackdropEmnu
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
}
|
2024-07-14 11:24:10 +00:00
|
|
|
|
|
|
|
|
|
public SettingsPage()
|
|
|
|
|
{
|
2024-07-28 13:33:21 +00:00
|
|
|
|
//this.windowEx = windowEx;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
ViewModel = App.GetService<SettingsViewModel>();
|
|
|
|
|
InitializeComponent();
|
2024-07-28 13:33:21 +00:00
|
|
|
|
|
|
|
|
|
//BackgroundRadioButtons
|
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
var v = iniHelper.GetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop);
|
|
|
|
|
switch (v)
|
|
|
|
|
{
|
|
|
|
|
case "None":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 0;
|
|
|
|
|
break;
|
|
|
|
|
case "Blur":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case "AcrylicBlur":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 2;
|
|
|
|
|
break;
|
|
|
|
|
case "Mica":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
BackgroundRadioButtons.SelectionChanged += BackgroundColor_SelectionChanged;
|
|
|
|
|
ModFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
|
|
|
|
}
|
|
|
|
|
private bool Backone = false;
|
|
|
|
|
private void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Backone)
|
|
|
|
|
{
|
|
|
|
|
if (MainWindow.Main != null && sender is RadioButtons rb)
|
|
|
|
|
{
|
|
|
|
|
var colorName = rb.SelectedItem as string;
|
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop, colorName);
|
|
|
|
|
iniHelper.Save();
|
|
|
|
|
gj.SetBackTheme(MainWindow.Main);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Backone = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void AutoSuggestBox_ModFileUrl(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
var dialog = new ContentDialog();
|
|
|
|
|
dialog.XamlRoot = this.XamlRoot;
|
|
|
|
|
|
|
|
|
|
//dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
|
|
|
|
|
dialog.Title = "选择搜索模式";
|
|
|
|
|
dialog.SecondaryButtonText = "手动选择";
|
|
|
|
|
dialog.CloseButtonText = "自动搜索";
|
|
|
|
|
dialog.Content = "自动搜索利用助手专属搜索引擎进行全盘搜索游戏文件夹,直到找到 Rusted Warfare 文件夹为止 途中可选择中断。";
|
|
|
|
|
//dialog.DefaultButton = ContentDialogButton.Primary;
|
|
|
|
|
dialog.SecondaryButtonClick += Dialog_SecondaryButtonClick;
|
|
|
|
|
dialog.CloseButtonClick += Dialog_CloseButtonClick;
|
|
|
|
|
await dialog.ShowAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Dialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
|
|
|
|
var mod = new mod();
|
|
|
|
|
ModFileUrlText.Text = mod.FileDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
|
|
|
|
|
|
|
|
|
var openPicker = new FolderPicker();
|
|
|
|
|
var window = App.MainWindow;
|
|
|
|
|
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
|
|
|
|
WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd);
|
|
|
|
|
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
|
|
|
|
|
openPicker.FileTypeFilter.Add("*");
|
|
|
|
|
var folder = await openPicker.PickSingleFolderAsync();
|
|
|
|
|
if (folder != null)
|
|
|
|
|
{
|
|
|
|
|
//StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
|
|
|
|
|
ModFileUrlText.Text = folder.Path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 获取 AutoSuggestBox 的当前文本
|
|
|
|
|
var text = ModFileUrlText.Text;
|
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, text);
|
|
|
|
|
iniHelper.Save();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|