diff --git a/Consts/MainConst.cs b/Consts/MainConst.cs
index 83549a5..34c67d6 100644
--- a/Consts/MainConst.cs
+++ b/Consts/MainConst.cs
@@ -12,7 +12,7 @@ namespace Sheas_Cealer.Consts
[GeneratedRegex(@"^\r$")]
internal static partial Regex HostRegex();
- [GeneratedRegex(@"^((((ht|f)tps?):\/\/)?[a-zA-Z0-9](-*[a-zA-Z0-9])*(\.[a-zA-Z0-9](-*[a-zA-Z0-9])*)*(:\d{1,5})?(\/[a-zA-Z0-9.-_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%]*)*)?$")]
+ [GeneratedRegex(@"^((((ht|f)tps?):\/\/)?[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 UrlRegex();
[GeneratedRegex(@"^(--[a-z](-?[a-z])*( --[a-z](-?[a-z])*)*)?$")]
diff --git a/Convs/MainContentBoxTextConv.cs b/Convs/MainContentBoxTextConv.cs
index d21d6ca..c8839eb 100644
--- a/Convs/MainContentBoxTextConv.cs
+++ b/Convs/MainContentBoxTextConv.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Windows.Data;
using Sheas_Cealer.Consts;
@@ -18,9 +19,9 @@ namespace Sheas_Cealer.Convs
if (mode == MainConst.Mode.browserPathMode)
{
- if((bool)!isFocused! && string.IsNullOrEmpty(browserPath))
+ if ((bool)!isFocused! && string.IsNullOrEmpty(browserPath))
return MainConst.BrowserPathPlaceHolder;
- else if((bool)isFocused! && browserPath == MainConst.BrowserPathPlaceHolder)
+ else if ((bool)isFocused! && browserPath == MainConst.BrowserPathPlaceHolder)
return string.Empty;
else
return browserPath!;
@@ -45,7 +46,7 @@ namespace Sheas_Cealer.Convs
}
else
{
- throw new Exception("Invalid mode");
+ throw new UnreachableException();
}
}
diff --git a/Convs/MainStartCealButtonIsEnabledConv.cs b/Convs/MainStartCealButtonIsEnabledConv.cs
new file mode 100644
index 0000000..3dda332
--- /dev/null
+++ b/Convs/MainStartCealButtonIsEnabledConv.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Globalization;
+using System.IO;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs
+{
+ internal class MainStartCealButtonIsEnabledConv : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ string? browserPath = values[0] as string;
+ string? upstreamUrl = values[1] as string;
+ string? extraArgs = values[2] as string;
+
+ if (File.Exists(browserPath) && Path.GetFileName(browserPath).ToLower().EndsWith(".exe") && MainConst.UrlRegex().IsMatch(upstreamUrl!) && MainConst.ArgsRegex().IsMatch(extraArgs!))
+ return true;
+
+ return false;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Wins/AboutWin.xaml.cs b/Wins/AboutWin.xaml.cs
index 3af7ba1..31c9498 100644
--- a/Wins/AboutWin.xaml.cs
+++ b/Wins/AboutWin.xaml.cs
@@ -14,10 +14,10 @@ namespace Sheas_Cealer.Wins
private void AboutButton_Click(object sender, RoutedEventArgs e)
{
- if (sender == VersionButton)
+ if (sender as Button == VersionButton)
MessageBox.Show("密码: 3wnj");
- ProcessStartInfo processStartInfo = new(sender == EmailButton ? "mailto:" : string.Empty + (sender as Button)!.ToolTip) { UseShellExecute = true };
+ ProcessStartInfo processStartInfo = new(sender as Button == EmailButton ? "mailto:" : string.Empty + (sender as Button)!.ToolTip) { UseShellExecute = true };
Process.Start(processStartInfo);
}
diff --git a/Wins/MainWin.xaml b/Wins/MainWin.xaml
index a1a3a8e..4b797ae 100644
--- a/Wins/MainWin.xaml
+++ b/Wins/MainWin.xaml
@@ -29,7 +29,7 @@
-
@@ -37,13 +37,13 @@
-
+
-
+
@@ -51,13 +51,13 @@
-
+
-
+
@@ -65,12 +65,26 @@
Click="BrowseButton_Click" />
-
+
+ Click="StartCealButton_Click">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -78,7 +92,7 @@
-
+
@@ -88,7 +102,7 @@
-
+
\ No newline at end of file
diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs
index 5408a70..1310937 100644
--- a/Wins/MainWin.xaml.cs
+++ b/Wins/MainWin.xaml.cs
@@ -61,18 +61,14 @@ namespace Sheas_Cealer.Wins
{
TextBox? ContentBox = sender as TextBox;
- switch (MainPres!.Mode)
- {
- case MainConst.Mode.browserPathMode:
- MainPres.BrowserPath = ContentBox!.Text;
- return;
- case MainConst.Mode.upstreamUrlMode:
- MainPres.UpstreamUrl = ContentBox!.Text;
- return;
- case MainConst.Mode.extraArgsMode:
- MainPres.ExtraArgs = ContentBox!.Text;
- return;
- };
+ if (MainPres!.Mode == MainConst.Mode.browserPathMode)
+ MainPres.BrowserPath = ContentBox!.Text;
+ else if (MainPres!.Mode == MainConst.Mode.upstreamUrlMode)
+ MainPres.UpstreamUrl = ContentBox!.Text;
+ else if (MainPres!.Mode == MainConst.Mode.extraArgsMode)
+ MainPres.ExtraArgs = ContentBox!.Text;
+ else
+ throw new UnreachableException();
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
@@ -123,7 +119,6 @@ namespace Sheas_Cealer.Wins
private async void UpdateHostButton_Click(object sender, RoutedEventArgs e)
{
string hostUrl = MainPres!.UpstreamUrl;
-
string UpdateHostString = await Http.GetAsync(hostUrl, MainClient);
StreamReader hostLocalStreamReader = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"));
string hostLocalString = hostLocalStreamReader.ReadToEnd();