mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-09-14 13:56:56 +08:00
1.1.0 -> 1.1.1 第3次更新
This commit is contained in:
parent
a834b7589e
commit
987a97802b
@ -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])*)*)?$")]
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
28
Convs/MainStartCealButtonIsEnabledConv.cs
Normal file
28
Convs/MainStartCealButtonIsEnabledConv.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox utils:FocusExtension.IsFocused="{Binding IsContentBoxFocused}"
|
||||
<TextBox x:Name="ContentText" utils:FocusExtension.IsFocused="{Binding IsContentBoxFocused}"
|
||||
Grid.Column="0" Margin="5" VerticalContentAlignment="Center"
|
||||
TextChanged="ContentBox_TextChanged" PreviewDragOver="MainWin_DragEnter">
|
||||
<TextBox.Text>
|
||||
@ -37,13 +37,13 @@
|
||||
<MultiBinding.Converter>
|
||||
<convs:MainContentBoxTextConv />
|
||||
</MultiBinding.Converter>
|
||||
|
||||
|
||||
<Binding Path="Mode" />
|
||||
<Binding Path="IsFocused" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="BrowserPath" />
|
||||
<Binding Path="UpstreamUrl" />
|
||||
<Binding Path="ExtraArgs" />
|
||||
|
||||
|
||||
</MultiBinding>
|
||||
</TextBox.Text>
|
||||
<TextBox.Foreground>
|
||||
@ -51,13 +51,13 @@
|
||||
<MultiBinding.Converter>
|
||||
<convs:MainContentBoxForegroundConv />
|
||||
</MultiBinding.Converter>
|
||||
|
||||
|
||||
<Binding Path="Mode" />
|
||||
<Binding Path="IsFocused" RelativeSource="{RelativeSource Self}" />
|
||||
<Binding Path="BrowserPath" />
|
||||
<Binding Path="UpstreamUrl" />
|
||||
<Binding Path="ExtraArgs" />
|
||||
|
||||
|
||||
</MultiBinding>
|
||||
</TextBox.Foreground>
|
||||
</TextBox>
|
||||
@ -65,12 +65,26 @@
|
||||
Click="BrowseButton_Click" />
|
||||
<Button Grid.Column="2" Margin="5" Content="{Binding SwitchModeButtonContent, Source={StaticResource MainConst}}"
|
||||
Click="SwitchModeButton_Click" />
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<Button IsDefault="True"
|
||||
Grid.Row="1" Margin="5" Content="{Binding StartCealButtonContent, Source={StaticResource MainConst}}"
|
||||
Click="StartCealButton_Click" />
|
||||
Click="StartCealButton_Click">
|
||||
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding>
|
||||
<MultiBinding.Converter>
|
||||
<convs:MainStartCealButtonIsEnabledConv />
|
||||
</MultiBinding.Converter>
|
||||
|
||||
<Binding Path="BrowserPath" />
|
||||
<Binding Path="UpstreamUrl" />
|
||||
<Binding Path="ExtraArgs" />
|
||||
|
||||
</MultiBinding>
|
||||
</Button.IsEnabled>
|
||||
</Button>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -78,7 +92,7 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<Button x:Name="EditHostButton"
|
||||
Grid.Column="0" Margin="5" Content="{Binding EditHostButtonContent, Source={StaticResource MainConst}}"
|
||||
Click="EditHostButton_Click" />
|
||||
@ -88,7 +102,7 @@
|
||||
<Button x:Name="AboutButton"
|
||||
Grid.Column="2" Margin="5" Content="{Binding AboutButtonContent, Source={StaticResource MainConst}}"
|
||||
Click="AboutButton_Click" />
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
@ -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<string>(hostUrl, MainClient);
|
||||
StreamReader hostLocalStreamReader = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"));
|
||||
string hostLocalString = hostLocalStreamReader.ReadToEnd();
|
||||
|
Loading…
Reference in New Issue
Block a user