1.1.0 -> 1.1.1 第8次更新

This commit is contained in:
Space Time 2024-05-22 21:15:18 +08:00
parent 353d5ec8cf
commit 6204dbb7e5
15 changed files with 411 additions and 144 deletions

View File

@ -6,7 +6,7 @@
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Red" SecondaryColor="Orange" /> <materialDesign:BundledTheme BaseTheme="Inherit" PrimaryColor="Red" SecondaryColor="Orange" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
@ -15,12 +15,12 @@
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" /> <Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
</Style> </Style>
<Style BasedOn="{StaticResource MaterialDesignFilledTextBox}" TargetType="{x:Type TextBox}" />
<Style BasedOn="{StaticResource MaterialDesignRaisedButton}" TargetType="{x:Type Button}"> <Style BasedOn="{StaticResource MaterialDesignRaisedButton}" TargetType="{x:Type Button}">
<Setter Property="Height" Value="Auto" /> <Setter Property="Height" Value="Auto" />
<Setter Property="Width" Value="Auto" /> <Setter Property="Width" Value="Auto" />
<Setter Property="Background" Value="Red" />
</Style> </Style>
<Style BasedOn="{StaticResource MaterialDesignCaptionHyperlink}" TargetType="{x:Type Hyperlink}" />
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -69,6 +69,24 @@ namespace Sheas_Cealer.Consts {
} }
} }
/// <summary>
/// 查找类似 的本地化字符串。
/// </summary>
public static string AboutButtonToolTip {
get {
return ResourceManager.GetString("AboutButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Browser Path 的本地化字符串。
/// </summary>
public static string BrowserPathModeName {
get {
return ResourceManager.GetString("BrowserPathModeName", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Edit Host 的本地化字符串。 /// 查找类似 Edit Host 的本地化字符串。
/// </summary> /// </summary>
@ -79,7 +97,25 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 (Fill in the path of a Chromium-based browser) 的本地化字符串。 /// 查找类似 的本地化字符串。
/// </summary>
public static string EditHostButtonToolTip {
get {
return ResourceManager.GetString("EditHostButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Additional Args 的本地化字符串。
/// </summary>
public static string ExtraArgsModeName {
get {
return ResourceManager.GetString("ExtraArgsModeName", resourceCulture);
}
}
/// <summary>
/// 查找类似 Fill in the path of a Chromium-based browser 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsBoxBrowserPathPlaceHolder { public static string SettingsBoxBrowserPathPlaceHolder {
get { get {
@ -88,7 +124,7 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 (Fill in extra Chromium startup arguments) 的本地化字符串。 /// 查找类似 Fill in extra Chromium startup arguments 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsBoxExtraArgsPlaceHolder { public static string SettingsBoxExtraArgsPlaceHolder {
get { get {
@ -97,7 +133,7 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 (Fill in the link to an upstream Cealing Host) 的本地化字符串。 /// 查找类似 Fill in the link to an upstream Cealing Host 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsBoxUpstreamUrlPlaceHolder { public static string SettingsBoxUpstreamUrlPlaceHolder {
get { get {
@ -106,7 +142,7 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 Browse 的本地化字符串。 /// 查找类似 Browse Path 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsFunctionButtonBrowserPathContent { public static string SettingsFunctionButtonBrowserPathContent {
get { get {
@ -115,7 +151,7 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 Clear 的本地化字符串。 /// 查找类似 Clear Args 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsFunctionButtonExtraArgsContent { public static string SettingsFunctionButtonExtraArgsContent {
get { get {
@ -124,7 +160,16 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 Reset 的本地化字符串。 /// 查找类似 的本地化字符串。
/// </summary>
public static string SettingsFunctionButtonToolTip {
get {
return ResourceManager.GetString("SettingsFunctionButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Reset Url 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsFunctionButtonUpstreamUrlContent { public static string SettingsFunctionButtonUpstreamUrlContent {
get { get {
@ -133,29 +178,11 @@ namespace Sheas_Cealer.Consts {
} }
/// <summary> /// <summary>
/// 查找类似 Browser Path &gt; 的本地化字符串。 /// 查找类似 的本地化字符串。
/// </summary> /// </summary>
public static string SettingsModeButtonBrowserPathContent { public static string SettingsModeButtonToolTip {
get { get {
return ResourceManager.GetString("SettingsModeButtonBrowserPathContent", resourceCulture); return ResourceManager.GetString("SettingsModeButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Additional Args &gt; 的本地化字符串。
/// </summary>
public static string SettingsModeButtonExtraArgsContent {
get {
return ResourceManager.GetString("SettingsModeButtonExtraArgsContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upstream Url &gt; 的本地化字符串。
/// </summary>
public static string SettingsModeButtonUpstreamUrlContent {
get {
return ResourceManager.GetString("SettingsModeButtonUpstreamUrlContent", resourceCulture);
} }
} }
@ -168,6 +195,51 @@ namespace Sheas_Cealer.Consts {
} }
} }
/// <summary>
/// 查找类似 的本地化字符串。
/// </summary>
public static string StartCealButtonToolTip {
get {
return ResourceManager.GetString("StartCealButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Light Theme 的本地化字符串。
/// </summary>
public static string ThemesButtonDarkThemeContent {
get {
return ResourceManager.GetString("ThemesButtonDarkThemeContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Auto Theme 的本地化字符串。
/// </summary>
public static string ThemesButtonInheritThemeContent {
get {
return ResourceManager.GetString("ThemesButtonInheritThemeContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Dark Theme 的本地化字符串。
/// </summary>
public static string ThemesButtonLightThemeContent {
get {
return ResourceManager.GetString("ThemesButtonLightThemeContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 的本地化字符串。
/// </summary>
public static string ThemesButtonToolTip {
get {
return ResourceManager.GetString("ThemesButtonToolTip", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Update Host 的本地化字符串。 /// 查找类似 Update Host 的本地化字符串。
/// </summary> /// </summary>
@ -176,5 +248,23 @@ namespace Sheas_Cealer.Consts {
return ResourceManager.GetString("UpdateHostButtonContent", resourceCulture); return ResourceManager.GetString("UpdateHostButtonContent", resourceCulture);
} }
} }
/// <summary>
/// 查找类似 的本地化字符串。
/// </summary>
public static string UpdateHostButtonToolTip {
get {
return ResourceManager.GetString("UpdateHostButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upstream Url 的本地化字符串。
/// </summary>
public static string UpstreamUrlModeName {
get {
return ResourceManager.GetString("UpstreamUrlModeName", resourceCulture);
}
}
} }
} }

View File

@ -120,40 +120,70 @@
<data name="AboutButtonContent" xml:space="preserve"> <data name="AboutButtonContent" xml:space="preserve">
<value>About Me</value> <value>About Me</value>
</data> </data>
<data name="AboutButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="BrowserPathModeName" xml:space="preserve">
<value>Browser Path</value>
</data>
<data name="EditHostButtonContent" xml:space="preserve"> <data name="EditHostButtonContent" xml:space="preserve">
<value>Edit Host</value> <value>Edit Host</value>
</data> </data>
<data name="EditHostButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="ExtraArgsModeName" xml:space="preserve">
<value>Additional Args</value>
</data>
<data name="SettingsBoxBrowserPathPlaceHolder" xml:space="preserve"> <data name="SettingsBoxBrowserPathPlaceHolder" xml:space="preserve">
<value>(Fill in the path of a Chromium-based browser)</value> <value>Fill in the path of a Chromium-based browser</value>
</data> </data>
<data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve"> <data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve">
<value>(Fill in extra Chromium startup arguments)</value> <value>Fill in extra Chromium startup arguments</value>
</data> </data>
<data name="SettingsBoxUpstreamUrlPlaceHolder" xml:space="preserve"> <data name="SettingsBoxUpstreamUrlPlaceHolder" xml:space="preserve">
<value>(Fill in the link to an upstream Cealing Host)</value> <value>Fill in the link to an upstream Cealing Host</value>
</data> </data>
<data name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve"> <data name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve">
<value>Browse</value> <value>Browse Path</value>
</data> </data>
<data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve"> <data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve">
<value>Clear</value> <value>Clear Args</value>
</data>
<data name="SettingsFunctionButtonToolTip" xml:space="preserve">
<value></value>
</data> </data>
<data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve"> <data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>Reset</value> <value>Reset Url</value>
</data> </data>
<data name="SettingsModeButtonBrowserPathContent" xml:space="preserve"> <data name="SettingsModeButtonToolTip" xml:space="preserve">
<value>Browser Path &gt;</value> <value></value>
</data>
<data name="SettingsModeButtonExtraArgsContent" xml:space="preserve">
<value>Additional Args &gt;</value>
</data>
<data name="SettingsModeButtonUpstreamUrlContent" xml:space="preserve">
<value>Upstream Url &gt;</value>
</data> </data>
<data name="StartCealButtonContent" xml:space="preserve"> <data name="StartCealButtonContent" xml:space="preserve">
<value>Start Cealing</value> <value>Start Cealing</value>
</data> </data>
<data name="StartCealButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="ThemesButtonDarkThemeContent" xml:space="preserve">
<value>Light Theme</value>
</data>
<data name="ThemesButtonInheritThemeContent" xml:space="preserve">
<value>Auto Theme</value>
</data>
<data name="ThemesButtonLightThemeContent" xml:space="preserve">
<value>Dark Theme</value>
</data>
<data name="ThemesButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="UpdateHostButtonContent" xml:space="preserve"> <data name="UpdateHostButtonContent" xml:space="preserve">
<value>Update Host</value> <value>Update Host</value>
</data> </data>
<data name="UpdateHostButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="UpstreamUrlModeName" xml:space="preserve">
<value>Upstream Url</value>
</data>
</root> </root>

View File

@ -120,40 +120,70 @@
<data name="AboutButtonContent" xml:space="preserve"> <data name="AboutButtonContent" xml:space="preserve">
<value>关于项目</value> <value>关于项目</value>
</data> </data>
<data name="AboutButtonToolTip" xml:space="preserve">
<value>点击打开关于窗口</value>
</data>
<data name="BrowserPathModeName" xml:space="preserve">
<value>文件路径</value>
</data>
<data name="EditHostButtonContent" xml:space="preserve"> <data name="EditHostButtonContent" xml:space="preserve">
<value>编辑规则</value> <value>编辑规则</value>
</data> </data>
<data name="EditHostButtonToolTip" xml:space="preserve">
<value>点击编辑伪造规则</value>
</data>
<data name="ExtraArgsModeName" xml:space="preserve">
<value>额外参数</value>
</data>
<data name="SettingsBoxBrowserPathPlaceHolder" xml:space="preserve"> <data name="SettingsBoxBrowserPathPlaceHolder" xml:space="preserve">
<value>(填入任意以 Chromium 为内核的浏览器的路径)</value> <value>填入任意以 Chromium 为内核的浏览器的路径</value>
</data> </data>
<data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve"> <data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve">
<value>(填入任意额外的 Chromium 启动参数)</value> <value>填入任意额外的 Chromium 启动参数</value>
</data> </data>
<data name="SettingsBoxUpstreamUrlPlaceHolder" xml:space="preserve"> <data name="SettingsBoxUpstreamUrlPlaceHolder" xml:space="preserve">
<value>(填入任意上游伪造规则的链接)</value> <value>填入任意上游伪造规则的链接</value>
</data> </data>
<data name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve"> <data name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve">
<value>浏览</value> <value>浏览路径</value>
</data> </data>
<data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve"> <data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve">
<value>清除</value> <value>清除参数</value>
</data>
<data name="SettingsFunctionButtonToolTip" xml:space="preserve">
<value>点击处理输入框内容</value>
</data> </data>
<data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve"> <data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>重置</value> <value>重置链接</value>
</data> </data>
<data name="SettingsModeButtonBrowserPathContent" xml:space="preserve"> <data name="SettingsModeButtonToolTip" xml:space="preserve">
<value>文件路径 &gt;</value> <value>点击切换输入框设置模式</value>
</data>
<data name="SettingsModeButtonExtraArgsContent" xml:space="preserve">
<value>额外参数 &gt;</value>
</data>
<data name="SettingsModeButtonUpstreamUrlContent" xml:space="preserve">
<value>上游链接 &gt;</value>
</data> </data>
<data name="StartCealButtonContent" xml:space="preserve"> <data name="StartCealButtonContent" xml:space="preserve">
<value>启动伪造</value> <value>启动伪造</value>
</data> </data>
<data name="StartCealButtonToolTip" xml:space="preserve">
<value>点击启动伪造注入后的浏览器</value>
</data>
<data name="ThemesButtonDarkThemeContent" xml:space="preserve">
<value>跟随系统</value>
</data>
<data name="ThemesButtonInheritThemeContent" xml:space="preserve">
<value>暗色模式</value>
</data>
<data name="ThemesButtonLightThemeContent" xml:space="preserve">
<value>亮色模式</value>
</data>
<data name="ThemesButtonToolTip" xml:space="preserve">
<value>点击切换显示主题</value>
</data>
<data name="UpdateHostButtonContent" xml:space="preserve"> <data name="UpdateHostButtonContent" xml:space="preserve">
<value>更新规则</value> <value>更新规则</value>
</data> </data>
<data name="UpdateHostButtonToolTip" xml:space="preserve">
<value>点击更新伪造规则</value>
</data>
<data name="UpstreamUrlModeName" xml:space="preserve">
<value>上游链接</value>
</data>
</root> </root>

View File

@ -1,30 +0,0 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using Sheas_Cealer.Consts;
namespace Sheas_Cealer.Convs;
internal class MainSettingsBoxForegroundConv : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
MainConst.SettingsMode? mode = values[0] as MainConst.SettingsMode?;
string? browserPath = values[1] as string;
string? upstreamUrl = values[2] as string;
string? extraArgs = values[3] as string;
switch (mode)
{
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));
}
return new SolidColorBrush(Color.FromRgb(0, 0, 0));
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
}

View File

@ -0,0 +1,25 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;
using Sheas_Cealer.Consts;
namespace Sheas_Cealer.Convs;
internal class MainSettingsBoxHintConv : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
MainConst.SettingsMode? mode = value as MainConst.SettingsMode?;
return mode switch
{
MainConst.SettingsMode.BrowserPathMode => MainConst.BrowserPathModeName,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.UpstreamUrlModeName,
MainConst.SettingsMode.ExtraArgsMode => MainConst.ExtraArgsModeName,
_ => throw new UnreachableException()
};
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}

View File

@ -10,19 +10,15 @@ internal class MainSettingsBoxTextConv : IMultiValueConverter
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{ {
MainConst.SettingsMode? mode = values[0] as MainConst.SettingsMode?; MainConst.SettingsMode? mode = values[0] as MainConst.SettingsMode?;
bool? isFocused = values[1] as bool?; string? browserPath = values[1] as string;
string? browserPath = values[2] as string; string? upstreamUrl = values[2] as string;
string? upstreamUrl = values[3] as string; string? extraArgs = values[3] as string;
string? extraArgs = values[4] as string;
return mode switch return mode switch
{ {
MainConst.SettingsMode.BrowserPathMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(browserPath) ? MainConst.SettingsBoxBrowserPathPlaceHolder : MainConst.SettingsMode.BrowserPathMode => browserPath!,
isFocused.GetValueOrDefault() && browserPath == MainConst.SettingsBoxBrowserPathPlaceHolder ? string.Empty : browserPath!, MainConst.SettingsMode.UpstreamUrlMode => upstreamUrl!,
MainConst.SettingsMode.UpstreamUrlMode => !isFocused.GetValueOrDefault() && string.IsNullOrEmpty(upstreamUrl) ? MainConst.SettingsBoxUpstreamUrlPlaceHolder : MainConst.SettingsMode.ExtraArgsMode => extraArgs!,
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(), _ => throw new UnreachableException(),
}; };
} }

View File

@ -0,0 +1,25 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;
using Sheas_Cealer.Consts;
namespace Sheas_Cealer.Convs;
internal class MainSettingsBoxToolTipConv : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
MainConst.SettingsMode? mode = value as MainConst.SettingsMode?;
return mode switch
{
MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsBoxBrowserPathPlaceHolder,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsBoxUpstreamUrlPlaceHolder,
MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsBoxExtraArgsPlaceHolder,
_ => throw new UnreachableException()
};
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}

View File

@ -13,9 +13,9 @@ internal class MainSettingsModeButtonContentConv : IValueConverter
return mode switch return mode switch
{ {
MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsModeButtonBrowserPathContent, MainConst.SettingsMode.BrowserPathMode => MainConst.UpstreamUrlModeName,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsModeButtonUpstreamUrlContent, MainConst.SettingsMode.UpstreamUrlMode => MainConst.ExtraArgsModeName,
MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsModeButtonExtraArgsContent, MainConst.SettingsMode.ExtraArgsMode => MainConst.BrowserPathModeName,
_ => throw new NotImplementedException() _ => throw new NotImplementedException()
}; };
} }

View File

@ -0,0 +1,18 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Sheas_Cealer.Consts;
namespace Sheas_Cealer.Convs;
internal class MainThemesButtonContentConv : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool? isLightMode = value as bool?;
return isLightMode.HasValue ? (isLightMode.GetValueOrDefault() ? MainConst.ThemesButtonLightThemeContent : MainConst.ThemesButtonDarkThemeContent) : MainConst.ThemesButtonInheritThemeContent;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}

View File

@ -1,6 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using Sheas_Cealer.Consts; using Sheas_Cealer.Consts;
using Sheas_Cealer.Props; using Sheas_Cealer.Props;
using File = System.IO.File; using File = System.IO.File;
@ -31,6 +35,16 @@ internal partial class MainPres : ObservableObject
[ObservableProperty] [ObservableProperty]
private MainConst.SettingsMode mode; private MainConst.SettingsMode mode;
[ObservableProperty]
private bool? isLightTheme = null;
partial void OnIsLightThemeChanged(bool? value)
{
PaletteHelper paletteHelper = new();
Theme newTheme = paletteHelper.GetTheme();
newTheme.SetBaseTheme(value.HasValue ? (value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark) : BaseTheme.Inherit);
paletteHelper.SetTheme(newTheme);
}
[ObservableProperty] [ObservableProperty]
private string browserPath; private string browserPath;
partial void OnBrowserPathChanged(string value) partial void OnBrowserPathChanged(string value)

View File

@ -6,8 +6,11 @@ namespace Sheas_Cealer.Utils;
internal class Command : Proc internal class Command : Proc
{ {
internal Command() : base("Cmd.exe") internal bool EnvironmentExitAfterProcessExited = true;
internal Command(bool environmentExitAfterProcessExited) : base("Cmd.exe")
{ {
EnvironmentExitAfterProcessExited = environmentExitAfterProcessExited;
} }
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
@ -16,5 +19,9 @@ internal class Command : Proc
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{ {
} }
public override void Process_Exited(object sender, EventArgs e) => Environment.Exit(0); public override void Process_Exited(object sender, EventArgs e)
{
if (EnvironmentExitAfterProcessExited)
Environment.Exit(0);
}
} }

View File

@ -6,7 +6,7 @@
xmlns:convs="clr-namespace:Sheas_Cealer.Convs" xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
xmlns:consts="clr-namespace:Sheas_Cealer.Consts" xmlns:consts="clr-namespace:Sheas_Cealer.Consts"
mc:Ignorable="d" mc:Ignorable="d"
Style="{DynamicResource CommonWindow}" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="500" MinWidth="500" Style="{DynamicResource CommonWindow}" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="600"
KeyDown="AboutWin_KeyDown"> KeyDown="AboutWin_KeyDown">
<Window.Resources> <Window.Resources>
<consts:AboutConst x:Key="AboutConst" /> <consts:AboutConst x:Key="AboutConst" />
@ -18,7 +18,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.1*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />

View File

@ -3,12 +3,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:consts="clr-namespace:Sheas_Cealer.Consts" xmlns:consts="clr-namespace:Sheas_Cealer.Consts"
xmlns:convs="clr-namespace:Sheas_Cealer.Convs" xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
xmlns:preses="clr-namespace:Sheas_Cealer.Preses" xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance preses:MainPres}" AllowDrop="True" d:DataContext="{d:DesignInstance preses:MainPres}" AllowDrop="True"
Style="{DynamicResource CommonWindow}" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" SizeToContent="Height" Width="500" MinWidth="500" Style="{DynamicResource CommonWindow}" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" SizeToContent="Height" Width="600"
Loaded="MainWin_Loaded" Closing="MainWin_Closing" DragEnter="MainWin_DragEnter" Drop="MainWin_Drop" KeyDown="MainWin_KeyDown"> Loaded="MainWin_Loaded" Closing="MainWin_Closing" DragEnter="MainWin_DragEnter" Drop="MainWin_Drop" KeyDown="MainWin_KeyDown">
<Window.Resources> <Window.Resources>
<consts:MainConst x:Key="MainConst" /> <consts:MainConst x:Key="MainConst" />
@ -16,7 +17,7 @@
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -28,7 +29,7 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="5" <Button Grid.Column="0" Margin="5" ToolTip="{Binding SettingsModeButtonToolTip, Source={StaticResource MainConst}}"
Click="SettingsModeButton_Click"> Click="SettingsModeButton_Click">
<Button.Content> <Button.Content>
<Binding Path="Mode"> <Binding Path="Mode">
@ -40,7 +41,7 @@
</Button> </Button>
<TextBox x:Name="SettingsBox" <TextBox x:Name="SettingsBox"
Grid.Column="1" Margin="5" VerticalContentAlignment="Center" Grid.Column="1" Margin="5" VerticalContentAlignment="Center" md:HintAssist.IsFloating="True"
TextChanged="SettingsBox_TextChanged" PreviewDragOver="MainWin_DragEnter"> TextChanged="SettingsBox_TextChanged" PreviewDragOver="MainWin_DragEnter">
<TextBox.Text> <TextBox.Text>
<MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged"> <MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged">
@ -49,26 +50,27 @@
</MultiBinding.Converter> </MultiBinding.Converter>
<Binding Path="Mode" /> <Binding Path="Mode" />
<Binding Path="IsFocused" RelativeSource="{RelativeSource Self}" />
<Binding Path="BrowserPath" /> <Binding Path="BrowserPath" />
<Binding Path="UpstreamUrl" /> <Binding Path="UpstreamUrl" />
<Binding Path="ExtraArgs" /> <Binding Path="ExtraArgs" />
</MultiBinding> </MultiBinding>
</TextBox.Text> </TextBox.Text>
<TextBox.Foreground> <TextBox.ToolTip>
<MultiBinding Mode="OneWay"> <Binding Path="Mode">
<MultiBinding.Converter> <Binding.Converter>
<convs:MainSettingsBoxForegroundConv /> <convs:MainSettingsBoxToolTipConv />
</MultiBinding.Converter> </Binding.Converter>
</Binding>
<Binding Path="Mode" /> </TextBox.ToolTip>
<Binding Path="BrowserPath" /> <md:HintAssist.Hint>
<Binding Path="UpstreamUrl" /> <Binding Path="Mode">
<Binding Path="ExtraArgs" /> <Binding.Converter>
</MultiBinding> <convs:MainSettingsBoxHintConv />
</TextBox.Foreground> </Binding.Converter>
</Binding>
</md:HintAssist.Hint>
</TextBox> </TextBox>
<Button Grid.Column="2" Margin="5" <Button Grid.Column="2" Margin="5" ToolTip="{Binding SettingsFunctionButtonToolTip, Source={StaticResource MainConst}}"
Click="SettingsFunctionButton_Click"> Click="SettingsFunctionButton_Click">
<Button.Content> <Button.Content>
<Binding Path="Mode"> <Binding Path="Mode">
@ -81,8 +83,8 @@
</Grid> </Grid>
<Button IsDefault="True" <Button IsDefault="True"
Grid.Row="1" Margin="5" Content="{Binding StartCealButtonContent, Source={StaticResource MainConst}}" Grid.Row="1" Margin="5" Content="{Binding StartCealButtonContent, Source={StaticResource MainConst}}" ToolTip="{Binding StartCealButtonToolTip, Source={StaticResource MainConst}}"
Click="StartCealButton_Click"> Click="StartCealButton_Click" PreviewMouseDown="StartCealButton_PreviewMouseDown">
<Button.IsEnabled> <Button.IsEnabled>
<MultiBinding> <MultiBinding>
@ -101,13 +103,14 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Name="EditHostButton" <Button x:Name="EditHostButton"
Grid.Column="0" Margin="5" Content="{Binding EditHostButtonContent, Source={StaticResource MainConst}}" Grid.Column="0" Margin="5" Content="{Binding EditHostButtonContent, Source={StaticResource MainConst}}" ToolTip="{Binding EditHostButtonToolTip, Source={StaticResource MainConst}}"
Click="EditHostButton_Click" /> Click="EditHostButton_Click" />
<Button x:Name="UpdateHostButton" <Button x:Name="UpdateHostButton"
Grid.Column="1" Margin="5" Content="{Binding UpdateHostButtonContent, Source={StaticResource MainConst}}" Grid.Column="1" Margin="5" Content="{Binding UpdateHostButtonContent, Source={StaticResource MainConst}}" ToolTip="{Binding UpdateHostButtonToolTip, Source={StaticResource MainConst}}"
Click="UpdateHostButton_Click"> Click="UpdateHostButton_Click">
<Button.IsEnabled> <Button.IsEnabled>
<Binding Path="UpstreamUrl"> <Binding Path="UpstreamUrl">
@ -117,8 +120,19 @@
</Binding> </Binding>
</Button.IsEnabled> </Button.IsEnabled>
</Button> </Button>
<Button x:Name="ThemesButton"
Grid.Column="2" Margin="5" ToolTip="{Binding ThemesButtonToolTip, Source={StaticResource MainConst}}"
Click="ThemesButton_Click">
<Button.Content>
<Binding Path="IsLightTheme">
<Binding.Converter>
<convs:MainThemesButtonContentConv />
</Binding.Converter>
</Binding>
</Button.Content>
</Button>
<Button x:Name="AboutButton" <Button x:Name="AboutButton"
Grid.Column="2" Margin="5" Content="{Binding AboutButtonContent, Source={StaticResource MainConst}}" Grid.Column="3" Margin="5" Content="{Binding AboutButtonContent, Source={StaticResource MainConst}}" ToolTip="{Binding AboutButtonToolTip, Source={StaticResource MainConst}}"
Click="AboutButton_Click" /> Click="AboutButton_Click" />
</Grid> </Grid>
</Grid> </Grid>

View File

@ -3,10 +3,13 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading;
using IWshRuntimeLibrary; using IWshRuntimeLibrary;
using MaterialDesignThemes.Wpf;
using Microsoft.Win32; using Microsoft.Win32;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OnaCore; using OnaCore;
@ -21,6 +24,7 @@ public partial class MainWin : Window
{ {
private static string CealArgs = string.Empty; private static string CealArgs = string.Empty;
private static readonly HttpClient MainClient = new(); private static readonly HttpClient MainClient = new();
private static DispatcherTimer HoldButtonTimer = new() { Interval = TimeSpan.FromSeconds(1) };
private static readonly FileSystemWatcher CealingHostWatcher = new(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json") { EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite }; private static readonly FileSystemWatcher CealingHostWatcher = new(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json") { EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite };
private static MainPres? MainPres; private static MainPres? MainPres;
@ -29,7 +33,11 @@ public partial class MainWin : Window
InitializeComponent(); InitializeComponent();
DataContext = MainPres = new(args); DataContext = MainPres = new(args);
CealingHostWatcher.Changed += CealingHostWatcher_Changed; Task.Run(() =>
{
CealingHostWatcher.Changed += CealingHostWatcher_Changed;
CealingHostWatcher_Changed(null!, null!);
});
} }
private void MainWin_Loaded(object sender, RoutedEventArgs e) => SettingsBox.Focus(); private void MainWin_Loaded(object sender, RoutedEventArgs e) => SettingsBox.Focus();
private void MainWin_Closing(object sender, CancelEventArgs e) => Environment.Exit(0); private void MainWin_Closing(object sender, CancelEventArgs e) => Environment.Exit(0);
@ -47,44 +55,40 @@ public partial class MainWin : Window
private void SettingsBox_TextChanged(object sender, TextChangedEventArgs e) private void SettingsBox_TextChanged(object sender, TextChangedEventArgs e)
{ {
TextBox? SettingsBox = sender as TextBox;
switch (MainPres!.Mode) switch (MainPres!.Mode)
{ {
case MainConst.SettingsMode.BrowserPathMode: case MainConst.SettingsMode.BrowserPathMode:
MainPres!.BrowserPath = SettingsBox!.Text; MainPres.BrowserPath = SettingsBox.Text;
return; return;
case MainConst.SettingsMode.UpstreamUrlMode: case MainConst.SettingsMode.UpstreamUrlMode:
MainPres!.UpstreamUrl = SettingsBox!.Text; MainPres.UpstreamUrl = SettingsBox.Text;
return; return;
case MainConst.SettingsMode.ExtraArgsMode: case MainConst.SettingsMode.ExtraArgsMode:
MainPres!.ExtraArgs = SettingsBox!.Text; MainPres.ExtraArgs = SettingsBox.Text;
return; return;
default:
throw new UnreachableException();
} }
} }
private void SettingsFunctionButton_Click(object sender, RoutedEventArgs e) private void SettingsFunctionButton_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog openFileDialog = new() { Filter = "浏览器 (*.exe)|*.exe" }; OpenFileDialog browserPathDialog = new() { Filter = "浏览器 (*.exe)|*.exe" };
switch (MainPres!.Mode) switch (MainPres!.Mode)
{ {
case MainConst.SettingsMode.BrowserPathMode when openFileDialog.ShowDialog().GetValueOrDefault(): case MainConst.SettingsMode.BrowserPathMode when browserPathDialog.ShowDialog().GetValueOrDefault():
SettingsBox.Focus(); SettingsBox.Focus();
MainPres!.BrowserPath = openFileDialog.FileName; MainPres.BrowserPath = browserPathDialog.FileName;
return; return;
case MainConst.SettingsMode.UpstreamUrlMode: case MainConst.SettingsMode.UpstreamUrlMode:
MainPres!.UpstreamUrl = MainConst.DefaultUpstreamUrl; MainPres.UpstreamUrl = MainConst.DefaultUpstreamUrl;
return; return;
case MainConst.SettingsMode.ExtraArgsMode: case MainConst.SettingsMode.ExtraArgsMode:
MainPres!.ExtraArgs = string.Empty; MainPres.ExtraArgs = string.Empty;
return; return;
} }
} }
private void SettingsModeButton_Click(object sender, RoutedEventArgs e) private void SettingsModeButton_Click(object sender, RoutedEventArgs e)
{ {
MainPres!.Mode = MainPres!.Mode switch MainPres!.Mode = MainPres.Mode switch
{ {
MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsMode.UpstreamUrlMode, MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsMode.UpstreamUrlMode,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsMode.ExtraArgsMode, MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsMode.ExtraArgsMode,
@ -95,6 +99,12 @@ public partial class MainWin : Window
private void StartCealButton_Click(object sender, RoutedEventArgs e) private void StartCealButton_Click(object sender, RoutedEventArgs e)
{ {
if (HoldButtonTimer.IsEnabled)
{
HoldButtonTimer.Stop();
return;
}
if (string.IsNullOrWhiteSpace(CealArgs)) if (string.IsNullOrWhiteSpace(CealArgs))
throw new Exception("规则无法识别,请检查伪造规则是否含有语法错误"); throw new Exception("规则无法识别,请检查伪造规则是否含有语法错误");
if (MessageBox.Show("启动前将关闭所选浏览器的所有进程,是否继续?", string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) if (MessageBox.Show("启动前将关闭所选浏览器的所有进程,是否继续?", string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
@ -105,13 +115,50 @@ public partial class MainWin : Window
uncealedBrowserShortcut.Description = "Created By Sheas Cealer"; uncealedBrowserShortcut.Description = "Created By Sheas Cealer";
uncealedBrowserShortcut.Save(); uncealedBrowserShortcut.Save();
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres!.BrowserPath))) foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
{ {
browserProcess.Kill(); browserProcess.Kill();
browserProcess.WaitForExit(); browserProcess.WaitForExit();
} }
new Command().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CealArgs + " " + MainPres!.ExtraArgs); new Command(true).ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CealArgs + (string.IsNullOrWhiteSpace(MainPres.ExtraArgs) ? "" : " " + MainPres.ExtraArgs));
}
private void StartCealButton_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
HoldButtonTimer = new() { Interval = TimeSpan.FromSeconds(1) };
HoldButtonTimer.Tick += StartCealButtonHoldButtonTimer_Tick;
HoldButtonTimer.Start();
}
private void StartCealButtonHoldButtonTimer_Tick(object? sender, EventArgs e)
{
HoldButtonTimer.Stop();
if (HoldButtonTimer.IsEnabled)
{
HoldButtonTimer.Stop();
return;
}
if (string.IsNullOrWhiteSpace(CealArgs))
throw new Exception("规则无法识别,请检查伪造规则是否含有语法错误");
if (MessageBox.Show("启动前将关闭所选浏览器的所有进程,是否继续?", string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
IWshShortcut uncealedBrowserShortcut = (IWshShortcut)new WshShell().CreateShortcut(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Uncealed-Browser.lnk"));
uncealedBrowserShortcut.TargetPath = MainPres!.BrowserPath;
uncealedBrowserShortcut.Description = "Created By Sheas Cealer";
uncealedBrowserShortcut.Save();
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
{
browserProcess.Kill();
browserProcess.WaitForExit();
}
if (string.IsNullOrWhiteSpace(MainPres.ExtraArgs))
MainPres.ExtraArgs = " " + MainPres.ExtraArgs;
new Command(false).ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CealArgs + (string.IsNullOrWhiteSpace(MainPres.ExtraArgs) ? "" : " " + MainPres.ExtraArgs));
} }
private void EditHostButton_Click(object sender, RoutedEventArgs e) private void EditHostButton_Click(object sender, RoutedEventArgs e)
@ -140,6 +187,7 @@ public partial class MainWin : Window
Process.Start(new ProcessStartInfo(hostUrl) { UseShellExecute = true }); Process.Start(new ProcessStartInfo(hostUrl) { UseShellExecute = true });
} }
} }
private void ThemesButton_Click(object sender, RoutedEventArgs e) => MainPres!.IsLightTheme = MainPres.IsLightTheme.HasValue ? (MainPres.IsLightTheme.Value ? null : true) : false;
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog(); private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog();
private void CealingHostWatcher_Changed(object sender, FileSystemEventArgs e) private void CealingHostWatcher_Changed(object sender, FileSystemEventArgs e)