mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 12:52:08 +08:00
1.1.4 -> 0.0.1 第2次更新
This commit is contained in:
parent
ecf6f87ae2
commit
2149a24ca8
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 System.Windows.Media;
|
||||
using Avalonia.Media;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Sheas_Cealer.Consts;
|
||||
namespace Sheas_Cealer_Nix.Consts;
|
||||
|
||||
internal abstract class AboutConst : AboutMultilangConst
|
||||
{
|
||||
public static Color AccentBlueColor => (Color)ColorConverter.ConvertFromString("#2196F3");
|
||||
public static Color AccentRedColor => (Color)ColorConverter.ConvertFromString("#F44336");
|
||||
public static Color AccentBlueColor => Color.Parse("#2196F3");
|
||||
public static Color AccentRedColor => Color.Parse("#F44336");
|
||||
|
||||
public static string DeveloperButtonUrl => "https://www.spacetimee.xyz";
|
||||
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 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 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";
|
||||
}
|
4
Consts/AboutMultilangConst.Designer.cs
generated
4
Consts/AboutMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sheas_Cealer.Consts {
|
||||
namespace Sheas_Cealer_Nix.Consts {
|
||||
using System;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
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;
|
||||
}
|
||||
return resourceMan;
|
||||
|
@ -4,14 +4,14 @@ using System.IO;
|
||||
using System.Security.Principal;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sheas_Cealer.Consts;
|
||||
namespace Sheas_Cealer_Nix.Consts;
|
||||
|
||||
internal abstract partial class MainConst : MainMultilangConst
|
||||
{
|
||||
internal enum SettingsMode
|
||||
{ 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 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 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 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[] MihomoNameServers => ["https://doh.apad.pro/dns-query", "https://ns.net.kg/dns-query"];
|
||||
|
||||
internal static string NotifyIconText => "Sheas Cealer";
|
||||
internal static string NotifyIconText => "Sheas Cealer Nix";
|
||||
|
||||
[GeneratedRegex(@"^(https?:\/\/)?[a-zA-Z0-9](-*[a-zA-Z0-9])*(\.[a-zA-Z0-9](-*[a-zA-Z0-9])*)*(:\d{1,5})?(\/[a-zA-Z0-9.\-_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%]*)*$")]
|
||||
internal static partial Regex UpstreamUrlRegex();
|
||||
|
4
Consts/MainMultilangConst.Designer.cs
generated
4
Consts/MainMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sheas_Cealer.Consts {
|
||||
namespace Sheas_Cealer_Nix.Consts {
|
||||
using System;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
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;
|
||||
}
|
||||
return resourceMan;
|
||||
|
@ -1,3 +1,3 @@
|
||||
namespace Sheas_Cealer.Consts;
|
||||
namespace Sheas_Cealer_Nix.Consts;
|
||||
|
||||
internal abstract class SettingsConst : SettingsMultilangConst;
|
4
Consts/SettingsMultilangConst.Designer.cs
generated
4
Consts/SettingsMultilangConst.Designer.cs
generated
@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sheas_Cealer.Consts {
|
||||
namespace Sheas_Cealer_Nix.Consts {
|
||||
using System;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Sheas_Cealer.Consts {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
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;
|
||||
}
|
||||
return resourceMan;
|
||||
|
@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using Avalonia.Data.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 versionButtonVersionContent = (string)values[1];
|
||||
@ -14,6 +15,4 @@ internal class AboutVersionButtonContentConv : IMultiValueConverter
|
||||
|
||||
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.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 extraArgs = (string)values[1];
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -1,13 +1,14 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Avalonia.Data.Converters;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 isComihomoIniting = (bool)values[1];
|
||||
@ -15,11 +16,9 @@ internal class MainMihomoButtonContentConv : IMultiValueConverter
|
||||
bool isCoproxyIniting = (bool)values[3];
|
||||
bool isCoproxyStopping = (bool)values[4];
|
||||
|
||||
return isCoproxyIniting || isCoproxyStopping ? Binding.DoNothing :
|
||||
return isCoproxyIniting || isCoproxyStopping ? MainConst.MihomoButtonIsInitingContent :
|
||||
isComihomoIniting ? MainConst.MihomoButtonIsStoppingContent :
|
||||
isMihomoIniting ? MainConst.MihomoButtonIsInitingContent :
|
||||
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.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 isMihomoExist = (bool)values[1];
|
||||
@ -16,6 +17,4 @@ internal class MainMihomoButtonIsEnabledConv : IMultiValueConverter
|
||||
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 isNginxRunning = (bool)values[1];
|
||||
@ -18,6 +19,4 @@ internal class MainNginxButtonContentConv : IMultiValueConverter
|
||||
isNginxIniting ? MainConst.NginxButtonIsInitingContent :
|
||||
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.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 isNginxExist = (bool)values[1];
|
||||
@ -17,6 +18,4 @@ internal class MainNginxButtonIsEnabledConv : IMultiValueConverter
|
||||
|
||||
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.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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 isNginxRunning = (bool)values[1];
|
||||
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
@ -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.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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];
|
||||
string browserPath = (string)values[1];
|
||||
@ -23,6 +24,4 @@ internal class MainSettingsBoxTextConv : IMultiValueConverter
|
||||
_ => 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.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
@ -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.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
@ -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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
@ -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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Avalonia.Data.Converters;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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?;
|
||||
|
||||
@ -16,5 +16,5 @@ internal class SettingsLangsButtonContentConv : IValueConverter
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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?;
|
||||
|
||||
@ -16,5 +16,5 @@ internal class SettingsThemesButtonContentConv : IValueConverter
|
||||
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.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
namespace Sheas_Cealer_Nix.Convs;
|
||||
|
||||
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?;
|
||||
|
||||
@ -16,5 +16,5 @@ internal class SettingsWeightsButtonContentConv : IValueConverter
|
||||
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;
|
||||
|
||||
namespace Sheas_Cealer.Preses;
|
||||
namespace Sheas_Cealer_Nix.Preses;
|
||||
|
||||
internal partial class AboutPres : GlobalPres
|
||||
{
|
||||
|
@ -1,42 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Props;
|
||||
using Sheas_Cealer.Utils;
|
||||
using Avalonia.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Props;
|
||||
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 GlobalPres()
|
||||
{
|
||||
IsLightTheme = Settings.Default.IsLightTheme switch
|
||||
{
|
||||
-1 => null,
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => throw new UnreachableException()
|
||||
};
|
||||
//IsLightTheme = Settings.Default.IsLightTheme switch
|
||||
//{
|
||||
// -1 => null,
|
||||
// 0 => false,
|
||||
// 1 => true,
|
||||
// _ => throw new UnreachableException()
|
||||
//};
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private static bool? isLightTheme = null;
|
||||
partial void OnIsLightThemeChanged(bool? value)
|
||||
{
|
||||
PaletteHelper paletteHelper = new();
|
||||
Theme newTheme = paletteHelper.GetTheme();
|
||||
//PaletteHelper paletteHelper = new();
|
||||
//Theme newTheme = paletteHelper.GetTheme();
|
||||
|
||||
newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
||||
paletteHelper.SetTheme(newTheme);
|
||||
//newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
||||
//paletteHelper.SetTheme(newTheme);
|
||||
|
||||
foreach (Window currentWindow in Application.Current.Windows)
|
||||
BorderThemeSetter.SetBorderTheme(currentWindow, value);
|
||||
//foreach (Window currentWindow in Application.Current.Windows)
|
||||
// BorderThemeSetter.SetBorderTheme(currentWindow, value);
|
||||
|
||||
Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
|
@ -1,38 +1,38 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Win32;
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Props;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Props;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Sheas_Cealer.Preses;
|
||||
namespace Sheas_Cealer_Nix.Preses;
|
||||
|
||||
internal partial class MainPres : GlobalPres
|
||||
{
|
||||
internal MainPres()
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
//string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
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 extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", 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 extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
|
||||
|
||||
BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
||||
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
||||
(Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
string.Empty).ToString()!;
|
||||
//BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ? args[browserPathIndex] :
|
||||
// !string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
|
||||
// (Registry.LocalMachine.OpenSubKey(MainConst.EdgeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
// Registry.LocalMachine.OpenSubKey(MainConst.ChromeBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
// Registry.LocalMachine.OpenSubKey(MainConst.BraveBrowserRegistryPath)?.GetValue(string.Empty, null) ??
|
||||
// string.Empty).ToString()!;
|
||||
|
||||
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
||||
!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
||||
args[upstreamUrlIndex];
|
||||
//UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
|
||||
// !string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :
|
||||
// args[upstreamUrlIndex];
|
||||
|
||||
ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
||||
!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
||||
args[extraArgsIndex];
|
||||
//ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
|
||||
// !string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty :
|
||||
// args[extraArgsIndex];
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
@ -42,33 +42,33 @@ internal partial class MainPres : GlobalPres
|
||||
private string browserPath;
|
||||
partial void OnBrowserPathChanged(string value)
|
||||
{
|
||||
if (!File.Exists(value) || !Path.GetFileName(value).ToLowerInvariant().EndsWith(".exe"))
|
||||
return;
|
||||
//if (!File.Exists(value) || !Path.GetFileName(value).ToLowerInvariant().EndsWith(".exe"))
|
||||
// return;
|
||||
|
||||
Settings.Default.BrowserPath = value;
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.BrowserPath = value;
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private string upstreamUrl;
|
||||
partial void OnUpstreamUrlChanged(string value)
|
||||
{
|
||||
if (!MainConst.UpstreamUrlRegex().IsMatch(value))
|
||||
return;
|
||||
//if (!MainConst.UpstreamUrlRegex().IsMatch(value))
|
||||
// return;
|
||||
|
||||
Settings.Default.UpstreamUrl = value;
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.UpstreamUrl = value;
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private string extraArgs;
|
||||
partial void OnExtraArgsChanged(string value)
|
||||
{
|
||||
if (!MainConst.ExtraArgsRegex().IsMatch(value))
|
||||
return;
|
||||
//if (!MainConst.ExtraArgsRegex().IsMatch(value))
|
||||
// return;
|
||||
|
||||
Settings.Default.ExtraArgs = value;
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.ExtraArgs = value;
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
@ -90,10 +90,10 @@ internal partial class MainPres : GlobalPres
|
||||
private bool isNginxIniting = false;
|
||||
|
||||
[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]
|
||||
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]
|
||||
private bool isComihomoExist = File.Exists(MainConst.ComihomoPath);
|
||||
@ -108,10 +108,10 @@ internal partial class MainPres : GlobalPres
|
||||
private bool isMihomoIniting = false;
|
||||
|
||||
[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]
|
||||
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]
|
||||
private bool isFlashing = false;
|
||||
|
@ -1,66 +1,61 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Sheas_Cealer.Props;
|
||||
using Sheas_Cealer_Nix.Props;
|
||||
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 SettingsPres()
|
||||
{
|
||||
IsEnglishLang = Settings.Default.IsEnglishLang switch
|
||||
{
|
||||
-1 => null,
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => throw new UnreachableException()
|
||||
};
|
||||
//IsEnglishLang = Settings.Default.IsEnglishLang switch
|
||||
//{
|
||||
// -1 => null,
|
||||
// 0 => false,
|
||||
// 1 => true,
|
||||
// _ => throw new UnreachableException()
|
||||
//};
|
||||
|
||||
IsLightWeight = Settings.Default.IsLightWeight switch
|
||||
{
|
||||
-1 => null,
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => throw new UnreachableException()
|
||||
};
|
||||
//IsLightWeight = Settings.Default.IsLightWeight switch
|
||||
//{
|
||||
// -1 => null,
|
||||
// 0 => false,
|
||||
// 1 => true,
|
||||
// _ => throw new UnreachableException()
|
||||
//};
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private static bool? isEnglishLang = null;
|
||||
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)
|
||||
currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
|
||||
//foreach (Window currentWindow in Application.Current.Windows)
|
||||
// currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
|
||||
|
||||
Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private static bool? isLightWeight = null;
|
||||
partial void OnIsLightWeightChanged(bool? value)
|
||||
{
|
||||
FontWeight newWeight = value.HasValue ? value.Value ? FontWeights.Light : FontWeights.Bold : FontWeights.Regular;
|
||||
Style newWindowStyle = new(typeof(Window), Application.Current.Resources["CommonWindow"] as Style);
|
||||
//FontWeight newWeight = value.HasValue ? value.Value ? FontWeights.Light : FontWeights.Bold : FontWeights.Regular;
|
||||
//Style newWindowStyle = new(typeof(Window), Application.Current.Resources["CommonWindow"] as Style);
|
||||
|
||||
newWindowStyle.Setters.Add(new Setter(Window.FontWeightProperty, newWeight));
|
||||
Application.Current.Resources["CommonWindow"] = newWindowStyle;
|
||||
//newWindowStyle.Setters.Add(new Setter(Window.FontWeightProperty, newWeight));
|
||||
//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));
|
||||
Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||
//newButtonStyle.Setters.Add(new Setter(Button.FontWeightProperty, newWeight));
|
||||
//Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||
|
||||
Settings.Default.IsLightWeight = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.IsLightWeight = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
using Sheas_Core;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace Sheas_Cealer.Proces;
|
||||
namespace Sheas_Cealer_Nix.Proces;
|
||||
|
||||
internal class BrowserProc : Proc
|
||||
{
|
||||
@ -18,6 +17,6 @@ internal class BrowserProc : Proc
|
||||
protected sealed override void Process_Exited(object? sender, EventArgs e)
|
||||
{
|
||||
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;
|
||||
|
||||
namespace Sheas_Cealer.Proces;
|
||||
namespace Sheas_Cealer_Nix.Proces;
|
||||
|
||||
internal class ComihomoProc : Proc
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Utils;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Utils;
|
||||
using Sheas_Core;
|
||||
using System;
|
||||
|
||||
namespace Sheas_Cealer.Proces;
|
||||
namespace Sheas_Cealer_Nix.Proces;
|
||||
|
||||
internal class ConginxProc : Proc
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Core;
|
||||
|
||||
namespace Sheas_Cealer.Proces;
|
||||
namespace Sheas_Cealer_Nix.Proces;
|
||||
|
||||
internal class MihomoProc : Proc
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Utils;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Utils;
|
||||
using Sheas_Core;
|
||||
using System;
|
||||
|
||||
namespace Sheas_Cealer.Proces;
|
||||
namespace Sheas_Cealer_Nix.Proces;
|
||||
|
||||
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>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sheas_Cealer.Props {
|
||||
namespace Sheas_Cealer_Nix.Props {
|
||||
|
||||
|
||||
[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 {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?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 />
|
||||
<Settings>
|
||||
<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>
|
||||
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageProjectUrl>https://github.com/SpaceTimee/Sheas-Cealer-Nix</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/SpaceTimee/Sheas-Cealer-Nix</RepositoryUrl>
|
||||
<PackageProjectUrl>https://github.com/Project-SheasCealerNix/Sheas-Cealer-Nix</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Project-SheasCealerNix/Sheas-Cealer-Nix</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Copyright>Copyright © 2077</Copyright>
|
||||
<OutputType>WinExe</OutputType>
|
||||
|
@ -1,31 +1,30 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Sheas_Cealer.Utils;
|
||||
namespace Sheas_Cealer_Nix.Utils;
|
||||
|
||||
internal static partial class BorderThemeSetter
|
||||
{
|
||||
private const int DwmwaUseImmersiveDarkModeOld = 19;
|
||||
private const int DwmwaUseImmersiveDarkMode = 20;
|
||||
//private const int DwmwaUseImmersiveDarkModeOld = 19;
|
||||
//private const int DwmwaUseImmersiveDarkMode = 20;
|
||||
|
||||
[LibraryImport("dwmapi.dll")]
|
||||
private static partial void DwmGetWindowAttribute(nint hwnd, uint attr, out nint attrValue, uint attrSize);
|
||||
[LibraryImport("dwmapi.dll")]
|
||||
private static partial void DwmSetWindowAttribute(nint hwnd, uint attr, ref nint attrValue, uint attrSize);
|
||||
//[LibraryImport("dwmapi.dll")]
|
||||
//private static partial void DwmGetWindowAttribute(nint hwnd, uint attr, out nint attrValue, uint attrSize);
|
||||
//[LibraryImport("dwmapi.dll")]
|
||||
//private static partial void DwmSetWindowAttribute(nint hwnd, uint attr, ref nint attrValue, uint attrSize);
|
||||
|
||||
internal static void SetBorderTheme(Window window, bool? isLightTheme)
|
||||
{
|
||||
nint isDarkTheme;
|
||||
nint desktopHwnd = nint.Zero;
|
||||
nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
|
||||
//internal static void SetBorderTheme(Window window, bool? isLightTheme)
|
||||
//{
|
||||
// nint isDarkTheme;
|
||||
// nint desktopHwnd = nint.Zero;
|
||||
// nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
|
||||
|
||||
if (isLightTheme.HasValue)
|
||||
isDarkTheme = !isLightTheme.Value ? 1 : 0;
|
||||
else
|
||||
DwmGetWindowAttribute(desktopHwnd, DwmwaUseImmersiveDarkMode, out isDarkTheme, (uint)Marshal.SizeOf(typeof(nint)));
|
||||
// if (isLightTheme.HasValue)
|
||||
// isDarkTheme = !isLightTheme.Value ? 1 : 0;
|
||||
// else
|
||||
// DwmGetWindowAttribute(desktopHwnd, DwmwaUseImmersiveDarkMode, out 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, DwmwaUseImmersiveDarkModeOld, 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;
|
||||
|
||||
namespace Sheas_Cealer.Utils;
|
||||
namespace Sheas_Cealer_Nix.Utils;
|
||||
|
||||
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.Windows.Media;
|
||||
|
||||
namespace Sheas_Cealer.Utils;
|
||||
namespace Sheas_Cealer_Nix.Utils;
|
||||
|
||||
internal static class ForegroundGenerator
|
||||
{
|
||||
|
@ -1,38 +1,37 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Sheas_Cealer.Utils;
|
||||
namespace Sheas_Cealer_Nix.Utils;
|
||||
|
||||
internal static partial class IconRemover
|
||||
{
|
||||
private const int GwlExStyle = -20;
|
||||
private const int WsExDlgModalFrame = 0x0001;
|
||||
private const int SwpNoSize = 0x0001;
|
||||
private const int SwpNoMove = 0x0002;
|
||||
private const int SwpNoZOrder = 0x0004;
|
||||
private const int SwpFrameChanged = 0x0020;
|
||||
private const uint WmSetIcon = 0x0080;
|
||||
//private const int GwlExStyle = -20;
|
||||
//private const int WsExDlgModalFrame = 0x0001;
|
||||
//private const int SwpNoSize = 0x0001;
|
||||
//private const int SwpNoMove = 0x0002;
|
||||
//private const int SwpNoZOrder = 0x0004;
|
||||
//private const int SwpFrameChanged = 0x0020;
|
||||
//private const uint WmSetIcon = 0x0080;
|
||||
|
||||
[LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")]
|
||||
private static partial int GetWindowLong(nint hwnd, int index);
|
||||
[LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")]
|
||||
private static partial void SetWindowLong(nint hwnd, int index, nint newStyle);
|
||||
[LibraryImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial void SetWindowPos(nint hwnd, nint hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
||||
private static partial void SendMessage(nint hwnd, uint msg, nint wParam, nint lParam);
|
||||
//[LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")]
|
||||
//private static partial int GetWindowLong(nint hwnd, int index);
|
||||
//[LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")]
|
||||
//private static partial void SetWindowLong(nint hwnd, int index, nint newStyle);
|
||||
//[LibraryImport("user32.dll")]
|
||||
//[return: MarshalAs(UnmanagedType.Bool)]
|
||||
//private static partial void SetWindowPos(nint hwnd, nint hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
//[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
||||
//private static partial void SendMessage(nint hwnd, uint msg, nint wParam, nint lParam);
|
||||
|
||||
internal static void RemoveIcon(Window window)
|
||||
{
|
||||
nint hwnd = new WindowInteropHelper(window).Handle;
|
||||
//internal static void RemoveIcon(Window window)
|
||||
//{
|
||||
// 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, nint.Zero, nint.Zero);
|
||||
}
|
||||
// SendMessage(hwnd, WmSetIcon, new(1), nint.Zero);
|
||||
// SendMessage(hwnd, WmSetIcon, nint.Zero, nint.Zero);
|
||||
//}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sheas_Cealer.Utils;
|
||||
namespace Sheas_Cealer_Nix.Utils;
|
||||
|
||||
internal static class NginxCleaner
|
||||
{
|
||||
|
@ -1,16 +1,15 @@
|
||||
<Window x:Class="Sheas_Cealer.Wins.AboutWin"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
<Window x:Class="Sheas_Cealer_Nix.Wins.AboutWin"
|
||||
x:DataType="preses:AboutPres"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="500"
|
||||
d:DataContext="{d:DesignInstance preses:AboutPres}"
|
||||
Style="{DynamicResource CommonWindow}"
|
||||
SourceInitialized="AboutWin_SourceInitialized" Loaded="AboutWin_Loaded" KeyDown="AboutWin_KeyDown">
|
||||
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height" Width="500"
|
||||
Loaded="AboutWin_Loaded" KeyDown="AboutWin_KeyDown">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
@ -24,16 +23,14 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<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}}"
|
||||
Content="{x:Static consts:AboutConst.DeveloperButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.DeveloperButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.DeveloperButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
<Button x:Name="VersionButton"
|
||||
Grid.Row="1" Grid.Column="0" Margin="5" d:Content="# # #: #.#.#"
|
||||
d:Foreground="{Binding Source={x:Static consts:AboutConst.AccentBlueColor}, Converter={x:Static convs:AboutConv.AboutAccentButtonForegroundConv}}"
|
||||
Grid.Row="1" Grid.Column="0" Margin="5"
|
||||
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">
|
||||
<Button.Content>
|
||||
<MultiBinding Converter="{x:Static convs:AboutConv.AboutVersionButtonContentConv}">
|
||||
@ -46,25 +43,25 @@
|
||||
<Button x:Name="EmailButton"
|
||||
Grid.Row="1" Grid.Column="1" Margin="5"
|
||||
Content="{x:Static consts:AboutConst.EmailButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.EmailButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.EmailButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
|
||||
<Button Grid.Row="0" Grid.Column="2" Margin="5"
|
||||
Content="{x:Static consts:AboutConst.DocumentationButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.DocumentationButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.DocumentationButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
<Button Grid.Row="1" Grid.Column="2" Margin="5"
|
||||
Content="{x:Static consts:AboutConst.RepositoryButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.RepositoryButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.RepositoryButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
|
||||
<Button Grid.Row="0" Grid.Column="3" Margin="5"
|
||||
Content="{x:Static consts:AboutConst.PolicyButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.PolicyButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.PolicyButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
<Button Grid.Row="1" Grid.Column="3" Margin="5"
|
||||
Content="{x:Static consts:AboutConst.AgreementButtonContent}"
|
||||
ToolTip="{x:Static consts:AboutConst.AgreementButtonUrl}"
|
||||
ToolTip.Tip="{x:Static consts:AboutConst.AgreementButtonUrl}"
|
||||
Click="AboutButton_Click" />
|
||||
</Grid>
|
||||
</Window>
|
@ -1,17 +1,17 @@
|
||||
using Ona_Core;
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Preses;
|
||||
using Sheas_Cealer.Utils;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using MsBox.Avalonia;
|
||||
using Ona_Core;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Preses;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
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
|
||||
{
|
||||
@ -20,15 +20,15 @@ public partial class AboutWin : Window
|
||||
|
||||
internal AboutWin()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = AboutPres = new();
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
private void AboutWin_SourceInitialized(object sender, EventArgs e)
|
||||
{
|
||||
IconRemover.RemoveIcon(this);
|
||||
BorderThemeSetter.SetBorderTheme(this, AboutPres.IsLightTheme);
|
||||
}
|
||||
//private void AboutWin_SourceInitialized(object sender, EventArgs e)
|
||||
//{
|
||||
// IconRemover.RemoveIcon(this);
|
||||
// BorderThemeSetter.SetBorderTheme(this, AboutPres.IsLightTheme);
|
||||
//}
|
||||
private async void AboutWin_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
@ -49,14 +49,14 @@ 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;
|
||||
|
||||
if (senderButton == VersionButton)
|
||||
MessageBox.Show($"{AboutConst._ReleasePagePasswordLabel} 3wnj");
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, $"{AboutConst._ReleasePagePasswordLabel} 3wnj").ShowAsync();
|
||||
|
||||
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); }
|
||||
catch (UnauthorizedAccessException)
|
@ -1,19 +1,18 @@
|
||||
<Window x:Class="Sheas_Cealer.Wins.MainWin"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
<Window x:Class="Sheas_Cealer_Nix.Wins.MainWin"
|
||||
x:DataType="preses:MainPres"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:vm="using:AvaloniaMVVMApplication2.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||
mc:Ignorable="d"
|
||||
AllowDrop="True"
|
||||
WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" SizeToContent="Height"
|
||||
d:DataContext="{d:DesignInstance preses:MainPres}"
|
||||
Style="{DynamicResource CommonWindow}"
|
||||
DragDrop.AllowDrop="True"
|
||||
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height"
|
||||
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.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -30,18 +29,18 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</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}}"
|
||||
ToolTip="{x:Static consts:MainConst.SettingsModeButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.SettingsModeButtonToolTip}"
|
||||
Click="SettingsModeButton_Click" />
|
||||
<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}}"
|
||||
md:HintAssist.Hint="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
||||
ToolTip="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxToolTipConv}}"
|
||||
TextChanged="SettingsBox_TextChanged" PreviewDragOver="MainWin_DragEnter">
|
||||
Watermark="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxHintConv}}"
|
||||
ToolTip.Tip="{Binding SettingsMode, Converter={x:Static convs:MainConv.MainSettingsBoxToolTipConv}}"
|
||||
TextChanged="SettingsBox_TextChanged" DragDrop.DragOver="MainWin_DragEnter">
|
||||
<TextBox.Text>
|
||||
<MultiBinding Mode="OneWay" UpdateSourceTrigger="PropertyChanged"
|
||||
<MultiBinding Mode="OneWay"
|
||||
Converter="{x:Static convs:MainConv.MainSettingsBoxTextConv}">
|
||||
<Binding Path="SettingsMode" />
|
||||
<Binding Path="BrowserPath" />
|
||||
@ -50,9 +49,9 @@
|
||||
</MultiBinding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<Button Grid.Column="2" Margin="5" d:Content="# # # #"
|
||||
<Button Grid.Column="2" Margin="5"
|
||||
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" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
@ -65,8 +64,8 @@
|
||||
<Button IsDefault="True"
|
||||
Grid.Column="0" Margin="5"
|
||||
Content="{x:Static consts:MainConst.BrowserButtonContent}"
|
||||
ToolTip="{x:Static consts:MainConst.BrowserButtonToolTip}"
|
||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
||||
ToolTip.Tip="{x:Static consts:MainConst.BrowserButtonToolTip}"
|
||||
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static convs:MainConv.MainBrowserButtonIsEnabledConv}">
|
||||
<Binding Path="BrowserPath" />
|
||||
@ -75,9 +74,9 @@
|
||||
</Button.IsEnabled>
|
||||
</Button>
|
||||
<Button x:Name="NginxButton"
|
||||
Grid.Column="1" Margin="5" d:Content="# # # #"
|
||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
||||
Grid.Column="1" Margin="5"
|
||||
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
||||
<Binding Path="IsConginxExist" />
|
||||
@ -96,18 +95,18 @@
|
||||
<Binding Path="IsNginxIniting" />
|
||||
</MultiBinding>
|
||||
</Button.Content>
|
||||
<Button.ToolTip>
|
||||
<ToolTip.Tip>
|
||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonToolTipConv}">
|
||||
<Binding Path="IsConginxRunning" />
|
||||
<Binding Path="IsNginxRunning" />
|
||||
</MultiBinding>
|
||||
</Button.ToolTip>
|
||||
</ToolTip.Tip>
|
||||
</Button>
|
||||
<Button x:Name="MihomoButton"
|
||||
Grid.Column="2" Margin="5" d:Content="# # # #"
|
||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
ToolTip="{Binding IsMihomoRunning, Converter={x:Static convs:MainConv.MainMihomoButtonToolTipConv}}"
|
||||
Click="LaunchButton_Click" PreviewMouseDown="LaunchButton_PreviewMouseDown">
|
||||
Grid.Column="2" Margin="5"
|
||||
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
ToolTip.Tip="{Binding IsMihomoRunning, Converter={x:Static convs:MainConv.MainMihomoButtonToolTipConv}}"
|
||||
Click="LaunchButton_Click" PointerPressed="LaunchButton_PointerPressed">
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static convs:MainConv.MainMihomoButtonIsEnabledConv}">
|
||||
<Binding Path="IsComihomoExist" />
|
||||
@ -139,17 +138,17 @@
|
||||
<Button x:Name="EditLocalHostButton"
|
||||
Grid.Column="0" Margin="5"
|
||||
Content="{x:Static consts:MainConst.EditLocalHostButtonContent}"
|
||||
ToolTip="{x:Static consts:MainConst.EditLocalHostButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.EditLocalHostButtonToolTip}"
|
||||
Click="EditHostButton_Click" />
|
||||
<Button Grid.Column="1" Margin="5"
|
||||
Content="{x:Static consts:MainConst.EditUpstreamHostButtonContent}"
|
||||
ToolTip="{x:Static consts:MainConst.EditUpstreamHostButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.EditUpstreamHostButtonToolTip}"
|
||||
Click="EditHostButton_Click" />
|
||||
<Button x:Name="EditNginxConfButton"
|
||||
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}"
|
||||
ToolTip="{x:Static consts:MainConst.EditNginxConfButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.EditNginxConfButtonToolTip}"
|
||||
Click="EditConfButton_Click">
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static convs:MainConv.MainNginxButtonIsEnabledConv}">
|
||||
@ -163,9 +162,9 @@
|
||||
</Button.IsEnabled>
|
||||
</Button>
|
||||
<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}"
|
||||
ToolTip="{x:Static consts:MainConst.EditMihomoConfButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.EditMihomoConfButtonToolTip}"
|
||||
Click="EditConfButton_Click">
|
||||
<Button.IsEnabled>
|
||||
<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}}" />
|
||||
</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}}"
|
||||
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" />
|
||||
<Button x:Name="EditHostsConfButton"
|
||||
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}"
|
||||
ToolTip="{x:Static consts:MainConst.EditHostsConfButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.EditHostsConfButtonToolTip}"
|
||||
Click="EditConfButton_Click" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="4">
|
||||
@ -205,17 +204,17 @@
|
||||
|
||||
<Button Grid.Column="0" Margin="5"
|
||||
Content="{x:Static consts:MainConst.SettingsButtonContent}"
|
||||
ToolTip="{x:Static consts:MainConst.SettingsButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.SettingsButtonToolTip}"
|
||||
Click="SettingsButton_Click" />
|
||||
<Button Focusable="False"
|
||||
Grid.Column="1" Margin="5" d:Content="# # # #"
|
||||
Visibility="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
Grid.Column="1" Margin="5"
|
||||
IsVisible="{Binding Source={x:Static consts:MainConst.IsAdmin}, Converter={x:Static convs:MainConv.MainAdminControlVisibilityConv}}"
|
||||
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" />
|
||||
<Button Grid.Column="2" Margin="5"
|
||||
Content="{x:Static consts:MainConst.AboutButtonContent}"
|
||||
ToolTip="{x:Static consts:MainConst.AboutButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:MainConst.AboutButtonToolTip}"
|
||||
Click="AboutButton_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
@ -1,37 +1,37 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Microsoft.Win32;
|
||||
using Avalonia.Controls;
|
||||
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 Ona_Core;
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Preses;
|
||||
using Sheas_Cealer.Proces;
|
||||
using Sheas_Cealer.Utils;
|
||||
using Sheas_Cealer_Nix.Consts;
|
||||
using Sheas_Cealer_Nix.Preses;
|
||||
using Sheas_Cealer_Nix.Proces;
|
||||
using Sheas_Cealer_Nix.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
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.NamingConventions;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Sheas_Cealer.Wins;
|
||||
namespace Sheas_Cealer_Nix.Wins;
|
||||
|
||||
public partial class MainWin : Window
|
||||
{
|
||||
@ -62,15 +62,15 @@ public partial class MainWin : Window
|
||||
|
||||
internal MainWin()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = MainPres = new();
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
private void MainWin_SourceInitialized(object sender, EventArgs e)
|
||||
{
|
||||
IconRemover.RemoveIcon(this);
|
||||
BorderThemeSetter.SetBorderTheme(this, MainPres.IsLightTheme);
|
||||
}
|
||||
//private void MainWin_SourceInitialized(object sender, EventArgs e)
|
||||
//{
|
||||
// IconRemover.RemoveIcon(this);
|
||||
// BorderThemeSetter.SetBorderTheme(this, MainPres.IsLightTheme);
|
||||
//}
|
||||
private async void MainWin_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
@ -94,25 +94,25 @@ public partial class MainWin : Window
|
||||
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)
|
||||
await File.WriteAllTextAsync(MainConst.NginxConfPath, ExtraNginxConfs);
|
||||
if (MainPres.IsMihomoIniting)
|
||||
await File.WriteAllTextAsync(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
||||
|
||||
Application.Current.Shutdown();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
private void MainWin_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
MainPres.BrowserPath = (e.Data.GetData(DataFormats.FileDrop) as string[])?[0] ?? string.Empty;
|
||||
if (e.Data.GetFiles() != null)
|
||||
MainPres.BrowserPath = e.Data.GetFiles()!.FirstOrDefault()!.Path.LocalPath;
|
||||
}
|
||||
|
||||
private void SettingsBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
@ -140,15 +140,16 @@ public partial class MainWin : Window
|
||||
_ => 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)
|
||||
{
|
||||
case MainConst.SettingsMode.BrowserPathMode when browserPathDialog.ShowDialog().GetValueOrDefault():
|
||||
SettingsBox.Focus();
|
||||
MainPres.BrowserPath = browserPathDialog.FileName;
|
||||
case MainConst.SettingsMode.BrowserPathMode:
|
||||
IReadOnlyList<IStorageFile> browserFiles = await TopLevel.GetTopLevel(this)!.StorageProvider.OpenFilePickerAsync(new() { Title = MainConst._BrowserPathDialogFilterFileType, AllowMultiple = false }); //Todo: Filter
|
||||
|
||||
if (browserFiles.Count > 0)
|
||||
MainPres.BrowserPath = browserFiles[0].Path.LocalPath; //Todo: Test Absolute Path
|
||||
|
||||
return;
|
||||
case MainConst.SettingsMode.UpstreamUrlMode:
|
||||
MainPres.UpstreamUrl = MainConst.DefaultUpstreamUrl;
|
||||
@ -173,7 +174,7 @@ public partial class MainWin : Window
|
||||
else
|
||||
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;
|
||||
|
||||
@ -185,11 +186,11 @@ public partial class MainWin : Window
|
||||
{
|
||||
HoldButtonTimer?.Stop();
|
||||
|
||||
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(sender is not true && MessageBox.Show(MainConst._KillBrowserProcessPrompt, 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 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._KillBrowserProcessPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes))
|
||||
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();
|
||||
await browserProcess.WaitForExitAsync();
|
||||
@ -212,12 +213,12 @@ public partial class MainWin : Window
|
||||
try
|
||||
{
|
||||
if ((!MainPres.IsConginxExist && !MainPres.IsNginxExist) ||
|
||||
(CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._CealHostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(NginxHttpsPort != 443 && MessageBox.Show(string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(NginxHttpPort != 80 && MessageBox.Show(string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(sender != null && MessageBox.Show(MainConst._LaunchHostsNginxPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||
(MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
||||
(CealHostRulesDict.ContainsValue(null!) && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._CealHostErrorPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||
(NginxHttpsPort != 443 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpsPortOccupiedPrompt, NginxHttpsPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||
(NginxHttpPort != 80 && await MessageBoxManager.GetMessageBoxStandard(string.Empty, string.Format(MainConst._NginxHttpPortOccupiedPrompt, NginxHttpPort), ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||
(sender != null && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchHostsNginxPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||
(await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchProxyPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes) ||
|
||||
(MainPres.IsFlashing && await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchNginxFlashingPrompt, ButtonEnum.YesNo).ShowAsync() != ButtonResult.Yes))
|
||||
return;
|
||||
|
||||
if (!File.Exists(MainConst.NginxConfPath))
|
||||
@ -326,7 +327,7 @@ public partial class MainWin : Window
|
||||
if (sender == null ? MainPres.IsConginxRunning : MainPres.IsNginxRunning)
|
||||
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 });
|
||||
|
||||
break;
|
||||
@ -335,7 +336,8 @@ public partial class MainWin : Window
|
||||
if (sender == null)
|
||||
MihomoButtonHoldTimer_Tick(null, EventArgs.Empty);
|
||||
|
||||
DnsFlusher.FlushDns();
|
||||
if (OperatingSystem.IsWindows())
|
||||
DnsFlusher.FlushDns();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -355,7 +357,7 @@ public partial class MainWin : Window
|
||||
if (isConginxRunning)
|
||||
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 (_, _) =>
|
||||
{
|
||||
@ -389,7 +391,7 @@ public partial class MainWin : Window
|
||||
return;
|
||||
if (string.IsNullOrWhiteSpace(MihomoConfs))
|
||||
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;
|
||||
|
||||
if (!File.Exists(MainConst.MihomoConfPath))
|
||||
@ -451,7 +453,7 @@ public partial class MainWin : Window
|
||||
if (MainPres.IsComihomoExist ? MainPres.IsComihomoRunning : MainPres.IsMihomoRunning)
|
||||
continue;
|
||||
|
||||
MessageBox.Show(MainConst._LaunchMihomoErrorMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._LaunchMihomoErrorMsg).ShowAsync();
|
||||
|
||||
break;
|
||||
}
|
||||
@ -476,7 +478,7 @@ public partial class MainWin : Window
|
||||
{
|
||||
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!);
|
||||
|
||||
@ -523,8 +525,12 @@ public partial class MainWin : Window
|
||||
if (!File.Exists(cealHostPath))
|
||||
await File.Create(cealHostPath).DisposeAsync();
|
||||
|
||||
try { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true }); }
|
||||
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(cealHostPath) { UseShellExecute = true, Verb = "RunAs" }); }
|
||||
if (OperatingSystem.IsWindows())
|
||||
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)
|
||||
{
|
||||
@ -545,7 +551,10 @@ public partial class MainWin : Window
|
||||
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)
|
||||
{
|
||||
@ -568,21 +577,21 @@ public partial class MainWin : Window
|
||||
{
|
||||
MainPres.IsUpstreamHostUtd = true;
|
||||
|
||||
MessageBox.Show(MainConst._UpstreamHostUtdMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._UpstreamHostUtdMsg).ShowAsync();
|
||||
}
|
||||
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);
|
||||
|
||||
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 }); }
|
||||
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); }
|
||||
}
|
||||
@ -590,12 +599,12 @@ public partial class MainWin : Window
|
||||
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)
|
||||
{
|
||||
if (GameFlashInterval <= 10)
|
||||
{
|
||||
MessageBox.Show(MainConst._GameReviewEndingMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameReviewEndingMsg).ShowAsync();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -603,19 +612,19 @@ public partial class MainWin : Window
|
||||
switch (++GameClickTime)
|
||||
{
|
||||
case 1:
|
||||
MessageBox.Show(MainConst._GameClickOnceMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickOnceMsg).ShowAsync();
|
||||
return;
|
||||
case 2:
|
||||
MessageBox.Show(MainConst._GameClickTwiceMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickTwiceMsg).ShowAsync();
|
||||
return;
|
||||
case 3:
|
||||
MessageBox.Show(MainConst._GameClickThreeMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameClickThreeMsg).ShowAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MainPres.IsFlashing)
|
||||
{
|
||||
MessageBox.Show(MainConst._GameStartMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameStartMsg).ShowAsync();
|
||||
MainPres.IsFlashing = true;
|
||||
NginxConfWatcher_Changed(null!, null!);
|
||||
|
||||
@ -623,28 +632,27 @@ public partial class MainWin : Window
|
||||
|
||||
while (GameFlashInterval > 10)
|
||||
{
|
||||
Left = random.Next(0, (int)(SystemParameters.PrimaryScreenWidth - ActualWidth));
|
||||
Top = random.Next(0, (int)(SystemParameters.PrimaryScreenHeight - ActualHeight));
|
||||
Position = new(random.Next(0, (int)(Screens.Primary!.Bounds.Width - Bounds.Width)), random.Next(0, (int)(Screens.Primary.Bounds.Height - Bounds.Height)));
|
||||
|
||||
PaletteHelper paletteHelper = new();
|
||||
Theme newTheme = paletteHelper.GetTheme();
|
||||
Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
||||
bool isLightTheme = random.Next(2) == 0;
|
||||
//PaletteHelper paletteHelper = new();
|
||||
//Theme newTheme = paletteHelper.GetTheme();
|
||||
//Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
|
||||
//bool isLightTheme = random.Next(2) == 0;
|
||||
|
||||
newTheme.SetPrimaryColor(newPrimaryColor);
|
||||
newTheme.SetBaseTheme(isLightTheme ? BaseTheme.Light : BaseTheme.Dark);
|
||||
paletteHelper.SetTheme(newTheme);
|
||||
//newTheme.SetPrimaryColor(newPrimaryColor);
|
||||
//newTheme.SetBaseTheme(isLightTheme ? BaseTheme.Light : BaseTheme.Dark);
|
||||
//paletteHelper.SetTheme(newTheme);
|
||||
|
||||
foreach (Window currentWindow in Application.Current.Windows)
|
||||
BorderThemeSetter.SetBorderTheme(currentWindow, isLightTheme);
|
||||
//foreach (Window currentWindow in Application.Current.Windows)
|
||||
// BorderThemeSetter.SetBorderTheme(currentWindow, isLightTheme);
|
||||
|
||||
Style newButtonStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
|
||||
(Color? newForegroundColor, Color newAccentForegroundColor) = ForegroundGenerator.GetForeground(newPrimaryColor.R, newPrimaryColor.G, newPrimaryColor.B);
|
||||
//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;
|
||||
//newButtonStyle.Setters.Add(new Setter(ForegroundProperty, newForegroundColor.HasValue ? new SolidColorBrush(newForegroundColor.Value) : new DynamicResourceExtension("MaterialDesignBackground")));
|
||||
//Application.Current.Resources[typeof(Button)] = newButtonStyle;
|
||||
|
||||
MainPres.AccentForegroundColor = newAccentForegroundColor;
|
||||
//MainPres.AccentForegroundColor = newAccentForegroundColor;
|
||||
|
||||
if (GameFlashInterval > 100)
|
||||
GameFlashInterval += random.Next(1, 4);
|
||||
@ -654,7 +662,7 @@ public partial class MainWin : Window
|
||||
|
||||
MainPres.IsFlashing = false;
|
||||
NginxConfWatcher_Changed(null!, null!);
|
||||
MessageBox.Show(MainConst._GameEndingMsg);
|
||||
await MessageBoxManager.GetMessageBoxStandard(string.Empty, MainConst._GameEndingMsg).ShowAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -672,21 +680,21 @@ public partial class MainWin : Window
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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.IsConginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ConginxPath)).Length != 0;
|
||||
MainPres.IsNginxRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.NginxPath)).Length != 0;
|
||||
MainPres.IsConginxRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ConginxPath) : Path.GetFileName(MainConst.ConginxPath)).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.IsMihomoExist = File.Exists(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, Path.GetFileName(MainConst.MihomoPath)));
|
||||
MainPres.IsComihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.ComihomoPath)).Length != 0;
|
||||
MainPres.IsMihomoRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainConst.MihomoPath)).Length != 0;
|
||||
MainPres.IsComihomoRunning = Process.GetProcessesByName(OperatingSystem.IsWindows() ? Path.GetFileNameWithoutExtension(MainConst.ComihomoPath) : Path.GetFileName(MainConst.ComihomoPath)).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)
|
||||
{
|
||||
@ -921,23 +929,10 @@ public partial class MainWin : Window
|
||||
}
|
||||
private void MainWin_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyboardDevice.Modifiers != ModifierKeys.Control)
|
||||
if (e.KeyModifiers != KeyModifiers.Control)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.W)
|
||||
Application.Current.Shutdown();
|
||||
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();
|
||||
}
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
<Window x:Class="Sheas_Cealer.Wins.SettingsWin"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
<Window x:Class="Sheas_Cealer_Nix.Wins.SettingsWin"
|
||||
x:DataType="preses:SettingsPres"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer.Preses"
|
||||
xmlns:consts="clr-namespace:Sheas_Cealer_Nix.Consts"
|
||||
xmlns:convs="clr-namespace:Sheas_Cealer_Nix.Convs"
|
||||
xmlns:preses="clr-namespace:Sheas_Cealer_Nix.Preses"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" SizeToContent="Height" Width="500"
|
||||
d:DataContext="{d:DesignInstance preses:SettingsPres}"
|
||||
Style="{DynamicResource CommonWindow}"
|
||||
SourceInitialized="SettingsWin_SourceInitialized" KeyDown="SettingsWin_KeyDown">
|
||||
WindowStartupLocation="CenterScreen" CanResize="False" SizeToContent="Height" Width="500"
|
||||
KeyDown="SettingsWin_KeyDown">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
@ -21,21 +20,21 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</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}}"
|
||||
ToolTip="{x:Static consts:SettingsConst.ThemesButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:SettingsConst.ThemesButtonToolTip}"
|
||||
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}}"
|
||||
ToolTip="{x:Static consts:SettingsConst.LangsButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:SettingsConst.LangsButtonToolTip}"
|
||||
Click="LangsButton_Click" />
|
||||
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
||||
Content="{x:Static consts:SettingsConst.ColorsButtonContent}"
|
||||
ToolTip="{x:Static consts:SettingsConst.ColorsButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:SettingsConst.ColorsButtonToolTip}"
|
||||
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}}"
|
||||
ToolTip="{x:Static consts:SettingsConst.WeightsButtonToolTip}"
|
||||
ToolTip.Tip="{x:Static consts:SettingsConst.WeightsButtonToolTip}"
|
||||
Click="WeightsButton_Click" />
|
||||
</Grid>
|
||||
</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