mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 21:02:08 +08:00
1.1.4 -> 0.0.1 第2次更新
This commit is contained in:
parent
53c83dea01
commit
a66ac97dac
31
App.axaml
Normal file
31
App.axaml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<Application x:Class="Sheas_Cealer_Nix.App"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
RequestedThemeVariant="Default">
|
||||||
|
<Application.Styles>
|
||||||
|
<FluentTheme DensityStyle="Compact" />
|
||||||
|
</Application.Styles>
|
||||||
|
|
||||||
|
<!--<Application.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<materialDesign:BundledTheme BaseTheme="Inherit" PrimaryColor="Red" SecondaryColor="Orange" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style x:Key="CommonWindow" TargetType="{x:Type Window}">
|
||||||
|
<Setter Property="AutomationProperties.Name" Value="Sheas Cealer" />
|
||||||
|
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
|
||||||
|
<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="Foreground" Value="{DynamicResource MaterialDesignBackground}" />
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</Application.Resources>-->
|
||||||
|
</Application>
|
82
App.axaml.cs
Normal file
82
App.axaml.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Data.Core.Plugins;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Markup.Xaml.MarkupExtensions;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
using Sheas_Cealer_Nix.Preses;
|
||||||
|
using Sheas_Cealer_Nix.Utils;
|
||||||
|
using Sheas_Cealer_Nix.Wins;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Sheas_Cealer_Nix;
|
||||||
|
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public override void Initialize() => AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
{
|
||||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
#region Upgrade Settings
|
||||||
|
//if (Settings.Default.IsUpgradeRequired)
|
||||||
|
//{
|
||||||
|
// Settings.Default.Upgrade();
|
||||||
|
// Settings.Default.IsUpgradeRequired = false;
|
||||||
|
// Settings.Default.Save();
|
||||||
|
//}
|
||||||
|
#endregion Upgrade Settings
|
||||||
|
|
||||||
|
#region Primary Color
|
||||||
|
//PaletteHelper paletteHelper = new();
|
||||||
|
//Theme newTheme = paletteHelper.GetTheme();
|
||||||
|
//Color newPrimaryColor = Color.FromRgb(Settings.Default.PrimaryColor.R, Settings.Default.PrimaryColor.G, Settings.Default.PrimaryColor.B);
|
||||||
|
|
||||||
|
//newTheme.SetPrimaryColor(newPrimaryColor);
|
||||||
|
//paletteHelper.SetTheme(newTheme);
|
||||||
|
#endregion Primary Color
|
||||||
|
|
||||||
|
#region Background Color
|
||||||
|
//if (Environment.OSVersion.Version.Build < 22000)
|
||||||
|
//{
|
||||||
|
// Style newWindowStyle = new(typeof(Window), Current.Resources["CommonWindow"] as Style);
|
||||||
|
|
||||||
|
// newWindowStyle.Setters.Add(new Setter(Window.BackgroundProperty, new DynamicResourceExtension("MaterialDesignBackground")));
|
||||||
|
// Current.Resources["CommonWindow"] = newWindowStyle;
|
||||||
|
//}
|
||||||
|
#endregion Background Color
|
||||||
|
|
||||||
|
#region Foreground Color
|
||||||
|
//Style newButtonStyle = new(typeof(Button), Current.Resources[typeof(Button)] as Style);
|
||||||
|
//(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
||||||
|
|
||||||
|
//newButtonStyle.Setters.Add(new Setter(Button.ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
||||||
|
//Current.Resources[typeof(Button)] = newButtonStyle;
|
||||||
|
|
||||||
|
//new SettingsPres().AccentForegroundColor = newAccentForegroundColor;
|
||||||
|
#endregion Foreground Color
|
||||||
|
|
||||||
|
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
|
||||||
|
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
|
||||||
|
DisableAvaloniaDataAnnotationValidation();
|
||||||
|
desktop.MainWindow = new MainWin();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableAvaloniaDataAnnotationValidation()
|
||||||
|
{
|
||||||
|
// Get an array of plugins to remove
|
||||||
|
var dataValidationPluginsToRemove = BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
|
||||||
|
|
||||||
|
// remove each entry found
|
||||||
|
foreach (var plugin in dataValidationPluginsToRemove)
|
||||||
|
BindingPlugins.DataValidators.Remove(plugin);
|
||||||
|
}
|
||||||
|
}
|
28
App.xaml
28
App.xaml
@ -1,28 +0,0 @@
|
|||||||
<Application x:Class="Sheas_Cealer.App"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
Startup="App_OnStartup" DispatcherUnhandledException="App_DispatcherUnhandledException">
|
|
||||||
<Application.Resources>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<materialDesign:BundledTheme BaseTheme="Inherit" PrimaryColor="Red" SecondaryColor="Orange" />
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
|
|
||||||
<Style x:Key="CommonWindow" TargetType="{x:Type Window}">
|
|
||||||
<Setter Property="AutomationProperties.Name" Value="Sheas Cealer" />
|
|
||||||
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
|
|
||||||
<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="Foreground" Value="{DynamicResource MaterialDesignBackground}" />
|
|
||||||
</Style>
|
|
||||||
</ResourceDictionary>
|
|
||||||
</Application.Resources>
|
|
||||||
</Application>
|
|
64
App.xaml.cs
64
App.xaml.cs
@ -1,64 +0,0 @@
|
|||||||
using MaterialDesignThemes.Wpf;
|
|
||||||
using Sheas_Cealer.Preses;
|
|
||||||
using Sheas_Cealer.Props;
|
|
||||||
using Sheas_Cealer.Utils;
|
|
||||||
using Sheas_Cealer.Wins;
|
|
||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer;
|
|
||||||
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
private void App_OnStartup(object sender, StartupEventArgs e)
|
|
||||||
{
|
|
||||||
#region Upgrade Settings
|
|
||||||
if (Settings.Default.IsUpgradeRequired)
|
|
||||||
{
|
|
||||||
Settings.Default.Upgrade();
|
|
||||||
Settings.Default.IsUpgradeRequired = false;
|
|
||||||
Settings.Default.Save();
|
|
||||||
}
|
|
||||||
#endregion Upgrade Settings
|
|
||||||
|
|
||||||
#region Primary Color
|
|
||||||
PaletteHelper paletteHelper = new();
|
|
||||||
Theme newTheme = paletteHelper.GetTheme();
|
|
||||||
Color newPrimaryColor = Color.FromRgb(Settings.Default.PrimaryColor.R, Settings.Default.PrimaryColor.G, Settings.Default.PrimaryColor.B);
|
|
||||||
|
|
||||||
newTheme.SetPrimaryColor(newPrimaryColor);
|
|
||||||
paletteHelper.SetTheme(newTheme);
|
|
||||||
#endregion Primary Color
|
|
||||||
|
|
||||||
#region Background Color
|
|
||||||
if (Environment.OSVersion.Version.Build < 22000)
|
|
||||||
{
|
|
||||||
Style newWindowStyle = new(typeof(Window), Current.Resources["CommonWindow"] as Style);
|
|
||||||
|
|
||||||
newWindowStyle.Setters.Add(new Setter(Window.BackgroundProperty, new DynamicResourceExtension("MaterialDesignBackground")));
|
|
||||||
Current.Resources["CommonWindow"] = newWindowStyle;
|
|
||||||
}
|
|
||||||
#endregion Background Color
|
|
||||||
|
|
||||||
#region Foreground Color
|
|
||||||
Style newButtonStyle = new(typeof(Button), Current.Resources[typeof(Button)] as Style);
|
|
||||||
(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
|
||||||
|
|
||||||
newButtonStyle.Setters.Add(new Setter(Button.ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
|
||||||
Current.Resources[typeof(Button)] = newButtonStyle;
|
|
||||||
|
|
||||||
new SettingsPres().AccentForegroundColor = newAccentForegroundColor;
|
|
||||||
#endregion Foreground Color
|
|
||||||
|
|
||||||
new MainWin().Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"Error: {e.Exception.Message}");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,12 @@
|
|||||||
using System.Reflection;
|
using Avalonia.Media;
|
||||||
using System.Windows.Media;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Consts;
|
namespace Sheas_Cealer_Nix.Consts;
|
||||||
|
|
||||||
internal abstract class AboutConst : AboutMultilangConst
|
internal abstract class AboutConst : AboutMultilangConst
|
||||||
{
|
{
|
||||||
public static Color AccentBlueColor => (Color)ColorConverter.ConvertFromString("#2196F3");
|
public static Color AccentBlueColor => Color.Parse("#2196F3");
|
||||||
public static Color AccentRedColor => (Color)ColorConverter.ConvertFromString("#F44336");
|
public static Color AccentRedColor => Color.Parse("#F44336");
|
||||||
|
|
||||||
public static string DeveloperButtonUrl => "https://www.spacetimee.xyz";
|
public static string DeveloperButtonUrl => "https://www.spacetimee.xyz";
|
||||||
public static string VersionButtonVersionContent => Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
public static string VersionButtonVersionContent => Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||||
@ -14,11 +14,11 @@ internal abstract class AboutConst : AboutMultilangConst
|
|||||||
public static string EmailButtonUrl => "Zeus6_6@163.com";
|
public static string EmailButtonUrl => "Zeus6_6@163.com";
|
||||||
|
|
||||||
public static string DocumentationButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer/wiki/Sheas-Cealer-Documentation";
|
public static string DocumentationButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer/wiki/Sheas-Cealer-Documentation";
|
||||||
public static string RepositoryButtonUrl => "https://github.com/SpaceTimee/Sheas-Cealer";
|
public static string RepositoryButtonUrl => "https://github.com/Project-SheasCealerNix/Sheas-Cealer-Nix";
|
||||||
|
|
||||||
public static string PolicyButtonUrl => "https://thoughts.teambition.com/share/6264eda98adeb10041b92fda#title=Sheas_Cealer_隐私政策";
|
public static string PolicyButtonUrl => "https://thoughts.teambition.com/share/6264eda98adeb10041b92fda#title=Sheas_Cealer_隐私政策";
|
||||||
public static string AgreementButtonUrl => "https://thoughts.teambition.com/share/6264edd78adeb10041b92fdb#title=Sheas_Cealer_使用协议";
|
public static string AgreementButtonUrl => "https://thoughts.teambition.com/share/6264edd78adeb10041b92fdb#title=Sheas_Cealer_使用协议";
|
||||||
|
|
||||||
internal static string ReleaseApiUrl => "https://api.github.com/repos/SpaceTimee/Sheas-Cealer/releases/latest";
|
internal static string ReleaseApiUrl => "https://api.github.com/repos/Project-SheasCealerNix/Sheas-Cealer-Nix/releases/latest";
|
||||||
internal static string ReleaseApiUserAgent => "Sheas-Cealer";
|
internal static string ReleaseApiUserAgent => "Sheas-Cealer";
|
||||||
}
|
}
|
4
Consts/AboutMultilangConst.Designer.cs
generated
4
Consts/AboutMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Sheas_Cealer.Consts {
|
namespace Sheas_Cealer_Nix.Consts {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
|||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer.Consts.AboutMultilangConst", typeof(AboutMultilangConst).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer_Nix.Consts.AboutMultilangConst", typeof(AboutMultilangConst).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
@ -4,14 +4,14 @@ using System.IO;
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Consts;
|
namespace Sheas_Cealer_Nix.Consts;
|
||||||
|
|
||||||
internal abstract partial class MainConst : MainMultilangConst
|
internal abstract partial class MainConst : MainMultilangConst
|
||||||
{
|
{
|
||||||
internal enum SettingsMode
|
internal enum SettingsMode
|
||||||
{ BrowserPathMode, UpstreamUrlMode, ExtraArgsMode }
|
{ BrowserPathMode, UpstreamUrlMode, ExtraArgsMode }
|
||||||
|
|
||||||
public static bool IsAdmin => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
|
public static bool IsAdmin => OperatingSystem.IsWindows() ? new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) : Environment.UserName == "root";
|
||||||
|
|
||||||
internal static string EdgeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe";
|
internal static string EdgeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe";
|
||||||
internal static string ChromeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
|
internal static string ChromeBrowserRegistryPath => @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
|
||||||
@ -22,7 +22,7 @@ internal abstract partial class MainConst : MainMultilangConst
|
|||||||
internal static string LocalHostPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-L.json");
|
internal static string LocalHostPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-L.json");
|
||||||
internal static string UpstreamHostPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-U.json");
|
internal static string UpstreamHostPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host-U.json");
|
||||||
|
|
||||||
internal static string HostsConfPath => Path.Combine(Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath")?.GetValue("DataBasePath", null)?.ToString() ?? @"C:\Windows\System32\drivers\etc", "hosts");
|
internal static string HostsConfPath => OperatingSystem.IsWindows() ? Path.Combine(Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath")?.GetValue("DataBasePath", null)?.ToString() ?? @"C:\Windows\System32\drivers\etc", "hosts") : "/etc/hosts";
|
||||||
internal static string HostsConfStartMarker => $"# Cealing Nginx Start{Environment.NewLine}";
|
internal static string HostsConfStartMarker => $"# Cealing Nginx Start{Environment.NewLine}";
|
||||||
internal static string HostsConfEndMarker => "# Cealing Nginx End";
|
internal static string HostsConfEndMarker => "# Cealing Nginx End";
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ internal abstract partial class MainConst : MainMultilangConst
|
|||||||
internal static string MihomoConfPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml");
|
internal static string MihomoConfPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml");
|
||||||
internal static string[] MihomoNameServers => ["https://ns.net.kg/dns-query", "https://dnschina1.soraharu.com/dns-query", "https://0ms.dev/dns-query"];
|
internal static string[] MihomoNameServers => ["https://ns.net.kg/dns-query", "https://dnschina1.soraharu.com/dns-query", "https://0ms.dev/dns-query"];
|
||||||
|
|
||||||
internal static string NotifyIconText => "Sheas Cealer";
|
internal static string NotifyIconText => "Sheas Cealer Nix";
|
||||||
|
|
||||||
[GeneratedRegex("^Cealing-Host-")]
|
[GeneratedRegex("^Cealing-Host-")]
|
||||||
internal static partial Regex CealHostPrefixRegex();
|
internal static partial Regex CealHostPrefixRegex();
|
||||||
|
4
Consts/MainMultilangConst.Designer.cs
generated
4
Consts/MainMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Sheas_Cealer.Consts {
|
namespace Sheas_Cealer_Nix.Consts {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
|||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer.Consts.MainMultilangConst", typeof(MainMultilangConst).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer_Nix.Consts.MainMultilangConst", typeof(MainMultilangConst).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
namespace Sheas_Cealer.Consts;
|
namespace Sheas_Cealer_Nix.Consts;
|
||||||
|
|
||||||
internal abstract class SettingsConst : SettingsMultilangConst;
|
internal abstract class SettingsConst : SettingsMultilangConst;
|
4
Consts/SettingsMultilangConst.Designer.cs
generated
4
Consts/SettingsMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Sheas_Cealer.Consts {
|
namespace Sheas_Cealer_Nix.Consts {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
|||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer.Consts.SettingsMultilangConst", typeof(SettingsMultilangConst).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheas_Cealer_Nix.Consts.SettingsMultilangConst", typeof(SettingsMultilangConst).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class AboutAccentButtonForegroundConv : IValueConverter
|
internal class AboutAccentButtonForegroundConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
Color accentForegroundColor = (Color)value;
|
Color accentForegroundColor = (Color)value;
|
||||||
|
|
||||||
return new SolidColorBrush(accentForegroundColor);
|
return new SolidColorBrush(accentForegroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal static class AboutConv
|
internal static class AboutConv
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class AboutVersionButtonContentConv : IMultiValueConverter
|
internal class AboutVersionButtonContentConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
string versionButtonLabelContent = (string)values[0];
|
string versionButtonLabelContent = (string)values[0];
|
||||||
string versionButtonVersionContent = (string)values[1];
|
string versionButtonVersionContent = (string)values[1];
|
||||||
@ -14,6 +15,4 @@ internal class AboutVersionButtonContentConv : IMultiValueConverter
|
|||||||
|
|
||||||
return $"{versionButtonLabelContent} {versionButtonVersionContent}" + (isSheasCealerUtd ? string.Empty : " *");
|
return $"{versionButtonLabelContent} {versionButtonVersionContent}" + (isSheasCealerUtd ? string.Empty : " *");
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,18 +1,17 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainAdminControlVisibilityConv : IValueConverter
|
internal class MainAdminControlVisibilityConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isAdmin = (bool)value;
|
bool isAdmin = (bool)value;
|
||||||
|
|
||||||
return isAdmin ? Visibility.Visible : Visibility.Collapsed;
|
return isAdmin ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,20 +1,19 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainBrowserButtonIsEnabledConv : IMultiValueConverter
|
internal class MainBrowserButtonIsEnabledConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
string browserPath = (string)values[0];
|
string browserPath = (string)values[0];
|
||||||
string extraArgs = (string)values[1];
|
string extraArgs = (string)values[1];
|
||||||
|
|
||||||
return File.Exists(browserPath) && Path.GetFileName(browserPath).ToLowerInvariant().EndsWith(".exe") && MainConst.ExtraArgsRegex().IsMatch(extraArgs);
|
return File.Exists(browserPath) && Path.GetFileName(browserPath).ToLowerInvariant().EndsWith(".exe") && MainConst.ExtraArgsRegex().IsMatch(extraArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal static class MainConv
|
internal static class MainConv
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainMihomoButtonContentConv : IMultiValueConverter
|
internal class MainMihomoButtonContentConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isMihomoRunning = (bool)values[0];
|
bool isMihomoRunning = (bool)values[0];
|
||||||
bool isComihomoIniting = (bool)values[1];
|
bool isComihomoIniting = (bool)values[1];
|
||||||
@ -15,11 +16,9 @@ internal class MainMihomoButtonContentConv : IMultiValueConverter
|
|||||||
bool isCoproxyIniting = (bool)values[3];
|
bool isCoproxyIniting = (bool)values[3];
|
||||||
bool isCoproxyStopping = (bool)values[4];
|
bool isCoproxyStopping = (bool)values[4];
|
||||||
|
|
||||||
return isCoproxyIniting || isCoproxyStopping ? Binding.DoNothing :
|
return isCoproxyIniting || isCoproxyStopping ? MainConst.MihomoButtonIsInitingContent :
|
||||||
isComihomoIniting ? MainConst.MihomoButtonIsStoppingContent :
|
isComihomoIniting ? MainConst.MihomoButtonIsStoppingContent :
|
||||||
isMihomoIniting ? MainConst.MihomoButtonIsInitingContent :
|
isMihomoIniting ? MainConst.MihomoButtonIsInitingContent :
|
||||||
isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent;
|
isMihomoRunning ? MainConst.MihomoButtonIsRunningContent : MainConst.MihomoButtonIsStoppedContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainMihomoButtonIsEnabledConv : IMultiValueConverter
|
internal class MainMihomoButtonIsEnabledConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isCoMihomoExist = (bool)values[0];
|
bool isCoMihomoExist = (bool)values[0];
|
||||||
bool isMihomoExist = (bool)values[1];
|
bool isMihomoExist = (bool)values[1];
|
||||||
@ -16,6 +17,4 @@ internal class MainMihomoButtonIsEnabledConv : IMultiValueConverter
|
|||||||
|
|
||||||
return !isCoproxyIniting && !isComihomoIniting && !isMihomoIniting && (isCoMihomoExist || isMihomoExist);
|
return !isCoproxyIniting && !isComihomoIniting && !isMihomoIniting && (isCoMihomoExist || isMihomoExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainMihomoButtonToolTipConv : IValueConverter
|
internal class MainMihomoButtonToolTipConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isMihomoRunning = (bool)value;
|
bool isMihomoRunning = (bool)value;
|
||||||
|
|
||||||
return isMihomoRunning ? MainConst.MihomoButtonIsRunningToolTip : MainConst.MihomoButtonIsStoppedToolTip;
|
return isMihomoRunning ? MainConst.MihomoButtonIsRunningToolTip : MainConst.MihomoButtonIsStoppedToolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,13 +1,14 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainNginxButtonContentConv : IMultiValueConverter
|
internal class MainNginxButtonContentConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isConginxRunning = (bool)values[0];
|
bool isConginxRunning = (bool)values[0];
|
||||||
bool isNginxRunning = (bool)values[1];
|
bool isNginxRunning = (bool)values[1];
|
||||||
@ -18,6 +19,4 @@ internal class MainNginxButtonContentConv : IMultiValueConverter
|
|||||||
isNginxIniting ? MainConst.NginxButtonIsInitingContent :
|
isNginxIniting ? MainConst.NginxButtonIsInitingContent :
|
||||||
isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent;
|
isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningContent : MainConst.NginxButtonIsStoppedContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainNginxButtonIsEnabledConv : IMultiValueConverter
|
internal class MainNginxButtonIsEnabledConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isConginxExist = (bool)values[0];
|
bool isConginxExist = (bool)values[0];
|
||||||
bool isNginxExist = (bool)values[1];
|
bool isNginxExist = (bool)values[1];
|
||||||
@ -17,6 +18,4 @@ internal class MainNginxButtonIsEnabledConv : IMultiValueConverter
|
|||||||
|
|
||||||
return !isCoproxyIniting && !isNginxIniting && !isComihomoIniting && !isMihomoIniting && (isConginxExist || isNginxExist);
|
return !isCoproxyIniting && !isNginxIniting && !isComihomoIniting && !isMihomoIniting && (isConginxExist || isNginxExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,19 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainNginxButtonToolTipConv : IMultiValueConverter
|
internal class MainNginxButtonToolTipConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isConginxRunning = (bool)values[0];
|
bool isConginxRunning = (bool)values[0];
|
||||||
bool isNginxRunning = (bool)values[1];
|
bool isNginxRunning = (bool)values[1];
|
||||||
|
|
||||||
return isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningToolTip : MainConst.NginxButtonIsStoppedToolTip;
|
return isConginxRunning || isNginxRunning ? MainConst.NginxButtonIsRunningToolTip : MainConst.NginxButtonIsStoppedToolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainNoClickButtonContentConv : IValueConverter
|
internal class MainNoClickButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isFlashing = (bool)value;
|
bool isFlashing = (bool)value;
|
||||||
|
|
||||||
return isFlashing ? MainConst.NoClickButtonIsFlashingContent : MainConst.NoClickButtonIsStoppedContent;
|
return isFlashing ? MainConst.NoClickButtonIsFlashingContent : MainConst.NoClickButtonIsStoppedContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainNoClickButtonToolTipConv : IValueConverter
|
internal class MainNoClickButtonToolTipConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isFlashing = (bool)value;
|
bool isFlashing = (bool)value;
|
||||||
|
|
||||||
return isFlashing ? MainConst.NoClickButtonIsFlashingToolTip : MainConst.NoClickButtonIsStoppedToolTip;
|
return isFlashing ? MainConst.NoClickButtonIsFlashingToolTip : MainConst.NoClickButtonIsStoppedToolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using System;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainProxyColumnWidthConv : IValueConverter
|
internal class MainProxyColumnWidthConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isAdmin = (bool)value;
|
bool isAdmin = (bool)value;
|
||||||
|
|
||||||
return new GridLength(1, isAdmin ? GridUnitType.Star : GridUnitType.Auto);
|
return new GridLength(1, isAdmin ? GridUnitType.Star : GridUnitType.Auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainSettingsBoxHintConv : IValueConverter
|
internal class MainSettingsBoxHintConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
||||||
|
|
||||||
@ -21,5 +21,5 @@ internal class MainSettingsBoxHintConv : IValueConverter
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,14 +1,15 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainSettingsBoxTextConv : IMultiValueConverter
|
internal class MainSettingsBoxTextConv : IMultiValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)values[0];
|
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)values[0];
|
||||||
string browserPath = (string)values[1];
|
string browserPath = (string)values[1];
|
||||||
@ -23,6 +24,4 @@ internal class MainSettingsBoxTextConv : IMultiValueConverter
|
|||||||
_ => throw new UnreachableException()
|
_ => throw new UnreachableException()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainSettingsBoxToolTipConv : IValueConverter
|
internal class MainSettingsBoxToolTipConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
||||||
|
|
||||||
@ -21,5 +21,5 @@ internal class MainSettingsBoxToolTipConv : IValueConverter
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainSettingsFunctionButtonContentConv : IValueConverter
|
internal class MainSettingsFunctionButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
||||||
|
|
||||||
@ -21,5 +21,5 @@ internal class MainSettingsFunctionButtonContentConv : IValueConverter
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainSettingsModeButtonContentConv : IValueConverter
|
internal class MainSettingsModeButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
MainConst.SettingsMode settingsMode = (MainConst.SettingsMode)value;
|
||||||
|
|
||||||
@ -20,5 +20,5 @@ internal class MainSettingsModeButtonContentConv : IValueConverter
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainUpdateHostButtonContentConv : IValueConverter
|
internal class MainUpdateHostButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isUpstreamHostUtd = (bool)value;
|
bool isUpstreamHostUtd = (bool)value;
|
||||||
|
|
||||||
return MainConst.UpdateUpstreamHostButtonContent + (isUpstreamHostUtd ? string.Empty : " *");
|
return MainConst.UpdateUpstreamHostButtonContent + (isUpstreamHostUtd ? string.Empty : " *");
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainUpdateHostButtonIsEnabledConv : IValueConverter
|
internal class MainUpdateHostButtonIsEnabledConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
string upstreamUrl = (string)value;
|
string upstreamUrl = (string)value;
|
||||||
|
|
||||||
return MainConst.UpstreamUrlRegex().IsMatch(upstreamUrl);
|
return MainConst.UpstreamUrlRegex().IsMatch(upstreamUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
using System;
|
using Avalonia.Data.Converters;
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class MainWinWidthConv : IValueConverter
|
internal class MainWinWidthConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool isAdmin = (bool)value;
|
bool isAdmin = (bool)value;
|
||||||
|
|
||||||
return isAdmin ? 708 : 500;
|
return isAdmin ? 708 : 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal static class SettingsConv
|
internal static class SettingsConv
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class SettingsLangsButtonContentConv : IValueConverter
|
internal class SettingsLangsButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool? isEnglishLang = value as bool?;
|
bool? isEnglishLang = value as bool?;
|
||||||
|
|
||||||
@ -16,5 +16,5 @@ internal class SettingsLangsButtonContentConv : IValueConverter
|
|||||||
SettingsConst.LangsButtonInheritLangContent;
|
SettingsConst.LangsButtonInheritLangContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class SettingsThemesButtonContentConv : IValueConverter
|
internal class SettingsThemesButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool? isLightMode = value as bool?;
|
bool? isLightMode = value as bool?;
|
||||||
|
|
||||||
@ -16,5 +16,5 @@ internal class SettingsThemesButtonContentConv : IValueConverter
|
|||||||
SettingsConst.ThemesButtonInheritThemeContent;
|
SettingsConst.ThemesButtonInheritThemeContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Data.Converters;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Convs;
|
namespace Sheas_Cealer_Nix.Convs;
|
||||||
|
|
||||||
internal class SettingsWeightsButtonContentConv : IValueConverter
|
internal class SettingsWeightsButtonContentConv : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
bool? isLightWeight = value as bool?;
|
bool? isLightWeight = value as bool?;
|
||||||
|
|
||||||
@ -16,5 +16,5 @@ internal class SettingsWeightsButtonContentConv : IValueConverter
|
|||||||
SettingsConst.WeightsButtonRegularWeightContent;
|
SettingsConst.WeightsButtonRegularWeightContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Preses;
|
namespace Sheas_Cealer_Nix.Preses;
|
||||||
|
|
||||||
internal partial class AboutPres : GlobalPres
|
internal partial class AboutPres : GlobalPres
|
||||||
{
|
{
|
||||||
|
@ -1,42 +1,39 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Avalonia.Media;
|
||||||
using MaterialDesignThemes.Wpf;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Cealer.Props;
|
using Sheas_Cealer_Nix.Props;
|
||||||
using Sheas_Cealer.Utils;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Preses;
|
namespace Sheas_Cealer_Nix.Preses;
|
||||||
|
|
||||||
internal partial class GlobalPres : ObservableObject
|
internal partial class GlobalPres : ObservableObject
|
||||||
{
|
{
|
||||||
internal GlobalPres()
|
internal GlobalPres()
|
||||||
{
|
{
|
||||||
IsLightTheme = Settings.Default.IsLightTheme switch
|
//IsLightTheme = Settings.Default.IsLightTheme switch
|
||||||
{
|
//{
|
||||||
-1 => null,
|
// -1 => null,
|
||||||
0 => false,
|
// 0 => false,
|
||||||
1 => true,
|
// 1 => true,
|
||||||
_ => throw new UnreachableException()
|
// _ => throw new UnreachableException()
|
||||||
};
|
//};
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private static bool? isLightTheme = null;
|
private static bool? isLightTheme = null;
|
||||||
partial void OnIsLightThemeChanged(bool? value)
|
partial void OnIsLightThemeChanged(bool? value)
|
||||||
{
|
{
|
||||||
PaletteHelper paletteHelper = new();
|
//PaletteHelper paletteHelper = new();
|
||||||
Theme newTheme = paletteHelper.GetTheme();
|
//Theme newTheme = paletteHelper.GetTheme();
|
||||||
|
|
||||||
newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
//newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
||||||
paletteHelper.SetTheme(newTheme);
|
//paletteHelper.SetTheme(newTheme);
|
||||||
|
|
||||||
foreach (Window currentWindow in Application.Current.Windows)
|
//foreach (Window currentWindow in Application.Current.Windows)
|
||||||
BorderThemeSetter.SetBorderTheme(currentWindow, value);
|
// BorderThemeSetter.SetBorderTheme(currentWindow, value);
|
||||||
|
|
||||||
Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
//Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Cealer.Props;
|
using Sheas_Cealer_Nix.Props;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Preses;
|
namespace Sheas_Cealer_Nix.Preses;
|
||||||
|
|
||||||
internal partial class MainPres : GlobalPres
|
internal partial class MainPres : GlobalPres
|
||||||
{
|
{
|
||||||
internal MainPres()
|
internal MainPres()
|
||||||
{
|
{
|
||||||
string[] args = Environment.GetCommandLineArgs();
|
//string[] args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
int browserPathIndex = Array.FindIndex(args, arg => arg.Equals("-b", StringComparison.OrdinalIgnoreCase)) + 1;
|
//int browserPathIndex = Array.FindIndex(args, arg => arg.Equals("-b", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
|
//int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
|
//int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||||
|
|
||||||
BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
//BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
// !string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
||||||
(Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
// (Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||||
Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
// Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||||
Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
// Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||||
string.Empty).ToString()!;
|
// string.Empty).ToString()!;
|
||||||
|
|
||||||
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
//UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
// !string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
||||||
args[upstreamUrlIndex];
|
// args[upstreamUrlIndex];
|
||||||
|
|
||||||
ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
//ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
||||||
!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
// !string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
||||||
args[extraArgsIndex];
|
// args[extraArgsIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@ -42,33 +42,33 @@ internal partial class MainPres : GlobalPres
|
|||||||
private string browserPath;
|
private string browserPath;
|
||||||
partial void OnBrowserPathChanged(string value)
|
partial void OnBrowserPathChanged(string value)
|
||||||
{
|
{
|
||||||
if (!File.Exists(value) || !Path.GetFileName(value).ToLowerInvariant().EndsWith(".exe"))
|
//if (!File.Exists(value) || !Path.GetFileName(value).ToLowerInvariant().EndsWith(".exe"))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
Settings.Default.BrowserPath = value;
|
//Settings.Default.BrowserPath = value;
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string upstreamUrl;
|
private string upstreamUrl;
|
||||||
partial void OnUpstreamUrlChanged(string value)
|
partial void OnUpstreamUrlChanged(string value)
|
||||||
{
|
{
|
||||||
if (!MainConst.UpstreamUrlRegex().IsMatch(value))
|
//if (!MainConst.UpstreamUrlRegex().IsMatch(value))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
Settings.Default.UpstreamUrl = value;
|
//Settings.Default.UpstreamUrl = value;
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string extraArgs;
|
private string extraArgs;
|
||||||
partial void OnExtraArgsChanged(string value)
|
partial void OnExtraArgsChanged(string value)
|
||||||
{
|
{
|
||||||
if (!MainConst.ExtraArgsRegex().IsMatch(value))
|
//if (!MainConst.ExtraArgsRegex().IsMatch(value))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
Settings.Default.ExtraArgs = value;
|
//Settings.Default.ExtraArgs = value;
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@ -90,10 +90,10 @@ internal partial class MainPres : GlobalPres
|
|||||||
private bool isNginxIniting = false;
|
private bool isNginxIniting = false;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isConginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ConginxPath)).Length != 0;
|
private bool isConginxRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ConginxPath) : Path.GetFileName(MainConst.ConginxPath)).Length != 0;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isNginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.NginxPath)).Length != 0;
|
private bool isNginxRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.NginxPath) : Path.GetFileName(MainConst.NginxPath)).Length != 0;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isComihomoExist = File.Exists(MainConst.ComihomoPath);
|
private bool isComihomoExist = File.Exists(MainConst.ComihomoPath);
|
||||||
@ -108,10 +108,10 @@ internal partial class MainPres : GlobalPres
|
|||||||
private bool isMihomoIniting = false;
|
private bool isMihomoIniting = false;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isComihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ComihomoPath)).Length != 0;
|
private bool isComihomoRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ComihomoPath) : Path.GetFileName(MainConst.ComihomoPath)).Length != 0;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isMihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.MihomoPath)).Length != 0;
|
private bool isMihomoRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.MihomoPath) : Path.GetFileName(MainConst.MihomoPath)).Length != 0;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isFlashing = false;
|
private bool isFlashing = false;
|
||||||
|
@ -1,66 +1,61 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Sheas_Cealer.Props;
|
using Sheas_Cealer_Nix.Props;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Markup;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Preses;
|
namespace Sheas_Cealer_Nix.Preses;
|
||||||
|
|
||||||
internal partial class SettingsPres : GlobalPres
|
internal partial class SettingsPres : GlobalPres
|
||||||
{
|
{
|
||||||
internal SettingsPres()
|
internal SettingsPres()
|
||||||
{
|
{
|
||||||
IsEnglishLang = Settings.Default.IsEnglishLang switch
|
//IsEnglishLang = Settings.Default.IsEnglishLang switch
|
||||||
{
|
//{
|
||||||
-1 => null,
|
// -1 => null,
|
||||||
0 => false,
|
// 0 => false,
|
||||||
1 => true,
|
// 1 => true,
|
||||||
_ => throw new UnreachableException()
|
// _ => throw new UnreachableException()
|
||||||
};
|
//};
|
||||||
|
|
||||||
IsLightWeight = Settings.Default.IsLightWeight switch
|
//IsLightWeight = Settings.Default.IsLightWeight switch
|
||||||
{
|
//{
|
||||||
-1 => null,
|
// -1 => null,
|
||||||
0 => false,
|
// 0 => false,
|
||||||
1 => true,
|
// 1 => true,
|
||||||
_ => throw new UnreachableException()
|
// _ => throw new UnreachableException()
|
||||||
};
|
//};
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private static bool? isEnglishLang = null;
|
private static bool? isEnglishLang = null;
|
||||||
partial void OnIsEnglishLangChanged(bool? value)
|
partial void OnIsEnglishLangChanged(bool? value)
|
||||||
{
|
{
|
||||||
CultureInfo newCulture = value.HasValue ? new(value.Value ? "en" : "zh") : CultureInfo.InstalledUICulture;
|
//CultureInfo newCulture = value.HasValue ? new(value.Value ? "en" : "zh") : CultureInfo.InstalledUICulture;
|
||||||
|
|
||||||
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = newCulture;
|
//Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = newCulture;
|
||||||
|
|
||||||
foreach (Window currentWindow in Application.Current.Windows)
|
//foreach (Window currentWindow in Application.Current.Windows)
|
||||||
currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
|
// currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
|
||||||
|
|
||||||
Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
//Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private static bool? isLightWeight = null;
|
private static bool? isLightWeight = null;
|
||||||
partial void OnIsLightWeightChanged(bool? value)
|
partial void OnIsLightWeightChanged(bool? value)
|
||||||
{
|
{
|
||||||
FontWeight newWeight = value.HasValue ? value.Value ? FontWeights.Light : FontWeights.Bold : FontWeights.Regular;
|
//FontWeight newWeight = value.HasValue ? value.Value ? FontWeights.Light : FontWeights.Bold : FontWeights.Regular;
|
||||||
Style newWindowStyle = new(typeof(Window), Application.Current.Resources["CommonWindow"] as Style);
|
//Style newWindowStyle = new(typeof(Window), Application.Current.Resources["CommonWindow"] as Style);
|
||||||
|
|
||||||
newWindowStyle.Setters.Add(new Setter(Window.FontWeightProperty, newWeight));
|
//newWindowStyle.Setters.Add(new Setter(Window.FontWeightProperty, newWeight));
|
||||||
Application.Current.Resources["CommonWindow"] = newWindowStyle;
|
//Application.Current.Resources["CommonWindow"] = newWindowStyle;
|
||||||
|
|
||||||
Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
//Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
||||||
|
|
||||||
newButtonStyle.Setters.Add(new Setter(Button.FontWeightProperty, newWeight));
|
//newButtonStyle.Setters.Add(new Setter(Button.FontWeightProperty, newWeight));
|
||||||
Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
//Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||||
|
|
||||||
Settings.Default.IsLightWeight = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
//Settings.Default.IsLightWeight = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||||
Settings.Default.Save();
|
//Settings.Default.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
using Sheas_Core;
|
using Sheas_Core;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Proces;
|
namespace Sheas_Cealer_Nix.Proces;
|
||||||
|
|
||||||
internal class BrowserProc : Proc
|
internal class BrowserProc : Proc
|
||||||
{
|
{
|
||||||
@ -13,6 +12,6 @@ internal class BrowserProc : Proc
|
|||||||
protected sealed override void Process_Exited(object? sender, EventArgs e)
|
protected sealed override void Process_Exited(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (ShutDownAppOnProcessExit)
|
if (ShutDownAppOnProcessExit)
|
||||||
Application.Current.Dispatcher.InvokeShutdown();
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Core;
|
using Sheas_Core;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Proces;
|
namespace Sheas_Cealer_Nix.Proces;
|
||||||
|
|
||||||
internal class ComihomoProc : Proc
|
internal class ComihomoProc : Proc
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Cealer.Utils;
|
using Sheas_Cealer_Nix.Utils;
|
||||||
using Sheas_Core;
|
using Sheas_Core;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Proces;
|
namespace Sheas_Cealer_Nix.Proces;
|
||||||
|
|
||||||
internal class ConginxProc : Proc
|
internal class ConginxProc : Proc
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Core;
|
using Sheas_Core;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Proces;
|
namespace Sheas_Cealer_Nix.Proces;
|
||||||
|
|
||||||
internal class MihomoProc : Proc
|
internal class MihomoProc : Proc
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Cealer.Utils;
|
using Sheas_Cealer_Nix.Utils;
|
||||||
using Sheas_Core;
|
using Sheas_Core;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Proces;
|
namespace Sheas_Cealer_Nix.Proces;
|
||||||
|
|
||||||
internal class NginxProc : Proc
|
internal class NginxProc : Proc
|
||||||
{
|
{
|
||||||
|
23
Program.cs
Normal file
23
Program.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using MsBox.Avalonia;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sheas_Cealer_Nix;
|
||||||
|
|
||||||
|
internal sealed class Program
|
||||||
|
{
|
||||||
|
[STAThread]
|
||||||
|
public static async Task Main(string[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.WithInterFont()
|
||||||
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
}
|
||||||
|
catch (Exception ex) { await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"Error: {ex.Message}").ShowAsync(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
4
Props/Settings.Designer.cs
generated
4
Props/Settings.Designer.cs
generated
@ -8,11 +8,11 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Sheas_Cealer.Props {
|
namespace Sheas_Cealer_Nix.Props {
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Sheas_Cealer.Props" GeneratedClassName="Settings">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Sheas_Cealer_Nix.Props" GeneratedClassName="Settings">
|
||||||
<Profiles />
|
<Profiles />
|
||||||
<Settings>
|
<Settings>
|
||||||
<Setting Name="BrowserPath" Type="System.String" Scope="User">
|
<Setting Name="BrowserPath" Type="System.String" Scope="User">
|
||||||
|
11
Props/launchSettings.json
Normal file
11
Props/launchSettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Sheas-Cealer-Nix": {
|
||||||
|
"commandName": "Project"
|
||||||
|
},
|
||||||
|
"WSL": {
|
||||||
|
"commandName": "WSL2",
|
||||||
|
"distributionName": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,8 +16,8 @@
|
|||||||
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
|
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
|
||||||
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
|
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageProjectUrl>https://github.com/SpaceTimee/Sheas-Cealer-Nix</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Project-SheasCealerNix/Sheas-Cealer-Nix</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/SpaceTimee/Sheas-Cealer-Nix</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Project-SheasCealerNix/Sheas-Cealer-Nix</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<Copyright>Copyright © 2077</Copyright>
|
<Copyright>Copyright © 2077</Copyright>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
|
@ -1,31 +1,30 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Interop;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Utils;
|
namespace Sheas_Cealer_Nix.Utils;
|
||||||
|
|
||||||
internal static partial class BorderThemeSetter
|
internal static partial class BorderThemeSetter
|
||||||
{
|
{
|
||||||
private const int DwmwaUseImmersiveDarkModeOld = 19;
|
//private const int DwmwaUseImmersiveDarkModeOld = 19;
|
||||||
private const int DwmwaUseImmersiveDarkMode = 20;
|
//private const int DwmwaUseImmersiveDarkMode = 20;
|
||||||
|
|
||||||
[LibraryImport("dwmapi.dll")]
|
//[LibraryImport("dwmapi.dll")]
|
||||||
private static partial void DwmGetWindowAttribute(nint hwnd, uint attr, out nint attrValue, uint attrSize);
|
//private static partial void DwmGetWindowAttribute(nint hwnd, uint attr, out nint attrValue, uint attrSize);
|
||||||
[LibraryImport("dwmapi.dll")]
|
//[LibraryImport("dwmapi.dll")]
|
||||||
private static partial void DwmSetWindowAttribute(nint hwnd, uint attr, ref nint attrValue, uint attrSize);
|
//private static partial void DwmSetWindowAttribute(nint hwnd, uint attr, ref nint attrValue, uint attrSize);
|
||||||
|
|
||||||
internal static void SetBorderTheme(Window window, bool? isLightTheme)
|
//internal static void SetBorderTheme(Window window, bool? isLightTheme)
|
||||||
{
|
//{
|
||||||
nint isDarkTheme;
|
// nint isDarkTheme;
|
||||||
nint desktopHwnd = nint.Zero;
|
// nint desktopHwnd = nint.Zero;
|
||||||
nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
|
// nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
|
||||||
|
|
||||||
if (isLightTheme.HasValue)
|
// if (isLightTheme.HasValue)
|
||||||
isDarkTheme = !isLightTheme.Value ? 1 : 0;
|
// isDarkTheme = !isLightTheme.Value ? 1 : 0;
|
||||||
else
|
// else
|
||||||
DwmGetWindowAttribute(desktopHwnd, DwmwaUseImmersiveDarkMode, out isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
// DwmGetWindowAttribute(desktopHwnd, DwmwaUseImmersiveDarkMode, out isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
||||||
|
|
||||||
DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkModeOld, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
// DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkModeOld, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
||||||
DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkMode, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
// DwmSetWindowAttribute(windowHwnd, DwmwaUseImmersiveDarkMode, ref isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
||||||
}
|
//}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Utils;
|
namespace Sheas_Cealer_Nix.Utils;
|
||||||
|
|
||||||
internal static partial class DnsFlusher
|
internal static partial class DnsFlusher
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Media;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Utils;
|
namespace Sheas_Cealer_Nix.Utils;
|
||||||
|
|
||||||
internal static class ForegroundGenerator
|
internal static class ForegroundGenerator
|
||||||
{
|
{
|
||||||
|
@ -1,38 +1,37 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Interop;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Utils;
|
namespace Sheas_Cealer_Nix.Utils;
|
||||||
|
|
||||||
internal static partial class IconRemover
|
internal static partial class IconRemover
|
||||||
{
|
{
|
||||||
private const int GwlExStyle = -20;
|
//private const int GwlExStyle = -20;
|
||||||
private const int WsExDlgModalFrame = 0x0001;
|
//private const int WsExDlgModalFrame = 0x0001;
|
||||||
private const int SwpNoSize = 0x0001;
|
//private const int SwpNoSize = 0x0001;
|
||||||
private const int SwpNoMove = 0x0002;
|
//private const int SwpNoMove = 0x0002;
|
||||||
private const int SwpNoZOrder = 0x0004;
|
//private const int SwpNoZOrder = 0x0004;
|
||||||
private const int SwpFrameChanged = 0x0020;
|
//private const int SwpFrameChanged = 0x0020;
|
||||||
private const uint WmSetIcon = 0x0080;
|
//private const uint WmSetIcon = 0x0080;
|
||||||
|
|
||||||
[LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")]
|
//[LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")]
|
||||||
private static partial int GetWindowLong(nint hwnd, int index);
|
//private static partial int GetWindowLong(nint hwnd, int index);
|
||||||
[LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")]
|
//[LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")]
|
||||||
private static partial void SetWindowLong(nint hwnd, int index, nint newStyle);
|
//private static partial void SetWindowLong(nint hwnd, int index, nint newStyle);
|
||||||
[LibraryImport("user32.dll")]
|
//[LibraryImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
//[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static partial void SetWindowPos(nint hwnd, nint hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
//private static partial void SetWindowPos(nint hwnd, nint hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||||
[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
//[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
||||||
private static partial void SendMessage(nint hwnd, uint msg, nint wParam, nint lParam);
|
//private static partial void SendMessage(nint hwnd, uint msg, nint wParam, nint lParam);
|
||||||
|
|
||||||
internal static void RemoveIcon(Window window)
|
//internal static void RemoveIcon(Window window)
|
||||||
{
|
//{
|
||||||
nint hwnd = new WindowInteropHelper(window).Handle;
|
// nint hwnd = new WindowInteropHelper(window).Handle;
|
||||||
|
|
||||||
SetWindowLong(hwnd, GwlExStyle, GetWindowLong(hwnd, GwlExStyle) | WsExDlgModalFrame);
|
// SetWindowLong(hwnd, GwlExStyle, GetWindowLong(hwnd, GwlExStyle) | WsExDlgModalFrame);
|
||||||
|
|
||||||
SetWindowPos(hwnd, nint.Zero, 0, 0, 0, 0, SwpNoMove | SwpNoSize | SwpNoZOrder | SwpFrameChanged);
|
// SetWindowPos(hwnd, nint.Zero, 0, 0, 0, 0, SwpNoMove | SwpNoSize | SwpNoZOrder | SwpFrameChanged);
|
||||||
|
|
||||||
SendMessage(hwnd, WmSetIcon, new(1), nint.Zero);
|
// SendMessage(hwnd, WmSetIcon, new(1), nint.Zero);
|
||||||
SendMessage(hwnd, WmSetIcon, nint.Zero, nint.Zero);
|
// SendMessage(hwnd, WmSetIcon, nint.Zero, nint.Zero);
|
||||||
}
|
//}
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Utils;
|
namespace Sheas_Cealer_Nix.Utils;
|
||||||
|
|
||||||
internal static class NginxCleaner
|
internal static class NginxCleaner
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
<Window x:Class="Sheas_Cealer.Wins.AboutWin"
|
<Window x:Class="Sheas_Cealer_Nix.Wins.AboutWin"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
x:DataType="preses:AboutPres"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
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:consts="clr-namespace:Sheas_Cealer.Consts"
|
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="500"
|
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height" Width="500"
|
||||||
d:DataContext="{d:DesignInstance preses:AboutPres}"
|
Loaded="AboutWin_Loaded" KeyDown="AboutWin_KeyDown">
|
||||||
Style="{DynamicResource CommonWindow}"
|
|
||||||
SourceInitialized="AboutWin_SourceInitialized" Loaded="AboutWin_Loaded" KeyDown="AboutWin_KeyDown">
|
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
@ -24,15 +23,14 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Button Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5"
|
<Button Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5"
|
||||||
d:Foreground="{Binding Source={x:Static consts:AboutConst.AccentBlueColor}, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
|
||||||
Foreground="{Binding AccentForegroundColor, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
Foreground="{Binding AccentForegroundColor, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
||||||
Content="{x:Static consts:AboutConst.DeveloperButtonContent}"
|
Content="{x:Static consts:AboutConst.DeveloperButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.DeveloperButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.DeveloperButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
<Button Grid.Row="1" Grid.Column="0" Margin="5" d:Content="# # #: #.#.#"
|
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
||||||
d:Foreground="{Binding Source={x:Static consts:AboutConst.AccentBlueColor}, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
d:Foreground="{Binding Source={x:Static consts:AboutConst.AccentBlueColor}, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
||||||
Foreground="{Binding AccentForegroundColor, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
Foreground="{Binding AccentForegroundColor, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
||||||
ToolTip="{x:Static consts:AboutConst.VersionButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.VersionButtonUrl}"
|
||||||
Click="AboutButton_Click">
|
Click="AboutButton_Click">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<MultiBinding Converter="{x:Static convs:AboutConv.AboutVersionButtonContentConv}">
|
<MultiBinding Converter="{x:Static convs:AboutConv.AboutVersionButtonContentConv}">
|
||||||
@ -45,25 +43,25 @@
|
|||||||
<Button x:Name="EmailButton"
|
<Button x:Name="EmailButton"
|
||||||
Grid.Row="1" Grid.Column="1" Margin="5"
|
Grid.Row="1" Grid.Column="1" Margin="5"
|
||||||
Content="{x:Static consts:AboutConst.EmailButtonContent}"
|
Content="{x:Static consts:AboutConst.EmailButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.EmailButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.EmailButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
|
|
||||||
<Button Grid.Row="0" Grid.Column="2" Margin="5"
|
<Button Grid.Row="0" Grid.Column="2" Margin="5"
|
||||||
Content="{x:Static consts:AboutConst.DocumentationButtonContent}"
|
Content="{x:Static consts:AboutConst.DocumentationButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.DocumentationButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.DocumentationButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
<Button Grid.Row="1" Grid.Column="2" Margin="5"
|
<Button Grid.Row="1" Grid.Column="2" Margin="5"
|
||||||
Content="{x:Static consts:AboutConst.RepositoryButtonContent}"
|
Content="{x:Static consts:AboutConst.RepositoryButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.RepositoryButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.RepositoryButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
|
|
||||||
<Button Grid.Row="0" Grid.Column="3" Margin="5"
|
<Button Grid.Row="0" Grid.Column="3" Margin="5"
|
||||||
Content="{x:Static consts:AboutConst.PolicyButtonContent}"
|
Content="{x:Static consts:AboutConst.PolicyButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.PolicyButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.PolicyButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
<Button Grid.Row="1" Grid.Column="3" Margin="5"
|
<Button Grid.Row="1" Grid.Column="3" Margin="5"
|
||||||
Content="{x:Static consts:AboutConst.AgreementButtonContent}"
|
Content="{x:Static consts:AboutConst.AgreementButtonContent}"
|
||||||
ToolTip="{x:Static consts:AboutConst.AgreementButtonUrl}"
|
ToolTip.Tip="{x:Static consts:AboutConst.AgreementButtonUrl}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
@ -1,17 +1,17 @@
|
|||||||
using Ona_Core;
|
using Avalonia.Controls;
|
||||||
using Sheas_Cealer.Consts;
|
using Avalonia.Input;
|
||||||
using Sheas_Cealer.Preses;
|
using Avalonia.Interactivity;
|
||||||
using Sheas_Cealer.Utils;
|
using MsBox.Avalonia;
|
||||||
|
using Ona_Core;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
|
using Sheas_Cealer_Nix.Preses;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Wins;
|
namespace Sheas_Cealer_Nix.Wins;
|
||||||
|
|
||||||
public partial class AboutWin : Window
|
public partial class AboutWin : Window
|
||||||
{
|
{
|
||||||
@ -20,15 +20,15 @@ public partial class AboutWin : Window
|
|||||||
|
|
||||||
internal AboutWin()
|
internal AboutWin()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
DataContext = AboutPres = new();
|
DataContext = AboutPres = new();
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
private void AboutWin_SourceInitialized(object sender, EventArgs e)
|
//private void AboutWin_SourceInitialized(object sender, EventArgs e)
|
||||||
{
|
//{
|
||||||
IconRemover.RemoveIcon(this);
|
// IconRemover.RemoveIcon(this);
|
||||||
BorderThemeSetter.SetBorderTheme(this, AboutPres.IsLightTheme);
|
// BorderThemeSetter.SetBorderTheme(this, AboutPres.IsLightTheme);
|
||||||
}
|
//}
|
||||||
private async void AboutWin_Loaded(object sender, RoutedEventArgs e)
|
private async void AboutWin_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
@ -49,11 +49,11 @@ public partial class AboutWin : Window
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AboutButton_Click(object sender, RoutedEventArgs e)
|
private async void AboutButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Button senderButton = (Button)sender;
|
Button senderButton = (Button)sender;
|
||||||
|
|
||||||
ProcessStartInfo processStartInfo = new(senderButton == EmailButton ? "mailto:" : string.Empty + senderButton.ToolTip) { UseShellExecute = true };
|
ProcessStartInfo processStartInfo = new(senderButton == EmailButton ? "mailto:" : string.Empty + ToolTip.GetTip(senderButton)) { UseShellExecute = true };
|
||||||
|
|
||||||
try { Process.Start(processStartInfo); }
|
try { Process.Start(processStartInfo); }
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
@ -1,19 +1,18 @@
|
|||||||
<Window x:Class="Sheas_Cealer.Wins.MainWin"
|
<Window x:Class="Sheas_Cealer_Nix.Wins.MainWin"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
x:DataType="preses:MainPres"
|
||||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:vm="using:AvaloniaMVVMApplication2.ViewModels"
|
||||||
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:consts="clr-namespace:Sheas_Cealer.Consts"
|
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
AllowDrop="True"
|
DragDrop.AllowDrop="True"
|
||||||
WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" SizeToContent="Height"
|
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height"
|
||||||
d:DataContext="{d:DesignInstance preses:MainPres}"
|
|
||||||
Style="{DynamicResource CommonWindow}"
|
|
||||||
Width="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainWinWidthConv}}"
|
Width="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainWinWidthConv}}"
|
||||||
SourceInitialized="MainWin_SourceInitialized" Loaded="MainWin_Loaded" Closing="MainWin_Closing" DragEnter="MainWin_DragEnter" Drop="MainWin_Drop" KeyDown="MainWin_KeyDown">
|
Loaded="MainWin_Loaded" Closing="MainWin_Closing" DragDrop.DragEnter="MainWin_DragEnter" DragDrop.Drop="MainWin_Drop" KeyDown="MainWin_KeyDown">
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -30,18 +29,18 @@
|
|||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Button Grid.Column="0" Margin="5" d:Content="# # # #"
|
<Button Grid.Column="0" Margin="5"
|
||||||
Content="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsModeButtonContentConv}}"
|
Content="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsModeButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:MainConst.SettingsModeButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.SettingsModeButtonToolTip}"
|
||||||
Click="SettingsModeButton_Click" />
|
Click="SettingsModeButton_Click" />
|
||||||
<TextBox x:Name="SettingsBox"
|
<TextBox x:Name="SettingsBox"
|
||||||
Grid.Column="1" Margin="5" VerticalContentAlignment="Center" md:HintAssist.IsFloating="True"
|
Grid.Column="1" Margin="5" VerticalContentAlignment="Center" UseFloatingWatermark="True"
|
||||||
AutomationProperties.Name="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
AutomationProperties.Name="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
||||||
md:HintAssist.Hint="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
Watermark="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
||||||
ToolTip="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxToolTipConv}}"
|
ToolTip.Tip="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxToolTipConv}}"
|
||||||
TextChanged="SettingsBox_TextChanged" PreviewDragOver="MainWin_DragEnter">
|
TextChanged="SettingsBox_TextChanged" DragDrop.DragOver="MainWin_DragEnter">
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
<MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged"
|
<MultiBinding Mode="OneWay"
|
||||||
Converter="{x:Static convs:MainConv.MainSettingsBoxTextConv}">
|
Converter="{x:Static convs:MainConv.MainSettingsBoxTextConv}">
|
||||||
<Binding Path="SettingsMode" />
|
<Binding Path="SettingsMode" />
|
||||||
<Binding Path="BrowserPath" />
|
<Binding Path="BrowserPath" />
|
||||||
@ -50,9 +49,9 @@
|
|||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBox.Text>
|
</TextBox.Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
<Button Grid.Column="2" Margin="5" d:Content="# # # #"
|
<Button Grid.Column="2" Margin="5"
|
||||||
Content="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsFunctionButtonContentConv}}"
|
Content="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsFunctionButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:MainConst.SettingsFunctionButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.SettingsFunctionButtonToolTip}"
|
||||||
Click="SettingsFunctionButton_Click" />
|
Click="SettingsFunctionButton_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
@ -65,8 +64,8 @@
|
|||||||
<Button IsDefault="True"
|
<Button IsDefault="True"
|
||||||
Grid.Column="0" Margin="5"
|
Grid.Column="0" Margin="5"
|
||||||
Content="{x:Static consts:MainConst.BrowserButtonContent}"
|
Content="{x:Static consts:MainConst.BrowserButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.BrowserButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.BrowserButtonToolTip}"
|
||||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||||
<Button.IsEnabled>
|
<Button.IsEnabled>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainBrowserButtonIsEnabledConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainBrowserButtonIsEnabledConv}">
|
||||||
<Binding Path="BrowserPath" />
|
<Binding Path="BrowserPath" />
|
||||||
@ -75,9 +74,9 @@
|
|||||||
</Button.IsEnabled>
|
</Button.IsEnabled>
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="NginxButton"
|
<Button x:Name="NginxButton"
|
||||||
Grid.Column="1" Margin="5" d:Content="# # # #"
|
Grid.Column="1" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||||
<Button.IsEnabled>
|
<Button.IsEnabled>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
||||||
<Binding Path="IsConginxExist" />
|
<Binding Path="IsConginxExist" />
|
||||||
@ -96,18 +95,18 @@
|
|||||||
<Binding Path="IsNginxIniting" />
|
<Binding Path="IsNginxIniting" />
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</Button.Content>
|
</Button.Content>
|
||||||
<Button.ToolTip>
|
<ToolTip.Tip>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonToolTipConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonToolTipConv}">
|
||||||
<Binding Path="IsConginxRunning" />
|
<Binding Path="IsConginxRunning" />
|
||||||
<Binding Path="IsNginxRunning" />
|
<Binding Path="IsNginxRunning" />
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</Button.ToolTip>
|
</ToolTip.Tip>
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="MihomoButton"
|
<Button x:Name="MihomoButton"
|
||||||
Grid.Column="2" Margin="5" d:Content="# # # #"
|
Grid.Column="2" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
ToolTip="{Binding IsMihomoRunning, Converter={x:Static convs:MainConv.MainMihomoButtonToolTipConv}}"
|
ToolTip.Tip="{Binding IsMihomoRunning, Converter={x:Static convs:MainConv.MainMihomoButtonToolTipConv}}"
|
||||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||||
<Button.IsEnabled>
|
<Button.IsEnabled>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainMihomoButtonIsEnabledConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainMihomoButtonIsEnabledConv}">
|
||||||
<Binding Path="IsComihomoExist" />
|
<Binding Path="IsComihomoExist" />
|
||||||
@ -139,17 +138,17 @@
|
|||||||
<Button x:Name="EditLocalHostButton"
|
<Button x:Name="EditLocalHostButton"
|
||||||
Grid.Column="0" Margin="5"
|
Grid.Column="0" Margin="5"
|
||||||
Content="{x:Static consts:MainConst.EditLocalHostButtonContent}"
|
Content="{x:Static consts:MainConst.EditLocalHostButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.EditLocalHostButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.EditLocalHostButtonToolTip}"
|
||||||
Click="EditHostButton_Click" />
|
Click="EditHostButton_Click" />
|
||||||
<Button Grid.Column="1" Margin="5"
|
<Button Grid.Column="1" Margin="5"
|
||||||
Content="{x:Static consts:MainConst.EditUpstreamHostButtonContent}"
|
Content="{x:Static consts:MainConst.EditUpstreamHostButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.EditUpstreamHostButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.EditUpstreamHostButtonToolTip}"
|
||||||
Click="EditHostButton_Click" />
|
Click="EditHostButton_Click" />
|
||||||
<Button x:Name="EditNginxConfButton"
|
<Button x:Name="EditNginxConfButton"
|
||||||
Grid.Column="2" Margin="5"
|
Grid.Column="2" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
Content="{x:Static consts:MainConst.EditNginxConfButtonContent}"
|
Content="{x:Static consts:MainConst.EditNginxConfButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.EditNginxConfButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.EditNginxConfButtonToolTip}"
|
||||||
Click="EditConfButton_Click">
|
Click="EditConfButton_Click">
|
||||||
<Button.IsEnabled>
|
<Button.IsEnabled>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
||||||
@ -163,9 +162,9 @@
|
|||||||
</Button.IsEnabled>
|
</Button.IsEnabled>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="3" Margin="5"
|
<Button Grid.Column="3" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
Content="{x:Static consts:MainConst.EditMihomoConfButtonContent}"
|
Content="{x:Static consts:MainConst.EditMihomoConfButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.EditMihomoConfButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.EditMihomoConfButtonToolTip}"
|
||||||
Click="EditConfButton_Click">
|
Click="EditConfButton_Click">
|
||||||
<Button.IsEnabled>
|
<Button.IsEnabled>
|
||||||
<MultiBinding Converter="{x:Static convs:MainConv.MainMihomoButtonIsEnabledConv}">
|
<MultiBinding Converter="{x:Static convs:MainConv.MainMihomoButtonIsEnabledConv}">
|
||||||
@ -184,16 +183,16 @@
|
|||||||
<ColumnDefinition Width="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainProxyColumnWidthConv}}" />
|
<ColumnDefinition Width="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainProxyColumnWidthConv}}" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Button Grid.Column="0" Margin="5" d:Content="# # # # # #"
|
<Button Grid.Column="0" Margin="5"
|
||||||
IsEnabled="{Binding UpstreamUrl, Converter={x:Static convs:MainConv.MainUpdateHostButtonIsEnabledConv}}"
|
IsEnabled="{Binding UpstreamUrl, Converter={x:Static convs:MainConv.MainUpdateHostButtonIsEnabledConv}}"
|
||||||
Content="{Binding IsUpstreamHostUtd, Converter={x:Static convs:MainConv.MainUpdateHostButtonContentConv}}"
|
Content="{Binding IsUpstreamHostUtd, Converter={x:Static convs:MainConv.MainUpdateHostButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:MainConst.UpdateUpstreamHostButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.UpdateUpstreamHostButtonToolTip}"
|
||||||
Click="UpdateUpstreamHostButton_Click" />
|
Click="UpdateUpstreamHostButton_Click" />
|
||||||
<Button x:Name="EditHostsConfButton"
|
<Button x:Name="EditHostsConfButton"
|
||||||
Grid.Column="1" Margin="5"
|
Grid.Column="1" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
Content="{x:Static consts:MainConst.EditHostsConfButtonContent}"
|
Content="{x:Static consts:MainConst.EditHostsConfButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.EditHostsConfButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.EditHostsConfButtonToolTip}"
|
||||||
Click="EditConfButton_Click" />
|
Click="EditConfButton_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="4">
|
<Grid Grid.Row="4">
|
||||||
@ -205,17 +204,17 @@
|
|||||||
|
|
||||||
<Button Grid.Column="0" Margin="5"
|
<Button Grid.Column="0" Margin="5"
|
||||||
Content="{x:Static consts:MainConst.SettingsButtonContent}"
|
Content="{x:Static consts:MainConst.SettingsButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.SettingsButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.SettingsButtonToolTip}"
|
||||||
Click="SettingsButton_Click" />
|
Click="SettingsButton_Click" />
|
||||||
<Button Focusable="False"
|
<Button Focusable="False"
|
||||||
Grid.Column="1" Margin="5" d:Content="# # # #"
|
Grid.Column="1" Margin="5"
|
||||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||||
Content="{Binding IsFlashing, Converter={x:Static convs:MainConv.MainNoClickButtonContentConv}}"
|
Content="{Binding IsFlashing, Converter={x:Static convs:MainConv.MainNoClickButtonContentConv}}"
|
||||||
ToolTip="{Binding IsFlashing, Converter={x:Static convs:MainConv.MainNoClickButtonToolTipConv}}"
|
ToolTip.Tip="{Binding IsFlashing, Converter={x:Static convs:MainConv.MainNoClickButtonToolTipConv}}"
|
||||||
Click="NoClickButton_Click" />
|
Click="NoClickButton_Click" />
|
||||||
<Button Grid.Column="2" Margin="5"
|
<Button Grid.Column="2" Margin="5"
|
||||||
Content="{x:Static consts:MainConst.AboutButtonContent}"
|
Content="{x:Static consts:MainConst.AboutButtonContent}"
|
||||||
ToolTip="{x:Static consts:MainConst.AboutButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:MainConst.AboutButtonToolTip}"
|
||||||
Click="AboutButton_Click" />
|
Click="AboutButton_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
@ -1,37 +1,37 @@
|
|||||||
using MaterialDesignThemes.Wpf;
|
using Avalonia.Controls;
|
||||||
using Microsoft.Win32;
|
using Avalonia.Headless;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using MsBox.Avalonia;
|
||||||
|
using MsBox.Avalonia.Enums;
|
||||||
using NginxConfigParser;
|
using NginxConfigParser;
|
||||||
using Ona_Core;
|
using Ona_Core;
|
||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer_Nix.Consts;
|
||||||
using Sheas_Cealer.Preses;
|
using Sheas_Cealer_Nix.Preses;
|
||||||
using Sheas_Cealer.Proces;
|
using Sheas_Cealer_Nix.Proces;
|
||||||
using Sheas_Cealer.Utils;
|
using Sheas_Cealer_Nix.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Wins;
|
namespace Sheas_Cealer_Nix.Wins;
|
||||||
|
|
||||||
public partial class MainWin : Window
|
public partial class MainWin : Window
|
||||||
{
|
{
|
||||||
@ -62,15 +62,15 @@ public partial class MainWin : Window
|
|||||||
|
|
||||||
internal MainWin()
|
internal MainWin()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
DataContext = MainPres = new();
|
DataContext = MainPres = new();
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
private void MainWin_SourceInitialized(object sender, EventArgs e)
|
//private void MainWin_SourceInitialized(object sender, EventArgs e)
|
||||||
{
|
//{
|
||||||
IconRemover.RemoveIcon(this);
|
// IconRemover.RemoveIcon(this);
|
||||||
BorderThemeSetter.SetBorderTheme(this, MainPres.IsLightTheme);
|
// BorderThemeSetter.SetBorderTheme(this, MainPres.IsLightTheme);
|
||||||
}
|
//}
|
||||||
private async void MainWin_Loaded(object sender, RoutedEventArgs e)
|
private async void MainWin_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
@ -94,25 +94,25 @@ public partial class MainWin : Window
|
|||||||
UpdateUpstreamHostButton_Click(null, null!);
|
UpdateUpstreamHostButton_Click(null, null!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private async void MainWin_Closing(object sender, CancelEventArgs e)
|
private async void MainWin_Closing(object sender, WindowClosingEventArgs e)
|
||||||
{
|
{
|
||||||
if (MainPres.IsNginxIniting)
|
if (MainPres.IsNginxIniting)
|
||||||
await File.WriteAllTextAsync(MainConst.NginxConfPath, ExtraNginxConfs);
|
await File.WriteAllTextAsync(MainConst.NginxConfPath, ExtraNginxConfs);
|
||||||
if (MainPres.IsMihomoIniting)
|
if (MainPres.IsMihomoIniting)
|
||||||
await File.WriteAllTextAsync(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
await File.WriteAllTextAsync(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
||||||
|
|
||||||
Application.Current.Shutdown();
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
e.Effects = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Link : DragDropEffects.None;
|
e.DragEffects = e.Data.GetFiles() != null ? DragDropEffects.Link : DragDropEffects.None;
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
private void MainWin_Drop(object sender, DragEventArgs e)
|
private void MainWin_Drop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
if (e.Data.GetFiles() != null)
|
||||||
MainPres.BrowserPath = (e.Data.GetData(DataFormats.FileDrop) as string[])?[0] ?? string.Empty;
|
MainPres.BrowserPath = e.Data.GetFiles()!.FirstOrDefault()!.Path.LocalPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsBox_TextChanged(object sender, TextChangedEventArgs e)
|
private void SettingsBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
@ -140,15 +140,16 @@ public partial class MainWin : Window
|
|||||||
_ => throw new UnreachableException()
|
_ => throw new UnreachableException()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
private void SettingsFunctionButton_Click(object sender, RoutedEventArgs e)
|
private async void SettingsFunctionButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog browserPathDialog = new() { Filter = $"{MainConst._BrowserPathDialogFilterFileType} (*.exe)|*.exe" };
|
|
||||||
|
|
||||||
switch (MainPres.SettingsMode)
|
switch (MainPres.SettingsMode)
|
||||||
{
|
{
|
||||||
case MainConst.SettingsMode.BrowserPathMode when browserPathDialog.ShowDialog().GetValueOrDefault():
|
case MainConst.SettingsMode.BrowserPathMode:
|
||||||
SettingsBox.Focus();
|
IReadOnlyList<IStorageFile> browserFiles = await TopLevel.GetTopLevel(this)!.StorageProvider.OpenFilePickerAsync(new() { Title = MainConst._BrowserPathDialogFilterFileType, AllowMultiple = false }); //Todo: Filter
|
||||||
MainPres.BrowserPath = browserPathDialog.FileName;
|
|
||||||
|
if (browserFiles.Count > 0)
|
||||||
|
MainPres.BrowserPath = browserFiles[0].Path.LocalPath; //Todo: Test Absolute Path
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case MainConst.SettingsMode.UpstreamUrlMode:
|
case MainConst.SettingsMode.UpstreamUrlMode:
|
||||||
MainPres.UpstreamUrl = MainConst.DefaultUpstreamUrl;
|
MainPres.UpstreamUrl = MainConst.DefaultUpstreamUrl;
|
||||||
@ -173,7 +174,7 @@ public partial class MainWin : Window
|
|||||||
else
|
else
|
||||||
BrowserButtonHoldTimer_Tick(sender == null, EventArgs.Empty);
|
BrowserButtonHoldTimer_Tick(sender == null, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
private void LaunchButton_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
private void LaunchButton_PointerPressed(object sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
Button senderButton = (Button)sender;
|
Button senderButton = (Button)sender;
|
||||||
|
|
||||||
@ -185,11 +186,11 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
HoldButtonTimer?.Stop();
|
HoldButtonTimer?.Stop();
|
||||||
|
|
||||||
if ((CealHostRulesDict.ContainsValue(null) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
if ((CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(sender is not true && MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
(sender is not true && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._KillBrowserProcessPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres.BrowserPath)))
|
foreach (Process browserProcess in Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainPres.BrowserPath) : Path.GetFileName(MainPres.BrowserPath)))
|
||||||
{
|
{
|
||||||
browserProcess.Kill();
|
browserProcess.Kill();
|
||||||
await browserProcess.WaitForExitAsync();
|
await browserProcess.WaitForExitAsync();
|
||||||
@ -209,12 +210,12 @@ public partial class MainWin : Window
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ((!MainPres.IsConginxExist && !MainPres.IsNginxExist) ||
|
if ((!MainPres.IsConginxExist && !MainPres.IsNginxExist) ||
|
||||||
(CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(NginxHttpsPort != 443 && MessageBox.Show(string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(NginxHttpsPort != 443 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(NginxHttpPort != 80 && MessageBox.Show(string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(NginxHttpPort != 80 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(sender != null && MessageBox.Show(MainConst._LaunchHostsNginxPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(sender != null && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchHostsNginxPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||||
(MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
(MainPres.IsFlashing && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxFlashingPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!File.Exists(MainConst.NginxConfPath))
|
if (!File.Exists(MainConst.NginxConfPath))
|
||||||
@ -323,7 +324,7 @@ public partial class MainWin : Window
|
|||||||
if (sender == null ? MainPres.IsConginxRunning : MainPres.IsNginxRunning)
|
if (sender == null ? MainPres.IsConginxRunning : MainPres.IsNginxRunning)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (MessageBox.Show(MainConst._LaunchNginxErrorPrompt, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
if (await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxErrorPrompt, ButtonEnum.YesNo).ShowAsync() == ButtonResult.Yes)
|
||||||
Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true });
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -332,7 +333,8 @@ public partial class MainWin : Window
|
|||||||
if (sender == null)
|
if (sender == null)
|
||||||
MihomoButtonHoldTimer_Tick(null, EventArgs.Empty);
|
MihomoButtonHoldTimer_Tick(null, EventArgs.Empty);
|
||||||
|
|
||||||
DnsFlusher.FlushDns();
|
if (OperatingSystem.IsWindows())
|
||||||
|
DnsFlusher.FlushDns();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -352,7 +354,7 @@ public partial class MainWin : Window
|
|||||||
if (isConginxRunning)
|
if (isConginxRunning)
|
||||||
MainPres.IsCoproxyStopping = true;
|
MainPres.IsCoproxyStopping = true;
|
||||||
|
|
||||||
foreach (Process nginxProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(isConginxRunning ? MainConst.ConginxPath : MainConst.NginxPath)))
|
foreach (Process nginxProcess in Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(isConginxRunning ? MainConst.ConginxPath : MainConst.NginxPath) : Path.GetFileName(isConginxRunning ? MainConst.ConginxPath : MainConst.NginxPath)))
|
||||||
{
|
{
|
||||||
nginxProcess.Exited += async (_, _) =>
|
nginxProcess.Exited += async (_, _) =>
|
||||||
{
|
{
|
||||||
@ -386,7 +388,7 @@ public partial class MainWin : Window
|
|||||||
return;
|
return;
|
||||||
if (string.IsNullOrWhiteSpace(MihomoConfs))
|
if (string.IsNullOrWhiteSpace(MihomoConfs))
|
||||||
throw new(MainConst._MihomoConfErrorMsg);
|
throw new(MainConst._MihomoConfErrorMsg);
|
||||||
if (!MainPres.IsConginxRunning && !MainPres.IsCoproxyStopping && MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
if (!MainPres.IsConginxRunning && !MainPres.IsCoproxyStopping && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!File.Exists(MainConst.MihomoConfPath))
|
if (!File.Exists(MainConst.MihomoConfPath))
|
||||||
@ -448,7 +450,7 @@ public partial class MainWin : Window
|
|||||||
if (MainPres.IsComihomoExist ? MainPres.IsComihomoRunning : MainPres.IsMihomoRunning)
|
if (MainPres.IsComihomoExist ? MainPres.IsComihomoRunning : MainPres.IsMihomoRunning)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MessageBox.Show(MainConst._LaunchMihomoErrorMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchMihomoErrorMsg).ShowAsync();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -473,7 +475,7 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
bool isComihomoRunning = MainPres.IsComihomoRunning;
|
bool isComihomoRunning = MainPres.IsComihomoRunning;
|
||||||
|
|
||||||
foreach (Process mihomoProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(isComihomoRunning ? MainConst.ComihomoPath : MainConst.MihomoPath)))
|
foreach (Process mihomoProcess in Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(isComihomoRunning ? MainConst.ComihomoPath : MainConst.MihomoPath) : Path.GetFileName(isComihomoRunning ? MainConst.ComihomoPath : MainConst.MihomoPath)))
|
||||||
{
|
{
|
||||||
mihomoProcess.Exited += (_, _) => MihomoConfWatcher_Changed(null!, null!);
|
mihomoProcess.Exited += (_, _) => MihomoConfWatcher_Changed(null!, null!);
|
||||||
|
|
||||||
@ -520,8 +522,12 @@ public partial class MainWin : Window
|
|||||||
if (!File.Exists(cealHostPath))
|
if (!File.Exists(cealHostPath))
|
||||||
await File.Create(cealHostPath).DisposeAsync();
|
await File.Create(cealHostPath).DisposeAsync();
|
||||||
|
|
||||||
try { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true }); }
|
if (OperatingSystem.IsWindows())
|
||||||
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true, Verb = "RunAs" }); }
|
try { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true }); }
|
||||||
|
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true, Verb = "RunAs" }); }
|
||||||
|
else
|
||||||
|
try { Process.Start("vi", cealHostPath); }
|
||||||
|
catch (UnauthorizedAccessException) { Process.Start("sudo", $"vi {cealHostPath}"); }
|
||||||
}
|
}
|
||||||
private async void EditConfButton_Click(object sender, RoutedEventArgs e)
|
private async void EditConfButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -542,7 +548,10 @@ public partial class MainWin : Window
|
|||||||
await File.Create(confPath).DisposeAsync();
|
await File.Create(confPath).DisposeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.Start(new ProcessStartInfo(confPath) { UseShellExecute = true });
|
if (OperatingSystem.IsWindows())
|
||||||
|
Process.Start(new ProcessStartInfo(confPath) { UseShellExecute = true });
|
||||||
|
else
|
||||||
|
Process.Start("vi", confPath);
|
||||||
}
|
}
|
||||||
private async void UpdateUpstreamHostButton_Click(object? sender, RoutedEventArgs e)
|
private async void UpdateUpstreamHostButton_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -565,21 +574,21 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
MainPres.IsUpstreamHostUtd = true;
|
MainPres.IsUpstreamHostUtd = true;
|
||||||
|
|
||||||
MessageBox.Show(MainConst._UpstreamHostUtdMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpstreamHostUtdMsg).ShowAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBoxResult overrideOptionResult = MessageBox.Show(MainConst._OverrideUpstreamHostPrompt, string.Empty, MessageBoxButton.YesNoCancel);
|
ButtonResult overrideOptionResult = await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._OverrideUpstreamHostPrompt, ButtonEnum.YesNoCancel).ShowAsync();
|
||||||
|
|
||||||
if (overrideOptionResult == MessageBoxResult.Yes)
|
if (overrideOptionResult == ButtonResult.Yes)
|
||||||
{
|
{
|
||||||
await File.WriteAllTextAsync(MainConst.UpstreamHostPath, upstreamUpstreamHostString);
|
await File.WriteAllTextAsync(MainConst.UpstreamHostPath, upstreamUpstreamHostString);
|
||||||
|
|
||||||
MainPres.IsUpstreamHostUtd = true;
|
MainPres.IsUpstreamHostUtd = true;
|
||||||
|
|
||||||
MessageBox.Show(MainConst._UpdateUpstreamHostSuccessMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpdateUpstreamHostSuccessMsg).ShowAsync();
|
||||||
}
|
}
|
||||||
else if (overrideOptionResult == MessageBoxResult.No)
|
else if (overrideOptionResult == ButtonResult.No)
|
||||||
try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); }
|
try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); }
|
||||||
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); }
|
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); }
|
||||||
}
|
}
|
||||||
@ -587,12 +596,12 @@ public partial class MainWin : Window
|
|||||||
catch when (sender == null) { }
|
catch when (sender == null) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsButton_Click(object sender, RoutedEventArgs e) => new SettingsWin().ShowDialog();
|
private void SettingsButton_Click(object sender, RoutedEventArgs e) => new SettingsWin().ShowDialog(this);
|
||||||
private async void NoClickButton_Click(object sender, RoutedEventArgs e)
|
private async void NoClickButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (GameFlashInterval <= 10)
|
if (GameFlashInterval <= 10)
|
||||||
{
|
{
|
||||||
MessageBox.Show(MainConst._GameReviewEndingMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameReviewEndingMsg).ShowAsync();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -600,19 +609,19 @@ public partial class MainWin : Window
|
|||||||
switch (++GameClickTime)
|
switch (++GameClickTime)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
MessageBox.Show(MainConst._GameClickOnceMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickOnceMsg).ShowAsync();
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
MessageBox.Show(MainConst._GameClickTwiceMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickTwiceMsg).ShowAsync();
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
MessageBox.Show(MainConst._GameClickThreeMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickThreeMsg).ShowAsync();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MainPres.IsFlashing)
|
if (!MainPres.IsFlashing)
|
||||||
{
|
{
|
||||||
MessageBox.Show(MainConst._GameStartMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameStartMsg).ShowAsync();
|
||||||
MainPres.IsFlashing = true;
|
MainPres.IsFlashing = true;
|
||||||
NginxConfWatcher_Changed(null!, null!);
|
NginxConfWatcher_Changed(null!, null!);
|
||||||
|
|
||||||
@ -620,28 +629,27 @@ public partial class MainWin : Window
|
|||||||
|
|
||||||
while (GameFlashInterval > 10)
|
while (GameFlashInterval > 10)
|
||||||
{
|
{
|
||||||
Left = random.Next(0, (int)(SystemParameters.PrimaryScreenWidth - ActualWidth));
|
Position = new(random.Next(0, (int)(Screens.Primary!.Bounds.Width - Bounds.Width)), random.Next(0, (int)(Screens.Primary.Bounds.Height - Bounds.Height)));
|
||||||
Top = random.Next(0, (int)(SystemParameters.PrimaryScreenHeight - ActualHeight));
|
|
||||||
|
|
||||||
PaletteHelper paletteHelper = new();
|
//PaletteHelper paletteHelper = new();
|
||||||
Theme newTheme = paletteHelper.GetTheme();
|
//Theme newTheme = paletteHelper.GetTheme();
|
||||||
Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
//Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
||||||
bool isLightTheme = random.Next(2) == 0;
|
//bool isLightTheme = random.Next(2) == 0;
|
||||||
|
|
||||||
newTheme.SetPrimaryColor(newPrimaryColor);
|
//newTheme.SetPrimaryColor(newPrimaryColor);
|
||||||
newTheme.SetBaseTheme(isLightTheme ? BaseTheme.Light : BaseTheme.Dark);
|
//newTheme.SetBaseTheme(isLightTheme ? BaseTheme.Light : BaseTheme.Dark);
|
||||||
paletteHelper.SetTheme(newTheme);
|
//paletteHelper.SetTheme(newTheme);
|
||||||
|
|
||||||
foreach (Window currentWindow in Application.Current.Windows)
|
//foreach (Window currentWindow in Application.Current.Windows)
|
||||||
BorderThemeSetter.SetBorderTheme(currentWindow, isLightTheme);
|
// BorderThemeSetter.SetBorderTheme(currentWindow, isLightTheme);
|
||||||
|
|
||||||
Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
//Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
||||||
(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
//(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
||||||
|
|
||||||
newButtonStyle.Setters.Add(new Setter(ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
//newButtonStyle.Setters.Add(new Setter(ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
||||||
Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
//Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||||
|
|
||||||
MainPres.AccentForegroundColor = newAccentForegroundColor;
|
//MainPres.AccentForegroundColor = newAccentForegroundColor;
|
||||||
|
|
||||||
if (GameFlashInterval > 100)
|
if (GameFlashInterval > 100)
|
||||||
GameFlashInterval += random.Next(1, 4);
|
GameFlashInterval += random.Next(1, 4);
|
||||||
@ -651,7 +659,7 @@ public partial class MainWin : Window
|
|||||||
|
|
||||||
MainPres.IsFlashing = false;
|
MainPres.IsFlashing = false;
|
||||||
NginxConfWatcher_Changed(null!, null!);
|
NginxConfWatcher_Changed(null!, null!);
|
||||||
MessageBox.Show(MainConst._GameEndingMsg);
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameEndingMsg).ShowAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -669,21 +677,21 @@ public partial class MainWin : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GameFlashInterval > 10)
|
if (GameFlashInterval > 10)
|
||||||
MessageBox.Show($"{MainConst._GameGradeMsg} {GameFlashInterval}");
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{MainConst._GameGradeMsg} {GameFlashInterval}").ShowAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog();
|
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWin().ShowDialog(this);
|
||||||
|
|
||||||
private void ProxyTimer_Tick(object? sender, EventArgs e)
|
private void ProxyTimer_Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MainPres.IsConginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.ConginxPath)));
|
MainPres.IsConginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.ConginxPath)));
|
||||||
MainPres.IsNginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.NginxPath)));
|
MainPres.IsNginxExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.NginxPath)));
|
||||||
MainPres.IsConginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ConginxPath)).Length != 0;
|
MainPres.IsConginxRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ConginxPath) : Path.GetFileName(MainConst.ConginxPath)).Length != 0;
|
||||||
MainPres.IsNginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.NginxPath)).Length != 0;
|
MainPres.IsNginxRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.NginxPath) : Path.GetFileName(MainConst.NginxPath)).Length != 0;
|
||||||
MainPres.IsComihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.ComihomoPath)));
|
MainPres.IsComihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.ComihomoPath)));
|
||||||
MainPres.IsMihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.MihomoPath)));
|
MainPres.IsMihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.MihomoPath)));
|
||||||
MainPres.IsComihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ComihomoPath)).Length != 0;
|
MainPres.IsComihomoRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ComihomoPath) : Path.GetFileName(MainConst.ComihomoPath)).Length != 0;
|
||||||
MainPres.IsMihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.MihomoPath)).Length != 0;
|
MainPres.IsMihomoRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.MihomoPath) : Path.GetFileName(MainConst.MihomoPath)).Length != 0;
|
||||||
}
|
}
|
||||||
private async void CealHostWatcher_Changed(object sender, FileSystemEventArgs e)
|
private async void CealHostWatcher_Changed(object sender, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
@ -918,23 +926,10 @@ public partial class MainWin : Window
|
|||||||
}
|
}
|
||||||
private void MainWin_KeyDown(object sender, KeyEventArgs e)
|
private void MainWin_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyboardDevice.Modifiers != ModifierKeys.Control)
|
if (e.KeyModifiers != KeyModifiers.Control)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (e.Key == Key.W)
|
if (e.Key == Key.W)
|
||||||
Application.Current.Shutdown();
|
Environment.Exit(0);
|
||||||
else if (e.Key == Key.H)
|
|
||||||
{
|
|
||||||
System.Windows.Forms.NotifyIcon notifyIcon = new() { Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), Text = MainConst.NotifyIconText, Visible = true };
|
|
||||||
|
|
||||||
notifyIcon.Click += (_, _) =>
|
|
||||||
{
|
|
||||||
Show();
|
|
||||||
|
|
||||||
notifyIcon.Dispose();
|
|
||||||
};
|
|
||||||
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,15 @@
|
|||||||
<Window x:Class="Sheas_Cealer.Wins.SettingsWin"
|
<Window x:Class="Sheas_Cealer_Nix.Wins.SettingsWin"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
x:DataType="preses:SettingsPres"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
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:consts="clr-namespace:Sheas_Cealer.Consts"
|
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="500"
|
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height" Width="500"
|
||||||
d:DataContext="{d:DesignInstance preses:SettingsPres}"
|
KeyDown="SettingsWin_KeyDown">
|
||||||
Style="{DynamicResource CommonWindow}"
|
|
||||||
SourceInitialized="SettingsWin_SourceInitialized" KeyDown="SettingsWin_KeyDown">
|
|
||||||
<Grid Margin="5">
|
<Grid Margin="5">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
@ -21,21 +20,21 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Button Grid.Row="0" Grid.Column="0" Margin="5" d:Content="# # # #"
|
<Button Grid.Row="0" Grid.Column="0" Margin="5"
|
||||||
Content="{Binding IsLightTheme, Converter={x:Static convs:SettingsConv.SettingsThemesButtonContentConv}}"
|
Content="{Binding IsLightTheme, Converter={x:Static convs:SettingsConv.SettingsThemesButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:SettingsConst.ThemesButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:SettingsConst.ThemesButtonToolTip}"
|
||||||
Click="ThemesButton_Click" />
|
Click="ThemesButton_Click" />
|
||||||
<Button Grid.Row="0" Grid.Column="1" Margin="5" d:Content="# # # #"
|
<Button Grid.Row="0" Grid.Column="1" Margin="5"
|
||||||
Content="{Binding IsEnglishLang, Converter={x:Static convs:SettingsConv.SettingsLangsButtonContentConv}}"
|
Content="{Binding IsEnglishLang, Converter={x:Static convs:SettingsConv.SettingsLangsButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:SettingsConst.LangsButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:SettingsConst.LangsButtonToolTip}"
|
||||||
Click="LangsButton_Click" />
|
Click="LangsButton_Click" />
|
||||||
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
||||||
Content="{x:Static consts:SettingsConst.ColorsButtonContent}"
|
Content="{x:Static consts:SettingsConst.ColorsButtonContent}"
|
||||||
ToolTip="{x:Static consts:SettingsConst.ColorsButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:SettingsConst.ColorsButtonToolTip}"
|
||||||
Click="ColorsButton_Click" />
|
Click="ColorsButton_Click" />
|
||||||
<Button Grid.Row="1" Grid.Column="1" Margin="5" d:Content="# # # #"
|
<Button Grid.Row="1" Grid.Column="1" Margin="5"
|
||||||
Content="{Binding IsLightWeight, Converter={x:Static convs:SettingsConv.SettingsWeightsButtonContentConv}}"
|
Content="{Binding IsLightWeight, Converter={x:Static convs:SettingsConv.SettingsWeightsButtonContentConv}}"
|
||||||
ToolTip="{x:Static consts:SettingsConst.WeightsButtonToolTip}"
|
ToolTip.Tip="{x:Static consts:SettingsConst.WeightsButtonToolTip}"
|
||||||
Click="WeightsButton_Click" />
|
Click="WeightsButton_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
61
Wins/SettingsWin.axaml.cs
Normal file
61
Wins/SettingsWin.axaml.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using MsBox.Avalonia;
|
||||||
|
using Sheas_Cealer_Nix.Consts;
|
||||||
|
using Sheas_Cealer_Nix.Preses;
|
||||||
|
|
||||||
|
namespace Sheas_Cealer_Nix.Wins;
|
||||||
|
|
||||||
|
public partial class SettingsWin : Window
|
||||||
|
{
|
||||||
|
private readonly SettingsPres SettingsPres;
|
||||||
|
|
||||||
|
internal SettingsWin()
|
||||||
|
{
|
||||||
|
DataContext = SettingsPres = new();
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
//private void SettingsWin_SourceInitialized(object sender, EventArgs e)
|
||||||
|
//{
|
||||||
|
// IconRemover.RemoveIcon(this);
|
||||||
|
// BorderThemeSetter.SetBorderTheme(this, SettingsPres.IsLightTheme);
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void ThemesButton_Click(object sender, RoutedEventArgs e) => SettingsPres.IsLightTheme = SettingsPres.IsLightTheme.HasValue ? SettingsPres.IsLightTheme.Value ? null : true : false;
|
||||||
|
private async void LangsButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SettingsPres.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false;
|
||||||
|
|
||||||
|
await MessageBoxManager.GetMessageBoxStandard(string.Empty, SettingsConst._ChangeLangSuccessMsg).ShowAsync();
|
||||||
|
}
|
||||||
|
private void ColorsButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//Random random = new();
|
||||||
|
//PaletteHelper paletteHelper = new();
|
||||||
|
//Theme newTheme = paletteHelper.GetTheme();
|
||||||
|
//Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
||||||
|
|
||||||
|
//newTheme.SetPrimaryColor(newPrimaryColor);
|
||||||
|
//paletteHelper.SetTheme(newTheme);
|
||||||
|
|
||||||
|
//Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
||||||
|
//(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
||||||
|
|
||||||
|
//newButtonStyle.Setters.Add(new Setter(ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
||||||
|
//Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||||
|
|
||||||
|
//SettingsPres.AccentForegroundColor = newAccentForegroundColor;
|
||||||
|
|
||||||
|
//Settings.Default.PrimaryColor = System.Drawing.Color.FromArgb(newPrimaryColor.A, newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
||||||
|
//Settings.Default.Save();
|
||||||
|
}
|
||||||
|
private void WeightsButton_Click(object sender, RoutedEventArgs e) => SettingsPres.IsLightWeight = SettingsPres.IsLightWeight.HasValue ? SettingsPres.IsLightWeight.Value ? null : true : false;
|
||||||
|
|
||||||
|
private void SettingsWin_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Escape)
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,65 +0,0 @@
|
|||||||
using MaterialDesignThemes.Wpf;
|
|
||||||
using Sheas_Cealer.Consts;
|
|
||||||
using Sheas_Cealer.Preses;
|
|
||||||
using Sheas_Cealer.Props;
|
|
||||||
using Sheas_Cealer.Utils;
|
|
||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Sheas_Cealer.Wins;
|
|
||||||
|
|
||||||
public partial class SettingsWin : Window
|
|
||||||
{
|
|
||||||
private readonly SettingsPres SettingsPres;
|
|
||||||
|
|
||||||
internal SettingsWin()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
DataContext = SettingsPres = new();
|
|
||||||
}
|
|
||||||
private void SettingsWin_SourceInitialized(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
IconRemover.RemoveIcon(this);
|
|
||||||
BorderThemeSetter.SetBorderTheme(this, SettingsPres.IsLightTheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ThemesButton_Click(object sender, RoutedEventArgs e) => SettingsPres.IsLightTheme = SettingsPres.IsLightTheme.HasValue ? SettingsPres.IsLightTheme.Value ? null : true : false;
|
|
||||||
private void LangsButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
SettingsPres.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false;
|
|
||||||
|
|
||||||
MessageBox.Show(SettingsConst._ChangeLangSuccessMsg);
|
|
||||||
}
|
|
||||||
private void ColorsButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
PaletteHelper paletteHelper = new();
|
|
||||||
Theme newTheme = paletteHelper.GetTheme();
|
|
||||||
Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
|
||||||
|
|
||||||
newTheme.SetPrimaryColor(newPrimaryColor);
|
|
||||||
paletteHelper.SetTheme(newTheme);
|
|
||||||
|
|
||||||
Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
|
||||||
(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
|
||||||
|
|
||||||
newButtonStyle.Setters.Add(new Setter(ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
|
||||||
Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
|
||||||
|
|
||||||
SettingsPres.AccentForegroundColor = newAccentForegroundColor;
|
|
||||||
|
|
||||||
Settings.Default.PrimaryColor = System.Drawing.Color.FromArgb(newPrimaryColor.A, newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
|
||||||
Settings.Default.Save();
|
|
||||||
}
|
|
||||||
private void WeightsButton_Click(object sender, RoutedEventArgs e) => SettingsPres.IsLightWeight = SettingsPres.IsLightWeight.HasValue ? SettingsPres.IsLightWeight.Value ? null : true : false;
|
|
||||||
|
|
||||||
private void SettingsWin_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Key == Key.Escape)
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user