1.1.0 -> 1.1.1 第4次更新

This commit is contained in:
Space Time 2024-05-12 18:29:00 +08:00
parent 987a97802b
commit 455ade0b2d
9 changed files with 214 additions and 39 deletions

View File

@ -69,15 +69,6 @@ namespace Sheas_Cealer.Consts {
}
}
/// <summary>
/// 查找类似 Browse 的本地化字符串。
/// </summary>
public static string BrowseButtonContent {
get {
return ResourceManager.GetString("BrowseButtonContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 (Fill in the path of a Chromium-based browser) 的本地化字符串。
/// </summary>
@ -105,6 +96,33 @@ namespace Sheas_Cealer.Consts {
}
}
/// <summary>
/// 查找类似 Browse 的本地化字符串。
/// </summary>
public static string FunctionButtonBrowserPathContent {
get {
return ResourceManager.GetString("FunctionButtonBrowserPathContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Clear 的本地化字符串。
/// </summary>
public static string FunctionButtonExtraArgsContent {
get {
return ResourceManager.GetString("FunctionButtonExtraArgsContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Reset 的本地化字符串。
/// </summary>
public static string FunctionButtonUpstreamUrlContent {
get {
return ResourceManager.GetString("FunctionButtonUpstreamUrlContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Start Cealing 的本地化字符串。
/// </summary>
@ -115,11 +133,29 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Switch 的本地化字符串。
/// 查找类似 Browser Path &gt; 的本地化字符串。
/// </summary>
public static string SwitchModeButtonContent {
public static string SwitchModeButtonBrowserPathContent {
get {
return ResourceManager.GetString("SwitchModeButtonContent", resourceCulture);
return ResourceManager.GetString("SwitchModeButtonBrowserPathContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Additional Args &gt; 的本地化字符串。
/// </summary>
public static string SwitchModeButtonExtraArgsContent {
get {
return ResourceManager.GetString("SwitchModeButtonExtraArgsContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upstream Url &gt; 的本地化字符串。
/// </summary>
public static string SwitchModeButtonUpstreamUrlContent {
get {
return ResourceManager.GetString("SwitchModeButtonUpstreamUrlContent", resourceCulture);
}
}

View File

@ -100,9 +100,6 @@
<data name="AboutButtonContent" xml:space="preserve">
<value>About Me</value>
</data>
<data name="BrowseButtonContent" xml:space="preserve">
<value>Browse</value>
</data>
<data name="BrowserPathPlaceHolder" xml:space="preserve">
<value>(Fill in the path of a Chromium-based browser)</value>
</data>
@ -112,12 +109,27 @@
<data name="ExtraArgsPlaceHolder" xml:space="preserve">
<value>(fill in extra Chromium startup arguments)</value>
</data>
<data name="SwitchModeButtonContent" xml:space="preserve">
<value>Switch</value>
<data name="FunctionButtonBrowserPathContent" xml:space="preserve">
<value>Browse</value>
</data>
<data name="FunctionButtonExtraArgsContent" xml:space="preserve">
<value>Clear</value>
</data>
<data name="FunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>Reset</value>
</data>
<data name="StartCealButtonContent" xml:space="preserve">
<value>Start Cealing</value>
</data>
<data name="SwitchModeButtonBrowserPathContent" xml:space="preserve">
<value>Browser Path &gt;</value>
</data>
<data name="SwitchModeButtonExtraArgsContent" xml:space="preserve">
<value>Additional Args &gt;</value>
</data>
<data name="SwitchModeButtonUpstreamUrlContent" xml:space="preserve">
<value>Upstream Url &gt;</value>
</data>
<data name="UpdateHostButtonContent" xml:space="preserve">
<value>Update Host</value>
</data>

View File

@ -120,9 +120,6 @@
<data name="AboutButtonContent" xml:space="preserve">
<value>关于项目</value>
</data>
<data name="BrowseButtonContent" xml:space="preserve">
<value>浏览</value>
</data>
<data name="BrowserPathPlaceHolder" xml:space="preserve">
<value>(填入任意以 Chromium 为内核的浏览器的路径)</value>
</data>
@ -132,12 +129,27 @@
<data name="ExtraArgsPlaceHolder" xml:space="preserve">
<value>(填入任意额外的 Chromium 启动参数)</value>
</data>
<data name="SwitchModeButtonContent" xml:space="preserve">
<value>切换</value>
<data name="FunctionButtonBrowserPathContent" xml:space="preserve">
<value>浏览</value>
</data>
<data name="FunctionButtonExtraArgsContent" xml:space="preserve">
<value>清除</value>
</data>
<data name="FunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>重置</value>
</data>
<data name="StartCealButtonContent" xml:space="preserve">
<value>启动伪造</value>
</data>
<data name="SwitchModeButtonBrowserPathContent" xml:space="preserve">
<value>文件路径 &gt;</value>
</data>
<data name="SwitchModeButtonExtraArgsContent" xml:space="preserve">
<value>额外参数 &gt;</value>
</data>
<data name="SwitchModeButtonUpstreamUrlContent" xml:space="preserve">
<value>上游链接 &gt;</value>
</data>
<data name="UpdateHostButtonContent" xml:space="preserve">
<value>更新规则</value>
</data>

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -24,13 +24,24 @@
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="5"
Click="SwitchModeButton_Click">
<Button.Content>
<Binding Path="Mode">
<Binding.Converter>
<convs:MainSwitchModeButtonContentConv />
</Binding.Converter>
</Binding>
</Button.Content>
</Button>
<TextBox x:Name="ContentText" utils:FocusExtension.IsFocused="{Binding IsContentBoxFocused}"
Grid.Column="0" Margin="5" VerticalContentAlignment="Center"
Grid.Column="1" Margin="5" VerticalContentAlignment="Center"
TextChanged="ContentBox_TextChanged" PreviewDragOver="MainWin_DragEnter">
<TextBox.Text>
<MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged">
@ -61,10 +72,16 @@
</MultiBinding>
</TextBox.Foreground>
</TextBox>
<Button Grid.Column="1" Margin="5" Content="{Binding BrowseButtonContent, Source={StaticResource MainConst}}"
Click="BrowseButton_Click" />
<Button Grid.Column="2" Margin="5" Content="{Binding SwitchModeButtonContent, Source={StaticResource MainConst}}"
Click="SwitchModeButton_Click" />
<Button Grid.Column="2" Margin="5"
Click="FunctionButton_Click">
<Button.Content>
<Binding Path="Mode">
<Binding.Converter>
<convs:MainFunctionButtonContentConv />
</Binding.Converter>
</Binding>
</Button.Content>
</Button>
</Grid>
@ -79,7 +96,6 @@
</MultiBinding.Converter>
<Binding Path="BrowserPath" />
<Binding Path="UpstreamUrl" />
<Binding Path="ExtraArgs" />
</MultiBinding>
@ -98,7 +114,15 @@
Click="EditHostButton_Click" />
<Button x:Name="UpdateHostButton"
Grid.Column="1" Margin="5" Content="{Binding UpdateHostButtonContent, Source={StaticResource MainConst}}"
Click="UpdateHostButton_Click" />
Click="UpdateHostButton_Click">
<Button.IsEnabled>
<Binding Path="UpstreamUrl">
<Binding.Converter>
<convs:MainUpdateHostButtonIsEnabledConv />
</Binding.Converter>
</Binding>
</Button.IsEnabled>
</Button>
<Button x:Name="AboutButton"
Grid.Column="2" Margin="5" Content="{Binding AboutButtonContent, Source={StaticResource MainConst}}"
Click="AboutButton_Click" />

View File

@ -70,7 +70,9 @@ namespace Sheas_Cealer.Wins
else
throw new UnreachableException();
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
private void FunctionButton_Click(object sender, RoutedEventArgs e)
{
if (MainPres!.Mode == MainConst.Mode.browserPathMode)
{
OpenFileDialog openFileDialog = new() { Filter = "浏览器 (*.exe)|*.exe" };
@ -80,6 +82,11 @@ namespace Sheas_Cealer.Wins
MainPres!.BrowserPath = openFileDialog.FileName;
}
}
else if (MainPres!.Mode == MainConst.Mode.upstreamUrlMode)
MainPres!.UpstreamUrl = MainConst.DefaultUpstreamUrl;
else if (MainPres!.Mode == MainConst.Mode.extraArgsMode)
MainPres!.ExtraArgs = string.Empty;
}
private void SwitchModeButton_Click(object sender, RoutedEventArgs e)
{
if (MainPres!.Mode == MainConst.Mode.browserPathMode)