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>
<ResourceDictionary>
<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.MergedDictionaries>
@ -15,12 +15,12 @@
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
</Style>
<Style BasedOn="{StaticResource MaterialDesignFilledTextBox}" TargetType="{x:Type TextBox}" />
<Style BasedOn="{StaticResource MaterialDesignRaisedButton}" TargetType="{x:Type Button}">
<Setter Property="Height" Value="Auto" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Background" Value="Red" />
</Style>
<Style BasedOn="{StaticResource MaterialDesignCaptionHyperlink}" TargetType="{x:Type Hyperlink}" />
</ResourceDictionary>
</Application.Resources>
</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>
/// 查找类似 Edit Host 的本地化字符串。
/// </summary>
@ -79,7 +97,25 @@ namespace Sheas_Cealer.Consts {
}
/// <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>
public static string SettingsBoxBrowserPathPlaceHolder {
get {
@ -88,7 +124,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 (Fill in extra Chromium startup arguments) 的本地化字符串。
/// 查找类似 Fill in extra Chromium startup arguments 的本地化字符串。
/// </summary>
public static string SettingsBoxExtraArgsPlaceHolder {
get {
@ -97,7 +133,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 (Fill in the link to an upstream Cealing Host) 的本地化字符串。
/// 查找类似 Fill in the link to an upstream Cealing Host 的本地化字符串。
/// </summary>
public static string SettingsBoxUpstreamUrlPlaceHolder {
get {
@ -106,7 +142,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Browse 的本地化字符串。
/// 查找类似 Browse Path 的本地化字符串。
/// </summary>
public static string SettingsFunctionButtonBrowserPathContent {
get {
@ -115,7 +151,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Clear 的本地化字符串。
/// 查找类似 Clear Args 的本地化字符串。
/// </summary>
public static string SettingsFunctionButtonExtraArgsContent {
get {
@ -124,7 +160,16 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Reset 的本地化字符串。
/// 查找类似 的本地化字符串。
/// </summary>
public static string SettingsFunctionButtonToolTip {
get {
return ResourceManager.GetString("SettingsFunctionButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Reset Url 的本地化字符串。
/// </summary>
public static string SettingsFunctionButtonUpstreamUrlContent {
get {
@ -133,29 +178,11 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Browser Path &gt; 的本地化字符串。
/// 查找类似 的本地化字符串。
/// </summary>
public static string SettingsModeButtonBrowserPathContent {
public static string SettingsModeButtonToolTip {
get {
return ResourceManager.GetString("SettingsModeButtonBrowserPathContent", 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);
return ResourceManager.GetString("SettingsModeButtonToolTip", 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>
/// 查找类似 Update Host 的本地化字符串。
/// </summary>
@ -176,5 +248,23 @@ namespace Sheas_Cealer.Consts {
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">
<value>About Me</value>
</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">
<value>Edit Host</value>
</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">
<value>(Fill in the path of a Chromium-based browser)</value>
<value>Fill in the path of a Chromium-based browser</value>
</data>
<data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve">
<value>(Fill in extra Chromium startup arguments)</value>
<value>Fill in extra Chromium startup arguments</value>
</data>
<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 name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve">
<value>Browse</value>
<value>Browse Path</value>
</data>
<data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve">
<value>Clear</value>
<value>Clear Args</value>
</data>
<data name="SettingsFunctionButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>Reset</value>
<value>Reset Url</value>
</data>
<data name="SettingsModeButtonBrowserPathContent" xml:space="preserve">
<value>Browser Path &gt;</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 name="SettingsModeButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="StartCealButtonContent" xml:space="preserve">
<value>Start Cealing</value>
</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">
<value>Update Host</value>
</data>
<data name="UpdateHostButtonToolTip" xml:space="preserve">
<value></value>
</data>
<data name="UpstreamUrlModeName" xml:space="preserve">
<value>Upstream Url</value>
</data>
</root>

View File

@ -120,40 +120,70 @@
<data name="AboutButtonContent" xml:space="preserve">
<value>关于项目</value>
</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">
<value>编辑规则</value>
</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">
<value>(填入任意以 Chromium 为内核的浏览器的路径)</value>
<value>填入任意以 Chromium 为内核的浏览器的路径</value>
</data>
<data name="SettingsBoxExtraArgsPlaceHolder" xml:space="preserve">
<value>(填入任意额外的 Chromium 启动参数)</value>
<value>填入任意额外的 Chromium 启动参数</value>
</data>
<data name="SettingsBoxUpstreamUrlPlaceHolder" xml:space="preserve">
<value>(填入任意上游伪造规则的链接)</value>
<value>填入任意上游伪造规则的链接</value>
</data>
<data name="SettingsFunctionButtonBrowserPathContent" xml:space="preserve">
<value>浏览</value>
<value>浏览路径</value>
</data>
<data name="SettingsFunctionButtonExtraArgsContent" xml:space="preserve">
<value>清除</value>
<value>清除参数</value>
</data>
<data name="SettingsFunctionButtonToolTip" xml:space="preserve">
<value>点击处理输入框内容</value>
</data>
<data name="SettingsFunctionButtonUpstreamUrlContent" xml:space="preserve">
<value>重置</value>
<value>重置链接</value>
</data>
<data name="SettingsModeButtonBrowserPathContent" xml:space="preserve">
<value>文件路径 &gt;</value>
</data>
<data name="SettingsModeButtonExtraArgsContent" xml:space="preserve">
<value>额外参数 &gt;</value>
</data>
<data name="SettingsModeButtonUpstreamUrlContent" xml:space="preserve">
<value>上游链接 &gt;</value>
<data name="SettingsModeButtonToolTip" xml:space="preserve">
<value>点击切换输入框设置模式</value>
</data>
<data name="StartCealButtonContent" xml:space="preserve">
<value>启动伪造</value>
</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">
<value>更新规则</value>
</data>
<data name="UpdateHostButtonToolTip" xml:space="preserve">
<value>点击更新伪造规则</value>
</data>
<data name="UpstreamUrlModeName" xml:space="preserve">
<value>上游链接</value>
</data>
</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)
{
MainConst.SettingsMode? mode = values[0] as MainConst.SettingsMode?;
bool? isFocused = values[1] as bool?;
string? browserPath = values[2] as string;
string? upstreamUrl = values[3] as string;
string? extraArgs = values[4] as string;
string? browserPath = values[1] as string;
string? upstreamUrl = values[2] as string;
string? extraArgs = values[3] as string;
return mode switch
{
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!,
MainConst.SettingsMode.BrowserPathMode => browserPath!,
MainConst.SettingsMode.UpstreamUrlMode => upstreamUrl!,
MainConst.SettingsMode.ExtraArgsMode => extraArgs!,
_ => 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
{
MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsModeButtonBrowserPathContent,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsModeButtonUpstreamUrlContent,
MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsModeButtonExtraArgsContent,
MainConst.SettingsMode.BrowserPathMode => MainConst.UpstreamUrlModeName,
MainConst.SettingsMode.UpstreamUrlMode => MainConst.ExtraArgsModeName,
MainConst.SettingsMode.ExtraArgsMode => MainConst.BrowserPathModeName,
_ => 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.IO;
using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using Sheas_Cealer.Consts;
using Sheas_Cealer.Props;
using File = System.IO.File;
@ -31,6 +35,16 @@ internal partial class MainPres : ObservableObject
[ObservableProperty]
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]
private string browserPath;
partial void OnBrowserPathChanged(string value)

View File

@ -6,8 +6,11 @@ namespace Sheas_Cealer.Utils;
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)
@ -16,5 +19,9 @@ internal class Command : Proc
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:consts="clr-namespace:Sheas_Cealer.Consts"
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">
<Window.Resources>
<consts:AboutConst x:Key="AboutConst" />
@ -18,7 +18,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.1*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />

View File

@ -3,12 +3,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:convs="clr-namespace:Sheas_Cealer.Convs"
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
mc:Ignorable="d"
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">
<Window.Resources>
<consts:MainConst x:Key="MainConst" />
@ -16,7 +17,7 @@
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@ -28,7 +29,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="5"
<Button Grid.Column="0" Margin="5" ToolTip="{Binding SettingsModeButtonToolTip, Source={StaticResource MainConst}}"
Click="SettingsModeButton_Click">
<Button.Content>
<Binding Path="Mode">
@ -40,7 +41,7 @@
</Button>
<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">
<TextBox.Text>
<MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged">
@ -49,26 +50,27 @@
</MultiBinding.Converter>
<Binding Path="Mode" />
<Binding Path="IsFocused" RelativeSource="{RelativeSource Self}" />
<Binding Path="BrowserPath" />
<Binding Path="UpstreamUrl" />
<Binding Path="ExtraArgs" />
</MultiBinding>
</TextBox.Text>
<TextBox.Foreground>
<MultiBinding Mode="OneWay">
<MultiBinding.Converter>
<convs:MainSettingsBoxForegroundConv />
</MultiBinding.Converter>
<Binding Path="Mode" />
<Binding Path="BrowserPath" />
<Binding Path="UpstreamUrl" />
<Binding Path="ExtraArgs" />
</MultiBinding>
</TextBox.Foreground>
<TextBox.ToolTip>
<Binding Path="Mode">
<Binding.Converter>
<convs:MainSettingsBoxToolTipConv />
</Binding.Converter>
</Binding>
</TextBox.ToolTip>
<md:HintAssist.Hint>
<Binding Path="Mode">
<Binding.Converter>
<convs:MainSettingsBoxHintConv />
</Binding.Converter>
</Binding>
</md:HintAssist.Hint>
</TextBox>
<Button Grid.Column="2" Margin="5"
<Button Grid.Column="2" Margin="5" ToolTip="{Binding SettingsFunctionButtonToolTip, Source={StaticResource MainConst}}"
Click="SettingsFunctionButton_Click">
<Button.Content>
<Binding Path="Mode">
@ -81,8 +83,8 @@
</Grid>
<Button IsDefault="True"
Grid.Row="1" Margin="5" Content="{Binding StartCealButtonContent, Source={StaticResource MainConst}}"
Click="StartCealButton_Click">
Grid.Row="1" Margin="5" Content="{Binding StartCealButtonContent, Source={StaticResource MainConst}}" ToolTip="{Binding StartCealButtonToolTip, Source={StaticResource MainConst}}"
Click="StartCealButton_Click" PreviewMouseDown="StartCealButton_PreviewMouseDown">
<Button.IsEnabled>
<MultiBinding>
@ -101,13 +103,14 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<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" />
<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">
<Button.IsEnabled>
<Binding Path="UpstreamUrl">
@ -117,8 +120,19 @@
</Binding>
</Button.IsEnabled>
</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"
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" />
</Grid>
</Grid>

View File

@ -3,10 +3,13 @@ using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using IWshRuntimeLibrary;
using MaterialDesignThemes.Wpf;
using Microsoft.Win32;
using Newtonsoft.Json.Linq;
using OnaCore;
@ -21,6 +24,7 @@ public partial class MainWin : Window
{
private static string CealArgs = string.Empty;
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 MainPres? MainPres;
@ -29,7 +33,11 @@ public partial class MainWin : Window
InitializeComponent();
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_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)
{
TextBox? SettingsBox = sender as TextBox;
switch (MainPres!.Mode)
{
case MainConst.SettingsMode.BrowserPathMode:
MainPres!.BrowserPath = SettingsBox!.Text;
MainPres.BrowserPath = SettingsBox.Text;
return;
case MainConst.SettingsMode.UpstreamUrlMode:
MainPres!.UpstreamUrl = SettingsBox!.Text;
MainPres.UpstreamUrl = SettingsBox.Text;
return;
case MainConst.SettingsMode.ExtraArgsMode:
MainPres!.ExtraArgs = SettingsBox!.Text;
MainPres.ExtraArgs = SettingsBox.Text;
return;
default:
throw new UnreachableException();
}
}
private void SettingsFunctionButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new() { Filter = "浏览器 (*.exe)|*.exe" };
OpenFileDialog browserPathDialog = new() { Filter = "浏览器 (*.exe)|*.exe" };
switch (MainPres!.Mode)
{
case MainConst.SettingsMode.BrowserPathMode when openFileDialog.ShowDialog().GetValueOrDefault():
case MainConst.SettingsMode.BrowserPathMode when browserPathDialog.ShowDialog().GetValueOrDefault():
SettingsBox.Focus();
MainPres!.BrowserPath = openFileDialog.FileName;
MainPres.BrowserPath = browserPathDialog.FileName;
return;
case MainConst.SettingsMode.UpstreamUrlMode:
MainPres!.UpstreamUrl = MainConst.DefaultUpstreamUrl;
MainPres.UpstreamUrl = MainConst.DefaultUpstreamUrl;
return;
case MainConst.SettingsMode.ExtraArgsMode:
MainPres!.ExtraArgs = string.Empty;
MainPres.ExtraArgs = string.Empty;
return;
}
}
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.UpstreamUrlMode => MainConst.SettingsMode.ExtraArgsMode,
@ -95,6 +99,12 @@ public partial class MainWin : Window
private void StartCealButton_Click(object sender, RoutedEventArgs e)
{
if (HoldButtonTimer.IsEnabled)
{
HoldButtonTimer.Stop();
return;
}
if (string.IsNullOrWhiteSpace(CealArgs))
throw new Exception("规则无法识别,请检查伪造规则是否含有语法错误");
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.Save();
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres!.BrowserPath)))
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
{
browserProcess.Kill();
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)
@ -140,6 +187,7 @@ public partial class MainWin : Window
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 CealingHostWatcher_Changed(object sender, FileSystemEventArgs e)