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

Commit

Permalink
Still this Version: Added Some Small Features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiroiame-Kusu committed Aug 8, 2024
1 parent 1ba353e commit b400726
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 28 deletions.
14 changes: 9 additions & 5 deletions LoCyanFrpDesktop/Dashboard/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@
Content="选择文件"
Icon="OpenFolder24"/>
</Grid>
<DockPanel HorizontalAlignment="Left" Width="100" >
<DockPanel HorizontalAlignment="Left" Width="110" >
<TextBlock DockPanel.Dock="Top" Text="主题设置" FontSize="12"/>
<ComboBox Name="AppliedTheme" DockPanel.Dock="Bottom" SelectionChanged="AppliedTheme_SelectionChanged">
<ComboBoxItem Content="跟随系统"></ComboBoxItem>
<ComboBox Name="AppliedTheme" DockPanel.Dock="Bottom" Padding="10,8">
<ComboBoxItem Content="跟随系统"/>
<ComboBoxItem Content="深色"/>
<ComboBoxItem Content="浅色"/>
</ComboBox>
</DockPanel>
<ui:Button Name="SignOut" Margin="0,10" Icon="ArrowExit20" Content="退出登录" Click="SignOut_Click"/>

<ui:Card HorizontalAlignment="Left" Width="150" Margin="0,10">
<StackPanel>
<ui:Button Name="CopyToken" Width="110" Margin="0,10" Icon="Copy24" Content="复制Token" Click="CopyToken_Click"/>
<ui:Button Name="SignOut" Width="110" Margin="0,10" Icon="ArrowExit20" Content="退出登录" Click="SignOut_Click"/>
</StackPanel>
</ui:Card>
</StackPanel>

</Grid>
Expand Down
49 changes: 26 additions & 23 deletions LoCyanFrpDesktop/Dashboard/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ namespace LoCyanFrpDesktop.Dashboard
/// </summary>
public partial class Settings : UiPage
{
private static int i = 0;

public Settings()
{

InitializeComponent();
Access.Settings = this;
_Version.Text = $"版本: Ver {Global.Version}-{Global.Branch}{Global.Revision}";
_Version.Text = $"版本: Ver {Global.Version}-{Global.Branch}{((Global.Branch == "Alpha" || Global.Branch == "Beta") ? "." : "")}{Global.Revision}";
_BuildInfo.Text = Global.BuildInfo.ToString();
_Developer.Text = $"开发者: {Global.Developer}";
_Copyright.Text = Global.Copyright;
FrpcPath.Text = Global.Config.FrpcPath;
AppliedTheme.SelectedIndex = Global.Config.AppliedTheme;
AppliedTheme.SelectionChanged += AppliedTheme_SelectionChanged;
}
public void Select_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -75,31 +76,33 @@ private void SignOut_Click(object sender, RoutedEventArgs e)

private void AppliedTheme_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

if(i > 0)
Global.Config.AppliedTheme = AppliedTheme.SelectedIndex;
switch (AppliedTheme.SelectedIndex)
{
Global.Config.AppliedTheme = AppliedTheme.SelectedIndex;
switch (AppliedTheme.SelectedIndex)
{
case 0:
MainWindow.IsDarkThemeEnabled();
case 0:
MainWindow.IsDarkThemeEnabled();

break;
case 1:
Global.isDarkThemeEnabled = true;
Theme.Apply(ThemeType.Dark);
break;
case 2:
Global.isDarkThemeEnabled = false;
Theme.Apply(ThemeType.Light);
break;
default:
throw new IndexOutOfRangeException();
break;
case 1:
Global.isDarkThemeEnabled = true;
Theme.Apply(ThemeType.Dark);
break;
case 2:
Global.isDarkThemeEnabled = false;
Theme.Apply(ThemeType.Light);
break;
default:
throw new IndexOutOfRangeException();

}
Access.DashBoard.ChangeColor();
}
i++;
Access.DashBoard.ChangeColor();

}

private void CopyToken_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(Global.Config.FrpToken);
Logger.MsgBox("LocyanFrpDesktop\n已经复制啦~", "LocyanFrpDesktop", 0, 47, 1);
}
}
}
44 changes: 44 additions & 0 deletions LoCyanFrpDesktop/Utils/RSAEncryption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace LoCyanFrpDesktop.Utils
{
internal class RSAEncryption
{
public RSAEncryption() {
string publicKey, privateKey;
using (var rsa = new RSACryptoServiceProvider(4096))
{
publicKey = rsa.ToXmlString(false); // Public key
privateKey = rsa.ToXmlString(true); // Private key
}

}
public static byte[] EncryptData(string dataToEncrypt, string publicKey)
{
byte[] encryptedData;
using (var rsa = new RSACryptoServiceProvider(4096))
{
rsa.FromXmlString(publicKey);
var dataToEncryptBytes = Encoding.UTF8.GetBytes(dataToEncrypt);
encryptedData = rsa.Encrypt(dataToEncryptBytes, false);
}
return encryptedData;
}

public static string DecryptData(byte[] dataToDecrypt, string privateKey)
{
byte[] decryptedData;
using (var rsa = new RSACryptoServiceProvider(4096))
{
rsa.FromXmlString(privateKey);
decryptedData = rsa.Decrypt(dataToDecrypt, false);
}
return Encoding.UTF8.GetString(decryptedData);
}
}
}

0 comments on commit b400726

Please sign in to comment.