1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00

调整Trojan参数设置界面

This commit is contained in:
ProxySU 2020-08-21 12:20:14 +08:00
parent c6f927f4a5
commit e7afe102b3
7 changed files with 149 additions and 268 deletions

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d"
Title="ProxySU" Height="600" Width="530">
Title="ProxySU - v1.8.4" Height="600" Width="530">
<!--以下样式参考自https://yq.aliyun.com/articles/331878
https://docs.microsoft.com/en-us/dotnet/desktop-wpf/fundamentals/styles-templates-overview-->
<Window.Resources>
@ -117,9 +117,9 @@
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Button x:Name="ButtonUpdateV2ray" Content="检测/升级V2Ray版本" Grid.Column="0" Grid.Row="0" Margin="5" Click="ButtonUpdateV2ray_Click"></Button>
<!--<Button x:Name="ButtonGuideConfiguration" Visibility="Visible" Content="启用向导" Grid.Column="0" Grid.Row="0" Click="ButtonGuideConfiguration_Click"></Button>
<TextBlock Text="通过向导生成配置文件" Visibility="Visible" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTemplateConfiguration" Content="V2ray模板库" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTemplateConfiguration_Click"></Button>
@ -131,8 +131,33 @@
<RadioButton x:Name="RadioButtonAdvancedConfiguration" Content="高级配置" Grid.Column="0" Grid.Row="2"></RadioButton>
<TextBox x:Name="TextBoxJsonPath" Margin="10" Grid.Column="1" Grid.Row="1"></TextBox>
<Button x:Name="ButtonSetConfiguration" Margin="6" Content="配置" Grid.Column="2" Grid.Row="2" Click="ButtonSetConfiguration_Click"></Button>-->
<Button x:Name="Button_Login" Content="V2ray一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="Button_Login_Click"></Button>
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
<Button x:Name="Button_Login" Content="V2ray一键安装" Margin="10" Grid.Column="0" Grid.Row="2" Click="Button_Login_Click"></Button>
<Button x:Name="ButtonUpdateV2ray" Content="检测/升级V2Ray" Margin="10" Grid.Column="1" Grid.Row="2" Click="ButtonUpdateV2ray_Click"></Button>
<Button x:Name="Button_canel" Content="取消" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="Trojan-Go" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<!--<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>-->
<!--<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>
<Button x:Name="ButtonTrojanGoSetUp" Content="Trojan-Go一键安装" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanGoSetUp_Click"/>
<Button x:Name="ButtonUpdateTrojanGo" Content="检测/升级Trojan-Go" Margin="10" Grid.Column="1" Grid.Row="2" Click="ButtonUpdateTrojanGo_Click"></Button>
<Button x:Name="ButtonTrojanGoCancel" Content="取消" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="Trojan" Width="100" Height="30">
@ -146,18 +171,49 @@
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Button x:Name="ButtonUpdateTrojan" Content="检测/升级Trojan版本" Grid.Column="0" Grid.Row="0" Margin="5" Click="ButtonUpdateTrojan_Click"></Button>
<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>
<GroupBox Header="参数设置" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="模式Trojan+TLS+Caddy" Grid.Column="1" Grid.Row="0"></TextBlock>
<TextBlock Text="服务器地址(域名)" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxTrojanHostDomain" Style="{StaticResource TitleText}" Tag="域名不可为空" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<TextBlock Text="端口443" Grid.Column="2" Grid.Row="1"></TextBlock>
<!--<TextBlock Text="用户名:" Grid.Column="0" Grid.Row="2"></TextBlock>
<TextBox x:Name="TextBoxUser" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
<Button x:Name="ButtonNaiveUser" Content="随机" Grid.Column="2" Grid.Row="2" Margin="2" Click="ButtonNaiveUser_Click"></Button>-->
<TextBlock Text="密码:" Grid.Column="0" Grid.Row="2"></TextBlock>
<TextBox x:Name="TextBoxTrojanPassword" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
<Button x:Name="ButtonTrojanPassword" Content="更新" Grid.Column="2" Grid.Row="2" Margin="2" Click="ButtonTrojanPassword_Click" ></Button>
<TextBlock Text="伪装网站:" Grid.Column="0" Grid.Row="3" Visibility="Collapsed"></TextBlock>
<TextBox x:Name="TextBoxTrojanSites" Style="{StaticResource TitleText}" Tag="可以增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="3" Margin="3" Visibility="Collapsed"></TextBox>
</Grid>
</GroupBox>
<!--<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>-->
<!--<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<!--<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="2" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>-->
<Button x:Name="ButtonTrojanSetUp" Content="Trojan一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanSetUp_Click"/>
<Button x:Name="ButtonTrojanCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
<Button x:Name="ButtonTrojanSetUp" Content="Trojan一键安装" Grid.Column="0" Grid.Row="2" Margin="10" Click="ButtonTrojanSetUp_Click"/>
<Button x:Name="ButtonUpdateTrojan" Content="检测/升级Trojan" Grid.Column="1" Grid.Row="2" Margin="10" Click="ButtonUpdateTrojan_Click"></Button>
<Button x:Name="ButtonTrojanCancel" Content="取消" Grid.Column="2" Grid.Row="2" Margin="10" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem x:Name="TabItemNaiveProxy" Header="NaiveProxy" Width="100" Height="30">
@ -170,7 +226,7 @@
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="参数设置" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="2">
<Grid>
@ -278,29 +334,7 @@
<Button x:Name="Button_canel3in1" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="Trojan-Go" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Button x:Name="ButtonUpdateTrojanGo" Content="检测/升级Trojan-Go版本" Grid.Column="0" Grid.Row="0" Margin="5" Click="ButtonUpdateTrojanGo_Click"></Button>
<!--<Button x:Name="ButtonTrojanTemplate" Content="Trojan参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanTemplate_Click"/>-->
<!--<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTrojanGoTemplate" Content="Trojan-Go参数设置" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonTrojanGoTemplate_Click"/>
<Button x:Name="ButtonTrojanGoSetUp" Content="Trojan-Go一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanGoSetUp_Click"/>
<Button x:Name="ButtonTrojanGoCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="系统工具" Width="100" Height="30">
<Grid>
<Grid.ColumnDefinitions>
@ -381,7 +415,7 @@
<WebBrowser x:Name="WebBrowserResourcesAndTools" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="9" Grid.RowSpan="13" Source="https://github.com/proxysu/windows/wiki/ResourcesAndTools" />
</Grid>
</TabItem>
<TabItem Header="关于" Width="110" Height="30">
<TabItem Header="关于" Width="110" Height="30" Visibility="Collapsed">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"></ColumnDefinition>

