diff --git a/App.xaml.cs b/App.xaml.cs index b173afa..2139015 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -4,9 +4,6 @@ namespace Sheas_Cealer { public partial class App : Application { - protected override void OnStartup(StartupEventArgs e) - { - new MainWindow(e.Args).Show(); - } + protected override void OnStartup(StartupEventArgs e) => new MainWindow(e.Args).Show(); } } \ No newline at end of file diff --git a/Cealing-Clash.exe b/Cealing-Clash.exe index 1aa8488..7dea730 100644 Binary files a/Cealing-Clash.exe and b/Cealing-Clash.exe differ diff --git a/Cealing-Host.json b/Cealing-Host.json index 6ea8cc2..7528b96 100644 --- a/Cealing-Host.json +++ b/Cealing-Host.json @@ -11,5 +11,6 @@ [["*instagram.com"],"ins","157.240.236.174"], [["*amazon.co.jp"],"ama","52.222.208.138"], [["*github.com"],"git","140.82.121.3"], - [["*mikuclub.cc"],"mik","43.224.152.124"] + [["*mikuclub.cc"],"mik","45.152.67.140"], + [["*twitch.tv"],"twi","199.232.138.167"] ] \ No newline at end of file diff --git a/Commons/Cmd.cs b/Commons/Cmd.cs index 3cf9542..9039b88 100644 --- a/Commons/Cmd.cs +++ b/Commons/Cmd.cs @@ -16,9 +16,6 @@ namespace Sheas_Cealer public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) { } - public override void Process_Exited(object sender, EventArgs e) - { - Environment.Exit(0); - } + public override void Process_Exited(object sender, EventArgs e) => Environment.Exit(0); } } \ No newline at end of file diff --git a/Commons/IconRemover.cs b/Commons/IconRemover.cs index 3242818..fbb4ef1 100644 --- a/Commons/IconRemover.cs +++ b/Commons/IconRemover.cs @@ -45,16 +45,10 @@ namespace Sheas_Cealer //使用IconRemover public partial class MainWindow { - protected override void OnSourceInitialized(EventArgs e) - { - IconRemover.RemoveIcon(this); - } + protected override void OnSourceInitialized(EventArgs e) => IconRemover.RemoveIcon(this); } public partial class AboutWindow { - protected override void OnSourceInitialized(EventArgs e) - { - IconRemover.RemoveIcon(this); - } + protected override void OnSourceInitialized(EventArgs e) => IconRemover.RemoveIcon(this); } } \ No newline at end of file diff --git a/Sheas-Cealer.csproj b/Sheas-Cealer.csproj index a064917..715a2d7 100644 --- a/Sheas-Cealer.csproj +++ b/Sheas-Cealer.csproj @@ -8,10 +8,10 @@ Just Ceal It Space Time Space Time - 1.0.1 - 1.0.1 - 1.0.1 - 1.0.1 + 1.0.2 + 1.0.2 + 1.0.2 + 1.0.2 Tool;Sheas;Cealer;Sni Sheas-Cealer-Logo.ico Sheas Cealer Logo.png diff --git a/Windows/AboutWindow.xaml.cs b/Windows/AboutWindow.xaml.cs index e765c39..f81e976 100644 --- a/Windows/AboutWindow.xaml.cs +++ b/Windows/AboutWindow.xaml.cs @@ -13,10 +13,7 @@ namespace Sheas_Cealer { InitializeComponent(); } - private void AboutWin_Loaded(object sender, RoutedEventArgs e) - { - UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2]; - } + private void AboutWin_Loaded(object sender, RoutedEventArgs e) => UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2]; private void AboutButton_Click(object sender, RoutedEventArgs e) { diff --git a/Windows/MainWindow.xaml.cs b/Windows/MainWindow.xaml.cs index 96d607d..7b7749e 100644 --- a/Windows/MainWindow.xaml.cs +++ b/Windows/MainWindow.xaml.cs @@ -16,6 +16,7 @@ namespace Sheas_Cealer public partial class MainWindow : Window { private static string? CEALING_ARGUMENT; + private static readonly FileSystemWatcher CEALING_HOST_WATCHER = new(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json") { EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite }; private static readonly DispatcherTimer MONITOR_TIMER = new() { Interval = new TimeSpan(1000000) }; //0.1s internal MainWindow(string[] args) @@ -34,28 +35,14 @@ namespace Sheas_Cealer else if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath)) Dispatcher.Invoke(() => ShowBox.Text = Properties.Settings.Default.BrowserPath); - string hostRules = string.Empty, hostResolverRules = string.Empty; - FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); - JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd()); - foreach (var hostJToken in hostJArray) - { - hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ","; - foreach (var hostName in hostJToken[0]!) - hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ","; - } - CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors"; + CEALING_HOST_WATCHER.Changed += CEALING_HOST_WATCHER_Changed; + CEALING_HOST_WATCHER_Changed(null!, null!); }); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } - private void MainWin_Loaded(object sender, RoutedEventArgs e) - { - ShowBox.Focus(); - } - private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - Environment.Exit(0); - } + private void MainWin_Loaded(object sender, RoutedEventArgs e) => ShowBox.Focus(); + private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e) => Environment.Exit(0); private void ShowBox_GotFocus(object sender, RoutedEventArgs e) { @@ -185,10 +172,7 @@ namespace Sheas_Cealer } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; } } - private void AboutButton_Click(object sender, RoutedEventArgs e) - { - new AboutWindow().ShowDialog(); - } + private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWindow().ShowDialog(); private void MONITOR_TIMER_Tick(object? sender, EventArgs e) { @@ -198,6 +182,26 @@ namespace Sheas_Cealer ClashButton.Content = "停代"; } + private void CEALING_HOST_WATCHER_Changed(object sender, FileSystemEventArgs e) + { + try + { + string hostRules = string.Empty, hostResolverRules = string.Empty; + FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); + JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd()); + + foreach (var hostJToken in hostJArray) + { + hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ","; + foreach (var hostName in hostJToken[0]!) + hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ","; + } + + CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors"; + } + catch { return; } + } + private void MainWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W)