added the setting to change the save location of the keyFiles and RpcFiles
This commit is contained in:
parent
a84fa0a20e
commit
a44c190f8b
4 changed files with 154 additions and 20 deletions
|
@ -13,10 +13,14 @@ namespace WeeXnes.Core
|
|||
{
|
||||
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
|
||||
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||
public static string KeyListPath = AppDataPath + "\\" + "Keys";
|
||||
public static string RpcListPath = AppDataPath + "\\" + "RPC";
|
||||
public static string DefaultKeyListPath = AppDataPath + "\\" + "Keys";
|
||||
public static string DefaultRpcListPath = AppDataPath + "\\" + "RPC";
|
||||
public static string KeyListPath = DefaultKeyListPath;
|
||||
public static string RpcListPath = DefaultRpcListPath;
|
||||
public static bool KeyCustomPath = false;
|
||||
public static bool RpcCustomPath = false;
|
||||
public static string SettingsFileName = "settings.ini";
|
||||
public static string version = "2.3";
|
||||
public static string version = "2.4";
|
||||
public static bool isRpcRunning = false;
|
||||
public static string defaultRpcClient;
|
||||
public static bool alwaysOnTop;
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
Name="tb_DefaultClientID"/>
|
||||
<Button Name="SaveDefaultID"
|
||||
Style="{StaticResource UniversalMaterialButton}"
|
||||
Content="Set Default"
|
||||
Content="Set Default ClientID"
|
||||
Background="#353340"
|
||||
Height="25"
|
||||
Click="SaveDefaultID_Click"
|
||||
|
@ -102,6 +102,26 @@
|
|||
Foreground="White"/>
|
||||
|
||||
</CheckBox>
|
||||
|
||||
|
||||
<Label Content="Placeholder" HorizontalAlignment="Center"
|
||||
FontSize="8"
|
||||
Foreground="White"
|
||||
Name="RpcPathLabel"/>
|
||||
<Button Name="SetRpcLocation"
|
||||
Style="{StaticResource UniversalMaterialButton}"
|
||||
Content="Set Rpc Files Path"
|
||||
Background="#353340"
|
||||
Height="25"
|
||||
Click="SetRpcLocation_OnClick"
|
||||
Margin="4,10,4,0"/>
|
||||
<Button Name="SetRpcLocationDefault"
|
||||
Style="{StaticResource UniversalMaterialButton}"
|
||||
Content="Set Default Path"
|
||||
Background="#353340"
|
||||
Height="25"
|
||||
Click="SetRpcLocationDefault_OnClick"
|
||||
Margin="4,10,4,0"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
@ -113,8 +133,7 @@
|
|||
CornerRadius="10"
|
||||
Margin="10,40,10,10">
|
||||
|
||||
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<CheckBox VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
|
@ -128,6 +147,28 @@
|
|||
FontSize="15"
|
||||
Foreground="White"/>
|
||||
</CheckBox>
|
||||
<Label Content="Placeholder" HorizontalAlignment="Center"
|
||||
FontSize="8"
|
||||
Foreground="White"
|
||||
Name="KeyPathLabel"/>
|
||||
<Button Name="SetKeyLocation"
|
||||
Style="{StaticResource UniversalMaterialButton}"
|
||||
Content="Set Key Files Path"
|
||||
Background="#353340"
|
||||
Height="25"
|
||||
Click="SetKeyLocation_OnClick"
|
||||
Margin="4,10,4,0"/>
|
||||
<Button Name="SetKeyLocationDefault"
|
||||
Style="{StaticResource UniversalMaterialButton}"
|
||||
Content="Set Default Path"
|
||||
Background="#353340"
|
||||
Height="25"
|
||||
Click="SetKeyLocationDefault_OnClick"
|
||||
Margin="4,10,4,0"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
<Button Name="OpenAppdataFolder" Grid.Row="1"
|
||||
|
|
|
@ -6,9 +6,9 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
@ -16,6 +16,8 @@ using System.Windows.Navigation;
|
|||
using System.Windows.Shapes;
|
||||
using Nocksoft.IO.ConfigFiles;
|
||||
using WeeXnes.Core;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
namespace WeeXnes.MVVM.View
|
||||
{
|
||||
|
@ -29,6 +31,7 @@ namespace WeeXnes.MVVM.View
|
|||
InitializeComponent();
|
||||
LoadUiFromSettingsFile();
|
||||
SetFunction();
|
||||
UpdatePathsOnUi();
|
||||
}
|
||||
|
||||
private void SetFunction()
|
||||
|
@ -95,6 +98,31 @@ namespace WeeXnes.MVVM.View
|
|||
Globals.defaultRpcClient = SettingsFile.GetValue("RPC", "defaultID");
|
||||
Console.WriteLine(Globals.defaultRpcClient);
|
||||
|
||||
|
||||
Globals.alwaysOnTop = Convert.ToBoolean(SettingsFile.GetValue("General", "AlwaysOnTop"));
|
||||
|
||||
|
||||
Globals.KeyCustomPath = Convert.ToBoolean(SettingsFile.GetValue("KeyFiles", "CustomKeyLocation"));
|
||||
if (Globals.KeyCustomPath)
|
||||
{
|
||||
Globals.KeyListPath = SettingsFile.GetValue("KeyFiles", "KeyPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.KeyListPath = Globals.DefaultKeyListPath;
|
||||
}
|
||||
|
||||
|
||||
Globals.RpcCustomPath = Convert.ToBoolean(SettingsFile.GetValue("rpc", "CustomRpcLocation"));
|
||||
if (Globals.RpcCustomPath)
|
||||
{
|
||||
Globals.RpcListPath = SettingsFile.GetValue("rpc", "RpcPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.RpcListPath = Globals.DefaultRpcListPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,5 +252,65 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
switchAutoRpc(proc_suc);
|
||||
}
|
||||
|
||||
private void UpdatePathsOnUi()
|
||||
{
|
||||
RpcPathLabel.Content = Globals.RpcListPath;
|
||||
KeyPathLabel.Content = Globals.KeyListPath;
|
||||
}
|
||||
|
||||
private void SetKeyLocationDefault_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("KeyFiles", "CustomKeyLocation", "false");
|
||||
SettingsFile.SetValue("KeyFiles", "KeyPath", "");
|
||||
CheckSetting();
|
||||
UpdatePathsOnUi();
|
||||
}
|
||||
|
||||
private void SetKeyLocation_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using(var fbd = new FolderBrowserDialog())
|
||||
{
|
||||
DialogResult result = fbd.ShowDialog();
|
||||
|
||||
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("KeyFiles", "CustomKeyLocation", "true");
|
||||
SettingsFile.SetValue("KeyFiles", "KeyPath", fbd.SelectedPath);
|
||||
CheckSetting();
|
||||
UpdatePathsOnUi();
|
||||
//MessageBox.Show("valid path: " + fbd.SelectedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetRpcLocationDefault_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("rpc", "CustomRpcLocation", "false");
|
||||
SettingsFile.SetValue("rpc", "RpcPath", "");
|
||||
CheckSetting();
|
||||
UpdatePathsOnUi();
|
||||
}
|
||||
|
||||
private void SetRpcLocation_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using(var fbd = new FolderBrowserDialog())
|
||||
{
|
||||
DialogResult result = fbd.ShowDialog();
|
||||
|
||||
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("rpc", "CustomRpcLocation", "true");
|
||||
SettingsFile.SetValue("rpc", "RpcPath", fbd.SelectedPath);
|
||||
CheckSetting();
|
||||
UpdatePathsOnUi();
|
||||
//MessageBox.Show("valid path: " + fbd.SelectedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Windows.Forms;
|
|||
using System.Windows.Input;
|
||||
using WeeXnes.Core;
|
||||
using WeeXnes.MVVM.View;
|
||||
using Nocksoft.IO.ConfigFiles;
|
||||
|
||||
namespace WeeXnes
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue