Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Add FrpcLaunchMode
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatHuang2007 committed Feb 2, 2022
1 parent 3120a03 commit a7cc426
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 59 deletions.
2 changes: 0 additions & 2 deletions github/RunOnAndroid.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[Readme](https://github.com/OldGodShen/OGFrp/blob/master/README.md#ogfrp)

# 有关在Android上使用OGFrp

## I.引言
Expand Down
2 changes: 0 additions & 2 deletions github/UseLinux.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[Readme](https://github.com/OldGodShen/OGFrp/blob/master/README.md#ogfrp)

# OGFrp.Linux使用帮助

## I.安装
Expand Down
2 changes: 0 additions & 2 deletions github/UseLite.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[Readme](https://github.com/OldGodShen/OGFrp/blob/master/README.md#ogfrp)

# OGFrp.Lite使用帮助

## I.安装
Expand Down
2 changes: 2 additions & 0 deletions src/OGFrp.Main/Application.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ShutdownMode="OnMainWindowClose">
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="BorderBrush" Value="#c1d0dc"/>
</Style>
<!--
<Style TargetType="Button">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#FF007BFF"/>
Expand All @@ -33,6 +34,7 @@ ShutdownMode="OnMainWindowClose">
</Setter.Value>
</Setter>
</Style>
-->
<Style x:Key="window_Border" TargetType="{x:Type Window}">
<Setter Property="Template">
<Setter.Value>
Expand Down
3 changes: 2 additions & 1 deletion src/OGFrp.Main/FrpcPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<ScrollViewer>
<Grid x:Name="Grid" VerticalAlignment="Top" Height="0"/>
<Grid x:Name="Grid" VerticalAlignment="Top">
</Grid>
</ScrollViewer>
</UserControl>
3 changes: 3 additions & 0 deletions src/OGFrp.Main/FrpcPanel.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Public Class FrpcPanel

Dim Assets As AssetModel

Dim ServerSelectionWindow As New ServerSelectionWindow

Public Sub _init_(ByVal token As String, ByVal Assets As AssetModel)
Me.Grid.Height = 0
Me.Assets = Assets
fctn = New FrpcCollections(token)
fctn.getFrpcConfigCollection()
Expand Down
26 changes: 26 additions & 0 deletions src/OGFrp.Main/LoginBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,30 @@
</Style>
</Grid.Resources>
</Grid>
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#FF007BFF"/>
<Setter Property="BorderThickness" Value="1.5"/>
<Setter Property="BorderBrush" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="8,8,8,8">
<TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#FF1585FF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Background" Value="#FF0070EA"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
</UserControl>
16 changes: 10 additions & 6 deletions src/OGFrp.Main/MainPanel.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Public Class MainPanel
Public Property UserImage As New System.Drawing.Bitmap(My.Resources.UserHead)

Public Assets As AssetModel
Public Config As Config

Dim SelectedBg As Brush

Expand Down Expand Up @@ -119,12 +120,15 @@ Public Class MainPanel
End Sub

Private Sub bt_frpc_Click(sender As Object, e As RoutedEventArgs) Handles bt_frpc.Click
'Dim nw As New ServerSelectionWindow
'nw.Assets = Me.Assets
'nw._init_(Me.UserToken)
'nw.ShowDialog()
selectBtn(bt_frpc)
EnablePage(ctm_FrpcPanel)
If Config.FrpcLaunchMode.Val = "node" Then
Dim nw As New ServerSelectionWindow
nw.Assets = Me.Assets
nw._init_(Me.UserToken)
nw.ShowDialog()
Else
selectBtn(bt_frpc)
EnablePage(ctm_FrpcPanel)
End If
End Sub

Private Sub bt_Settings_Click(sender As Object, e As RoutedEventArgs) Handles bt_Settings.Click
Expand Down
3 changes: 2 additions & 1 deletion src/OGFrp.Main/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Class MainWindow
Me.MainPanel.Username = Me.LoginBox.Username
Me.MainPanel.Nickname = Me.LoginBox.Username
Me.MainPanel.UserToken = Me.LoginBox.UserToken
Me.txtTitle.Text = "OGFrp Beta"
Me.MainPanel.Config = Me.Config
Me.MainPanel._init_()
Me.txtTitle.Text = "OGFrp"
End Sub
End Class
4 changes: 2 additions & 2 deletions src/OGFrp.Main/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ Imports System.Windows
'通过使用 "*",如下所示:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("2.0.0.0")>
<Assembly: AssemblyFileVersion("2.0.2022.0202")>
7 changes: 7 additions & 0 deletions src/OGFrp.Main/OGFrp.Main.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
<Compile Include="MainPanel.xaml.vb">
<DependentUpon>MainPanel.xaml</DependentUpon>
</Compile>
<Compile Include="SettingsItems\FrpcLaunchMode.xaml.vb">
<DependentUpon>FrpcLaunchMode.xaml</DependentUpon>
</Compile>
<Compile Include="SettingsItems\LanguageConfig.xaml.vb">
<DependentUpon>LanguageConfig.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -167,6 +170,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="SettingsItems\FrpcLaunchMode.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SettingsItems\LanguageConfig.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
20 changes: 20 additions & 0 deletions src/OGFrp.Main/SettingsItems/FrpcLaunchMode.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<UserControl x:Class="FrpcLaunchMode"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OGFrp.Main"
mc:Ignorable="d">
<Grid>
<TextBlock x:Name="lb_flm" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Frpc Launch Mode" VerticalAlignment="Top" Foreground="Black" FontSize="24"/>
<ComboBox x:Name="cb_val" Margin="0,10,10,0" HorizontalAlignment="Right" Width="350" VerticalAlignment="Top"/>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20"/>
</Style>
<Style TargetType="ComboBox">
<Setter Property="FontSize" Value="20"/>
</Style>
</Grid.Resources>
</Grid>
</UserControl>
27 changes: 27 additions & 0 deletions src/OGFrp.Main/SettingsItems/FrpcLaunchMode.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Public Class FrpcLaunchMode

Public Assets As UI.AssetModel
Public Config As UI.Config

Public Sub _init_()
Me.lb_flm.Text = Assets.FrpcLaunchMode
Me.cb_val.Items.Add(Assets.ByProxy)
Me.cb_val.Items.Add(Assets.ByNode)
If Config.FrpcLaunchMode.Val = "node" Then
Me.cb_val.Text = Assets.ByNode
Else
Config.FrpcLaunchMode.Val = "prroxy"
Me.cb_val.Text = Assets.ByProxy
End If
End Sub

Private Sub cb_val_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles cb_val.SelectionChanged
Select Case Me.cb_val.SelectedItem
Case Assets.ByProxy
Config.FrpcLaunchMode.Val = "prroxy"
Case Assets.ByNode
Config.FrpcLaunchMode.Val = "node"
End Select
Config.WriteConfig()
End Sub
End Class
1 change: 1 addition & 0 deletions src/OGFrp.Main/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</Grid.ColumnDefinitions>
<TextBlock x:Name="lb_title" TextWrapping="Wrap" Text="Settings" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="28" Grid.Column="1" Grid.Row="1"/>
<local:LanguageConfig x:Name="ctm_lang" Grid.Column="1" HorizontalAlignment="Stretch" Margin="0,36,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<local:FrpcLaunchMode x:Name="ctm_flm" Grid.Column="1" Margin="0,77,0,0" Grid.Row="1" VerticalAlignment="Top"/>
</Grid>
</ScrollViewer>
</UserControl>
3 changes: 3 additions & 0 deletions src/OGFrp.Main/SettingsPage.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
Me.ctm_lang.Assets = Me.Assets
Me.ctm_lang.Config = Me.Config
Me.ctm_lang._init_()
Me.ctm_flm.Assets = Me.Assets
Me.ctm_flm.Config = Me.Config
Me.ctm_flm._init_()
End Sub

End Class
26 changes: 15 additions & 11 deletions src/OGFrp.Main/Visual/Window/ServerSelectionWindow.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/OGFrp.Main/Visual/Window/ServerSelectionWindow.vb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ Public Class ServerSelectionWindow

Private Sub bt_launch_Click(sender As Object, e As EventArgs) Handles bt_launch.Click
Dim SelectedServer As FrpServerModel = Me.cb_Server.SelectedItem
If Frp.launchFrpc(Me.AccessToken, SelectedServer.ID) = -1 Then
MsgBox("启动失败!", 16, "OGFrp")
End If
Frp.launchFrpc(Me.AccessToken, SelectedServer.ID)
Me.Dispose()
End Sub

Expand Down
47 changes: 23 additions & 24 deletions src/OGFrp.SharedCS/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ namespace OGFrp.UI
public partial class Config
{


ConfigModel[] ConfigArray = new ConfigModel[4];

/// <summary>
/// 构造函数
/// </summary>
public Config()
{
ConfigArray[0] = this.Lang;
ConfigArray[1] = this.Username;
ConfigArray[2] = this.Password;
ConfigArray[3] = this.FrpcLaunchMode;
try
{
ReadConfig();
}
catch
{
this.Lang.Val = "zh_cn";
WriteConfig();
ReadConfig();
}
Expand Down Expand Up @@ -86,7 +92,7 @@ public void ReadConfig()
while (true)
{
temp = reader.Read();
if(Chr(temp) == "=")
if (Chr(temp) == "=")
{
break;
}
Expand All @@ -96,7 +102,7 @@ public void ReadConfig()
}
}
Right = reader.ReadLine();
if(Left == "::end")
if (Left == "::end")
{
reader.Close();
return;
Expand All @@ -112,6 +118,9 @@ public void ReadConfig()
case "Password":
this.Password.Val = Right;
break;
case "FrpcLaunchMode":
this.FrpcLaunchMode.Val = Right;
break;
default:
break;
}
Expand All @@ -124,29 +133,19 @@ public void ReadConfig()
/// </summary>
public void WriteConfig()
{
CreateFolder();
ConfigModel[] ConfigArray = new ConfigModel[3];
ConfigArray[0] = this.Lang;
ConfigArray[1] = this.Username;
ConfigArray[2] = this.Password;
StreamWriter writer = new StreamWriter(configpath);
string content = null;
for (int i = 0; i < ConfigArray.Length; i++)
{
content += ConfigArray[i].Name;
content += "=";
content += ConfigArray[i].Val;
content += "\n";
}
content += "::end=1";
writer.Write(content);
writer.Close();
try
{
}
catch
CreateFolder();
StreamWriter writer = new StreamWriter(configpath);
string content = null;
for (int i = 0; i < ConfigArray.Length; i++)
{
content += ConfigArray[i].Name;
content += "=";
content += ConfigArray[i].Val;
content += "\n";
}
content += "::end=1";
writer.Write(content);
writer.Close();
}

}
Expand Down
Loading

0 comments on commit a7cc426

Please sign in to comment.