├── Sheas-Cealer-Logo.ico ├── Consts ├── SettingsConst.cs ├── AboutConst.cs ├── MainConst.cs ├── AboutMultilangConst.Designer.cs ├── AboutMultilangConst.zh.resx ├── SettingsMultilangConst.zh.resx ├── SettingsMultilangConst.resx ├── AboutMultilangConst.resx ├── SettingsMultilangConst.Designer.cs ├── MainMultilangConst.zh.resx ├── MainMultilangConst.resx └── MainMultilangConst.Designer.cs ├── Proces ├── MihomoProc.cs ├── ComihomoProc.cs ├── NginxProc.cs ├── ConginxProc.cs └── BrowserProc.cs ├── Preses ├── AboutPres.cs ├── GlobalPres.cs ├── SettingsPres.cs └── MainPres.cs ├── Convs ├── AboutConv.cs ├── SettingsConv.cs ├── MainWinWidthConv.cs ├── MainAdminControlVisibilityConv.cs ├── MainProxyColumnWidthConv.cs ├── AboutAccentButtonForegroundConv.cs ├── MainUpdateHostButtonIsEnabledConv.cs ├── MainNoClickButtonContentConv.cs ├── MainNoClickButtonToolTipConv.cs ├── MainMihomoButtonToolTipConv.cs ├── MainUpdateHostButtonContentConv.cs ├── MainNginxButtonToolTipConv.cs ├── AboutVersionButtonContentConv.cs ├── MainBrowserButtonIsEnabledConv.cs ├── SettingsThemesButtonContentConv.cs ├── SettingsLangsButtonContentConv.cs ├── SettingsWeightsButtonContentConv.cs ├── MainMihomoButtonIsEnabledConv.cs ├── MainNginxButtonIsEnabledConv.cs ├── MainNginxButtonContentConv.cs ├── MainSettingsBoxToolTipConv.cs ├── MainSettingsModeButtonContentConv.cs ├── MainSettingsBoxHintConv.cs ├── MainSettingsFunctionButtonContentConv.cs ├── MainSettingsBoxTextConv.cs ├── MainMihomoButtonContentConv.cs └── MainConv.cs ├── Utils ├── DnsFlusher.cs ├── BorderThemeSetter.cs ├── NginxCleaner.cs ├── IconRemover.cs └── ForegroundGenerator.cs ├── Props ├── Settings.settings └── Settings.Designer.cs ├── App.xaml ├── Wins ├── SettingsWin.xaml ├── AboutWin.xaml.cs ├── SettingsWin.xaml.cs ├── AboutWin.xaml └── MainWin.xaml ├── .filenesting.json ├── App.xaml.cs ├── Sheas-Cealer.sln ├── .gitattributes ├── README.md ├── README_EN.md ├── Sheas-Cealer.csproj └── .gitignore /Sheas-Cealer-Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceTimee/Sheas-Cealer/HEAD/Sheas-Cealer-Logo.ico -------------------------------------------------------------------------------- /Consts/SettingsConst.cs: -------------------------------------------------------------------------------- 1 | namespace Sheas_Cealer.Consts; 2 | 3 | internal abstract class SettingsConst : SettingsMultilangConst; -------------------------------------------------------------------------------- /Proces/MihomoProc.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using Sheas_Core; 3 | 4 | namespace Sheas_Cealer.Proces; 5 | 6 | internal class MihomoProc : Proc 7 | { 8 | internal MihomoProc() : base(MainConst.MihomoPath) { } 9 | } -------------------------------------------------------------------------------- /Proces/ComihomoProc.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using Sheas_Core; 3 | 4 | namespace Sheas_Cealer.Proces; 5 | 6 | internal class ComihomoProc : Proc 7 | { 8 | internal ComihomoProc() : base(MainConst.ComihomoPath) { } 9 | } -------------------------------------------------------------------------------- /Preses/AboutPres.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | 3 | namespace Sheas_Cealer.Preses; 4 | 5 | internal partial class AboutPres : GlobalPres 6 | { 7 | [ObservableProperty] 8 | private bool isSheasCealerUtd = true; 9 | } -------------------------------------------------------------------------------- /Convs/AboutConv.cs: -------------------------------------------------------------------------------- 1 | namespace Sheas_Cealer.Convs; 2 | 3 | internal static class AboutConv 4 | { 5 | public static AboutAccentButtonForegroundConv AboutAccentButtonForegroundConv => new(); 6 | public static AboutVersionButtonContentConv AboutVersionButtonContentConv => new(); 7 | } -------------------------------------------------------------------------------- /Utils/DnsFlusher.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Sheas_Cealer.Utils; 4 | 5 | internal static partial class DnsFlusher 6 | { 7 | [LibraryImport("dnsapi.dll")] 8 | private static partial void DnsFlushResolverCache(); 9 | 10 | internal static void FlushDns() => DnsFlushResolverCache(); 11 | } 12 | -------------------------------------------------------------------------------- /Convs/SettingsConv.cs: -------------------------------------------------------------------------------- 1 | namespace Sheas_Cealer.Convs; 2 | 3 | internal static class SettingsConv 4 | { 5 | public static SettingsLangsButtonContentConv SettingsLangsButtonContentConv => new(); 6 | public static SettingsThemesButtonContentConv SettingsThemesButtonContentConv => new(); 7 | public static SettingsWeightsButtonContentConv SettingsWeightsButtonContentConv => new(); 8 | } -------------------------------------------------------------------------------- /Proces/NginxProc.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using Sheas_Cealer.Utils; 3 | using Sheas_Core; 4 | using System; 5 | 6 | namespace Sheas_Cealer.Proces; 7 | 8 | internal class NginxProc : Proc 9 | { 10 | internal NginxProc() : base(MainConst.NginxPath) { } 11 | 12 | protected override async void Process_Exited(object? sender, EventArgs e) => await NginxCleaner.Clean(); 13 | } -------------------------------------------------------------------------------- /Proces/ConginxProc.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using Sheas_Cealer.Utils; 3 | using Sheas_Core; 4 | using System; 5 | 6 | namespace Sheas_Cealer.Proces; 7 | 8 | internal class ConginxProc : Proc 9 | { 10 | internal ConginxProc() : base(MainConst.ConginxPath) { } 11 | 12 | protected override async void Process_Exited(object? sender, EventArgs e) => await NginxCleaner.Clean(); 13 | } -------------------------------------------------------------------------------- /Convs/MainWinWidthConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Sheas_Cealer.Convs; 6 | 7 | internal class MainWinWidthConv : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | bool isAdmin = (bool)value; 12 | 13 | return isAdmin ? 708 : 500; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 17 | } -------------------------------------------------------------------------------- /Proces/BrowserProc.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Core; 2 | using System; 3 | using System.Windows; 4 | 5 | namespace Sheas_Cealer.Proces; 6 | 7 | internal class BrowserProc : Proc 8 | { 9 | private readonly bool ShutDownAppOnProcessExit; 10 | 11 | internal BrowserProc(string browserPath, bool shutDownAppOnProcessExit) : base(browserPath) => ShutDownAppOnProcessExit = shutDownAppOnProcessExit; 12 | 13 | protected sealed override void Process_Exited(object? sender, EventArgs e) 14 | { 15 | if (ShutDownAppOnProcessExit) 16 | Application.Current.Dispatcher.InvokeShutdown(); 17 | } 18 | } -------------------------------------------------------------------------------- /Convs/MainAdminControlVisibilityConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainAdminControlVisibilityConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isAdmin = (bool)value; 13 | 14 | return isAdmin ? Visibility.Visible : Visibility.Collapsed; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainProxyColumnWidthConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainProxyColumnWidthConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isAdmin = (bool)value; 13 | 14 | return new GridLength(1, isAdmin ? GridUnitType.Star : GridUnitType.Auto); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/AboutAccentButtonForegroundConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class AboutAccentButtonForegroundConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | Color accentForegroundColor = (Color)value; 13 | 14 | return new SolidColorBrush(accentForegroundColor); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainUpdateHostButtonIsEnabledConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainUpdateHostButtonIsEnabledConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | string upstreamUrl = (string)value; 13 | 14 | return MainConst.UpstreamUrlRegex().IsMatch(upstreamUrl); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainNoClickButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainNoClickButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isFlashing = (bool)value; 13 | 14 | return isFlashing ? MainConst.NoClickButtonIsFlashingContent : MainConst.NoClickButtonIsStoppedContent; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainNoClickButtonToolTipConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainNoClickButtonToolTipConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isFlashing = (bool)value; 13 | 14 | return isFlashing ? MainConst.NoClickButtonIsFlashingToolTip : MainConst.NoClickButtonIsStoppedToolTip; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainMihomoButtonToolTipConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainMihomoButtonToolTipConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isMihomoRunning = (bool)value; 13 | 14 | return isMihomoRunning ? MainConst.MihomoButtonIsRunningToolTip : MainConst.MihomoButtonIsStoppedToolTip; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainUpdateHostButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainUpdateHostButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isUpstreamHostUtd = (bool)value; 13 | 14 | return MainConst.UpdateUpstreamHostButtonContent + (isUpstreamHostUtd ? string.Empty : " *"); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 18 | } -------------------------------------------------------------------------------- /Convs/MainNginxButtonToolTipConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainNginxButtonToolTipConv : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isConginxRunning = (bool)values[0]; 13 | bool isNginxRunning = (bool)values[1]; 14 | 15 | return isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningToolTip : MainConst.NginxButtonIsStoppedToolTip; 16 | } 17 | 18 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 19 | } -------------------------------------------------------------------------------- /Convs/AboutVersionButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Sheas_Cealer.Convs; 6 | 7 | internal class AboutVersionButtonContentConv : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | string versionButtonLabelContent = (string)values[0]; 12 | string versionButtonVersionContent = (string)values[1]; 13 | bool isSheasCealerUtd = (bool)values[2]; 14 | 15 | return $"{versionButtonLabelContent} {versionButtonVersionContent}" + (isSheasCealerUtd ? string.Empty : " *"); 16 | } 17 | 18 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 19 | } -------------------------------------------------------------------------------- /Convs/MainBrowserButtonIsEnabledConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Windows.Data; 6 | 7 | namespace Sheas_Cealer.Convs; 8 | 9 | internal class MainBrowserButtonIsEnabledConv : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | string browserPath = (string)values[0]; 14 | string extraArgs = (string)values[1]; 15 | 16 | return File.Exists(browserPath) && Path.GetFileName(browserPath).ToLowerInvariant().EndsWith(".exe") && MainConst.ExtraArgsRegex().IsMatch(extraArgs); 17 | } 18 | 19 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 20 | } -------------------------------------------------------------------------------- /Convs/SettingsThemesButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class SettingsThemesButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool? isLightMode = value as bool?; 13 | 14 | return isLightMode.HasValue ? 15 | isLightMode.GetValueOrDefault() ? SettingsConst.ThemesButtonLightThemeContent : SettingsConst.ThemesButtonDarkThemeContent : 16 | SettingsConst.ThemesButtonInheritThemeContent; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 20 | } -------------------------------------------------------------------------------- /Convs/SettingsLangsButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class SettingsLangsButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool? isEnglishLang = value as bool?; 13 | 14 | return isEnglishLang.HasValue ? 15 | isEnglishLang.GetValueOrDefault() ? SettingsConst.LangsButtonEnglishLangContent : SettingsConst.LangsButtonChineseLangContent : 16 | SettingsConst.LangsButtonInheritLangContent; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 20 | } -------------------------------------------------------------------------------- /Convs/SettingsWeightsButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class SettingsWeightsButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool? isLightWeight = value as bool?; 13 | 14 | return isLightWeight.HasValue ? 15 | isLightWeight.GetValueOrDefault() ? SettingsConst.WeightsButtonLightWeightContent : SettingsConst.WeightsButtonBoldWeightContent : 16 | SettingsConst.WeightsButtonRegularWeightContent; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 20 | } -------------------------------------------------------------------------------- /Convs/MainMihomoButtonIsEnabledConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Sheas_Cealer.Convs; 6 | 7 | internal class MainMihomoButtonIsEnabledConv : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | bool isCoMihomoExist = (bool)values[0]; 12 | bool isMihomoExist = (bool)values[1]; 13 | bool isCoproxyIniting = (bool)values[2]; 14 | bool isComihomoIniting = (bool)values[3]; 15 | bool isMihomoIniting = (bool)values[4]; 16 | 17 | return !isCoproxyIniting && !isComihomoIniting && !isMihomoIniting && (isCoMihomoExist || isMihomoExist); 18 | } 19 | 20 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 21 | } -------------------------------------------------------------------------------- /Convs/MainNginxButtonIsEnabledConv.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Sheas_Cealer.Convs; 6 | 7 | internal class MainNginxButtonIsEnabledConv : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | bool isConginxExist = (bool)values[0]; 12 | bool isNginxExist = (bool)values[1]; 13 | bool isCoproxyIniting = (bool)values[2]; 14 | bool isNginxIniting = (bool)values[3]; 15 | bool isComihomoIniting = (bool)values[4]; 16 | bool isMihomoIniting = (bool)values[5]; 17 | 18 | return !isCoproxyIniting && !isNginxIniting && !isComihomoIniting && !isMihomoIniting && (isConginxExist || isNginxExist); 19 | } 20 | 21 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 22 | } -------------------------------------------------------------------------------- /Convs/MainNginxButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainNginxButtonContentConv : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isConginxRunning = (bool)values[0]; 13 | bool isNginxRunning = (bool)values[1]; 14 | bool isCoproxyIniting = (bool)values[2]; 15 | bool isNginxIniting = (bool)values[3]; 16 | 17 | return isCoproxyIniting ? MainConst.ConginxButtonIsInitingContent : 18 | isNginxIniting ? MainConst.NginxButtonIsInitingContent : 19 | isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent; 20 | } 21 | 22 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 23 | } -------------------------------------------------------------------------------- /Convs/MainSettingsBoxToolTipConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | namespace Sheas_Cealer.Convs; 8 | 9 | internal class MainSettingsBoxToolTipConv : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value; 14 | 15 | return settingsMode switch 16 | { 17 | MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsBoxBrowserPathToolTip, 18 | MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsBoxUpstreamUrlToolTip, 19 | MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsBoxExtraArgsToolTip, 20 | _ => throw new UnreachableException() 21 | }; 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 25 | } -------------------------------------------------------------------------------- /Convs/MainSettingsModeButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainSettingsModeButtonContentConv : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value; 13 | 14 | return settingsMode switch 15 | { 16 | MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsModeButtonUpstreamUrlContent, 17 | MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsModeButtonExtraArgsContent, 18 | MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsModeButtonBrowserPathContent, 19 | _ => throw new NotImplementedException() 20 | }; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 24 | } -------------------------------------------------------------------------------- /Convs/MainSettingsBoxHintConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | namespace Sheas_Cealer.Convs; 8 | 9 | internal class MainSettingsBoxHintConv : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value; 14 | 15 | return settingsMode switch 16 | { 17 | MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsModeButtonBrowserPathContent, 18 | MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsModeButtonUpstreamUrlContent, 19 | MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsModeButtonExtraArgsContent, 20 | _ => throw new UnreachableException() 21 | }; 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 25 | } -------------------------------------------------------------------------------- /Convs/MainSettingsFunctionButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | namespace Sheas_Cealer.Convs; 8 | 9 | internal class MainSettingsFunctionButtonContentConv : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value; 14 | 15 | return settingsMode switch 16 | { 17 | MainConst.SettingsMode.BrowserPathMode => MainConst.SettingsFunctionButtonBrowserPathContent, 18 | MainConst.SettingsMode.UpstreamUrlMode => MainConst.SettingsFunctionButtonUpstreamUrlContent, 19 | MainConst.SettingsMode.ExtraArgsMode => MainConst.SettingsFunctionButtonExtraArgsContent, 20 | _ => throw new UnreachableException() 21 | }; 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); 25 | } -------------------------------------------------------------------------------- /Convs/MainSettingsBoxTextConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | namespace Sheas_Cealer.Convs; 8 | 9 | internal class MainSettingsBoxTextConv : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)values[0]; 14 | string browserPath = (string)values[1]; 15 | string upstreamUrl = (string)values[2]; 16 | string extraArgs = (string)values[3]; 17 | 18 | return settingsMode switch 19 | { 20 | MainConst.SettingsMode.BrowserPathMode => browserPath, 21 | MainConst.SettingsMode.UpstreamUrlMode => upstreamUrl, 22 | MainConst.SettingsMode.ExtraArgsMode => extraArgs, 23 | _ => throw new UnreachableException() 24 | }; 25 | } 26 | 27 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 28 | } -------------------------------------------------------------------------------- /Convs/MainMihomoButtonContentConv.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Sheas_Cealer.Convs; 7 | 8 | internal class MainMihomoButtonContentConv : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool isMihomoRunning = (bool)values[0]; 13 | bool isComihomoIniting = (bool)values[1]; 14 | bool isMihomoIniting = (bool)values[2]; 15 | bool isCoproxyIniting = (bool)values[3]; 16 | bool isCoproxyStopping = (bool)values[4]; 17 | 18 | return isCoproxyIniting || isCoproxyStopping ? Binding.DoNothing : 19 | isComihomoIniting ? MainConst.MihomoButtonIsStoppingContent : 20 | isMihomoIniting ? MainConst.MihomoButtonIsInitingContent : 21 | isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent; 22 | } 23 | 24 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); 25 | } -------------------------------------------------------------------------------- /Props/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 244, 67, 54 16 | 17 | 18 | -1 19 | 20 | 21 | -1 22 | 23 | 24 | -1 25 | 26 | 27 | True 28 | 29 | 30 | -------------------------------------------------------------------------------- /Utils/BorderThemeSetter.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System.Windows; 3 | using System.Windows.Interop; 4 | 5 | namespace Sheas_Cealer.Utils; 6 | 7 | internal static partial class BorderThemeSetter 8 | { 9 | private const int DwmwaUseImmersiveDarkModeOld = 19; 10 | private const int DwmwaUseImmersiveDarkMode = 20; 11 | 12 | [LibraryImport("dwmapi.dll")] 13 | private static partial void DwmGetWindowAttribute(nint hwnd, uint attr, out nint attrValue, uint attrSize); 14 | [LibraryImport("dwmapi.dll")] 15 | private static partial void DwmSetWindowAttribute(nint hwnd, uint attr, ref nint attrValue, uint attrSize); 16 | 17 | internal static void SetBorderTheme(Window window, bool? isLightTheme) 18 | { 19 | nint isDarkTheme; 20 | nint desktopHwnd = nint.Zero; 21 | nint windowHwnd = new WindowInteropHelper(window).EnsureHandle(); 22 | 23 | if (isLightTheme.HasValue) 24 | isDarkTheme = !isLightTheme.Value ? 1 : 0; 25 | else 26 | DwmGetWindowAttribute(desktopHwnd, DwmwaUseImmersiveDarkMode, out isDarkTheme, (uint)Marshal.SizeOf(typeof(nint))); 27 | 28 | DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkModeOld, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint))); 29 | DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkMode, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint))); 30 | } 31 | } -------------------------------------------------------------------------------- /Utils/NginxCleaner.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.IO; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Threading.Tasks; 6 | 7 | namespace Sheas_Cealer.Utils; 8 | 9 | internal static class NginxCleaner 10 | { 11 | internal static async Task Clean() 12 | { 13 | string hostsContent = await File.ReadAllTextAsync(MainConst.HostsConfPath); 14 | int hostsConfStartIndex = hostsContent.IndexOf(MainConst.HostsConfStartMarker, StringComparison.Ordinal); 15 | int hostsConfEndIndex = hostsContent.LastIndexOf(MainConst.HostsConfEndMarker, StringComparison.Ordinal); 16 | 17 | if (hostsConfStartIndex != -1 && hostsConfEndIndex != -1) 18 | await File.WriteAllTextAsync(MainConst.HostsConfPath, hostsContent.Remove(hostsConfStartIndex, hostsConfEndIndex - hostsConfStartIndex + MainConst.HostsConfEndMarker.Length)); 19 | 20 | using X509Store certStore = new(StoreName.Root, StoreLocation.LocalMachine, OpenFlags.ReadWrite); 21 | 22 | foreach (X509Certificate2 storedCert in certStore.Certificates) 23 | if (storedCert.Subject == MainConst.NginxRootCertSubjectName) 24 | while (true) 25 | try 26 | { 27 | certStore.Remove(storedCert); 28 | 29 | break; 30 | } 31 | catch { } 32 | 33 | certStore.Close(); 34 | } 35 | } -------------------------------------------------------------------------------- /Consts/AboutConst.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Windows.Media; 3 | 4 | namespace Sheas_Cealer.Consts; 5 | 6 | internal abstract class AboutConst : AboutMultilangConst 7 | { 8 | public static Color AccentBlueColor => (Color)ColorConverter.ConvertFromString("#2196F3"); 9 | public static Color AccentRedColor => (Color)ColorConverter.ConvertFromString("#F44336"); 10 | 11 | public static string DeveloperButtonUrl => "https://www.spacetimee.xyz"; 12 | public static string VersionButtonVersionContent => Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; 13 | public static string VersionButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer/releases/latest"; 14 | public static string EmailButtonUrl => "Zeus6_6@163.com"; 15 | 16 | public static string DocumentationButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer/wiki/Sheas-Cealer-Documentation"; 17 | public static string RepositoryButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer"; 18 | 19 | public static string PolicyButtonUrl => "https://thoughts.teambition.com/share/6264eda98adeb10041b92fda#title=Sheas_Cealer_隐私政策"; 20 | public static string AgreementButtonUrl => "https://thoughts.teambition.com/share/6264edd78adeb10041b92fdb#title=Sheas_Cealer_使用协议"; 21 | 22 | internal static string ReleaseApiUrl => "https://api.github.com/repos/SpaceTimee/Sheas-Cealer/releases/latest"; 23 | internal static string ReleaseApiUserAgent => "Sheas-Cealer"; 24 | } -------------------------------------------------------------------------------- /Preses/GlobalPres.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using MaterialDesignThemes.Wpf; 3 | using Sheas_Cealer.Consts; 4 | using Sheas_Cealer.Props; 5 | using Sheas_Cealer.Utils; 6 | using System.Diagnostics; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace Sheas_Cealer.Preses; 11 | 12 | internal partial class GlobalPres : ObservableObject 13 | { 14 | internal GlobalPres() 15 | { 16 | IsLightTheme = Settings.Default.IsLightTheme switch 17 | { 18 | -1 => null, 19 | 0 => false, 20 | 1 => true, 21 | _ => throw new UnreachableException() 22 | }; 23 | } 24 | 25 | [ObservableProperty] 26 | private static bool? isLightTheme = null; 27 | partial void OnIsLightThemeChanged(bool? value) 28 | { 29 | PaletteHelper paletteHelper = new(); 30 | Theme newTheme = paletteHelper.GetTheme(); 31 | 32 | newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit); 33 | paletteHelper.SetTheme(newTheme); 34 | 35 | foreach (Window currentWindow in Application.Current.Windows) 36 | BorderThemeSetter.SetBorderTheme(currentWindow, value); 37 | 38 | Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1); 39 | Settings.Default.Save(); 40 | } 41 | 42 | [ObservableProperty] 43 | private static Color accentForegroundColor = AboutConst.AccentBlueColor; 44 | } -------------------------------------------------------------------------------- /Utils/IconRemover.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System.Windows; 3 | using System.Windows.Interop; 4 | 5 | namespace Sheas_Cealer.Utils; 6 | 7 | internal static partial class IconRemover 8 | { 9 | private const int GwlExStyle = -20; 10 | private const int WsExDlgModalFrame = 0x0001; 11 | private const int SwpNoSize = 0x0001; 12 | private const int SwpNoMove = 0x0002; 13 | private const int SwpNoZOrder = 0x0004; 14 | private const int SwpFrameChanged = 0x0020; 15 | private const uint WmSetIcon = 0x0080; 16 | 17 | [LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")] 18 | private static partial int GetWindowLong(nint hwnd, int index); 19 | [LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")] 20 | private static partial void SetWindowLong(nint hwnd, int index, nint newStyle); 21 | [LibraryImport("user32.dll")] 22 | [return: MarshalAs(UnmanagedType.Bool)] 23 | private static partial void SetWindowPos(nint hwnd, nint hwndInsertAfter, int x, int y, int width, int height, uint flags); 24 | [LibraryImport("user32.dll", EntryPoint = "SendMessageW")] 25 | private static partial void SendMessage(nint hwnd, uint msg, nint wParam, nint lParam); 26 | 27 | internal static void RemoveIcon(Window window) 28 | { 29 | nint hwnd = new WindowInteropHelper(window).Handle; 30 | 31 | SetWindowLong(hwnd, GwlExStyle, GetWindowLong(hwnd, GwlExStyle) | WsExDlgModalFrame); 32 | 33 | SetWindowPos(hwnd, nint.Zero, 0, 0, 0, 0, SwpNoMove | SwpNoSize | SwpNoZOrder | SwpFrameChanged); 34 | 35 | SendMessage(hwnd, WmSetIcon, new(1), nint.Zero); 36 | SendMessage(hwnd, WmSetIcon, nint.Zero, nint.Zero); 37 | } 38 | } -------------------------------------------------------------------------------- /Convs/MainConv.cs: -------------------------------------------------------------------------------- 1 | namespace Sheas_Cealer.Convs; 2 | 3 | internal static class MainConv 4 | { 5 | public static MainAdminControlVisibilityConv MainAdminControlVisibilityConv => new(); 6 | public static MainMihomoButtonContentConv MainMihomoButtonContentConv => new(); 7 | public static MainMihomoButtonIsEnabledConv MainMihomoButtonIsEnabledConv => new(); 8 | public static MainMihomoButtonToolTipConv MainMihomoButtonToolTipConv => new(); 9 | public static MainNginxButtonContentConv MainNginxButtonContentConv => new(); 10 | public static MainNginxButtonToolTipConv MainNginxButtonToolTipConv => new(); 11 | public static MainNoClickButtonContentConv MainNoClickButtonContentConv => new(); 12 | public static MainNoClickButtonToolTipConv MainNoClickButtonToolTipConv => new(); 13 | public static MainNginxButtonIsEnabledConv MainNginxButtonIsEnabledConv => new(); 14 | public static MainProxyColumnWidthConv MainProxyColumnWidthConv => new(); 15 | public static MainSettingsBoxHintConv MainSettingsBoxHintConv => new(); 16 | public static MainSettingsBoxTextConv MainSettingsBoxTextConv => new(); 17 | public static MainSettingsBoxToolTipConv MainSettingsBoxToolTipConv => new(); 18 | public static MainSettingsFunctionButtonContentConv MainSettingsFunctionButtonContentConv => new(); 19 | public static MainSettingsModeButtonContentConv MainSettingsModeButtonContentConv => new(); 20 | public static MainBrowserButtonIsEnabledConv MainBrowserButtonIsEnabledConv => new(); 21 | public static MainUpdateHostButtonContentConv MainUpdateHostButtonContentConv => new(); 22 | public static MainUpdateHostButtonIsEnabledConv MainUpdateHostButtonIsEnabledConv => new(); 23 | public static MainWinWidthConv MainWinWidthConv => new(); 24 | } -------------------------------------------------------------------------------- /App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Utils/ForegroundGenerator.cs: -------------------------------------------------------------------------------- 1 | using Sheas_Cealer.Consts; 2 | using System; 3 | using System.Windows.Media; 4 | 5 | namespace Sheas_Cealer.Utils; 6 | 7 | internal static class ForegroundGenerator 8 | { 9 | internal static (Color?, Color) GetForeground(int red, int green, int blue) 10 | { 11 | double redComponent = red / 255.0, greenComponent = green / 255.0, blueComponent = blue / 255.0; 12 | 13 | double luminance = 0.2126 * GammaCorrect(redComponent) + 0.7152 * GammaCorrect(greenComponent) + 0.0722 * GammaCorrect(blueComponent); 14 | 15 | double blackContrast = (luminance + 0.05) / 0.05; 16 | double whiteContrast = 1.05 / (luminance + 0.05); 17 | 18 | double hue = redComponent > greenComponent && redComponent > blueComponent ? 60 * ((greenComponent - blueComponent) / (redComponent - Math.Min(greenComponent, blueComponent)) + (greenComponent < blueComponent ? 6 : 0)) : 19 | greenComponent > blueComponent && greenComponent > redComponent ? 60 * ((blueComponent - redComponent) / (greenComponent - Math.Min(blueComponent, redComponent)) + 2) : 20 | blueComponent > redComponent && blueComponent > greenComponent ? 60 * ((redComponent - greenComponent) / (blueComponent - Math.Min(redComponent, greenComponent)) + 4) : 0; 21 | 22 | double blueContrast = Math.Min(Math.Abs(hue - 206.57), 360 - Math.Abs(hue - 206.57)); 23 | double redContrast = Math.Min(Math.Abs(hue - 4.11), 360 - Math.Abs(hue - 4.11)); 24 | 25 | return (blackContrast >= 5.5 && whiteContrast >= 2.5 ? null : 26 | blackContrast >= whiteContrast ? Colors.Black : Colors.White, 27 | blueContrast >= redContrast ? AboutConst.AccentBlueColor : AboutConst.AccentRedColor); 28 | } 29 | 30 | private static double GammaCorrect(double component) => component <= 0.03928 ? component / 12.92 : Math.Pow((component + 0.055) / 1.055, 2.4); 31 | } -------------------------------------------------------------------------------- /Wins/SettingsWin.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 45 | 77 | 106 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 165 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 |