View File

@ -64,6 +64,9 @@ namespace ProxySU
//初始化参数给
ReceiveConfigurationParameters = new string[8];
//初始化Trojan的密码
TextBoxTrojanPassword.Text = RandomUUID();
//初始化NaiveProxy的用户名和密码
TextBoxNaivePassword.Text = RandomUUID();
TextBoxNaiveUser.Text = RandomUserName();
@ -578,8 +581,8 @@ namespace ProxySU
}
else
{
currentShellCommandResult = "检测结果未安装V2Ray";
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
currentStatus = "检测结果未安装V2Ray";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
currentShellCommandResult = currentStatus;
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
@ -2346,16 +2349,16 @@ namespace ProxySU
#region Trojan相关
//打开Trojan参数设置界面
private void ButtonTrojanTemplate_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
//private void ButtonTrojanTemplate_Click(object sender, RoutedEventArgs e)
//{
// for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
{
ReceiveConfigurationParameters[i] = "";
}
TrojanTemplateWindow windowTrojanTemplateConfiguration = new TrojanTemplateWindow();
windowTrojanTemplateConfiguration.ShowDialog();
}
// {
// ReceiveConfigurationParameters[i] = "";
// }
// TrojanTemplateWindow windowTrojanTemplateConfiguration = new TrojanTemplateWindow();
// windowTrojanTemplateConfiguration.ShowDialog();
//}
//Trojan参数传递
private void ButtonTrojanSetUp_Click(object sender, RoutedEventArgs e)
@ -2366,23 +2369,61 @@ namespace ProxySU
MessageBox.Show("远程主机连接信息有误,请检查");
return;
}
string serverConfig = ""; //服务端配置文件
string clientConfig = ""; //生成的客户端配置文件
string upLoadPath = "/usr/local/etc/trojan/config.json"; //服务端文件位置
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
//清空参数空间
for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
{
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
ReceiveConfigurationParameters[i] = "";
}
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true)
if (string.IsNullOrEmpty(TextBoxTrojanHostDomain.Text.ToString()) == true)
{
MessageBox.Show("请先选择配置模板");
MessageBox.Show("域名不能为空");
return;
}
else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanTLS2Web"))
//传递模板类型
ReceiveConfigurationParameters[0] = "TrojanTLS2Web";
//传递域名
ReceiveConfigurationParameters[4] = TextBoxTrojanHostDomain.Text.ToString();
//传递伪装网站
ReceiveConfigurationParameters[7] = TextBoxTrojanSites.Text.ToString();
//处理伪装网站域名中的前缀
if (TextBoxTrojanSites.Text.ToString().Length >= 7)
{
serverConfig = "TemplateConfg\\trojan_server_config.json";
clientConfig = "TemplateConfg\\trojan_client_config.json";
string testDomain = TextBoxTrojanSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
ReceiveConfigurationParameters[7] = TextBoxTrojanSites.Text.Replace("/", "\\/");
}
else
{
ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxTrojanSites.Text;
}
}
//传递服务端口
ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
ReceiveConfigurationParameters[2] = TextBoxTrojanPassword.Text.ToString();
string serverConfig = "TemplateConfg\\trojan_server_config.json"; //服务端配置文件
string clientConfig = "TemplateConfg\\trojan_client_config.json"; //生成的客户端配置文件
string upLoadPath = "/usr/local/etc/trojan/config.json"; //服务端文件位置
//if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
//{
// ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
//}
//if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true)
//{
// MessageBox.Show("请先选择配置模板!");
// return;
//}
//else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanTLS2Web"))
//{
// serverConfig = "TemplateConfg\\trojan_server_config.json";
// clientConfig = "TemplateConfg\\trojan_client_config.json";
//}
Thread thread = new Thread(() => StartSetUpTrojan(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
@ -2392,7 +2433,7 @@ namespace ProxySU
private void StartSetUpTrojan(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar, string serverConfig, string clientConfig, string upLoadPath)
{
string currentStatus = "正在登录远程主机......";
Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
//Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
currentShellCommandResult = currentStatus;
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
@ -2511,8 +2552,8 @@ namespace ProxySU
}
else
{
currentShellCommandResult = "检测结果未安装Trojan";
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
currentStatus = "检测结果未安装Trojan";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);//显示命令执行的结果
currentShellCommandResult = currentStatus;
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
@ -3970,6 +4011,12 @@ namespace ProxySU
#endregion
}
//更新Trojan的密码
private void ButtonTrojanPassword_Click(object sender, RoutedEventArgs e)
{
TextBoxTrojanPassword.Text = RandomUUID();
}
#endregion
#region Trojan-go相关
@ -4132,8 +4179,8 @@ namespace ProxySU
}
else
{
currentShellCommandResult = "检测结果未安装Trojan-go";
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
currentStatus = "检测结果未安装Trojan-go";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);//显示命令执行的结果
currentShellCommandResult = currentStatus;
TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果
@ -6574,8 +6621,7 @@ namespace ProxySU
//更新NaiveProxy的密码
private void ButtonNaivePassword_Click(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNaivePassword.Text = uuid.ToString();
TextBoxNaivePassword.Text = RandomUUID();
}
//生成随机UUID
@ -8036,9 +8082,9 @@ namespace ProxySU
#endregion
}
#endregion
#endregion
}
}

