diff --git a/Consts/MainMultilangConst.Designer.cs b/Consts/MainMultilangConst.Designer.cs index b16c670..c695671 100644 --- a/Consts/MainMultilangConst.Designer.cs +++ b/Consts/MainMultilangConst.Designer.cs @@ -69,15 +69,6 @@ namespace Sheas_Cealer.Consts { } } - /// - /// 查找类似 Browse 的本地化字符串。 - /// - public static string BrowseButtonContent { - get { - return ResourceManager.GetString("BrowseButtonContent", resourceCulture); - } - } - /// /// 查找类似 (Fill in the path of a Chromium-based browser) 的本地化字符串。 /// @@ -105,6 +96,33 @@ namespace Sheas_Cealer.Consts { } } + /// + /// 查找类似 Browse 的本地化字符串。 + /// + public static string FunctionButtonBrowserPathContent { + get { + return ResourceManager.GetString("FunctionButtonBrowserPathContent", resourceCulture); + } + } + + /// + /// 查找类似 Clear 的本地化字符串。 + /// + public static string FunctionButtonExtraArgsContent { + get { + return ResourceManager.GetString("FunctionButtonExtraArgsContent", resourceCulture); + } + } + + /// + /// 查找类似 Reset 的本地化字符串。 + /// + public static string FunctionButtonUpstreamUrlContent { + get { + return ResourceManager.GetString("FunctionButtonUpstreamUrlContent", resourceCulture); + } + } + /// /// 查找类似 Start Cealing 的本地化字符串。 /// @@ -115,11 +133,29 @@ namespace Sheas_Cealer.Consts { } /// - /// 查找类似 Switch 的本地化字符串。 + /// 查找类似 Browser Path > 的本地化字符串。 /// - public static string SwitchModeButtonContent { + public static string SwitchModeButtonBrowserPathContent { get { - return ResourceManager.GetString("SwitchModeButtonContent", resourceCulture); + 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); } } diff --git a/Consts/MainMultilangConst.resx b/Consts/MainMultilangConst.resx index 2a35480..a2e4d3a 100644 --- a/Consts/MainMultilangConst.resx +++ b/Consts/MainMultilangConst.resx @@ -100,9 +100,6 @@ About Me - - Browse - (Fill in the path of a Chromium-based browser) @@ -112,12 +109,27 @@ (fill in extra Chromium startup arguments) - - Switch + + Browse + + + Clear + + + Reset Start Cealing + + Browser Path > + + + Additional Args > + + + Upstream Url > + Update Host diff --git a/Consts/MainMultilangConst.zh.resx b/Consts/MainMultilangConst.zh.resx index 6757cf8..ae636cf 100644 --- a/Consts/MainMultilangConst.zh.resx +++ b/Consts/MainMultilangConst.zh.resx @@ -120,9 +120,6 @@ 关于项目 - - 浏览 - (填入任意以 Chromium 为内核的浏览器的路径) @@ -132,12 +129,27 @@ (填入任意额外的 Chromium 启动参数) - - 切换 + + 浏览 + + + 清除 + + + 重置 启动伪造 + + 文件路径 > + + + 额外参数 > + + + 上游链接 > + 更新规则 diff --git a/Convs/MainFunctionButtonContentConv.cs b/Convs/MainFunctionButtonContentConv.cs new file mode 100644 index 0000000..792ed9c --- /dev/null +++ b/Convs/MainFunctionButtonContentConv.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using Sheas_Cealer.Consts; + +namespace Sheas_Cealer.Convs +{ + internal class MainFunctionButtonContentConv : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + MainConst.Mode? mode = value as MainConst.Mode?; + + if (mode == MainConst.Mode.browserPathMode) + return MainConst.FunctionButtonBrowserPathContent; + else if (mode == MainConst.Mode.upstreamUrlMode) + return MainConst.FunctionButtonUpstreamUrlContent; + else if (mode == MainConst.Mode.extraArgsMode) + return MainConst.FunctionButtonExtraArgsContent; + + throw new UnreachableException(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Convs/MainStartCealButtonIsEnabledConv.cs b/Convs/MainStartCealButtonIsEnabledConv.cs index 3dda332..87c9fa3 100644 --- a/Convs/MainStartCealButtonIsEnabledConv.cs +++ b/Convs/MainStartCealButtonIsEnabledConv.cs @@ -11,10 +11,9 @@ namespace Sheas_Cealer.Convs public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { string? browserPath = values[0] as string; - string? upstreamUrl = values[1] as string; - string? extraArgs = values[2] as string; + string? extraArgs = values[1] as string; - if (File.Exists(browserPath) && Path.GetFileName(browserPath).ToLower().EndsWith(".exe") && MainConst.UrlRegex().IsMatch(upstreamUrl!) && MainConst.ArgsRegex().IsMatch(extraArgs!)) + if (File.Exists(browserPath) && Path.GetFileName(browserPath).ToLower().EndsWith(".exe") && (MainConst.ArgsRegex().IsMatch(extraArgs!) || extraArgs == MainConst.ExtraArgsPlaceHolder)) return true; return false; diff --git a/Convs/MainSwitchModeButtonContentConv.cs b/Convs/MainSwitchModeButtonContentConv.cs new file mode 100644 index 0000000..c0f4b0d --- /dev/null +++ b/Convs/MainSwitchModeButtonContentConv.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Windows.Data; +using Sheas_Cealer.Consts; + +namespace Sheas_Cealer.Convs +{ + internal class MainSwitchModeButtonContentConv : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + MainConst.Mode? mode = value as MainConst.Mode?; + + if (mode == MainConst.Mode.browserPathMode) + return MainConst.SwitchModeButtonBrowserPathContent; + else if (mode == MainConst.Mode.upstreamUrlMode) + return MainConst.SwitchModeButtonUpstreamUrlContent; + else if (mode == MainConst.Mode.extraArgsMode) + return MainConst.SwitchModeButtonExtraArgsContent; + + throw new UnreachableException(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Convs/MainUpdateHostButtonIsEnabledConv.cs b/Convs/MainUpdateHostButtonIsEnabledConv.cs new file mode 100644 index 0000000..fab5534 --- /dev/null +++ b/Convs/MainUpdateHostButtonIsEnabledConv.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using Sheas_Cealer.Consts; + +namespace Sheas_Cealer.Convs +{ + internal class MainUpdateHostButtonIsEnabledConv : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string? upstreamUrl = value as string; + + if (MainConst.UrlRegex().IsMatch(upstreamUrl!)) + return true; + + return false; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Wins/MainWin.xaml b/Wins/MainWin.xaml index 4b797ae..549ff4d 100644 --- a/Wins/MainWin.xaml +++ b/Wins/MainWin.xaml @@ -24,13 +24,24 @@ - + + + @@ -61,10 +72,16 @@ - @@ -79,7 +96,6 @@ - @@ -98,7 +114,15 @@ Click="EditHostButton_Click" />