diff --git a/Consts/MainMultilangConst.Designer.cs b/Consts/MainMultilangConst.Designer.cs index c695671..5d92e3f 100644 --- a/Consts/MainMultilangConst.Designer.cs +++ b/Consts/MainMultilangConst.Designer.cs @@ -69,15 +69,6 @@ namespace Sheas_Cealer.Consts { } } - /// - /// 查找类似 (Fill in the path of a Chromium-based browser) 的本地化字符串。 - /// - public static string BrowserPathPlaceHolder { - get { - return ResourceManager.GetString("BrowserPathPlaceHolder", resourceCulture); - } - } - /// /// 查找类似 Edit Host 的本地化字符串。 /// @@ -88,38 +79,83 @@ namespace Sheas_Cealer.Consts { } /// - /// 查找类似 (fill in extra Chromium startup arguments) 的本地化字符串。 + /// 查找类似 (Fill in the path of a Chromium-based browser) 的本地化字符串。 /// - public static string ExtraArgsPlaceHolder { + public static string SettingsBoxBrowserPathPlaceHolder { get { - return ResourceManager.GetString("ExtraArgsPlaceHolder", resourceCulture); + return ResourceManager.GetString("SettingsBoxBrowserPathPlaceHolder", resourceCulture); + } + } + + /// + /// 查找类似 (Fill in extra Chromium startup arguments) 的本地化字符串。 + /// + public static string SettingsBoxExtraArgsPlaceHolder { + get { + return ResourceManager.GetString("SettingsBoxExtraArgsPlaceHolder", resourceCulture); + } + } + + /// + /// 查找类似 (Fill in the link to an upstream Cealing Host) 的本地化字符串。 + /// + public static string SettingsBoxUpstreamUrlPlaceHolder { + get { + return ResourceManager.GetString("SettingsBoxUpstreamUrlPlaceHolder", resourceCulture); } } /// /// 查找类似 Browse 的本地化字符串。 /// - public static string FunctionButtonBrowserPathContent { + public static string SettingsFunctionButtonBrowserPathContent { get { - return ResourceManager.GetString("FunctionButtonBrowserPathContent", resourceCulture); + return ResourceManager.GetString("SettingsFunctionButtonBrowserPathContent", resourceCulture); } } /// /// 查找类似 Clear 的本地化字符串。 /// - public static string FunctionButtonExtraArgsContent { + public static string SettingsFunctionButtonExtraArgsContent { get { - return ResourceManager.GetString("FunctionButtonExtraArgsContent", resourceCulture); + return ResourceManager.GetString("SettingsFunctionButtonExtraArgsContent", resourceCulture); } } /// /// 查找类似 Reset 的本地化字符串。 /// - public static string FunctionButtonUpstreamUrlContent { + public static string SettingsFunctionButtonUpstreamUrlContent { get { - return ResourceManager.GetString("FunctionButtonUpstreamUrlContent", resourceCulture); + return ResourceManager.GetString("SettingsFunctionButtonUpstreamUrlContent", resourceCulture); + } + } + + /// + /// 查找类似 Browser Path > 的本地化字符串。 + /// + public static string SettingsModeButtonBrowserPathContent { + get { + return ResourceManager.GetString("SettingsModeButtonBrowserPathContent", resourceCulture); + } + } + + /// + /// 查找类似 Additional Args > 的本地化字符串。 + /// + public static string SettingsModeButtonExtraArgsContent { + get { + return ResourceManager.GetString("SettingsModeButtonExtraArgsContent", resourceCulture); + } + } + + /// + /// 查找类似 Upstream Url > 的本地化字符串。 + /// + public static string SettingsModeButtonUpstreamUrlContent { + get { + return ResourceManager.GetString("SettingsModeButtonUpstreamUrlContent", resourceCulture); } } @@ -132,33 +168,6 @@ namespace Sheas_Cealer.Consts { } } - /// - /// 查找类似 Browser Path > 的本地化字符串。 - /// - public static string SwitchModeButtonBrowserPathContent { - get { - return ResourceManager.GetString("SwitchModeButtonBrowserPathContent", resourceCulture); - } - } - - /// - /// 查找类似 Additional Args > 的本地化字符串。 - /// - public static string SwitchModeButtonExtraArgsContent { - get { - return ResourceManager.GetString("SwitchModeButtonExtraArgsContent", resourceCulture); - } - } - - /// - /// 查找类似 Upstream Url > 的本地化字符串。 - /// - public static string SwitchModeButtonUpstreamUrlContent { - get { - return ResourceManager.GetString("SwitchModeButtonUpstreamUrlContent", resourceCulture); - } - } - /// /// 查找类似 Update Host 的本地化字符串。 /// @@ -167,14 +176,5 @@ namespace Sheas_Cealer.Consts { return ResourceManager.GetString("UpdateHostButtonContent", resourceCulture); } } - - /// - /// 查找类似 (Fill in the link to an upstream Cealing Host) 的本地化字符串。 - /// - public static string UpstreamUrlPlaceHolder { - get { - return ResourceManager.GetString("UpstreamUrlPlaceHolder", resourceCulture); - } - } } } diff --git a/Consts/MainMultilangConst.resx b/Consts/MainMultilangConst.resx index a2e4d3a..a01e3ee 100644 --- a/Consts/MainMultilangConst.resx +++ b/Consts/MainMultilangConst.resx @@ -1,76 +1,96 @@  + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + - + + @@ -89,51 +109,51 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 About Me - - (Fill in the path of a Chromium-based browser) - Edit Host - - (fill in extra Chromium startup arguments) + + (Fill in the path of a Chromium-based browser) - + + (Fill in extra Chromium startup arguments) + + + (Fill in the link to an upstream Cealing Host) + + Browse - + Clear - + Reset + + Browser Path > + + + Additional Args > + + + Upstream Url > + Start Cealing - - Browser Path > - - - Additional Args > - - - Upstream Url > - Update Host - - (Fill in the link to an upstream Cealing Host) - \ No newline at end of file diff --git a/Consts/MainMultilangConst.zh.resx b/Consts/MainMultilangConst.zh.resx index ae636cf..9e9287b 100644 --- a/Consts/MainMultilangConst.zh.resx +++ b/Consts/MainMultilangConst.zh.resx @@ -7,7 +7,7 @@ The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConv classes + various data types are done through the TypeConverter classes associated with the data types. Example: @@ -32,7 +32,7 @@ Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConv architecture. + text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. @@ -56,7 +56,7 @@ mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConv + : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> @@ -120,40 +120,40 @@ 关于项目 - - (填入任意以 Chromium 为内核的浏览器的路径) - 编辑规则 - + + (填入任意以 Chromium 为内核的浏览器的路径) + + (填入任意额外的 Chromium 启动参数) - + + (填入任意上游伪造规则的链接) + + 浏览 - + 清除 - + 重置 + + 文件路径 > + + + 额外参数 > + + + 上游链接 > + 启动伪造 - - 文件路径 > - - - 额外参数 > - - - 上游链接 > - 更新规则 - - (填入任意上游伪造规则的链接) - \ No newline at end of file diff --git a/Convs/MainContentBoxForegroundConv.cs b/Convs/MainSettingsBoxForegroundConv.cs similarity index 81% rename from Convs/MainContentBoxForegroundConv.cs rename to Convs/MainSettingsBoxForegroundConv.cs index 320f3dc..570d2a8 100644 --- a/Convs/MainContentBoxForegroundConv.cs +++ b/Convs/MainSettingsBoxForegroundConv.cs @@ -6,7 +6,7 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainContentBoxForegroundConv : IMultiValueConverter +internal class MainSettingsBoxForegroundConv : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { @@ -17,9 +17,9 @@ internal class MainContentBoxForegroundConv : IMultiValueConverter switch (mode) { - case MainConst.SettingsMode.BrowserPathMode when browserPath == MainConst.BrowserPathPlaceHolder: - case MainConst.SettingsMode.UpstreamUrlMode when upstreamUrl == MainConst.UpstreamUrlPlaceHolder: - case MainConst.SettingsMode.ExtraArgsMode when extraArgs == MainConst.ExtraArgsPlaceHolder: + case MainConst.SettingsMode.BrowserPathMode when browserPath == MainConst.SettingsBoxBrowserPathPlaceHolder: + case MainConst.SettingsMode.UpstreamUrlMode when upstreamUrl == MainConst.SettingsBoxUpstreamUrlPlaceHolder: + case MainConst.SettingsMode.ExtraArgsMode when extraArgs == MainConst.SettingsBoxExtraArgsPlaceHolder: return new SolidColorBrush(Color.FromRgb(191, 205, 219)); } diff --git a/Convs/MainContentBoxTextConv.cs b/Convs/MainSettingsBoxTextConv.cs similarity index 77% rename from Convs/MainContentBoxTextConv.cs rename to Convs/MainSettingsBoxTextConv.cs index 68fe4ab..c17e654 100644 --- a/Convs/MainContentBoxTextConv.cs +++ b/Convs/MainSettingsBoxTextConv.cs @@ -5,7 +5,7 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainContentBoxTextConv : IMultiValueConverter +internal class MainSettingsBoxTextConv : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { @@ -17,12 +17,12 @@ internal class MainContentBoxTextConv : IMultiValueConverter return mode switch { - MainConst.SettingsMode.BrowserPathMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(browserPath) ? MainConst.BrowserPathPlaceHolder : - isFocused.GetValueOrDefault() && browserPath == MainConst.BrowserPathPlaceHolder ? string.Empty : browserPath!, - MainConst.SettingsMode.UpstreamUrlMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(upstreamUrl) ? MainConst.UpstreamUrlPlaceHolder : - isFocused.GetValueOrDefault() && upstreamUrl == MainConst.UpstreamUrlPlaceHolder ? string.Empty : upstreamUrl!, - MainConst.SettingsMode.ExtraArgsMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(extraArgs) ? MainConst.ExtraArgsPlaceHolder : - isFocused.GetValueOrDefault() && extraArgs == MainConst.ExtraArgsPlaceHolder ? string.Empty : extraArgs!, + MainConst.SettingsMode.BrowserPathMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(browserPath) ? MainConst.SettingsBoxBrowserPathPlaceHolder : + isFocused.GetValueOrDefault() && browserPath == MainConst.SettingsBoxBrowserPathPlaceHolder ? string.Empty : browserPath!, + MainConst.SettingsMode.UpstreamUrlMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(upstreamUrl) ? MainConst.SettingsBoxUpstreamUrlPlaceHolder : + isFocused.GetValueOrDefault() && upstreamUrl == MainConst.SettingsBoxUpstreamUrlPlaceHolder ? string.Empty : upstreamUrl!, + MainConst.SettingsMode.ExtraArgsMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(extraArgs) ? MainConst.SettingsBoxExtraArgsPlaceHolder : + isFocused.GetValueOrDefault() && extraArgs == MainConst.SettingsBoxExtraArgsPlaceHolder ? string.Empty : extraArgs!, _ => throw new UnreachableException(), }; } diff --git a/Convs/MainFunctionButtonContentConv.cs b/Convs/MainSettingsFunctionButtonContentConv.cs similarity index 73% rename from Convs/MainFunctionButtonContentConv.cs rename to Convs/MainSettingsFunctionButtonContentConv.cs index 629bd5c..7692048 100644 --- a/Convs/MainFunctionButtonContentConv.cs +++ b/Convs/MainSettingsFunctionButtonContentConv.cs @@ -6,7 +6,7 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainFunctionButtonContentConv : IValueConverter +internal class MainSettingsFunctionButtonContentConv : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { @@ -14,9 +14,9 @@ internal class MainFunctionButtonContentConv : IValueConverter return mode switch { - MainConst.SettingsMode.BrowserPathMode => MainConst.FunctionButtonBrowserPathContent, - MainConst.SettingsMode.UpstreamUrlMode => MainConst.FunctionButtonUpstreamUrlContent, - MainConst.SettingsMode.ExtraArgsMode => MainConst.FunctionButtonExtraArgsContent, + MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsFunctionButtonBrowserPathContent, + MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsFunctionButtonUpstreamUrlContent, + MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsFunctionButtonExtraArgsContent, _ => throw new UnreachableException() }; } diff --git a/Convs/MainSwitchModeButtonContentConv.cs b/Convs/MainSettingsModeButtonContentConv.cs similarity index 74% rename from Convs/MainSwitchModeButtonContentConv.cs rename to Convs/MainSettingsModeButtonContentConv.cs index 6b3f45b..a1fcf0e 100644 --- a/Convs/MainSwitchModeButtonContentConv.cs +++ b/Convs/MainSettingsModeButtonContentConv.cs @@ -5,7 +5,7 @@ using Sheas_Cealer.Consts; namespace Sheas_Cealer.Convs; -internal class MainSwitchModeButtonContentConv : IValueConverter +internal class MainSettingsModeButtonContentConv : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { @@ -13,9 +13,9 @@ internal class MainSwitchModeButtonContentConv : IValueConverter return mode switch { - MainConst.SettingsMode.BrowserPathMode => MainConst.SwitchModeButtonBrowserPathContent, - MainConst.SettingsMode.UpstreamUrlMode => MainConst.SwitchModeButtonUpstreamUrlContent, - MainConst.SettingsMode.ExtraArgsMode => MainConst.SwitchModeButtonExtraArgsContent, + MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsModeButtonBrowserPathContent, + MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsModeButtonUpstreamUrlContent, + MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsModeButtonExtraArgsContent, _ => throw new NotImplementedException() }; } diff --git a/Convs/MainStartCealButtonIsEnabledConv.cs b/Convs/MainStartCealButtonIsEnabledConv.cs index 680abf0..1b5010f 100644 --- a/Convs/MainStartCealButtonIsEnabledConv.cs +++ b/Convs/MainStartCealButtonIsEnabledConv.cs @@ -13,7 +13,7 @@ internal class MainStartCealButtonIsEnabledConv : IMultiValueConverter string? browserPath = values[0] as string; string? extraArgs = values[1] as string; - return File.Exists(browserPath) && Path.GetFileName(browserPath).ToLower().EndsWith(".exe") && (MainConst.ExtraArgsRegex().IsMatch(extraArgs!) || extraArgs == MainConst.ExtraArgsPlaceHolder); + return File.Exists(browserPath) && Path.GetFileName(browserPath).ToLower().EndsWith(".exe") && (MainConst.ExtraArgsRegex().IsMatch(extraArgs!) || extraArgs == MainConst.SettingsBoxExtraArgsPlaceHolder); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); diff --git a/Preses/MainPres.cs b/Preses/MainPres.cs index b413a87..0b04579 100644 --- a/Preses/MainPres.cs +++ b/Preses/MainPres.cs @@ -2,6 +2,7 @@ using System.IO; using CommunityToolkit.Mvvm.ComponentModel; using Sheas_Cealer.Consts; +using Sheas_Cealer.Props; using File = System.IO.File; namespace Sheas_Cealer.Preses; @@ -15,20 +16,20 @@ internal partial class MainPres : ObservableObject extraArgsIndex = Array.FindIndex(args, arg => arg == "e") + 1; BrowserPath = browserPathIndex == 0 ? - (!string.IsNullOrWhiteSpace(Props.Settings.Default.BrowserPath) ? Props.Settings.Default.BrowserPath : string.Empty) : + (!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath : string.Empty) : args[browserPathIndex]; UpstreamUrl = upstreamUrlIndex == 0 ? - (!string.IsNullOrWhiteSpace(Props.Settings.Default.UpstreamUrl) ? Props.Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl) : + (!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl) : args[upstreamUrlIndex]; ExtraArgs = extraArgsIndex == 0 ? - (!string.IsNullOrWhiteSpace(Props.Settings.Default.ExtraArgs) ? Props.Settings.Default.ExtraArgs : string.Empty) : + (!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty) : args[extraArgsIndex]; } [ObservableProperty] - private MainConst.SettingsMode mode = MainConst.SettingsMode.BrowserPathMode; + private MainConst.SettingsMode mode; [ObservableProperty] private string browserPath; @@ -36,8 +37,8 @@ internal partial class MainPres : ObservableObject { if (File.Exists(value) && Path.GetFileName(value).ToLower().EndsWith(".exe")) { - Props.Settings.Default.BrowserPath = value; - Props.Settings.Default.Save(); + Settings.Default.BrowserPath = value; + Settings.Default.Save(); } } @@ -47,8 +48,8 @@ internal partial class MainPres : ObservableObject { if (MainConst.UpstreamUrlRegex().IsMatch(value)) { - Props.Settings.Default.UpstreamUrl = value; - Props.Settings.Default.Save(); + Settings.Default.UpstreamUrl = value; + Settings.Default.Save(); } } @@ -58,8 +59,8 @@ internal partial class MainPres : ObservableObject { if (MainConst.ExtraArgsRegex().IsMatch(value)) { - Props.Settings.Default.ExtraArgs = value; - Props.Settings.Default.Save(); + Settings.Default.ExtraArgs = value; + Settings.Default.Save(); } } } \ No newline at end of file diff --git a/Wins/MainWin.xaml b/Wins/MainWin.xaml index b21c1a0..b9593de 100644 --- a/Wins/MainWin.xaml +++ b/Wins/MainWin.xaml @@ -29,23 +29,23 @@ - + TextChanged="SettingsBox_TextChanged" PreviewDragOver="MainWin_DragEnter"> - + @@ -58,7 +58,7 @@ - + @@ -69,11 +69,11 @@