diff --git a/App.axaml b/App.axaml
new file mode 100644
index 0000000..b354f3e
--- /dev/null
+++ b/App.axaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/App.axaml.cs b/App.axaml.cs
new file mode 100644
index 0000000..14cc986
--- /dev/null
+++ b/App.axaml.cs
@@ -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().ToArray();
+
+ // remove each entry found
+ foreach (var plugin in dataValidationPluginsToRemove)
+ BindingPlugins.DataValidators.Remove(plugin);
+ }
+}
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
deleted file mode 100644
index c91ade3..0000000
--- a/App.xaml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/App.xaml.cs b/App.xaml.cs
deleted file mode 100644
index e17ffd9..0000000
--- a/App.xaml.cs
+++ /dev/null
@@ -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;
- }
-}
\ No newline at end of file
diff --git a/Consts/AboutConst.cs b/Consts/AboutConst.cs
index 7a266ab..851fc2f 100644
--- a/Consts/AboutConst.cs
+++ b/Consts/AboutConst.cs
@@ -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";
}
\ No newline at end of file
diff --git a/Consts/AboutMultilangConst.Designer.cs b/Consts/AboutMultilangConst.Designer.cs
index cf482d4..b9fa65f 100644
--- a/Consts/AboutMultilangConst.Designer.cs
+++ b/Consts/AboutMultilangConst.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-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;
diff --git a/Consts/MainConst.cs b/Consts/MainConst.cs
index e08cb25..71526e3 100644
--- a/Consts/MainConst.cs
+++ b/Consts/MainConst.cs
@@ -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();
diff --git a/Consts/MainMultilangConst.Designer.cs b/Consts/MainMultilangConst.Designer.cs
index e91b911..6fe0f7c 100644
--- a/Consts/MainMultilangConst.Designer.cs
+++ b/Consts/MainMultilangConst.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-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;
diff --git a/Consts/SettingsConst.cs b/Consts/SettingsConst.cs
index c88c487..28f4179 100644
--- a/Consts/SettingsConst.cs
+++ b/Consts/SettingsConst.cs
@@ -1,3 +1,3 @@
-namespace Sheas_Cealer.Consts;
+namespace Sheas_Cealer_Nix.Consts;
internal abstract class SettingsConst : SettingsMultilangConst;
\ No newline at end of file
diff --git a/Consts/SettingsMultilangConst.Designer.cs b/Consts/SettingsMultilangConst.Designer.cs
index 1b8d80c..51dd887 100644
--- a/Consts/SettingsMultilangConst.Designer.cs
+++ b/Consts/SettingsMultilangConst.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-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;
diff --git a/Convs/AboutAccentButtonForegroundConv.cs b/Convs/AboutAccentButtonForegroundConv.cs
index 277c84b..bd583ed 100644
--- a/Convs/AboutAccentButtonForegroundConv.cs
+++ b/Convs/AboutAccentButtonForegroundConv.cs
@@ -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();
}
\ No newline at end of file
diff --git a/Convs/AboutConv.cs b/Convs/AboutConv.cs
index 28937f3..aef34af 100644
--- a/Convs/AboutConv.cs
+++ b/Convs/AboutConv.cs
@@ -1,4 +1,4 @@
-namespace Sheas_Cealer.Convs;
+namespace Sheas_Cealer_Nix.Convs;
internal static class AboutConv
{
diff --git a/Convs/AboutVersionButtonContentConv.cs b/Convs/AboutVersionButtonContentConv.cs
index 3cbdc15..1427c3c 100644
--- a/Convs/AboutVersionButtonContentConv.cs
+++ b/Convs/AboutVersionButtonContentConv.cs
@@ -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