View File

@ -51,5 +51,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.3.0")]
[assembly: AssemblyFileVersion("1.8.3.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]

View File

@ -102,9 +102,6 @@
<Compile Include="TrojanResultClientInfoWindow.xaml.cs">
<DependentUpon>TrojanResultClientInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TrojanTemplateWindow.xaml.cs">
<DependentUpon>TrojanTemplateWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -145,10 +142,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TrojanTemplateWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

View File

@ -1,105 +0,0 @@
<Window x:Class="ProxySU.TrojanTemplateWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d"
Title="TrojanTemplateWindow" Height="400" Width="600">
<Window.Resources>
<Style BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="TextBox"
x:Key="TitleText">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Text" Value=""/>
<Condition Property="TextBox.IsFocused" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="1" BorderBrush="Gray" Margin="0">
<TextBlock x:Name="MainTextBlock" Text="{TemplateBinding TextBox.Tag}" Width="{TemplateBinding TextBox.ActualWidth}" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</MultiTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.7*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="模板库" Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonTrojanTLS2Web" Content="Trojan+TLS+Web" Grid.Column="0" Grid.Row="1" Checked="RadioButtonTrojanTLS2Web_Checked"></RadioButton>
<TextBlock Text="说明" Grid.Column="1" Grid.Row="1"></TextBlock>
</Grid>
</GroupBox>
<GroupBox Header="其他设置" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="TextBlockDomain" Text="域名:" Grid.Column="0" Grid.Row="0" ></TextBlock>
<TextBox x:Name="TextBoxDomain" Style="{StaticResource TitleText}" Tag="不可为空" Grid.Column="1" Grid.Row="0" Margin="3"></TextBox>
<TextBlock Text="端口443" Grid.Column="2" Grid.Row="0" Margin="5"></TextBlock>
<!--<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="2" Grid.Row="0" Margin="2" Click="ButtonDomain_Click"></Button>-->
<!--<TextBlock x:Name="TextBlockServerListenPort" Text="服务端口:" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxServerListenPort" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<Button x:Name="ButtonServerListenPort" Content="随机选择" Grid.Column="2" Grid.Row="1" Margin="2" Click="ButtonServerListenPort_Click"></Button>-->
<TextBlock x:Name="TextBlockNewUUID" Text="密码:" Grid.Column="0" Grid.Row="1" ></TextBlock>
<TextBox x:Name="TextBoxNewUUID" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<Button x:Name="ButtonNewUUID" Content="更新" Grid.Column="2" Grid.Row="1" Margin="3" Click="ButtonNewUUID_Click"></Button>
<TextBlock Text="使用已有密码,直接粘贴到框中" TextWrapping="Wrap" Grid.Column="3" Grid.Row="1"></TextBlock>
<TextBlock x:Name="TextBlockMaskSites" Text="伪装网站:" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Visibility="Hidden"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="设置此项可增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="3" Margin="3" Visibility="Hidden"></TextBox>
<Grid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="ButtondDecide" Content="确定" Grid.Column="1" Grid.Row="6" Margin="3" Click="ButtondDecide_Click"></Button>
<Button x:Name="ButtondCancel" Content="取消" Grid.Column="3" Grid.Row="6" Margin="3" Click="ButtondCancel_Click"></Button>
</Grid>
</Grid>
</GroupBox>
</Grid>
</Grid>
</Window>

View File

@ -1,87 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ProxySU
{
/// <summary>
/// TrojanTemplateWindow.xaml 的交互逻辑
/// </summary>
public partial class TrojanTemplateWindow : Window
{
public TrojanTemplateWindow()
{
InitializeComponent();
RadioButtonTrojanTLS2Web.IsChecked = true;
}
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
{
if (RadioButtonTrojanTLS2Web.IsChecked == true)
{
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
{
MessageBox.Show("域名不能为空!");
return;
}
//传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "TrojanTLS2Web";
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
if (TextBoxMaskSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxMaskSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
}
else
{
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
}
}
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
}
this.Close();
}
private void ButtonNewUUID_Click(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
}
//private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e)
//{
// Random random = new Random();
// int randomServerPort = random.Next(10000, 50000);
// TextBoxServerListenPort.Text = randomServerPort.ToString();
//}
private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close();
private void RadioButtonTrojanTLS2Web_Checked(object sender, RoutedEventArgs e)
{
Guid uuid = Guid.NewGuid();
TextBoxNewUUID.Text = uuid.ToString();
//Random random = new Random();
//int randomServerPort = random.Next(10000, 50000);
//TextBoxServerListenPort.Text = "443";
}
}
}

Binary file not shown.