Skip to content

Commit

Permalink
1.0.4 (beta) 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed May 19, 2022
1 parent 6c10f37 commit 76804a3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
9 changes: 5 additions & 4 deletions Sheas-Cealer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<PackageReleaseNotes>Just Ceal It</PackageReleaseNotes>
<Authors>Space Time</Authors>
<Company>Space Time</Company>
<AssemblyVersion>1.0.3</AssemblyVersion>
<Version>1.0.3</Version>
<FileVersion>1.0.3</FileVersion>
<InformationalVersion>1.0.3</InformationalVersion>
<AssemblyVersion>1.0.4</AssemblyVersion>
<Version>1.0.4</Version>
<FileVersion>1.0.4</FileVersion>
<InformationalVersion>1.0.4</InformationalVersion>
<PackageTags>Tool;Sheas;Cealer;Sni</PackageTags>
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
Expand Down Expand Up @@ -74,6 +74,7 @@
<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 13 additions & 5 deletions Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Grid Grid.Row="0" Margin="5">
Expand All @@ -21,17 +22,24 @@
<Button x:Name="ViewButton" Grid.Column="2" Content="浏览" Click="ViewButton_Click" />
</Grid>

<Grid Grid.Row="1" Margin="5">
<Grid Grid.Row="1" Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="ClashButton" Content="启动代理" Grid.Column="0" Margin="5,0,5,0" Click="ClashButton_Click" />
<Button x:Name="OpenButton" Content="启动伪造" Grid.Column="1" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
</Grid>

<Grid Grid.Row="2" Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="EditButton" Content="编辑" Grid.Column="0" Margin="0,0,5,0" Click="EditButton_Click" />
<Button x:Name="ClashButton" Content="代理" Grid.Column="1" Margin="5,0,5,0" Click="ClashButton_Click" />
<Button x:Name="OpenButton" Content="启动" Grid.Column="2" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
<Button x:Name="AboutButton" Content="关于" Grid.Column="3" Margin="5,0,0,0" Click="AboutButton_Click" />
<Button x:Name="ConfigButton" Content="代理规则" Grid.Column="0" Margin="5,0,5,0" Click="ConfigButton_Click" />
<Button x:Name="HostButton" Content="伪造规则" Grid.Column="1" Margin="5,0,5,0" Click="HostButton_Click" />
<Button x:Name="AboutButton" Content="关于项目" Grid.Column="2" Margin="5,0,5,0" Click="AboutButton_Click" />
</Grid>
</Grid>
</Window>
41 changes: 28 additions & 13 deletions Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using IWshRuntimeLibrary;
using Microsoft.Win32;
using Newtonsoft.Json.Linq;
using YamlDotNet.RepresentationModel;
using File = System.IO.File;

namespace Sheas_Cealer
Expand Down Expand Up @@ -119,24 +120,19 @@ private void ViewButton_Click(object sender, RoutedEventArgs e)
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}

private void EditButton_Click(object sender, RoutedEventArgs e)
{
try
{
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json")) { UseShellExecute = true };
Process.Start(processStartInfo);
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void ClashButton_Click(object sender, RoutedEventArgs e)
{
try
{
RegistryKey proxyKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!;
if (ClashButton.Content.ToString() == "代理")
if (ClashButton.Content.ToString() == "启动代理")
{
YamlStream configStream = new();
configStream.Load(File.OpenText(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"config.yaml")));
YamlMappingNode configMap = (YamlMappingNode)configStream.Documents[0].RootNode;

proxyKey.SetValue("ProxyEnable", 1);
proxyKey.SetValue("ProxyServer", "127.0.0.1:7880");
proxyKey.SetValue("ProxyServer", "127.0.0.1:" + configMap["mixed-port"]);

new Clash().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "-d .");
}
Expand Down Expand Up @@ -172,14 +168,33 @@ private void OpenButton_Click(object sender, RoutedEventArgs e)
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}

private void ConfigButton_Click(object sender, RoutedEventArgs e)
{
try
{
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"config.yaml")) { UseShellExecute = true };
Process.Start(processStartInfo);
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void HostButton_Click(object sender, RoutedEventArgs e)
{
try
{
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json")) { UseShellExecute = true };
Process.Start(processStartInfo);
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWindow().ShowDialog();

private void MONITOR_TIMER_Tick(object? sender, EventArgs e)
{
if (Process.GetProcessesByName("Cealing-Clash").Length == 0)
ClashButton.Content = "代理";
ClashButton.Content = "启动代理";
else
ClashButton.Content = "停代";
ClashButton.Content = "停止代理";
}

private void CEALING_HOST_WATCHER_Changed(object sender, FileSystemEventArgs e)
Expand Down

0 comments on commit 76804a3

Please sign in to comment.