optimized settings
This commit is contained in:
parent
fddfd1ce6b
commit
4dde7eab20
6 changed files with 260 additions and 180 deletions
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Nocksoft.IO.ConfigFiles;
|
||||
|
||||
namespace WeeXnes.Core
|
||||
|
@ -14,30 +15,152 @@ 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 SettingsFileName = "settings.ini";
|
||||
public static string version = "2.4";
|
||||
public static bool isRpcRunning = false;
|
||||
|
||||
public static bool settings_alwaysOnTop;
|
||||
|
||||
public static bool settings_copySelectedToClipboard;
|
||||
|
||||
public static string settings_KeyManagerItemsPath_Default = AppDataPath + "\\" + "Keys";
|
||||
public static bool settings_KeyManagerItemsPath_Bool = false;
|
||||
public static string settings_KeyManagerItemsPath = settings_KeyManagerItemsPath_Default;
|
||||
|
||||
public static string settings_RpcItemsPath_Default = AppDataPath + "\\" + "RPC";
|
||||
public static string settings_RpcItemsPath = settings_RpcItemsPath_Default;
|
||||
public static bool settings_RpcItemsPath_Bool = false;
|
||||
|
||||
public static bool settings_RpcShowElapsedTime;
|
||||
public static string settings_RpcDefaultClientID;
|
||||
|
||||
public static string version = "2.5";
|
||||
public static bool info_isRpcRunning = false;
|
||||
public static bool info_RpcAutoStart;
|
||||
|
||||
public static UpdateVar<bool> settings_alwaysOnTop = new UpdateVar<bool>();
|
||||
|
||||
public static UpdateVar<bool> settings_copySelectedToClipboard = new UpdateVar<bool>();
|
||||
|
||||
public static string settings_KeyManagerItemsPath_Default = AppDataPath + "\\" + "Keys";
|
||||
public static UpdateVar<string> settings_KeyManagerItemsPath = new UpdateVar<string>();
|
||||
public static UpdateVar<bool> settings_KeyManagerItemsPath_Bool = new UpdateVar<bool>();
|
||||
|
||||
public static string settings_RpcItemsPath_Default = AppDataPath + "\\" + "RPC";
|
||||
public static UpdateVar<string> settings_RpcItemsPath = new UpdateVar<string>();
|
||||
public static UpdateVar<bool> settings_RpcItemsPath_Bool = new UpdateVar<bool>();
|
||||
|
||||
public static UpdateVar<bool> settings_RpcShowElapsedTime = new UpdateVar<bool>();
|
||||
public static UpdateVar<string> settings_RpcDefaultClientID = new UpdateVar<string>();
|
||||
public static UpdateVar<bool> settings_RpcAutoStart = new UpdateVar<bool>();
|
||||
|
||||
|
||||
|
||||
|
||||
public static UpdateVar<string> searchbox_content = new UpdateVar<string>();
|
||||
}
|
||||
public static class SettingsManager
|
||||
{
|
||||
private static INIFile SettingsFile = new INIFile(
|
||||
Globals.AppDataPath + "\\" + Globals.SettingsFileName,
|
||||
true
|
||||
);
|
||||
public static void start()
|
||||
{
|
||||
loadSettings();
|
||||
setEventListeners();
|
||||
}
|
||||
public static void refresh()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void loadSettings()
|
||||
{
|
||||
Globals.settings_alwaysOnTop.Value = Convert.ToBoolean(SettingsFile.GetValue("general", "alwaysOnTop"));
|
||||
|
||||
Globals.settings_copySelectedToClipboard.Value = Convert.ToBoolean(SettingsFile.GetValue("KeyManager", "copySelectedToClipboard"));
|
||||
Globals.settings_KeyManagerItemsPath_Bool.Value = Convert.ToBoolean(SettingsFile.GetValue("KeyManager", "KeyManagerItemsPath_Bool"));
|
||||
if (Globals.settings_KeyManagerItemsPath_Bool.Value)
|
||||
{
|
||||
Globals.settings_KeyManagerItemsPath.Value = SettingsFile.GetValue("KeyManager", "KeyManagerItemsPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.settings_KeyManagerItemsPath.Value = Globals.settings_KeyManagerItemsPath_Default;
|
||||
}
|
||||
|
||||
|
||||
Globals.settings_RpcShowElapsedTime.Value = Convert.ToBoolean(SettingsFile.GetValue("rpc", "RpcShowElapsedTime"));
|
||||
Globals.settings_RpcItemsPath_Bool.Value = Convert.ToBoolean(SettingsFile.GetValue("rpc", "RpcItemsPath_Bool"));
|
||||
if (Globals.settings_RpcItemsPath_Bool.Value)
|
||||
{
|
||||
Globals.settings_RpcItemsPath.Value = SettingsFile.GetValue("rpc", "RpcItemsPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.settings_RpcItemsPath.Value = Globals.settings_RpcItemsPath_Default;
|
||||
}
|
||||
|
||||
Globals.settings_RpcDefaultClientID.Value = SettingsFile.GetValue("rpc", "RpcDefaultClientID");
|
||||
if (String.IsNullOrEmpty(Globals.settings_RpcDefaultClientID.Value))
|
||||
{
|
||||
Globals.settings_RpcDefaultClientID.Value = "605116707035676701";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void setEventListeners()
|
||||
{
|
||||
Globals.settings_KeyManagerItemsPath_Bool.ValueChanged += () =>
|
||||
{
|
||||
if (Globals.settings_KeyManagerItemsPath_Bool.Value)
|
||||
{
|
||||
SettingsFile.SetValue("KeyManager", "KeyManagerItemsPath_Bool", "true");
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsFile.SetValue("KeyManager", "KeyManagerItemsPath_Bool", "false");
|
||||
}
|
||||
};
|
||||
Globals.settings_KeyManagerItemsPath.ValueChanged += () =>
|
||||
{
|
||||
if (Globals.settings_KeyManagerItemsPath_Bool.Value)
|
||||
{
|
||||
SettingsFile.SetValue("KeyManager", "KeyManagerItemsPath", Globals.settings_KeyManagerItemsPath.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsFile.SetValue("KeyManager", "KeyManagerItemsPath", "");
|
||||
}
|
||||
};
|
||||
Globals.settings_RpcItemsPath_Bool.ValueChanged += () =>
|
||||
{
|
||||
if (Globals.settings_RpcItemsPath_Bool.Value)
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcItemsPath_Bool", "true");
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcItemsPath_Bool", "false");
|
||||
}
|
||||
};
|
||||
Globals.settings_RpcItemsPath.ValueChanged += () =>
|
||||
{
|
||||
if (Globals.settings_RpcItemsPath_Bool.Value)
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcItemsPath", Globals.settings_RpcItemsPath.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcItemsPath", "");
|
||||
}
|
||||
};
|
||||
Globals.settings_alwaysOnTop.ValueChanged += () =>
|
||||
{
|
||||
SettingsFile.SetValue("general","alwaysOnTop",Convert.ToString(Globals.settings_alwaysOnTop.Value));
|
||||
};
|
||||
Globals.settings_copySelectedToClipboard.ValueChanged += () =>
|
||||
{
|
||||
SettingsFile.SetValue("KeyManager","copySelectedToClipboard",Convert.ToString(Globals.settings_copySelectedToClipboard.Value));
|
||||
};
|
||||
Globals.settings_RpcDefaultClientID.ValueChanged += () =>
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcDefaultClientID", Globals.settings_RpcDefaultClientID.Value);
|
||||
};
|
||||
Globals.settings_RpcShowElapsedTime.ValueChanged += () =>
|
||||
{
|
||||
SettingsFile.SetValue("rpc", "RpcShowElapsedTime", Convert.ToString(Globals.settings_RpcShowElapsedTime.Value));
|
||||
};
|
||||
Globals.settings_RpcAutoStart.ValueChanged += () =>
|
||||
{
|
||||
SettingsFile.SetValue("rpc","RpcAutoStart", Convert.ToString(Globals.settings_RpcAutoStart.Value));
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
public static class funcs
|
||||
{
|
||||
public static bool IsDirectoryEmpty(string path)
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace WeeXnes.MVVM.View
|
|||
public static UpdateVar<string> triggerLogupdate = new UpdateVar<string>();
|
||||
public DiscordRpcView()
|
||||
{
|
||||
CheckFolders();
|
||||
InitializeComponent();
|
||||
triggerLogupdate.ValueChanged += () =>
|
||||
{
|
||||
|
@ -48,6 +49,15 @@ namespace WeeXnes.MVVM.View
|
|||
CheckForAutostart();
|
||||
}
|
||||
|
||||
public void CheckFolders()
|
||||
{
|
||||
if (!Directory.Exists(Globals.settings_RpcItemsPath.Value))
|
||||
{
|
||||
Directory.CreateDirectory(Globals.settings_RpcItemsPath.Value);
|
||||
Console.WriteLine("Created settings_RpcItemsPath");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForAutostart()
|
||||
{
|
||||
if (Globals.info_RpcAutoStart)
|
||||
|
@ -83,7 +93,7 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
Globals.isRpcRunning = true;
|
||||
Globals.info_isRpcRunning = true;
|
||||
writeLog("Thread Started");
|
||||
bool runWorker = true;
|
||||
int delay = 2000;
|
||||
|
@ -110,7 +120,7 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
Globals.isRpcRunning = false;
|
||||
Globals.info_isRpcRunning = false;
|
||||
foreach(Game game in Games)
|
||||
{
|
||||
game.isRunning = false;
|
||||
|
@ -150,7 +160,7 @@ namespace WeeXnes.MVVM.View
|
|||
public void generateNewGame()
|
||||
{
|
||||
string filename = Guid.NewGuid().ToString() + ".rpc";
|
||||
Game newGame = new Game(filename, generateIncrementalName(), null, Globals.settings_RpcDefaultClientID);
|
||||
Game newGame = new Game(filename, generateIncrementalName(), null, Globals.settings_RpcDefaultClientID.Value);
|
||||
saveGameToFile(newGame);
|
||||
}
|
||||
public string generateIncrementalName()
|
||||
|
@ -161,7 +171,7 @@ namespace WeeXnes.MVVM.View
|
|||
}
|
||||
public void saveGameToFile(Game game)
|
||||
{
|
||||
INIFile rpcFile = new INIFile(Globals.settings_RpcItemsPath + "\\" + game.fileName, true);
|
||||
INIFile rpcFile = new INIFile(Globals.settings_RpcItemsPath.Value + "\\" + game.fileName, true);
|
||||
rpcFile.SetValue("config", "name", game.Name);
|
||||
rpcFile.SetValue("config", "pname", game.ProcessName);
|
||||
rpcFile.SetValue("config", "id", game.id);
|
||||
|
@ -177,7 +187,7 @@ namespace WeeXnes.MVVM.View
|
|||
{
|
||||
try
|
||||
{
|
||||
File.Delete(Globals.settings_RpcItemsPath + "\\" + game.fileName);
|
||||
File.Delete(Globals.settings_RpcItemsPath.Value + "\\" + game.fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -187,12 +197,12 @@ namespace WeeXnes.MVVM.View
|
|||
}
|
||||
public void readRpcFileDirectory()
|
||||
{
|
||||
bool Empty = funcs.IsDirectoryEmpty(Globals.settings_RpcItemsPath);
|
||||
bool Empty = funcs.IsDirectoryEmpty(Globals.settings_RpcItemsPath.Value);
|
||||
List<Game> readGames = new List<Game>();
|
||||
if (!Empty)
|
||||
{
|
||||
Console.WriteLine("RpcDir is not Empty, Reading content");
|
||||
string[] files = Directory.GetFiles(Globals.settings_RpcItemsPath, "*.rpc", SearchOption.AllDirectories);
|
||||
string[] files = Directory.GetFiles(Globals.settings_RpcItemsPath.Value, "*.rpc", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
INIFile rpcFile = new INIFile(file);
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
public KeyManagerView()
|
||||
{
|
||||
CheckForFolders();
|
||||
InitializeComponent();
|
||||
Globals.searchbox_content.ValueChanged += () => { SearchboxChanged(); };
|
||||
}
|
||||
|
@ -118,10 +119,9 @@ namespace WeeXnes.MVVM.View
|
|||
private void StackPanel_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KeyManagerLib.KeyList.Clear();
|
||||
CheckForFolders();
|
||||
if (!SaveInterface.IsDirectoryEmpty(Globals.settings_KeyManagerItemsPath))
|
||||
if (!SaveInterface.IsDirectoryEmpty(Globals.settings_KeyManagerItemsPath.Value))
|
||||
{
|
||||
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath);
|
||||
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath.Value);
|
||||
foreach (string file in files)
|
||||
{
|
||||
Console.WriteLine(file);
|
||||
|
@ -154,9 +154,9 @@ namespace WeeXnes.MVVM.View
|
|||
Directory.CreateDirectory(Globals.AppDataPath);
|
||||
Console.WriteLine("Created AppDataPath");
|
||||
}
|
||||
if (!Directory.Exists(Globals.settings_KeyManagerItemsPath))
|
||||
if (!Directory.Exists(Globals.settings_KeyManagerItemsPath.Value))
|
||||
{
|
||||
Directory.CreateDirectory(Globals.settings_KeyManagerItemsPath);
|
||||
Directory.CreateDirectory(Globals.settings_KeyManagerItemsPath.Value);
|
||||
Console.WriteLine("Created settings_KeyManagerItemsPath");
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ namespace WeeXnes.MVVM.View
|
|||
if(selectedItem != null)
|
||||
{
|
||||
Console.WriteLine(selectedItem.name + ": " + selectedItem.value);
|
||||
if (Globals.settings_copySelectedToClipboard)
|
||||
if (Globals.settings_copySelectedToClipboard.Value)
|
||||
{
|
||||
Clipboard.SetText(selectedItem.value);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ namespace WeeXnes.MVVM.View
|
|||
KeyItem selectedItem = (KeyItem)KeyListView.SelectedItem;
|
||||
Console.WriteLine("Doubleclicked " + selectedItem.name);
|
||||
KeyManagerLib.KeyList.Remove(selectedItem);
|
||||
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath);
|
||||
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath.Value);
|
||||
foreach (string file in files)
|
||||
{
|
||||
Console.WriteLine(file);
|
||||
|
|
|
@ -29,11 +29,77 @@ namespace WeeXnes.MVVM.View
|
|||
public SettingView()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadUiFromSettingsFile();
|
||||
//LoadUiFromSettingsFile();
|
||||
SetFunction();
|
||||
UpdatePathsOnUi();
|
||||
SetUiUpdateListeners();
|
||||
InitializeUi();
|
||||
//UpdatePathsOnUi();
|
||||
}
|
||||
|
||||
public void InitializeUi()
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Globals.settings_RpcItemsPath.Value))
|
||||
{
|
||||
RpcPathLabel.Content = Globals.settings_RpcItemsPath.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
RpcPathLabel.Content = "Default";
|
||||
}
|
||||
if (!String.IsNullOrEmpty(Globals.settings_KeyManagerItemsPath.Value))
|
||||
{
|
||||
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyPathLabel.Content = "Default";
|
||||
}
|
||||
|
||||
if (Globals.settings_alwaysOnTop.Value)
|
||||
{
|
||||
AlwaysOnTopSwitch.IsChecked = true;
|
||||
}
|
||||
|
||||
if (Globals.settings_RpcAutoStart.Value)
|
||||
{
|
||||
EnableAutoStart.IsChecked = true;
|
||||
}
|
||||
|
||||
if (Globals.settings_RpcShowElapsedTime.Value)
|
||||
{
|
||||
ShowElapsedTimeOnRpc.IsChecked = true;
|
||||
}
|
||||
|
||||
if (Globals.settings_copySelectedToClipboard.Value)
|
||||
{
|
||||
ItemToClipboardSwitch.IsChecked = true;
|
||||
}
|
||||
}
|
||||
private void SetUiUpdateListeners()
|
||||
{
|
||||
Globals.settings_RpcItemsPath.ValueChanged += () =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Globals.settings_RpcItemsPath.Value))
|
||||
{
|
||||
RpcPathLabel.Content = Globals.settings_RpcItemsPath.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
RpcPathLabel.Content = "Default";
|
||||
}
|
||||
};
|
||||
Globals.settings_KeyManagerItemsPath.ValueChanged += () =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Globals.settings_KeyManagerItemsPath.Value))
|
||||
{
|
||||
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyPathLabel.Content = "Default";
|
||||
}
|
||||
};
|
||||
}
|
||||
private void SetFunction()
|
||||
{
|
||||
EnableAutoStart.Checked += EnableAutoStart_Checked;
|
||||
|
@ -45,135 +111,36 @@ namespace WeeXnes.MVVM.View
|
|||
EnableAutoStart.Unchecked -= EnableAutoStart_Unchecked;
|
||||
}
|
||||
|
||||
private void LoadUiFromSettingsFile()
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
if (Globals.settings_alwaysOnTop)
|
||||
{
|
||||
AlwaysOnTopSwitch.IsChecked = true;
|
||||
}
|
||||
if (Globals.settings_RpcShowElapsedTime)
|
||||
{
|
||||
ShowElapsedTimeOnRpc.IsChecked = true;
|
||||
}
|
||||
|
||||
if (Globals.settings_copySelectedToClipboard)
|
||||
{
|
||||
ItemToClipboardSwitch.IsChecked = true;
|
||||
}
|
||||
bool autoStartRpc = Convert.ToBoolean(SettingsFile.GetValue("RPC", "autoStartRpc"));
|
||||
if (autoStartRpc)
|
||||
{
|
||||
EnableAutoStart.IsChecked = true;
|
||||
}
|
||||
|
||||
|
||||
tb_DefaultClientID.Text = Globals.settings_RpcDefaultClientID;
|
||||
}
|
||||
public static void CheckSetting()
|
||||
{
|
||||
|
||||
|
||||
if(!File.Exists(Globals.AppDataPath + "\\" + Globals.SettingsFileName))
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("General", "AlwaysOnTop", "false");
|
||||
SettingsFile.SetValue("RPC", "showElapsedTime", "true");
|
||||
SettingsFile.SetValue("KeyManager", "copyToClipboard", "false");
|
||||
SettingsFile.SetValue("RPC", "defaultID", "605116707035676701");
|
||||
CheckSetting();
|
||||
}
|
||||
else
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName);
|
||||
|
||||
Globals.settings_alwaysOnTop = Convert.ToBoolean(SettingsFile.GetValue("General", "AlwaysOnTop"));
|
||||
Console.WriteLine(Globals.settings_alwaysOnTop);
|
||||
Globals.settings_RpcShowElapsedTime = Convert.ToBoolean(SettingsFile.GetValue("RPC", "showElapsedTime"));
|
||||
Console.WriteLine(Globals.settings_RpcShowElapsedTime);
|
||||
Globals.settings_copySelectedToClipboard = Convert.ToBoolean(SettingsFile.GetValue("KeyManager", "copyToClipboard"));
|
||||
Console.WriteLine(Globals.settings_copySelectedToClipboard);
|
||||
|
||||
|
||||
Globals.settings_RpcDefaultClientID = SettingsFile.GetValue("RPC", "defaultID");
|
||||
Console.WriteLine(Globals.settings_RpcDefaultClientID);
|
||||
|
||||
|
||||
Globals.settings_alwaysOnTop = Convert.ToBoolean(SettingsFile.GetValue("General", "AlwaysOnTop"));
|
||||
|
||||
|
||||
Globals.settings_KeyManagerItemsPath_Bool = Convert.ToBoolean(SettingsFile.GetValue("KeyFiles", "CustomKeyLocation"));
|
||||
if (Globals.settings_KeyManagerItemsPath_Bool)
|
||||
{
|
||||
Globals.settings_KeyManagerItemsPath = SettingsFile.GetValue("KeyFiles", "KeyPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.settings_KeyManagerItemsPath = Globals.settings_KeyManagerItemsPath_Default;
|
||||
}
|
||||
|
||||
|
||||
Globals.settings_RpcItemsPath_Bool = Convert.ToBoolean(SettingsFile.GetValue("rpc", "CustomRpcLocation"));
|
||||
if (Globals.settings_RpcItemsPath_Bool)
|
||||
{
|
||||
Globals.settings_RpcItemsPath = SettingsFile.GetValue("rpc", "RpcPath");
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.settings_RpcItemsPath = Globals.settings_RpcItemsPath_Default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SettingsFile.SetValue("settings", "alwaysOnTop", "false");
|
||||
Globals.alwaysOnTop = false;
|
||||
SettingsFile.SetValue("RPC", "elapsedTime", "true");
|
||||
Globals.showElapsedTime = true;
|
||||
*/
|
||||
}
|
||||
private void AlwaysOnTopSwitch_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("General", "AlwaysOnTop", "true");
|
||||
CheckSetting();
|
||||
Globals.settings_alwaysOnTop.Value = true;
|
||||
}
|
||||
|
||||
|
||||
private void AlwaysOnTopSwitch_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("General", "AlwaysOnTop", "false");
|
||||
CheckSetting();
|
||||
Globals.settings_alwaysOnTop.Value = false;
|
||||
}
|
||||
|
||||
private void ShowElapsedTimeOnRpc_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("RPC", "showElapsedTime", "true");
|
||||
CheckSetting();
|
||||
Globals.settings_RpcShowElapsedTime.Value = true;
|
||||
}
|
||||
|
||||
private void ShowElapsedTimeOnRpc_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("RPC", "showElapsedTime", "false");
|
||||
CheckSetting();
|
||||
Globals.settings_RpcShowElapsedTime.Value = false;
|
||||
}
|
||||
|
||||
private void ItemToClipboardSwitch_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("KeyManager", "copyToClipboard", "true");
|
||||
CheckSetting();
|
||||
Globals.settings_copySelectedToClipboard.Value = true;
|
||||
}
|
||||
|
||||
private void ItemToClipboardSwitch_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
SettingsFile.SetValue("KeyManager", "copyToClipboard", "false");
|
||||
CheckSetting();
|
||||
Globals.settings_copySelectedToClipboard.Value = false;
|
||||
}
|
||||
|
||||
private void OpenAppdataFolder_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -183,11 +150,9 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
private void SaveDefaultID_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
if (!String.IsNullOrEmpty(tb_DefaultClientID.Text))
|
||||
{
|
||||
SettingsFile.SetValue("RPC", "defaultID", tb_DefaultClientID.Text);
|
||||
CheckSetting();
|
||||
Globals.settings_RpcDefaultClientID.Value = tb_DefaultClientID.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -200,15 +165,14 @@ namespace WeeXnes.MVVM.View
|
|||
{
|
||||
UnsetFunction();
|
||||
|
||||
INIFile SettingsFile = new INIFile(Globals.AppDataPath + "\\" + Globals.SettingsFileName, true);
|
||||
if (on)
|
||||
{
|
||||
SettingsFile.SetValue("RPC", "autoStartRpc", "true");
|
||||
Globals.settings_RpcAutoStart.Value = true;
|
||||
EnableAutoStart.IsChecked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsFile.SetValue("RPC", "autoStartRpc", "false");
|
||||
Globals.settings_RpcAutoStart.Value = false;
|
||||
EnableAutoStart.IsChecked = false;
|
||||
}
|
||||
SetFunction();
|
||||
|
@ -253,19 +217,11 @@ namespace WeeXnes.MVVM.View
|
|||
switchAutoRpc(proc_suc);
|
||||
}
|
||||
|
||||
private void UpdatePathsOnUi()
|
||||
{
|
||||
RpcPathLabel.Content = Globals.settings_RpcItemsPath;
|
||||
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath;
|
||||
}
|
||||
|
||||
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();
|
||||
Globals.settings_KeyManagerItemsPath_Bool.Value = false;
|
||||
Globals.settings_KeyManagerItemsPath.Value = "";
|
||||
}
|
||||
|
||||
private void SetKeyLocation_OnClick(object sender, RoutedEventArgs e)
|
||||
|
@ -276,11 +232,9 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
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();
|
||||
|
||||
Globals.settings_KeyManagerItemsPath_Bool.Value = true;
|
||||
Globals.settings_KeyManagerItemsPath.Value = fbd.SelectedPath;
|
||||
//MessageBox.Show("valid path: " + fbd.SelectedPath);
|
||||
}
|
||||
}
|
||||
|
@ -288,11 +242,8 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
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();
|
||||
Globals.settings_RpcItemsPath_Bool.Value = false;
|
||||
Globals.settings_RpcItemsPath.Value = "";
|
||||
}
|
||||
|
||||
private void SetRpcLocation_OnClick(object sender, RoutedEventArgs e)
|
||||
|
@ -303,12 +254,8 @@ namespace WeeXnes.MVVM.View
|
|||
|
||||
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);
|
||||
Globals.settings_RpcItemsPath_Bool.Value = true;
|
||||
Globals.settings_RpcItemsPath.Value = fbd.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,9 @@ namespace WeeXnes
|
|||
|
||||
private void CheckForSettingsFile()
|
||||
{
|
||||
SettingView.CheckSetting();
|
||||
//SettingView.CheckSetting();
|
||||
SettingsManager.start();
|
||||
|
||||
}
|
||||
|
||||
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
|
@ -139,17 +141,12 @@ namespace WeeXnes
|
|||
Directory.CreateDirectory(Globals.AppDataPath);
|
||||
Console.WriteLine("Created AppDataPath");
|
||||
}
|
||||
if (!Directory.Exists(Globals.settings_RpcItemsPath))
|
||||
{
|
||||
Directory.CreateDirectory(Globals.settings_RpcItemsPath);
|
||||
Console.WriteLine("Created settings_RpcItemsPath");
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Deactivated(object sender, EventArgs e)
|
||||
{
|
||||
Window window = (Window)sender;
|
||||
if (Globals.settings_alwaysOnTop)
|
||||
if (Globals.settings_alwaysOnTop.Value)
|
||||
{
|
||||
window.Topmost = true;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,10 @@ namespace WeeXnes.RPC
|
|||
SmallImageText = this.smallimgtext
|
||||
}
|
||||
});
|
||||
client.UpdateStartTime();
|
||||
if (Globals.settings_RpcShowElapsedTime.Value)
|
||||
{
|
||||
client.UpdateStartTime();
|
||||
}
|
||||
}
|
||||
public void stop()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue