Complete Rewrite + Change to new GUI Library

This commit is contained in:
WeeXnes 2022-11-25 15:30:38 +01:00
parent 111fa35070
commit 4258ef9a03
73 changed files with 1866 additions and 4035 deletions

View file

@ -2,38 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WeeXnes"
xmlns:viewModel="clr-namespace:WeeXnes.MVVM.ViewModel"
xmlns:view="clr-namespace:WeeXnes.MVVM.View"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
StartupUri="MainWindow.xaml"
Startup="App_OnStartup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Theme/MenuButtonTheme.xaml"/>
<ResourceDictionary Source="Theme/TextBoxTheme.xaml"/>
<ResourceDictionary Source="Theme/ControlButtonTheme.xaml"/>
<ResourceDictionary Source="Theme/ModernCheckbox.xaml"/>
<ResourceDictionary Source="Theme/Scrollbar.xaml"/>
<ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewModel:HomeViewModel}">
<view:HomeView/>
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:KeyManagerViewModel}">
<view:KeyManagerView/>
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:DiscordRpcViewModel}">
<view:DiscordRpcView/>
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:SettingsViewModel}">
<view:SettingView/>
</DataTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>

View file

@ -1,7 +1,13 @@
using System;
using System.ComponentModel;
using System.Windows;
using WeeXnes.Core;
using System.IO;
using Newtonsoft.Json.Linq;
using Nocksoft.IO.ConfigFiles;
using WeeXnes.Core;
using WeeXnes.Views.DiscordRPC;
using WeeXnes.Views.KeyManager;
using WeeXnes.Views.Settings;
using Application = System.Windows.Forms.Application;
namespace WeeXnes
@ -14,20 +20,94 @@ namespace WeeXnes
private void App_OnStartup(object sender, StartupEventArgs e)
{
Environment.CurrentDirectory = Application.StartupPath;
if (e.Args.Length > 0)
CheckForDebugMode();
CheckForFolder();
LoadSettings();
SaveSettingsHandler.SetupSaveEvents();
LoadFiles();
CheckStartupArgs(e.Args);
}
private void LoadSettings()
{
for (int i = 0; i != e.Args.Length; ++i)
if(!File.Exists(Path.Combine(Global.AppDataPath, Global.SettingsFile)))
return;
KeyManagerView.Data.censorKeys.Value =
Convert.ToBoolean(SettingsView.Data.settingsFile.GetValue(
SaveSettingsHandler.Data.KeyManager.Section,
SaveSettingsHandler.Data.KeyManager.CensorKeys));
}
private void LoadFiles()
{
//MessageBox.Show(e.Args[i]);
if (e.Args[i] == "-autostart")
Functions.CheckFolderAndCreate(Global.AppDataPathRPC);
DirectoryInfo rpcDirectoryInfo = new DirectoryInfo(Global.AppDataPathRPC);
foreach (var file in rpcDirectoryInfo.GetFiles("*.rpc"))
{
//MessageBox.Show("Launched via autostart");
Globals.info_RpcAutoStart = true;
try
{
Game newGame = Game.Methods.GameFromIni(new INIFile(file.FullName));
DiscordRPCView.Data.Games.Add(newGame);
Console.WriteLine(file.Name + " loaded");
}
catch (Exception ex)
{
Console.WriteLine(file.Name + ": " + ex.Message);
}
}
Functions.CheckFolderAndCreate(Global.AppDataPathKEY);
DirectoryInfo keyDirectoryInfo = new DirectoryInfo(Global.AppDataPathKEY);
foreach (var file in keyDirectoryInfo.GetFiles("*.wx"))
{
try
{
//Load KeyFiles
WXFile wxFile = new WXFile(file.FullName);
KeyItem newItem = new KeyItem(
wxFile.GetName(),
EncryptionLib.EncryptorLibary.decrypt(
Information.EncryptionHash,
wxFile.GetValue()
)
);
newItem.Filename = file.Name;
KeyManagerView.Data.KeyItemsList.Add(newItem);
Console.WriteLine(file.Name + " loaded");
}
catch (Exception ex)
{
Console.WriteLine(file.Name + ": " + ex.Message);
}
}
}
private void CheckForFolder()
{
Functions.CheckFolderAndCreate(Global.AppDataPath);
}
private void CheckStartupArgs(string[] arguments)
{
foreach (string argument in arguments)
{
switch (argument)
{
case "-autostart":
HandleLaunchArguments.arg_autostart();
break;
case "-debugMode":
HandleLaunchArguments.arg_debugMode();
break;
}
}
}
}
//Globals.autoStartRpc = true;
private void CheckForDebugMode()
{
#if DEBUG
HandleLaunchArguments.arg_enableConsole();
#endif
}
}
}

View file

@ -1,30 +0,0 @@
namespace WeeXnes.Core
{
public class ApiResponse
{
public string download_url { get; set; }
public string file_name { get; set; }
public string tag_name { get; set; }
public string name { get; set; }
public string description { get; set; }
public ApiResponse(string _download_url, string _file_name, string _tag_name, string _name, string _description)
{
this.download_url = _download_url;
this.file_name = _file_name;
this.tag_name = _tag_name;
this.name = _name;
this.description = _description;
}
public override string ToString()
{
string returnval =
"download_url: " + this.download_url + "\n" +
"file_name: " + this.file_name + "\n" +
"tag_name: " + this.tag_name + "\n" +
"name: " + this.name + "\n" +
"description: " + this.description;
return returnval;
}
}
}

24
WeeXnes/Core/DataTypes.cs Normal file
View file

@ -0,0 +1,24 @@
using System;
namespace WeeXnes.Core
{
public class UpdateVar<T>
{
private T _value;
public Action ValueChanged;
public T Value
{
get => _value;
set
{
_value = value;
OnValueChanged();
}
}
protected virtual void OnValueChanged() => ValueChanged?.Invoke();
}
}

View file

@ -47,25 +47,7 @@ namespace EncryptionLib
}
return returnval;
}
public static string[] readFile(string filepath)
{
string[] lines = System.IO.File.ReadAllLines(filepath);
var listOfStrings = new List<string>();
foreach (string line in lines)
{
listOfStrings.Add(line);
}
string[] arrayOfStrings = listOfStrings.ToArray();
return arrayOfStrings;
}
public static void writeFile(string[] stringArray, string filepath)
{
for (int i = 0; i < stringArray.Length; i++)
{
Console.WriteLine(stringArray[i]);
}
File.WriteAllLines(filepath, stringArray, Encoding.UTF8);
}
public static string[] encryptArray(string hash, string[] arrayToEncrypt)
{
for (int i = 0; i < arrayToEncrypt.Length; i++)

43
WeeXnes/Core/Functions.cs Normal file
View file

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
namespace WeeXnes.Core
{
public static class Functions
{
public static void CheckFolderAndCreate(string path)
{
try
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
public static string[] readFile(string filepath)
{
string[] lines = System.IO.File.ReadAllLines(filepath);
var listOfStrings = new List<string>();
foreach (string line in lines)
{
listOfStrings.Add(line);
}
string[] arrayOfStrings = listOfStrings.ToArray();
return arrayOfStrings;
}
public static void writeFile(string[] stringArray, string filepath)
{
for (int i = 0; i < stringArray.Length; i++)
{
Console.WriteLine(stringArray[i]);
}
File.WriteAllLines(filepath, stringArray, Encoding.UTF8);
}
}
}

21
WeeXnes/Core/Global.cs Normal file
View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace WeeXnes.Core
{
public class Information
{
public const string Version = "4.0.0";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
}
public class Global
{
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
public static string AppDataPathRPC = Path.Combine(AppDataPath, "RPC");
public static string AppDataPathKEY = Path.Combine(AppDataPath, "Keys");
public static string SettingsFile = "settings.ini";
}
}

View file

@ -1,212 +0,0 @@
using WeeXnes.RPC;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Nocksoft.IO.ConfigFiles;
using MessageBox = System.Windows.MessageBox;
namespace WeeXnes.Core
{
internal class Globals
{
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 = "3.6.4";
public static bool info_isRpcRunning = false;
public static bool info_RpcAutoStart;
public static string apiUrl = "http://weexnes.com:5169/";
public static UpdateVar<bool> settings_alwaysOnTop = new UpdateVar<bool>();
public static UpdateVar<bool> settings_osxStyleControlls = 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 UpdateVar<bool> settings_KeyManagerCensorKeys = 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
{
public static INIFile SettingsFile = new INIFile(
Globals.AppDataPath + "\\" + Globals.SettingsFileName,
true
);
public static void start()
{
loadSettings();
setEventListeners();
}
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"));
Globals.settings_KeyManagerCensorKeys.Value = Convert.ToBoolean(SettingsFile.GetValue("KeyManager", "CensorKeys"));
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_osxStyleControlls.Value = Convert.ToBoolean(SettingsFile.GetValue("general", "OSXStyle"));
Globals.settings_RpcShowElapsedTime.Value = Convert.ToBoolean(SettingsFile.GetValue("rpc", "RpcShowElapsedTime"));
Globals.settings_RpcItemsPath_Bool.Value = Convert.ToBoolean(SettingsFile.GetValue("rpc", "RpcItemsPath_Bool"));
Globals.settings_RpcAutoStart.Value = Convert.ToBoolean(SettingsFile.GetValue("rpc", "RpcAutoStart"));
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_KeyManagerCensorKeys.ValueChanged += () =>
{
if (Globals.settings_KeyManagerCensorKeys.Value)
{
SettingsFile.SetValue("KeyManager", "CensorKeys", "true");
}
else
{
SettingsFile.SetValue("KeyManager", "CensorKeys", "false");
}
};
Globals.settings_osxStyleControlls.ValueChanged += () =>
{
SettingsFile.SetValue("general", "OSXStyle", Globals.settings_osxStyleControlls.Value.ToString());
};
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)
{
return !Directory.EnumerateFileSystemEntries(path).Any();
}
}
public class UpdateVar<T>
{
private T _value;
public Action ValueChanged;
public T Value
{
get => _value;
set
{
_value = value;
OnValueChanged();
}
}
protected virtual void OnValueChanged() => ValueChanged?.Invoke();
}
}

View file

@ -0,0 +1,25 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;
namespace WeeXnes.Core
{
public class HandleLaunchArguments
{
private const int ATTACH_PARENT_PROCESS = -1;
[DllImport("kernel32.dll")]
private static extern bool AttachConsole(int dwProcessId);
public static void arg_autostart()
{
}
public static void arg_debugMode()
{
}
public static void arg_enableConsole()
{
AttachConsole(ATTACH_PARENT_PROCESS);
}
}
}

296
WeeXnes/Core/INIFile.cs Normal file
View file

@ -0,0 +1,296 @@
/**
* Copyright by Nocksoft
* https://www.nocksoft.de
* https://nocksoft.de/tutorials/visual-c-sharp-arbeiten-mit-ini-dateien/
* https://github.com/Nocksoft/INIFile.cs
* -----------------------------------
* Author: Rafael Nockmann @ Nocksoft
* Updated: 2022-01-09
* Version: 1.0.3
*
* Language: Visual C#
*
* License: MIT license
* License URL: https://github.com/Nocksoft/INIFile.cs/blob/master/LICENSE
*
* Description:
* Provides basic functions for working with INI files.
*
* ##############################################################################################
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace Nocksoft.IO.ConfigFiles
{
public class INIFile
{
private string _File;
/// <summary>
/// Call the constructor creates a new object of the INIFile class to work with INI files.
/// </summary>
/// <param name="file">Name of INI file, which you want to access.</param>
/// <param name="createFile">Specifies whether the INI file should be created if it does not exist.</param>
public INIFile(string file, bool createFile = false)
{
if (createFile == true && File.Exists(file) == false)
{
FileInfo fileInfo = new FileInfo(file);
FileStream fileStream = fileInfo.Create();
fileStream.Close();
}
_File = file;
}
#region Public Methods
/// <summary>
/// Removes all comments and empty lines from a complete section and returns the sections.
/// This method is not case-sensitive.
/// The return value does not contain any spaces at the beginning or at the end of a line.
/// </summary>
/// <param name="section">Name of the requested section.</param>
/// <param name="includeComments">Specifies whether comments should also be returned.</param>
/// <returns>Returns the whole section.</returns>
public List<string> GetSection(string section, bool includeComments = false)
{
section = CheckSection(section);
List<string> completeSection = new List<string>();
bool sectionStart = false;
string[] fileArray = File.ReadAllLines(_File);
foreach (var item in fileArray)
{
if (item.Length <= 0) continue;
// Beginning of section.
if (item.Replace(" ", "").ToLower() == section)
{
sectionStart = true;
}
// Beginning of next section.
if (sectionStart == true && item.Replace(" ", "").ToLower() != section && item.Replace(" ", "").Substring(0, 1) == "[" && item.Replace(" ", "").Substring(item.Length - 1, 1) == "]")
{
break;
}
if (sectionStart == true)
{
// Add the entry to the List<string> completeSection, if it is not a comment or an empty entry.
if (includeComments == false
&& item.Replace(" ", "").Substring(0, 1) != ";" && !string.IsNullOrWhiteSpace(item))
{
completeSection.Add(ReplaceSpacesAtStartAndEnd(item));
}
if (includeComments == true && !string.IsNullOrWhiteSpace(item))
{
completeSection.Add(ReplaceSpacesAtStartAndEnd(item));
}
}
}
return completeSection;
}
/// <summary>
/// The method returns a value for the associated key.
/// This method is not case-sensitive.
/// </summary>
/// <param name="section">Name of the requested section.</param>
/// <param name="key">Name of the requested key.</param>
/// <param name="convertValueToLower">If "true" is passed, the value will be returned in lowercase letters.</param>
/// <returns>Returns the value for the specified key in the specified section, if available, otherwise null.</returns>
public string GetValue(string section, string key, bool convertValueToLower = false)
{
section = CheckSection(section);
key = key.ToLower();
List<string> completeSection = GetSection(section);
foreach (var item in completeSection)
{
// Continue if entry is no key.
if (!item.Contains("=") && item.Contains("[") && item.Contains("]")) continue;
string[] keyAndValue = item.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (keyAndValue[0].ToLower() == key && keyAndValue.Count() > 1)
{
if (convertValueToLower == true)
{
keyAndValue[1] = keyAndValue[1].ToLower();
}
return keyAndValue[1];
}
}
return null;
}
/// <summary>
/// Set or add a value of the associated key in the specified section.
/// This method is not case-sensitive.
/// </summary>
/// <param name="section">Name of the section.</param>
/// <param name="key">Name of the key.</param>
/// <param name="value">Value to save.</param>
/// <param name="convertValueToLower">If "true" is passed, the value will be saved in lowercase letters.</param>
public void SetValue(string section, string key, string value, bool convertValueToLower = false)
{
section = CheckSection(section, false);
string sectionToLower = section.ToLower();
bool sectionFound = false;
List<string> iniFileContent = new List<string>();
string[] fileLines = File.ReadAllLines(_File);
// Creates a new INI file if none exists.
if (fileLines.Length <= 0)
{
iniFileContent = AddSection(iniFileContent, section, key, value, convertValueToLower);
WriteFile(iniFileContent);
return;
}
for (int i = 0; i < fileLines.Length; i++)
{
// Possibility 1: The desired section has not (yet) been found.
if (fileLines[i].Replace(" ", "").ToLower() != sectionToLower)
{
iniFileContent.Add(fileLines[i]);
// If a section does not exist, the section will be created.
if (i == fileLines.Length - 1 && fileLines[i].Replace(" ", "").ToLower() != sectionToLower && sectionFound == false)
{
iniFileContent.Add(null);
iniFileContent = AddSection(iniFileContent, section, key, value, convertValueToLower);
break;
}
continue;
}
// Possibility 2 -> Desired section was found.
sectionFound = true;
// Get the complete section in which the target key may be.
List<string> targetSection = GetSection(sectionToLower, true);
for (int x = 0; x < targetSection.Count; x++)
{
string[] targetKey = targetSection[x].Split(new string[] { "=" }, StringSplitOptions.None);
// When the target key is found.
if (targetKey[0].ToLower() == key.ToLower())
{
if (convertValueToLower == true)
{
iniFileContent.Add(key + "=" + value.ToLower());
}
else
{
iniFileContent.Add(key + "=" + value);
}
i = i + x;
break;
}
else
{
iniFileContent.Add(targetSection[x]);
// If the target key is not found, it will be created.
if (x == targetSection.Count - 1 && targetKey[0].ToLower() != key.ToLower())
{
if (convertValueToLower == true)
{
iniFileContent.Add(key + "=" + value.ToLower());
}
else
{
iniFileContent.Add(key + "=" + value);
}
i = i + x;
break;
}
}
}
}
WriteFile(iniFileContent);
}
#endregion
#region Private Methods
/// <summary>
/// Ensures that a section is always in the following format: [section].
/// </summary>
/// <param name="section">Section to be checked for correct format.</param>
/// <param name="convertToLower">Specifies whether the section should be vonverted in lower case letters.</param>
/// <returns>Returns section in this form: [section].</returns>
private string CheckSection(string section, bool convertToLower = true)
{
if (convertToLower == true)
{
section = section.ToLower();
}
if (!section.StartsWith("[") && !section.EndsWith("]"))
{
section = "[" + section + "]";
}
return section;
}
/// <summary>
/// Removes leading and trailing spaces from sections, keys and values.
/// </summary>
/// <param name="item">String to be trimmed.</param>
/// <returns>Returns the trimmed string.</returns>
private string ReplaceSpacesAtStartAndEnd(string item)
{
// If the string has a key and a value.
if (item.Contains("=") && !item.Contains("[") && !item.Contains("]"))
{
string[] keyAndValue = item.Split(new string[] { "=" }, StringSplitOptions.None);
return keyAndValue[0].Trim() + "=" + keyAndValue[1].Trim();
}
return item.Trim();
}
/// <summary>
/// Adds a new section with key value pair.
/// </summary>
/// <param name="iniFileContent">List iniFileContent from SetValue.</param>
/// <param name="section">Section to be created.</param>
/// <param name="key">Key to be added.</param>
/// <param name="value">Value to be added.</param>
/// <param name="convertValueToLower">Specifies whether the key and value should be saved in lower case letters.</param>
/// <returns>Returns the new created section with key value pair.</returns>
private List<string> AddSection(List<string> iniFileContent, string section, string key, string value, bool convertValueToLower)
{
if (convertValueToLower == true)
{
value = value.ToLower();
}
iniFileContent.Add(section);
iniFileContent.Add($"{key}={value}");
return iniFileContent;
}
private void WriteFile(List<string> content)
{
StreamWriter writer = new StreamWriter(_File);
foreach (var item in content)
{
writer.WriteLine(item);
}
writer.Close();
}
#endregion
}
}

View file

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace WeeXnes.Core
{
internal class ObservableObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}

View file

@ -1,30 +0,0 @@
using System;
using System.Windows.Input;
namespace WeeXnes.Core
{
internal class RelayCommand : ICommand
{
private Action<object> _execute;
private Func<object, bool> _canExecute;
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value;}
}
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute == null || _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
}
}

View file

@ -0,0 +1,43 @@
using System.Collections.Specialized;
using WeeXnes.Views.KeyManager;
using WeeXnes.Views.Settings;
namespace WeeXnes.Core
{
public static class SaveSettingsHandler
{
public static class Data
{
//Layout-Names for INIFiles
public static class KeyManager
{
public const string Section = "KEY_MANAGER";
public const string CensorKeys = "CensorKeys";
}
public static class DiscordRpcFiles
{
public const string Section = "CONFIG";
public const string ProcessName = "ProcessName";
public const string ClientId = "ClientID";
public const string State = "State";
public const string Details = "Details";
public const string BigImageKey = "BigImageKey";
public const string BigImageText = "BigImageText";
public const string SmallImageKey = "SmallImageKey";
public const string SmallImageText = "SmallImageText";
public const string UUID = "UUID";
}
}
public static void SetupSaveEvents()
{
KeyManagerView.Data.censorKeys.ValueChanged += () =>
{
SettingsView.Data.settingsFile.SetValue(
Data.KeyManager.Section,
Data.KeyManager.CensorKeys,
KeyManagerView.Data.censorKeys.Value.ToString()
);
};
}
}
}

97
WeeXnes/Core/WXFile.cs Normal file
View file

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using WeeXnes.Views.KeyManager;
namespace WeeXnes.Core
{
public class WXFile
{
private const string FileIdentifier = "##WXfile##";
public string path
{
get;
set;
}
public WXFile(string _path)
{
this.path = _path;
}
public string GetName()
{
string returnval = null;
string[] rawcontent = Methods.ReadFile(this.path);
if (Methods.Verify(rawcontent))
{
try
{
returnval = rawcontent[1];
}
catch (Exception e)
{
returnval = null;
}
}
return returnval;
}
public string GetValue()
{
string returnval = null;
string[] rawcontent = Methods.ReadFile(this.path);
if (Methods.Verify(rawcontent))
{
try
{
returnval = rawcontent[2];
}catch (Exception e)
{
returnval = null;
}
}
return returnval;
}
public static class Methods
{
public static void WriteFile(KeyItem keyItem, WXFile wxFile)
{
string[] fileContent = new string[]
{
"##WXfile##",
keyItem.Name,
EncryptionLib.EncryptorLibary.encrypt(
Information.EncryptionHash,
keyItem.Value
)
};
Functions.writeFile(fileContent, wxFile.path);
}
public static string[] ReadFile(string filepath)
{
string[] lines = System.IO.File.ReadAllLines(filepath);
var listOfStrings = new List<string>();
foreach (string line in lines)
{
listOfStrings.Add(line);
}
string[] arrayOfStrings = listOfStrings.ToArray();
return arrayOfStrings;
}
public static bool Verify(string[] content)
{
bool integ = false;
if(content != null)
{
if(content[0] == FileIdentifier)
{
integ = true;
}
}
return integ;
}
}
}
}

View file

@ -1,57 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
namespace WeeXnes.Core
{
public enum EventType
{
ProcessStartedEvent,
ProcessStoppedEvent,
RPCUpdateEvent,
RPCReadyEvent
}
public class customEvent
{
public string Content { get; set; }
public EventType Type { get; set; }
public string GradientColor1 { get; set; }
public string GradientColor2 { get; set; }
public customEvent(string content, EventType type)
{
this.Content = content;
this.Type = type;
if (this.Type == EventType.ProcessStartedEvent)
{
this.GradientColor1 = "#46db69";
this.GradientColor2 = "#33a34d";
}
else if (this.Type == EventType.ProcessStoppedEvent)
{
this.GradientColor1 = "#d1415d";
this.GradientColor2 = "#a33349";
}
else if (this.Type == EventType.RPCUpdateEvent)
{
this.GradientColor1 = "#3e65c9";
this.GradientColor2 = "#3352a3";
}
else if (this.Type == EventType.RPCReadyEvent)
{
this.GradientColor1 = "#c93eb4";
this.GradientColor2 = "#a33389";
}
}
public override string ToString()
{
return this.Content;
}
}
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.Keys
{
public class KeyItem
{
public string name { get; set; }
public string value { get; set; }
public KeyItem(string _name, string _value)
{
this.name = _name;
this.value = _value;
}
}
}

View file

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.Keys
{
public class KeyManagerLib
{
public static List<KeyItem> KeyList = new List<KeyItem>();
}
}

View file

@ -1,277 +0,0 @@
<UserControl x:Class="WeeXnes.MVVM.View.DiscordRpcView"
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:WeeXnes.MVVM.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Unloaded="UserControl_Unloaded">
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="340"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border
CornerRadius="4"
Height="300"
VerticalAlignment="Top">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#202127" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<ListBox Height="300"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
Name="RpcItemList"
Foreground="White"
SelectionChanged="RpcItemList_SelectionChanged"
MouseDoubleClick="RpcItemList_MouseDoubleClick"/>
</Border>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,20,0,0"
Name="tb_FormName"
Background="#212329"
Tag="Name (for List)"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,60,0,0"
Name="tb_FormPName"
Background="#212329"
Tag="Process Name"/>
<Label Content=".exe"
Foreground="White"
FontSize="20" Grid.Column="1"
Margin="240,56,0,0"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,100,0,0"
Name="tb_FormClient"
Background="#212329"
Tag="ClientID"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,180,0,0"
Name="tb_FormState"
Background="#212329"
Tag="State"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,140,0,0"
Name="tb_FormDetails"
Background="#212329"
Tag="Details"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,220,0,0"
Name="tb_FormLargeImgKey"
Background="#212329"
Tag="Large Image Key"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="250,220,0,0"
Name="tb_FormLargeImgTxt"
Background="#202127"
Tag="Large Image Text"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20,260,0,0"
Name="tb_FormSmallImgKey"
Background="#212329"
Tag="Small Image Key"/>
<TextBox Grid.Column="1"
Style="{StaticResource MaterialTextBox}"
Height="33"
Width="220"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="250,260,0,0"
Name="tb_FormSmallImgTxt"
Background="#202127"
Tag="Small Image Text"/>
<Button Height="30"
Width="65"
Style="{StaticResource UniversalMaterialButton}"
Name="DiscordRpcSave"
Click="DiscordRpcSave_Click"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Grid.Column="1"
Margin="20,0,0,5"
Background="#212329"
Content="Save"/>
<Button Height="30"
Width="65"
Style="{StaticResource UniversalMaterialButton}"
Name="DiscordRpcStop"
Click="DiscordRpcStop_Click"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Margin="70,0,0,5"
Background="#212329"
Content="Stop"/>
<Button Height="30"
Width="65"
Style="{StaticResource UniversalMaterialButton}"
Name="DiscordRpcStart"
Click="DiscordRpcStart_Click"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Margin="0,0,0,5"
Background="#212329"
Content="Start"/>
<Button Height="30"
Width="65"
Style="{StaticResource UniversalMaterialButton}"
Name="DiscordRpcNew"
Click="DiscordRpcNew_Click"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Margin="140,0,0,5"
Background="#212329"
Content="New"/>
</Grid>
<Border Grid.Row="1"
CornerRadius="4">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1b1c21" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<ScrollViewer Grid.Column="0" Background="Transparent" VerticalScrollBarVisibility="Hidden" Foreground="White"
Padding="5,5,5,5" Name="LogViewer">
<StackPanel>
<StackPanel>
<ItemsControl x:Name="ListViewVersions" ItemsSource="{Binding version}" Loaded="ListViewVersions_OnLoaded"
>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Border Height="30" CornerRadius="4" Margin="0,3,0,0" Name="ParentBorder"
Opacity="0">
<Border.Triggers>
<!-- Animate the button's Width property. -->
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ParentBorder"
Storyboard.TargetProperty="(Border.Opacity)"
To="1" Duration="0:0:00.5" AutoReverse="False"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="{Binding GradientColor1}" />
<GradientStop Offset="1" Color="{Binding GradientColor2}" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<TextBlock Margin="5 0" Text="{Binding Content}" FontSize="12"
Foreground="White"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Padding="10,0,0,0">
<TextBlock.Effect>
<DropShadowEffect ShadowDepth="1"/>
</TextBlock.Effect>
</TextBlock>
</Border>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Border>
</Grid>
</Grid>
</UserControl>

View file

@ -1,321 +0,0 @@
using Nocksoft.IO.ConfigFiles;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using WeeXnes.Core;
using WeeXnes.RPC;
namespace WeeXnes.MVVM.View
{
/// <summary>
/// Interaktionslogik für DiscordRpcView.xaml
/// </summary>
public partial class DiscordRpcView : UserControl
{
public List<customEvent> events = new List<customEvent>();
//static bool shouldBeRunning = false;
BackgroundWorker backgroundWorker = new BackgroundWorker();
List<Game> Games = new List<Game>();
Game lastSelectedGame = null;
public static customEvent logContent = null;
public static UpdateVar<string> triggerLogupdate = new UpdateVar<string>();
public DiscordRpcView()
{
CheckFolders();
InitializeComponent();
triggerLogupdate.ValueChanged += () =>
{
if(logContent != null)
{
writeLog(logContent);
}
};
InitializeSettings();
CheckForAutostart();
}
public void CheckFolders()
{
if (!Globals.settings_RpcItemsPath_Bool.Value)
{
Globals.settings_RpcItemsPath.Value = Globals.settings_RpcItemsPath_Default;
}
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)
{
Globals.info_RpcAutoStart = false;
runBackgroundWorker();
}
}
private void InitializeSettings()
{
backgroundWorker.WorkerReportsProgress = true;
backgroundWorker.WorkerSupportsCancellation = true;
backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;
backgroundWorker.DoWork += BackgroundWorker_DoWork;
Refresh();
}
public void writeLog(customEvent _content, bool _timestamp = true)
{
string timestamp = DateTime.Now.ToString("HH:mm:ss");
this.Dispatcher.Invoke(() =>
{
ListViewVersions.Items.Add(_content);
LogViewer.ScrollToEnd();
});
}
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
Globals.info_isRpcRunning = true;
writeLog(new customEvent("Thread Started", EventType.ProcessStartedEvent));
bool runWorker = true;
int delay = 2000;
while (runWorker)
{
if (backgroundWorker.CancellationPending)
{
runWorker = false;
delay = 0;
foreach (Game game in Games)
{
game.stop();
}
}
Process[] processes = Process.GetProcesses();
foreach (Game game in Games)
{
game.checkState(processes);
}
Thread.Sleep(delay);
}
}
private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Globals.info_isRpcRunning = false;
foreach(Game game in Games)
{
game.isRunning = false;
}
writeLog(new customEvent("Thread Closed",EventType.ProcessStoppedEvent));
}
public void runBackgroundWorker()
{
try
{
backgroundWorker.RunWorkerAsync();
}
catch (Exception e)
{
Misc.Message message = new Misc.Message(e.ToString());
message.Show();
}
}
public void stopBackgroundWorker()
{
try
{
backgroundWorker.CancelAsync();
}
catch (Exception e)
{
Misc.Message message = new Misc.Message(e.ToString());
message.Show();
}
}
public void Refresh()
{
readRpcFileDirectory();
LoadGamesIntoListBox();
}
public void generateNewGame()
{
string filename = Guid.NewGuid().ToString() + ".rpc";
Game newGame = new Game(filename, generateIncrementalName(), null, Globals.settings_RpcDefaultClientID.Value);
saveGameToFile(newGame);
}
public string generateIncrementalName()
{
Random random = new Random();
int randomInt = random.Next(1000);
return "New Game " + randomInt;
}
public void saveGameToFile(Game game)
{
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);
rpcFile.SetValue("config", "state", game.state);
rpcFile.SetValue("config", "details", game.details);
rpcFile.SetValue("config", "BigImgKey", game.bigimgkey);
rpcFile.SetValue("config", "SmallImgKey", game.smallimgkey);
rpcFile.SetValue("config", "BigImgText", game.bigimgtext);
rpcFile.SetValue("config", "SmallImgText", game.smallimgtext);
rpcFile.SetValue("config", "FileName", game.fileName);
}
public void deleteGameFile(Game game)
{
try
{
File.Delete(Globals.settings_RpcItemsPath.Value + "\\" + game.fileName);
}
catch (Exception e)
{
Misc.Message message = new Misc.Message(e.ToString());
message.Show();
}
}
public void readRpcFileDirectory()
{
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.Value, "*.rpc", SearchOption.AllDirectories);
foreach (string file in files)
{
INIFile rpcFile = new INIFile(file);
string Name = rpcFile.GetValue("config", "name");
string ProcessName = rpcFile.GetValue("config", "pname");
string id = rpcFile.GetValue("config", "id");
string state = rpcFile.GetValue("config", "state");
string details = rpcFile.GetValue("config", "details");
string bigimgkey = rpcFile.GetValue("config", "BigImgKey");
string smallimgkey = rpcFile.GetValue("config", "SmallImgKey");
string bigimgtxt = rpcFile.GetValue("config", "BigImgText");
string smallimgtxt = rpcFile.GetValue("config", "SmallImgText");
string FileName = rpcFile.GetValue("config", "FileName");
Game newGame = new Game(FileName, Name, ProcessName, id, state, details, bigimgkey, smallimgkey, bigimgtxt, smallimgtxt);
readGames.Add(newGame);
}
Games.Clear();
foreach (Game game in readGames)
{
//Console.WriteLine("Added " + game + " from file");
Games.Add(game);
}
}
}
public void LoadGamesIntoListBox()
{
RpcItemList.Items.Clear();
foreach (Game game in Games)
{
RpcItemList.Items.Add(game);
}
}
private void RpcItemList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (RpcItemList.SelectedItem != null)
{
Game selectedGame = RpcItemList.SelectedItem as Game;
lastSelectedGame = selectedGame;
tb_FormPName.Text = selectedGame.ProcessName;
tb_FormClient.Text = selectedGame.id;
tb_FormName.Text = selectedGame.Name;
tb_FormState.Text = selectedGame.state;
tb_FormDetails.Text = selectedGame.details;
tb_FormLargeImgKey.Text = selectedGame.bigimgkey;
tb_FormLargeImgTxt.Text = selectedGame.bigimgtext;
tb_FormSmallImgKey.Text = selectedGame.smallimgkey;
tb_FormSmallImgTxt.Text = selectedGame.smallimgtext;
}
}
private void RpcItemList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (RpcItemList.SelectedItem != null)
{
deleteGameFile((Game)RpcItemList.SelectedItem);
}
Refresh();
}
private void DiscordRpcSave_Click(object sender, RoutedEventArgs e)
{
Game selectedItem = lastSelectedGame;
if (selectedItem != null)
{
Game editedGame = new Game(
selectedItem.fileName,
tb_FormName.Text,
tb_FormPName.Text,
tb_FormClient.Text,
tb_FormState.Text,
tb_FormDetails.Text,
tb_FormLargeImgKey.Text,
tb_FormSmallImgKey.Text,
tb_FormLargeImgTxt.Text,
tb_FormSmallImgTxt.Text
);
saveGameToFile(editedGame);
}
Refresh();
}
private void DiscordRpcStop_Click(object sender, RoutedEventArgs e)
{
stopBackgroundWorker();
}
private void DiscordRpcStart_Click(object sender, RoutedEventArgs e)
{
runBackgroundWorker();
}
private void DiscordRpcNew_Click(object sender, RoutedEventArgs e)
{
generateNewGame();
Refresh();
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
stopBackgroundWorker();
}
private void ListViewVersions_OnLoaded(object sender, RoutedEventArgs e)
{
}
}
}

View file

@ -1,35 +0,0 @@
<UserControl x:Class="WeeXnes.MVVM.View.HomeView"
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:WeeXnes.MVVM.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel>
<TextBlock Text="Welcome to WeeXnes Hub"
Foreground="White"
FontSize="28"
Margin="0,0,0,20"
Name="WelcomeMSG"
HorizontalAlignment="Center"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="300"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image RenderOptions.BitmapScalingMode="HighQuality"
Source="/Images/wicon.png" Grid.Row="0"
HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" />
<TextBlock Text="WeeXnes Hub" Grid.Row="1"
Foreground="White"
FontFamily="/Fonts/#Poppins"
FontSize="28"
HorizontalAlignment="Center"
Name="VersionInfo"
/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WeeXnes.Core;
namespace WeeXnes.MVVM.View
{
/// <summary>
/// Interaktionslogik für HomeView.xaml
/// </summary>
public partial class HomeView : UserControl
{
public HomeView()
{
InitializeComponent();
SetWelcomeMSG();
SetVersionInfo();
}
private void SetVersionInfo()
{
VersionInfo.Text = VersionInfo.Text + " v" + Globals.version;
}
private void SetWelcomeMSG()
{
WelcomeMSG.Text = "Welcome, " + Environment.UserName;
}
}
}

View file

@ -1,91 +0,0 @@
<UserControl x:Class="WeeXnes.MVVM.View.KeyManagerView"
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:WeeXnes.MVVM.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="430"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Loaded="StackPanel_Loaded"
Grid.Row="0">
<TextBlock Text="Key Manager"
Foreground="White"
FontSize="25"
HorizontalAlignment="Center"
Margin="0,0,0,20"/>
<Grid>
<Border
CornerRadius="4"
Height="375">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1b1c21" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<ListView Name="KeyListView"
Background="Transparent"
Foreground="White"
BorderThickness="0"
SelectionChanged="KeyListView_SelectionChanged" MouseDoubleClick="KeyListView_MouseDoubleClick"
>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding name}"
Grid.Column="0"/>
<TextBlock Text="{Binding value}"
Grid.Column="1"
Name="monkeman"
Loaded="Key_OnLoaded"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBox Name="Textbox_Name"
Height="30"
HorizontalAlignment="Left"
Width="250"
Style="{StaticResource MaterialTextBox}"
Background="#1c1e23" Tag="Name"/>
<TextBox Name="Textbox_Value"
Height="30"
HorizontalAlignment="Right"
Width="250"
Margin="15,0,0,0"
Style="{StaticResource MaterialTextBox}"
Background="#1c1e23" Tag="Value"/>
<Button Width="90"
Height="30"
Name="AddButton"
Margin="15,0,0,0"
Click="AddButton_Click"
Content="Add"
Background="#1c1e23"
Style="{StaticResource UniversalMaterialButton}"
/>
</StackPanel>
</Grid>
</UserControl>

View file

@ -1,267 +0,0 @@
using System;
using System.Collections.Generic;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WeeXnes.Keys;
using WeeXnes.Core;
using wx;
using System.IO;
using System.ComponentModel;
namespace WeeXnes.MVVM.View
{
/// <summary>
/// Interaktionslogik für KeyManagerView.xaml
/// </summary>
public partial class KeyManagerView : UserControl
{
public KeyManagerView()
{
CheckForFolders();
InitializeComponent();
Globals.searchbox_content.ValueChanged += () => { SearchboxChanged(); };
}
public void SearchboxChanged()
{
Console.WriteLine("Searchbox: " + Globals.searchbox_content.Value);
KeyListView.Items.Clear();
List<KeyItem> items = new List<KeyItem>();
foreach(KeyItem item in KeyManagerLib.KeyList)
{
if(Contains(item.name, Globals.searchbox_content.Value, StringComparison.OrdinalIgnoreCase))
{
items.Add(item);
}
}
if(items.Count > 0)
{
foreach(KeyItem item in items)
{
KeyListView.Items.Add(item);
}
}
else
{
KeyListView.Items.Clear();
}
}
public bool Contains(string source, string toCheck, StringComparison comp)
{
return source?.IndexOf(toCheck, comp) >= 0;
}
#region ListControls
public void FillList()
{
Console.WriteLine("->Filling Listview");
KeyListView.Items.Clear();
foreach (KeyItem key in KeyManagerLib.KeyList)
{
KeyListView.Items.Add(key);
}
}
public void AddItemFromUI()
{
if (!String.IsNullOrEmpty(Textbox_Name.Text))
{
if (!String.IsNullOrEmpty(Textbox_Value.Text))
{
KeyItem newkey = new KeyItem(Textbox_Name.Text, Textbox_Value.Text);
KeyManagerLib.KeyList.Add(newkey);
string filename = Globals.settings_KeyManagerItemsPath.Value + "\\" + Guid.NewGuid().ToString() + ".wx";
string[] filecontent = new string[] { "##WXfile##", newkey.name, EncryptionLib.EncryptorLibary.encrypt(Globals.encryptionKey, newkey.value) };
/*
INIFile newini = new INIFile(filename, true);
newini.SetValue("key", "name", newkey.name);
newini.SetValue("key", "value", newkey.value);
*/
EncryptionLib.EncryptorLibary.writeFile(filecontent, filename);
Console.WriteLine("Added: <" + newkey.name + "> Value: " + newkey.value);
}
}
}
public void AddItem(string _name, string _value)
{
KeyItem newkey = new KeyItem(_name, _value);
KeyManagerLib.KeyList.Add(newkey);
}
public void PrintList()
{
Console.WriteLine("-------------------------------");
foreach (KeyItem item in KeyManagerLib.KeyList)
{
Console.WriteLine(item.name + ": " + item.value);
}
}
#endregion
private void StackPanel_Loaded(object sender, RoutedEventArgs e)
{
KeyManagerLib.KeyList.Clear();
if (!SaveInterface.IsDirectoryEmpty(Globals.settings_KeyManagerItemsPath.Value))
{
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath.Value);
foreach (string file in files)
{
Console.WriteLine(file);
try
{
wxfile inifile = new wxfile(file);
string name = inifile.GetName();
string value = inifile.GetValue();
value = EncryptionLib.EncryptorLibary.decrypt(Globals.encryptionKey, value);
if (name != null && value != null)
{
KeyItem newitem = new KeyItem(name, value);
KeyManagerLib.KeyList.Add(newitem);
Console.WriteLine("Added Item: <" + newitem.name + ">");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
FillList();
}
}
}
private void CheckForFolders()
{
if (!Globals.settings_KeyManagerItemsPath_Bool.Value)
{
Globals.settings_KeyManagerItemsPath.Value = Globals.settings_KeyManagerItemsPath_Default;
}
if (!Directory.Exists(Globals.AppDataPath))
{
Directory.CreateDirectory(Globals.AppDataPath);
Console.WriteLine("Created AppDataPath");
}
if (!Directory.Exists(Globals.settings_KeyManagerItemsPath.Value))
{
Directory.CreateDirectory(Globals.settings_KeyManagerItemsPath.Value);
Console.WriteLine("Created settings_KeyManagerItemsPath");
}
}
private void AddButton_Click(object sender, RoutedEventArgs e)
{
AddItemFromUI();
FillList();
ClearInputs();
}
private void DebugBtn_Click(object sender, RoutedEventArgs e)
{
PrintList();
}
private void RefreshBtn_Click(object sender, RoutedEventArgs e)
{
FillList();
}
private void KeyListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
KeyItem selectedItem = (KeyItem)KeyListView.SelectedItem;
if(selectedItem != null)
{
Console.WriteLine(selectedItem.name + ": " + selectedItem.value);
if (Globals.settings_copySelectedToClipboard.Value)
{
Clipboard.SetText(selectedItem.value);
}
Console.WriteLine("Copied: " + selectedItem.value + " to Clipboard");
}
}
private void KeyListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
KeyItem selectedItem = (KeyItem)KeyListView.SelectedItem;
Console.WriteLine("Doubleclicked " + selectedItem.name);
KeyManagerLib.KeyList.Remove(selectedItem);
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath.Value);
foreach (string file in files)
{
Console.WriteLine(file);
try
{
wxfile inifile = new wxfile(file);
string name = inifile.GetName();
string value = inifile.GetValue();
if(name == selectedItem.name)
{
File.Delete(file);
Console.WriteLine("Removed File: " + file);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
FillList();
}
private void ClearInputs()
{
Textbox_Name.Clear();
Textbox_Value.Clear();
}
private void addNameClip_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
Console.WriteLine("fnmgikegnmek");
}
private void Key_OnLoaded(object sender, RoutedEventArgs e)
{
if (Globals.settings_KeyManagerCensorKeys.Value)
{
TextBlock tb = (TextBlock)sender;
int text_size = tb.Text.Length;
string censored_string = "";
for (int i = 0; i <= text_size; i++)
censored_string = censored_string + "•";
tb.Text = censored_string;
}
}
}
public static class SaveInterface
{
public static bool IsDirectoryEmpty(string path)
{
return !Directory.EnumerateFileSystemEntries(path).Any();
}
public static string[] GetFilesInDir(string path)
{
return Directory.GetFiles(path, "*.wx");
}
}
}

View file

@ -1,254 +0,0 @@
<UserControl x:Class="WeeXnes.MVVM.View.SettingView"
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:WeeXnes.MVVM.View"
mc:Ignorable="d"
d:DesignHeight="2000" d:DesignWidth="800">
<ScrollViewer>
<Grid >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0"
CornerRadius="4"
Margin="10,10,10,10"
Padding="0,0,0,5">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1b1c21" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Vertical">
<Label Content="General"
Foreground="White"
HorizontalAlignment="Center"
FontSize="23"/>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="AlwaysOnTopSwitch"
Checked="AlwaysOnTopSwitch_Checked"
Unchecked="AlwaysOnTopSwitch_Unchecked"
Margin="10,10,0,0">
<TextBlock
Text="Always On Top"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="OSXSwitch"
Checked="OSXSwitch_OnChecked"
Unchecked="OSXSwitch_OnUnchecked"
Margin="10,10,0,0">
<TextBlock
Text="Enable OSX Style (Restart Required)"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<Button Name="CheckForUpdateBtn"
Style="{StaticResource UniversalMaterialButton}"
Content="Check for Updates"
Background="#2f313b"
Height="25"
Click="CheckForUpdateBtn_OnClick"
Margin="4,10,4,0"/>
<Button Name="createShortcut"
Style="{StaticResource UniversalMaterialButton}"
Content="Create Startmenu Entry"
Background="#2f313b"
Height="25"
Click="CreateShortcut_OnClick"
Margin="4,10,4,0"/>
<Button Name="OpenAppdataFolder" Grid.Row="1"
Style="{StaticResource UniversalMaterialButton}"
Content="Open AppData Folder"
Background="#2f313b"
Height="25"
Margin="4,10,4,0"
Click="OpenAppdataFolder_Click"/>
</StackPanel>
</Border>
<Border Grid.Row="1"
CornerRadius="4"
Margin="10,10,10,10"
Padding="0,0,0,5">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1b1c21" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Vertical">
<Label Content="RPC"
Foreground="White"
HorizontalAlignment="Center"
FontSize="23"/>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="ShowElapsedTimeOnRpc"
Checked="ShowElapsedTimeOnRpc_Checked"
Unchecked="ShowElapsedTimeOnRpc_Unchecked"
Margin="10,10,0,0">
<TextBlock
Text="Show Elapsed Time"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<Label Content="Default RPC ClientID:"
Margin="0,0,0,0"
FontSize="13"
Foreground="White"
HorizontalAlignment="Center"/>
<TextBox Style="{StaticResource MaterialTextBox}"
Margin="4,0,4,0"
Name="tb_DefaultClientID"
Background="#2f313b"
Tag="Default Client ID"/>
<Button Name="SaveDefaultID"
Style="{StaticResource UniversalMaterialButton}"
Content="Set Default ClientID"
Background="#2f313b"
Height="25"
Click="SaveDefaultID_Click"
Margin="4,10,4,0"/>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="EnableAutoStart"
Margin="10,10,0,0">
<TextBlock
Text="Enable RPC autostart"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<Label Content="Placeholder" HorizontalAlignment="Center"
FontSize="13"
Foreground="White"
Name="RpcPathLabel"/>
<Button Name="SetRpcLocation"
Style="{StaticResource UniversalMaterialButton}"
Content="Set Rpc Files Path"
Background="#2f313b"
Height="25"
Click="SetRpcLocation_OnClick"
Margin="4,10,4,0"/>
<Button Name="SetRpcLocationDefault"
Style="{StaticResource UniversalMaterialButton}"
Content="Set Default Path"
Background="#2f313b"
Height="25"
Click="SetRpcLocationDefault_OnClick"
Margin="4,10,4,0"/>
</StackPanel>
</Border>
<Border Grid.Row="2"
CornerRadius="4"
Margin="10,10,10,10"
Padding="0,0,0,5">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1b1c21" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Vertical">
<Label Content="Key Manager"
Foreground="White"
HorizontalAlignment="Center"
FontSize="23"/>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="ItemToClipboardSwitch"
Checked="ItemToClipboardSwitch_Checked"
Unchecked="ItemToClipboardSwitch_Unchecked"
Margin="10,10,0,0">
<TextBlock
Text="Selected Item to Clipboard"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<CheckBox VerticalAlignment="Top"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Name="CensorKeysSwitch"
Checked="CensorKeysSwitch_OnChecked"
Unchecked="CensorKeysSwitch_OnUnchecked"
Margin="10,10,0,0">
<TextBlock
Text="Censor Keys Visually"
VerticalAlignment="Center"
FontSize="15"
Foreground="White"/>
</CheckBox>
<Label Content="Placeholder" HorizontalAlignment="Center"
FontSize="13"
Foreground="White"
Name="KeyPathLabel"/>
<Button Name="SetKeyLocation"
Style="{StaticResource UniversalMaterialButton}"
Content="Set Key Files Path"
Background="#2f313b"
Height="25"
Click="SetKeyLocation_OnClick"
Margin="4,10,4,0"/>
<Button Name="SetKeyLocationDefault"
Style="{StaticResource UniversalMaterialButton}"
Content="Set Default Path"
Background="#2f313b"
Height="25"
Click="SetKeyLocationDefault_OnClick"
Margin="4,10,4,0"/>
</StackPanel>
</Border>
</Grid>
</ScrollViewer>
</UserControl>

View file

@ -1,349 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Newtonsoft.Json;
using Nocksoft.IO.ConfigFiles;
using WeeXnes.Core;
using WeeXnes.Misc;
using Application = System.Windows.Forms.Application;
using Message = WeeXnes.Misc.Message;
using MessageBox = System.Windows.MessageBox;
using Path = System.IO.Path;
using UserControl = System.Windows.Controls.UserControl;
namespace WeeXnes.MVVM.View
{
/// <summary>
/// Interaktionslogik für SettingView.xaml
/// </summary>
public partial class SettingView : UserControl
{
public SettingView()
{
InitializeComponent();
//LoadUiFromSettingsFile();
SetFunction();
SetUiUpdateListeners();
InitializeUi();
//UpdatePathsOnUi();
}
public void InitializeUi()
{
if (!String.IsNullOrEmpty(Globals.settings_RpcItemsPath.Value))
{
RpcPathLabel.Content = Globals.settings_RpcItemsPath.Value;
}
else
{
RpcPathLabel.Content = Globals.settings_RpcItemsPath_Default;
}
if (!String.IsNullOrEmpty(Globals.settings_KeyManagerItemsPath.Value))
{
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath.Value;
}
else
{
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath_Default;
}
if (Globals.settings_alwaysOnTop.Value)
{
AlwaysOnTopSwitch.IsChecked = true;
}
if (Globals.settings_osxStyleControlls.Value)
{
OSXSwitch.IsChecked = true;
}
if (Globals.settings_RpcAutoStart.Value)
{
UnsetFunction();
EnableAutoStart.IsChecked = true;
SetFunction();
}
if (Globals.settings_RpcShowElapsedTime.Value)
{
ShowElapsedTimeOnRpc.IsChecked = true;
}
if (Globals.settings_copySelectedToClipboard.Value)
{
ItemToClipboardSwitch.IsChecked = true;
}
if (Globals.settings_KeyManagerCensorKeys.Value)
{
CensorKeysSwitch.IsChecked = true;
}
tb_DefaultClientID.Text = Globals.settings_RpcDefaultClientID.Value;
}
private void SetUiUpdateListeners()
{
Globals.settings_RpcItemsPath.ValueChanged += () =>
{
if (!String.IsNullOrEmpty(Globals.settings_RpcItemsPath.Value))
{
RpcPathLabel.Content = Globals.settings_RpcItemsPath.Value;
}
else
{
RpcPathLabel.Content = Globals.settings_RpcItemsPath_Default;
}
};
Globals.settings_KeyManagerItemsPath.ValueChanged += () =>
{
if (!String.IsNullOrEmpty(Globals.settings_KeyManagerItemsPath.Value))
{
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath.Value;
}
else
{
KeyPathLabel.Content = Globals.settings_KeyManagerItemsPath_Default;
}
};
}
private void SetFunction()
{
EnableAutoStart.Checked += EnableAutoStart_Checked;
EnableAutoStart.Unchecked += EnableAutoStart_Unchecked;
}
private void UnsetFunction()
{
EnableAutoStart.Checked -= EnableAutoStart_Checked;
EnableAutoStart.Unchecked -= EnableAutoStart_Unchecked;
}
private void AlwaysOnTopSwitch_Checked(object sender, RoutedEventArgs e)
{
Globals.settings_alwaysOnTop.Value = true;
}
private void AlwaysOnTopSwitch_Unchecked(object sender, RoutedEventArgs e)
{
Globals.settings_alwaysOnTop.Value = false;
}
private void ShowElapsedTimeOnRpc_Checked(object sender, RoutedEventArgs e)
{
Globals.settings_RpcShowElapsedTime.Value = true;
}
private void ShowElapsedTimeOnRpc_Unchecked(object sender, RoutedEventArgs e)
{
Globals.settings_RpcShowElapsedTime.Value = false;
}
private void ItemToClipboardSwitch_Checked(object sender, RoutedEventArgs e)
{
Globals.settings_copySelectedToClipboard.Value = true;
}
private void ItemToClipboardSwitch_Unchecked(object sender, RoutedEventArgs e)
{
Globals.settings_copySelectedToClipboard.Value = false;
}
private void OpenAppdataFolder_Click(object sender, RoutedEventArgs e)
{
Process.Start(Globals.AppDataPath);
}
private void SaveDefaultID_Click(object sender, RoutedEventArgs e)
{
if (!String.IsNullOrEmpty(tb_DefaultClientID.Text))
{
Globals.settings_RpcDefaultClientID.Value = tb_DefaultClientID.Text;
}
else
{
Misc.Message message = new Misc.Message("Dont leave ClientID empty");
message.Show();
}
}
public void switchAutoRpc(bool on)
{
UnsetFunction();
if (on)
{
Globals.settings_RpcAutoStart.Value = true;
EnableAutoStart.IsChecked = true;
}
else
{
Globals.settings_RpcAutoStart.Value = false;
EnableAutoStart.IsChecked = false;
}
SetFunction();
}
private void EnableAutoStart_Checked(object sender, RoutedEventArgs e)
{
bool proc_suc;
try
{
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-EnableAutostart");
uacpromp.WaitForExit();
proc_suc = true;
}
catch (Exception ex)
{
Misc.Message message = new Misc.Message(ex.ToString());
message.Show();
proc_suc = false;
}
switchAutoRpc(proc_suc);
}
private void EnableAutoStart_Unchecked(object sender, RoutedEventArgs e)
{
bool proc_suc;
try
{
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-DisableAutostart");
uacpromp.WaitForExit();
proc_suc = false;
}
catch (Exception ex)
{
Misc.Message message = new Misc.Message(ex.ToString());
message.Show();
proc_suc = true;
}
switchAutoRpc(proc_suc);
}
private void SetKeyLocationDefault_OnClick(object sender, RoutedEventArgs e)
{
Globals.settings_KeyManagerItemsPath_Bool.Value = false;
Globals.settings_KeyManagerItemsPath.Value = "";
}
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))
{
Globals.settings_KeyManagerItemsPath_Bool.Value = true;
Globals.settings_KeyManagerItemsPath.Value = fbd.SelectedPath;
//MessageBox.Show("valid path: " + fbd.SelectedPath);
}
}
}
private void SetRpcLocationDefault_OnClick(object sender, RoutedEventArgs e)
{
Globals.settings_RpcItemsPath_Bool.Value = false;
Globals.settings_RpcItemsPath.Value = "";
}
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))
{
Globals.settings_RpcItemsPath_Bool.Value = true;
Globals.settings_RpcItemsPath.Value = fbd.SelectedPath;
}
}
}
private void CheckForUpdateBtn_OnClick(object sender, RoutedEventArgs e)
{
WebClient client = new WebClient();
try
{
string downloadString = client.DownloadString(Globals.apiUrl);
ApiResponse GitHub = JsonConvert.DeserializeObject<ApiResponse>(downloadString);
if (GitHub.tag_name != Globals.version)
{
Misc.UpdateMessage updateMessage = new UpdateMessage(
GitHub,
"Update Found");
updateMessage.Show();
}
else
{
Misc.Message msg = new Misc.Message("No Updates found");
msg.Show();
}
}
catch (Exception ex)
{
Misc.Message error = new Misc.Message(ex.ToString());
error.Show();
}
}
private void CreateShortcut_OnClick(object sender, RoutedEventArgs e)
{
try
{
Process p = Process.Start("WeeXnes_UAC.exe", "-CreateStartMenuShortcut");
p.WaitForExit();
}
catch (Exception ex)
{
Misc.CriticalMessage message = new Misc.CriticalMessage(ex.ToString());
message.Show();
}
}
private void CensorKeysSwitch_OnChecked(object sender, RoutedEventArgs e)
{
Globals.settings_KeyManagerCensorKeys.Value = true;
}
private void CensorKeysSwitch_OnUnchecked(object sender, RoutedEventArgs e)
{
Globals.settings_KeyManagerCensorKeys.Value = false;
}
private void OSXSwitch_OnChecked(object sender, RoutedEventArgs e)
{
Globals.settings_osxStyleControlls.Value = true;
}
private void OSXSwitch_OnUnchecked(object sender, RoutedEventArgs e)
{
Globals.settings_osxStyleControlls.Value = false;
}
}
}

View file

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.MVVM.ViewModel
{
internal class DiscordRpcViewModel
{
}
}

View file

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.MVVM.ViewModel
{
internal class HomeViewModel
{
}
}

View file

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.MVVM.ViewModel
{
internal class KeyManagerViewModel
{
}
}

View file

@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeeXnes.Core;
namespace WeeXnes.MVVM.ViewModel
{
internal class MainViewModel : ObservableObject
{
public RelayCommand HomeViewCommand { get; set; }
public RelayCommand KeyManagerViewCommand { get; set; }
public RelayCommand DiscordRpcViewCommand { get; set; }
public RelayCommand SettingsViewCommand { get; set; }
public HomeViewModel HomeVM { get; set; }
public KeyManagerViewModel KeyManagerVM { get; set; }
public DiscordRpcViewModel DiscordRpcVM { get; set; }
public SettingsViewModel SettingsVM { get; set; }
private object _currentView;
public object CurrentView
{
get { return _currentView; }
set
{
_currentView = value;
OnPropertyChanged();
}
}
public MainViewModel()
{
HomeVM = new HomeViewModel();
KeyManagerVM = new KeyManagerViewModel();
DiscordRpcVM = new DiscordRpcViewModel();
SettingsVM = new SettingsViewModel();
CurrentView = HomeVM;
HomeViewCommand = new RelayCommand(o =>
{
CurrentView = HomeVM;
});
KeyManagerViewCommand = new RelayCommand(o =>
{
CurrentView = KeyManagerVM;
});
DiscordRpcViewCommand = new RelayCommand(o =>
{
CurrentView = DiscordRpcVM;
});
SettingsViewCommand = new RelayCommand(o =>
{
CurrentView = SettingsVM;
});
}
}
}

View file

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeXnes.MVVM.ViewModel
{
internal class SettingsViewModel
{
}
}

View file

@ -1,385 +1,94 @@
<Window x:Class="WeeXnes.MainWindow"
<ui:UiWindow x:Class="WeeXnes.MainWindow"
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:WeeXnes"
xmlns:viewModel="clr-namespace:WeeXnes.MVVM.ViewModel"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:home="clr-namespace:WeeXnes.Views.Home"
xmlns:keymanager="clr-namespace:WeeXnes.Views.KeyManager"
xmlns:settings="clr-namespace:WeeXnes.Views.Settings"
xmlns:discordrpc="clr-namespace:WeeXnes.Views.DiscordRPC"
mc:Ignorable="d"
Height="632"
Width="952"
WindowStyle="None"
ResizeMode="NoResize"
Background="Transparent"
AllowsTransparency="True"
Height="400"
Width="500"
Title="WeeXnes"
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded"
Deactivated="Window_Deactivated"
StateChanged="Window_StateChanged"
Closing="Window_Closing">
<Window.DataContext>
<viewModel:MainViewModel/>
</Window.DataContext>
<Border
CornerRadius="4"
MouseDown="Border_MouseDown"
Name="window_border"
Margin="16">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#2c2e36" />
<GradientStop Offset="1" Color="#212329" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="0"/>
</Border.Effect>
Background="{DynamicResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
<RowDefinition Height="50"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ui:TitleBar
Grid.Row="0"
Title="WeeXnes Suite"
ForceShutdown="False"
MinimizeToTray="False"
ShowHelp="False"
ShowClose="True"
ShowMaximize="True"
ShowMinimize="True"
UseSnapLayout="True">
<ui:TitleBar.Tray>
<ui:NotifyIcon Icon="/Images/wicon.png">
<!--
<ui:NotifyIcon.Menu>
<ContextMenu>
</ContextMenu>
</ui:NotifyIcon.Menu>
-->
</ui:NotifyIcon>
</ui:TitleBar.Tray>
<Border Grid.Row="1" Width="50" Name="NavigationBorder"
Margin="5,0,0,0">
<Border.Triggers>
</ui:TitleBar>
<!-- Animate the button's Width property. -->
<EventTrigger RoutedEvent="Border.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="NavigationBorder"
Storyboard.TargetProperty="(Border.Width)"
To="200" Duration="0:0:00.4" AutoReverse="False"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Border.MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="NavigationBorder"
Storyboard.TargetProperty="(Border.Width)"
To="50" Duration="0:0:00.4" AutoReverse="False"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<StackPanel Name="NavigationBar">
<RadioButton Content="Home"
Height="50"
Foreground="White"
FontSize="14"
Style="{StaticResource HomeMenuButton}"
IsChecked="True"
Command="{Binding HomeViewCommand}"
Name="HomeMenuButton"
Tag="/Images/wicon.png"/>
<RadioButton Content="Key Manager"
Height="50"
Foreground="White"
FontSize="14"
Style="{StaticResource KeyManagerMenuButton}"
Command="{Binding KeyManagerViewCommand}"
Name="KMMenuButton"/>
<RadioButton Content="DiscordRPC"
Height="50"
Foreground="White"
FontSize="14"
Style="{StaticResource DiscordMenuButton}"
Command="{Binding DiscordRpcViewCommand}"
Name="RpcMenuButton"/>
<RadioButton Content="Settings"
Height="50"
Foreground="White"
FontSize="14"
Style="{StaticResource SettingsMenuButton}"
Command="{Binding SettingsViewCommand}"
Name="SettingsMenuButton"/>
</StackPanel>
</Border>
<TextBox Grid.Column="1"
Width="250"
Height="40"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="10,5,5,5"
Style="{StaticResource MaterialTextBox}"
Background="#212329" Tag="Search..."
TextChanged="Searchbox_TextChanged"
Name="Searchbox"
/>
<Button Width="50"
Height="23"
Name="MinimizeBtn"
Click="MinimizeBtn_Click"
Content="―"
FontSize="11"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,0,50,0"
Style="{StaticResource ModernMinimizeButton}"
Grid.Column="1"
Visibility="Hidden"/>
<Button Width="50"
Height="23"
Name="CloseBtn"
Click="CloseBtn_Click"
Content=""
FontSize="11"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Style="{StaticResource ModernCloseButton}"
Grid.Column="1"
Visibility="Hidden"/>
<DockPanel Grid.Column="1" Margin="0,5,5,5"
Height="23"
VerticalAlignment="Top"
HorizontalAlignment="Right" Visibility="Hidden" Name="OSXControlls">
<Button Name="MinimizeButton" Width="20" BorderThickness="0" Background="Transparent"
Style="{StaticResource OSXButtonStyle}" Click="MinimizeBtn_Click">
<StackPanel>
<Image Source="Images\green.png" Margin="1"/>
</StackPanel>
</Button>
<Button Name="MaximizeButton" Width="20" BorderThickness="0" Background="Transparent"
Style="{StaticResource OSXButtonStyle}">
<StackPanel>
<Image Source="Images\yellow.png" Margin="1"/>
</StackPanel>
</Button>
<Button Name="CloseButton" Width="20" BorderThickness="0" Background="Transparent"
Style="{StaticResource OSXButtonStyle}" Click="CloseBtn_Click">
<StackPanel>
<Image Source="Images\red.png" Margin="1"/>
</StackPanel>
</Button>
</DockPanel>
<ContentControl Grid.Row="1"
Grid.Column="1"
Margin="10"
Content="{Binding CurrentView}"/>
</Grid>
</Border>
<Window.Resources>
<Style TargetType="Image">
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
</Style>
<SolidColorBrush x:Key="StandardBorderBrush" Color="#888" />
<SolidColorBrush x:Key="StandardBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="HoverBorderBrush" Color="#DDD" />
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="Gray" />
<SolidColorBrush x:Key="SelectedForegroundBrush" Color="White" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<SolidColorBrush x:Key="NormalBrush" Color="#888" />
<SolidColorBrush x:Key="NormalBorderBrush" Color="#888" />
<SolidColorBrush x:Key="HorizontalNormalBrush" Color="#FF686868" />
<SolidColorBrush x:Key="HorizontalNormalBorderBrush" Color="#888" />
<LinearGradientBrush x:Key="ListBoxBackgroundBrush" StartPoint="0,0" EndPoint="1,0.001">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="White" Offset="0.6" />
<GradientStop Color="#DDDDDD" Offset="1.2"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="StandardBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#CCC" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="0.1"/>
<GradientStop Color="#EEE" Offset="0.9"/>
<GradientStop Color="#FFF" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
<Setter Property="Visibility" Value="Hidden"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Name="Border" Margin="1" CornerRadius="2" Background="{StaticResource NormalBrush}" BorderBrush="{StaticResource NormalBorderBrush}" BorderThickness="1">
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{StaticResource GlyphBrush}" Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="Visibility" Value="Hidden"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Black" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border CornerRadius="4" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Width="8" Margin="8,0,-2,0"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="0"/>
<RowDefinition Height="0.00001*"/>
<RowDefinition MaxHeight="0"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" CornerRadius="2" Background="Transparent" />
<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 8 4 L 4 0 Z" />
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="{StaticResource HorizontalNormalBrush}" BorderBrush="{StaticResource HorizontalNormalBorderBrush}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Row="3" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineDownCommand" Content="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="18"/>
<ColumnDefinition Width="0.00001*"/>
<ColumnDefinition MaxWidth="18"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="3" CornerRadius="2" Background="#F0F0F0"/>
<RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineLeftCommand" Content="M 4 0 L 4 8 L 0 4 Z" />
<Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,1,0,1" Background="{StaticResource NormalBrush}" BorderBrush="{StaticResource NormalBorderBrush}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineRightCommand" Content="M 0 0 L 4 4 L 0 8 Z"/>
</Grid>
</ControlTemplate>
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="18" />
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="18"/>
<Setter Property="Height" Value="Auto" />
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="FavsScrollViewer" TargetType="{x:Type ScrollViewer}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<Grid Margin="8" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter Grid.Column="1"/>
<ScrollBar Name="PART_VerticalScrollBar" Value="{TemplateBinding VerticalOffset}" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Value="{TemplateBinding HorizontalOffset}" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
<ui:NavigationStore
Grid.Column="0"
Frame="{Binding ElementName=MainFrame}"
SelectedPageIndex="0">
<ui:NavigationStore.Items>
<ui:NavigationItem
Content="Home"
Icon="Home24"
PageTag="home"
PageType="{x:Type home:HomeView}"/>
<ui:NavigationItem
Content="Keys"
Icon="Key24"
PageTag="Keys"
PageType="{x:Type keymanager:KeyManagerView}"/>
<ui:NavigationItem
Content="RPC"
Icon="XboxController24"
Name="RPCBtn"
PageTag="RPC"
PageType="{x:Type discordrpc:DiscordRPCView}"/>
</ui:NavigationStore.Items>
<ui:NavigationStore.Footer>
<ui:NavigationItem
Content="Settings"
Icon="Settings24"
PageTag="Settings"
PageType="{x:Type settings:SettingsView}"/>
</ui:NavigationStore.Footer>
</ui:NavigationStore>
<Frame
x:Name="MainFrame"
Grid.Column="1"
Margin="8,0,0,0" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
</Grid>
</ui:UiWindow>
</Window>

View file

@ -1,4 +1,6 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.IO;
using System.Windows;
@ -7,184 +9,23 @@ using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using WeeXnes.Core;
using WeeXnes.MVVM.View;
using Wpf.Ui.Mvvm.Services;
using Button = System.Windows.Controls.Button;
using MessageBox = System.Windows.MessageBox;
namespace WeeXnes
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow
{
System.Windows.Forms.NotifyIcon trayIcon = new System.Windows.Forms.NotifyIcon();
private ContextMenuStrip trayIconMenu = new ContextMenuStrip();
public MainWindow()
{
buildTrayMenu();
trayIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
trayIcon.Visible = false;
trayIcon.DoubleClick += TrayIcon_DoubleClick;
trayIcon.ContextMenuStrip = trayIconMenu;
InitializeComponent();
}
private void buildTrayMenu()
{
trayIconMenu.Items.Add("Show Window",null, (sender, args) =>
{
this.Show();
this.WindowState = WindowState.Normal;
trayIcon.Visible = false;
});
//RPC MENU//////////////////////////////////////////////////////////////////////////////////////
//monke
ToolStripMenuItem DiscordMenu = new ToolStripMenuItem("DiscordRPC");
DiscordMenu.DropDownItems.Add("Stop DiscordRPC",null, (sender, args) =>
{
controllRpcFromTray(false);
});
DiscordMenu.DropDownItems.Add("Start DiscordRPC",null, (sender, args) =>
{
controllRpcFromTray(true);
});
trayIconMenu.Items.Add(DiscordMenu);
////////////////////////////////////////////////////////////////////////////////////////////
trayIconMenu.Items.Add("Exit",null, (sender, args) =>
{
this.Close();
});
trayIconMenu.Opening += (sender, args) =>
{
};
}
public void controllRpcFromTray(bool start)
{
//set tray controlls.
if (start)
{
HomeMenuButton.Command.Execute(null);
HomeMenuButton.IsChecked = true;
Globals.info_RpcAutoStart = true;
RpcMenuButton.Command.Execute(null);
RpcMenuButton.IsChecked = true;
}
else
{
HomeMenuButton.Command.Execute(null);
HomeMenuButton.IsChecked = true;
}
}
private void TrayIcon_DoubleClick(object sender, EventArgs e)
{
this.Show();
this.WindowState = WindowState.Normal;
trayIcon.Visible = false;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CheckForFolders();
CheckForSettingsFile();
CheckForAutoStartup();
}
private void CheckForSettingsFile()
{
//SettingView.CheckSetting();
SettingsManager.start();
if (Globals.settings_osxStyleControlls.Value)
{
OSXControlls.Visibility = Visibility.Visible;
}
else
{
MinimizeBtn.Visibility = Visibility.Visible;
CloseBtn.Visibility = Visibility.Visible;
}
}
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
private void Searchbox_TextChanged(object sender, TextChangedEventArgs e)
{
Globals.searchbox_content.Value = Searchbox.Text;
}
private void CloseBtn_Click(object sender, RoutedEventArgs e)
{
if (Globals.info_isRpcRunning)
{
WindowState = WindowState.Minimized;
}
else
{
this.Close();
}
}
private void MinimizeBtn_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void CheckForAutoStartup()
{
if (Globals.info_RpcAutoStart)
{
WindowState = WindowState.Minimized;
RpcMenuButton.Command.Execute(null);
RpcMenuButton.IsChecked = true;
}
}
private void CheckForFolders()
{
if (!Directory.Exists(Globals.AppDataPath))
{
Directory.CreateDirectory(Globals.AppDataPath);
Console.WriteLine("Created AppDataPath");
}
}
private void Window_Deactivated(object sender, EventArgs e)
{
Window window = (Window)sender;
if (Globals.settings_alwaysOnTop.Value)
{
window.Topmost = true;
}
else
{
window.Topmost = false;
}
}
private void Window_StateChanged(object sender, EventArgs e)
{
if (WindowState == System.Windows.WindowState.Minimized)
{
this.Hide();
trayIcon.Visible = true;
}
}
private void Window_Closing(object sender, CancelEventArgs e)
{
trayIcon.Dispose();
}
}
}

View file

@ -1,53 +0,0 @@
<Window x:Class="WeeXnes.Misc.CriticalMessage"
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:WeeXnes.Misc"
mc:Ignorable="d"
Title="Message" Height="150" Width="300"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
SizeToContent="WidthAndHeight"
Background="Transparent"
AllowsTransparency="True"
WindowStyle="None">
<Border CornerRadius="4"
Margin="16"
MouseDown="UIElement_OnMouseDown">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#8a1c2c" />
<GradientStop Offset="1" Color="#751e2c" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="0"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Placeholder"
Name="MessageLabel"
Foreground="White"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="100,20,100,20"/>
<Button Grid.Row="1"
Style="{StaticResource UniversalMaterialButton}"
Content="OK"
Width="140"
Height="40"
Background="#520b16"
Name="okButton"
Click="okButton_Click"
Margin="0,0,0,20"/>
</Grid>
</Border>
</Window>

View file

@ -1,26 +0,0 @@
using System.Windows;
using System.Windows.Input;
namespace WeeXnes.Misc
{
public partial class CriticalMessage : Window
{
public CriticalMessage(string _message, string _title = "Message")
{
InitializeComponent();
MessageLabel.Content = _message;
this.Title = _title;
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
}
}

View file

@ -1,305 +0,0 @@
/**
* Copyright by Nocksoft
* https://www.nocksoft.de
* https://nocksoft.de/tutorials/visual-c-sharp-arbeiten-mit-ini-dateien/
* https://github.com/Nocksoft/INIFile
* -----------------------------------
* Author: Rafael Nockmann @ Nocksoft
* Updated: 2017-08-23
* Version: 1.0.3
*
* Language: Visual C#
*
* License: MIT license
*
* Description:
* Provides basic functions for working with INI files.
*
* ##############################################################################################
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace Nocksoft.IO.ConfigFiles
{
public class INIFile
{
private string _File;
/// <summary>
/// Aufruf des Konstruktors initialisiert ein Objekt der Klasse INIFile.
/// </summary>
/// <param name="file">INI-Datei, auf der zugegriffen werden soll.</param>
/// <param name="createFile">Gibt an, ob die Datei erstellt werden soll, wenn diese nicht vorhanden ist.</param>
public INIFile(string file, bool createFile = false)
{
if (createFile == true && File.Exists(file) == false)
{
FileInfo fileInfo = new FileInfo(file);
FileStream fileStream = fileInfo.Create();
fileStream.Close();
}
_File = file;
}
#region Öffentliche Methoden
/// <summary>
/// Entfernt alle Kommentare und leeren Zeilen aus einer kompletten Section und gibt diese zurück.
/// Die Methode ist nicht Case-sensitivity und ignoriert daher Groß- und Kleinschreibung.
/// Der Rückgabewert enthält keine Leerzeichen.
/// </summary>
/// <param name="section">Name der angeforderten Section.</param>
/// <param name="getComments">Gibt an, ob Kommentare berücksichtigt werden sollen.</param>
/// <returns>Gibt die komplette Section zurück.</returns>
public List<string> GetSection(string section, bool getComments = false)
{
// Stellt sicher, dass eine Section immer im folgenden Format vorliegt: [section]
section = CheckSection(section);
List<string> completeSection = new List<string>();
bool sectionStart = false;
// Liest die Zieldatei ein
string[] fileArray = File.ReadAllLines(_File);
foreach (var item in fileArray)
{
if (item.Length <= 0) continue;
// Wenn die gewünschte Section erreicht ist
if (item.Replace(" ", "").ToLower() == section)
{
sectionStart = true;
}
// Wenn auf eine neue Section getroffen wird, wird die Schleife beendet
if (sectionStart == true && item.Replace(" ", "").ToLower() != section && item.Replace(" ", "").Substring(0, 1) == "[" && item.Replace(" ", "").Substring(item.Length - 1, 1) == "]")
{
break;
}
if (sectionStart == true)
{
// Wenn der Eintrag kein Kommentar und kein leerer Eintrag ist, wird er der List<string> completeSection hinzugefügt
if (getComments == false
&& item.Replace(" ", "").Substring(0, 1) != ";" && !string.IsNullOrWhiteSpace(item))
{
completeSection.Add(ReplaceScpacesAtStartAndEnd(item));
}
if (getComments == true && !string.IsNullOrWhiteSpace(item))
{
completeSection.Add(ReplaceScpacesAtStartAndEnd(item));
}
}
}
return completeSection;
}
/// <summary>
/// Die Methode gibt einen Wert zum dazugehörigen Key zurück.
/// Die Methode ist nicht Case-sensitivity und ignoriert daher Groß- und Kleinschreibung.
/// </summary>
/// <param name="section">Name der angeforderten Section.</param>
/// <param name="key">Name des angeforderten Keys.</param>
/// <param name="convertKeyToLower">Wenn "true" übergeben wird, wird der Rückgabewert in Kleinbuchstaben zurückgegeben.</param>
/// <returns>Gibt, wenn vorhanden, den Wert zu dem angegebenen Key in der angegeben Section zurück.</returns>
public string GetValue(string section, string key, bool convertValueToLower = false)
{
// Stellt sicher, dass eine Section immer im folgenden Format vorliegt: [section]
section = CheckSection(section);
key = key.ToLower();
List<string> completeSection = GetSection(section);
foreach (var item in completeSection)
{
// In Schleife fortfahren, wenn kein Key
if (!item.Contains("=") && item.Contains("[") && item.Contains("]")) continue;
string[] keyAndValue = item.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (keyAndValue[0].ToLower() == key && keyAndValue.Count() > 1)
{
if (convertValueToLower == true)
{
keyAndValue[1] = keyAndValue[1].ToLower();
}
return keyAndValue[1];
}
}
return null;
}
/// <summary>
/// Ändert einen Wert des dazugehörigen Schlüssels in der angegebenen Section.
/// </summary>
/// <param name="section">Name der Section, in dem sich der Schlüssel befindet.</param>
/// <param name="key">Name des Schlüssels, dessen Wert geändert werden soll.</param>
/// <param name="value">Neuer Wert.</param>
/// <param name="convertValueToLower">Wenn "true" übergeben wird, wird der Wert in Kleinbuchstaben gespeichert.</param>
public void SetValue(string section, string key, string value, bool convertValueToLower = false)
{
// Stellt sicher, dass eine Section immer im folgenden Format vorliegt: [section]
section = CheckSection(section);
string keyToLower = key.ToLower();
// Prüft, ob die gesuchte Section gefunden wurde
bool sectionFound = false;
List<string> newFileContent = new List<string>();
// Liest die Zieldatei ein
string[] fileLines = File.ReadAllLines(_File);
// Wenn die Zieldatei leer ist...
if (fileLines.Length <= 0)
{
newFileContent = CreateSection(newFileContent, section, value, key, convertValueToLower);
WriteFile(newFileContent);
return;
}
// ...sonst wird jede Zeile durchsucht
for (int i = 0; i < fileLines.Length; i++)
{
// Option 1 -> Gewünschte Section wurde (noch) nicht gefunden
if (fileLines[i].Replace(" ", "").ToLower() != section)
{
newFileContent.Add(fileLines[i]);
// Wenn Section nicht vorhanden ist, wird diese erzeugt
if (i == fileLines.Length - 1 && fileLines[i].Replace(" ", "").ToLower() != section && sectionFound == false)
{
newFileContent.Add(null);
newFileContent = CreateSection(newFileContent, section, value, key, convertValueToLower);
break;
}
continue;
}
// Option 2 -> Gewünschte Section wurde gefunden
sectionFound = true;
// Enthält die komplette Section, in der sich der Zielschlüssel befindet
List<string> targetSection = GetSection(section, true);
// Jeden Eintrag in der Section, in der sich der Zielschlüssel befindet, durchgehen
for (int x = 0; x < targetSection.Count; x++)
{
string[] targetKey = targetSection[x].Split(new string[] { "=" }, StringSplitOptions.None);
// Wenn der Zielschlüssel gefunden ist
if (targetKey[0].ToLower() == keyToLower)
{
// Prüft, in welcher Schreibweise die Werte abgespeichert werden sollen
if (convertValueToLower == true)
{
newFileContent.Add(keyToLower + "=" + value.ToLower());
}
else
{
newFileContent.Add(key + "=" + value);
}
i = i + x;
break;
}
else
{
newFileContent.Add(targetSection[x]);
// Wenn Key nicht vorhanden ist, wird dieser erzeugt
if (x == targetSection.Count - 1 && targetKey[0].ToLower() != keyToLower)
{
// Prüft, in welcher Schreibweise die Werte abgespeichert werden sollen
if (convertValueToLower == true)
{
newFileContent.Add(keyToLower + "=" + value.ToLower());
}
else
{
newFileContent.Add(key + "=" + value);
}
i = i + x;
break;
}
}
}
}
WriteFile(newFileContent);
}
#endregion
#region Private Methoden
/// <summary>
/// Stellt sicher, dass eine Section immer im folgenden Format vorliegt: [section]
/// </summary>
/// <param name="section">Section, die auf korrektes Format geprüft werden soll.</param>
/// <returns>Gibt Section in dieser Form zurück: [section]</returns>
private string CheckSection(string section)
{
section = section.ToLower();
if (section.Substring(0, 1) != "[" && section.Substring(section.Length - 1, 1) != "]")
{
section = "[" + section + "]";
}
return section;
}
/// <summary>
/// Entfernt voranstehende und hintenstehende Leerzeichen bei Sections, Keys und Values.
/// </summary>
/// <param name="item">String, der gekürzt werden soll.</param>
/// <returns>Gibt einen gekürzten String zurück.</returns>
private string ReplaceScpacesAtStartAndEnd(string item)
{
// Wenn der Eintrag einen Schlüssel und einen Wert hat
if (item.Contains("=") && !item.Contains("[") && !item.Contains("]"))
{
string[] keyAndValue = item.Split(new string[] { "=" }, StringSplitOptions.None);
return keyAndValue[0].Trim() + "=" + keyAndValue[1].Trim();
}
return item.Trim();
}
/// <summary>
/// Legt eine neue Section an.
/// </summary>
/// <param name="newSettings">Liste newSettings aus SetValue.</param>
/// <param name="section">section die angelegt werden soll.</param>
/// <param name="value">Wert der hinzugefügt werden soll.</param>
/// <param name="key">Schlüssel der hinzugefügt werden soll.</param>
/// <param name="convertValueToLower">Gibt an, ob Schlüssel und Wert in Kleinbuchstaben abgespeichert werden sollen.</param>
/// <returns></returns>
private List<string> CreateSection(List<string> newSettings, string section, string value, string key, bool convertValueToLower)
{
string keyToLower = key.ToLower();
newSettings.Add(section);
// Prüft, in welcher Schreibweise die Werte abgespeichert werden sollen
if (convertValueToLower == true)
{
newSettings.Add(keyToLower + "=" + value.ToLower());
}
else
{
newSettings.Add(key + "=" + value);
}
return newSettings;
}
private void WriteFile(List<string> content)
{
StreamWriter writer = new StreamWriter(_File);
foreach (var item in content)
{
writer.WriteLine(item);
}
writer.Close();
}
#endregion
}
}

View file

@ -1,53 +0,0 @@
<Window x:Class="WeeXnes.Misc.Message"
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:WeeXnes.Misc"
mc:Ignorable="d"
Title="Message" Height="150" Width="300"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
SizeToContent="WidthAndHeight"
Background="Transparent"
AllowsTransparency="True"
WindowStyle="None">
<Border CornerRadius="4"
Margin="16"
MouseDown="UIElement_OnMouseDown">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1f2026" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="0"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Placeholder"
Name="MessageLabel"
Foreground="White"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="100,20,100,20"/>
<Button Grid.Row="1"
Style="{StaticResource UniversalMaterialButton}"
Content="OK"
Width="140"
Height="40"
Background="#2f313b"
Name="okButton"
Click="okButton_Click"
Margin="0,0,0,20"/>
</Grid>
</Border>
</Window>

View file

@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WeeXnes.Misc
{
/// <summary>
/// Interaktionslogik für Message.xaml
/// </summary>
public partial class Message : Window
{
public Message(string _message, string _title = "Message")
{
InitializeComponent();
MessageLabel.Content = _message;
this.Title = _title;
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
}
}

View file

@ -1,77 +0,0 @@
<Window x:Class="WeeXnes.Misc.UpdateMessage"
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:WeeXnes.Misc"
mc:Ignorable="d"
Title="Message" Height="158" Width="308"
ResizeMode="NoResize"
Background="Transparent"
AllowsTransparency="True"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
SizeToContent="WidthAndHeight">
<Window.Resources>
<Style TargetType="Image">
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
</Style>
</Window.Resources>
<Border CornerRadius="4"
Margin="16"
MouseDown="UIElement_OnMouseDown">
<Border.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#212329" />
<GradientStop Offset="1" Color="#1f2026" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="0"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Placeholder"
Name="MessageLabel"
Foreground="White"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="100,20,100,20"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Grid.Row="1"
Style="{StaticResource UniversalMaterialButton}"
Content="OK"
Width="140"
Height="40"
Background="#2f313b"
Name="okButton"
Click="OkButton_OnClick"
Margin="0,0,10,20"/>
<Button Grid.Row="1"
Style="{StaticResource UniversalMaterialButton}"
Content="CANCEL"
Width="140"
Height="40"
Background="#2f313b"
Name="cancelButton"
Click="CancelButton_OnClick"
Margin="10,0,0,20"/>
</StackPanel>
</Grid>
</Border>
</Window>

View file

@ -1,68 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Input;
using WeeXnes.Core;
using Application = System.Windows.Forms.Application;
namespace WeeXnes.Misc
{
public partial class UpdateMessage : Window
{
public static ApiResponse GitHub;
public UpdateMessage(ApiResponse _GitHub, string _title = "Message")
{
InitializeComponent();
string content = "Your Version: " + Globals.version + "\n" +
"Current Version: " + _GitHub.tag_name;
MessageLabel.Content = content;
this.Title = _title;
GitHub = _GitHub;
}
public static void downloadAssets()
{
checkForFile();
WebClient client = new WebClient();
client.DownloadFile(GitHub.download_url, GitHub.file_name);
}
private static void checkForFile()
{
if (File.Exists(GitHub.file_name))
{
File.Delete(GitHub.file_name);
}
}
private void OkButton_OnClick(object sender, RoutedEventArgs e)
{
downloadAssets();
try
{
string path = Application.StartupPath;
string fileName = Path.GetFileName(Application.ExecutablePath);
string pid = Process.GetCurrentProcess().Id.ToString();
Process updateProc = Process.Start("Update.exe", "\"" + path + "\"" + " " + "\"" + fileName + "\"" + " " + "\"" + pid + "\"" + " " + "\"" + GitHub.file_name + "\"");
}
catch (Exception ex)
{
Misc.Message message = new Misc.Message(ex.ToString());
message.Show();
}
this.Close();
}
private void CancelButton_OnClick(object sender, RoutedEventArgs e)
{
this.Close();
}
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
}
}

View file

@ -1,82 +0,0 @@
#pragma warning disable CS0168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace wx
{
public class wxfile
{
public string path { get; set; }
public wxfile(string _path)
{
this.path = _path;
}
public string GetName()
{
string returnval = null;
string[] rawcontent = wxfilefuncs.readFile(this.path);
if (wxfilefuncs.verify(rawcontent))
{
try
{
returnval = rawcontent[1];
}
catch (Exception e)
{
returnval = null;
}
}
return returnval;
}
public string GetValue()
{
string returnval = null;
string[] rawcontent = wxfilefuncs.readFile(this.path);
if (wxfilefuncs.verify(rawcontent))
{
try
{
returnval = rawcontent[2];
}catch (Exception e)
{
returnval = null;
}
}
return returnval;
}
}
public class wxfilefuncs
{
public static string[] readFile(string filepath)
{
string[] lines = System.IO.File.ReadAllLines(filepath);
var listOfStrings = new List<string>();
foreach (string line in lines)
{
listOfStrings.Add(line);
}
string[] arrayOfStrings = listOfStrings.ToArray();
return arrayOfStrings;
}
public static bool verify(string[] content)
{
bool integ = false;
if(content != null)
{
if(content[0] == "##WXfile##")
{
integ = true;
}
}
return integ;
}
}
}

View file

@ -1,142 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeeXnes.Core;
using WeeXnes.MVVM.View;
using DiscordRPC;
using DiscordRPC.Message;
using EventType = WeeXnes.Core.EventType;
namespace WeeXnes.RPC
{
class EventCache
{
public static string cache1 = "";
}
public class Game
{
public DiscordRpcClient client { get; set; }
public string id { get; set; }
public string state { get; set; }
public string details { get; set; }
public string ProcessName { get; set; }
public string Name { get; set; }
public string bigimgkey { get; set; }
public string smallimgkey { get; set; }
public string bigimgtext { get; set; }
public string smallimgtext { get; set; }
public bool isRunning { get; set; }
public string fileName { get; set; }
public Game(string _fileName, string _name, string _pname = null, string _id = null, string _state = null, string _details = null, string _bigimgkey = null, string _smallimgkey = null, string _bigimgtext = null, string _smallimgtext = null)
{
this.fileName = _fileName;
this.id = _id;
this.state = _state;
this.details = _details;
this.Name = _name;
this.ProcessName = _pname;
this.bigimgkey = _bigimgkey;
this.smallimgkey = _smallimgkey;
this.bigimgtext = _bigimgtext;
this.smallimgtext = _smallimgtext;
this.client = new DiscordRpcClient(id);
}
public void start()
{
if (!client.IsInitialized)
{
client.Initialize();
}
client.OnReady += ClientOnOnReady;
client.OnPresenceUpdate += ClientOnOnPresenceUpdate;
client.SetPresence(new RichPresence()
{
Details = this.details,
State = this.state,
Assets = new Assets()
{
LargeImageKey = this.bigimgkey,
LargeImageText = this.bigimgtext,
SmallImageKey = this.smallimgkey,
SmallImageText = this.smallimgtext
}
});
if (Globals.settings_RpcShowElapsedTime.Value)
{
client.UpdateStartTime();
}
}
private void ClientOnOnPresenceUpdate(object sender, PresenceMessage args)
{
DiscordRpcView.logContent = new customEvent("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name, EventType.RPCUpdateEvent);
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
}
private void ClientOnOnReady(object sender, ReadyMessage args)
{
DiscordRpcView.logContent = new customEvent("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username, EventType.RPCReadyEvent);
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
}
public void stop()
{
if (this.client.IsInitialized)
{
client.ClearPresence();
client.OnReady -= ClientOnOnReady;
client.OnPresenceUpdate -= ClientOnOnPresenceUpdate;
}
}
public void checkState(Process[] processes)
{
if(!String.IsNullOrEmpty(this.ProcessName))
{
if (!String.IsNullOrEmpty(this.id))
{
bool foundProcess = false;
foreach (Process process in processes)
{
if (process.ProcessName == this.ProcessName)
{
foundProcess = true;
}
}
if (!this.isRunning)
{
if (foundProcess)
{
start();
DiscordRpcView.logContent = new customEvent("↪ " + this.Name + " [" + this.ProcessName + ".exe] started", EventType.ProcessStartedEvent);
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
this.isRunning = true;
}
}
if (this.isRunning)
{
if (!foundProcess)
{
stop();
DiscordRpcView.logContent = new customEvent( "↩ " + this.Name + " [" + this.ProcessName + ".exe] closed", EventType.ProcessStoppedEvent);
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
this.isRunning = false;
}
}
}
}
}
public override string ToString()
{
return this.Name;
}
}
}

View file

@ -1,91 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Button}"
x:Key="ModernCloseButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="0"
Background="#b82727">
<Grid>
<Rectangle StrokeThickness="1"/>
<TextBlock Text="{TemplateBinding Property=Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="DarkGray"
Margin="0,0,0,5"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Button}"
x:Key="ModernMinimizeButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="0"
Background="#25272e">
<Grid>
<Rectangle StrokeThickness="1"/>
<TextBlock Text="{TemplateBinding Property=Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="DarkGray"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Button}"
x:Key="UniversalMaterialButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border CornerRadius="4"
Background="{TemplateBinding Background}">
<Grid>
<Rectangle StrokeThickness="1"/>
<TextBlock Text="{TemplateBinding Property=Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="DarkGray"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="OSXButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -1,219 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="MenuButtonTheme">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Background="{TemplateBinding Background}">
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="50,0,0,0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#22202f"/>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="MenuButtonRoundTheme">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="50,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#212329"/>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="DiscordMenuButton">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<StackPanel Orientation="Horizontal">
<Image Margin="10,0,10,0" RenderOptions.BitmapScalingMode="HighQuality"
Source="/../Images/discord.png" Width="30">
</Image>
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="0,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#212329"/>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="HomeMenuButton">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<StackPanel Orientation="Horizontal">
<Image Margin="10,0,10,0" RenderOptions.BitmapScalingMode="HighQuality"
Source="/../Images/home.png" Width="30">
</Image>
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="0,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#212329"/>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="SettingsMenuButton">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<StackPanel Orientation="Horizontal">
<Image Margin="10,0,10,0" RenderOptions.BitmapScalingMode="HighQuality"
Source="/../Images/settings.png" Width="30">
</Image>
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="0,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#212329"/>
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}"
x:Key="KeyManagerMenuButton">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<StackPanel Orientation="Horizontal">
<Image Margin="10,0,10,0" RenderOptions.BitmapScalingMode="HighQuality"
Source="/../Images/key.png" Width="30">
</Image>
<TextBlock Text="{TemplateBinding Property=Content}"
VerticalAlignment="Center"
Margin="0,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#212329"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View file

@ -1,35 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type CheckBox}"
x:Key="ModernChecbox">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Border CornerRadius="10"
Background="#353340">
<Grid>
<Rectangle StrokeThickness="1"/>
<CheckBox Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Center"
Foreground="DarkGray"
Background="#353340"
Margin="5,0,0,0"
BorderThickness="0"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#22202f"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View file

@ -1,18 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="ScrollBarThumbHor" TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border CornerRadius="1" Background="#c8c8c8" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Height="8" Margin="0,0,-2,0"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -1,50 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBox}"
x:Key="MaterialTextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border CornerRadius="4"
Background="{TemplateBinding Background}">
<Grid>
<Rectangle StrokeThickness="1"/>
<TextBox Margin="1"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, UpdateSourceTrigger=PropertyChanged}"
BorderThickness="0"
Background="Transparent"
VerticalAlignment="Center"
Padding="5"
Foreground="#cfcfcf"
x:Name="SearchBox"/>
<TextBlock IsHitTestVisible="False"
Text="{TemplateBinding Tag}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="10,0,0,0"
FontSize="11"
Foreground="DarkGray"
Grid.Column="1">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding Text, ElementName=SearchBox}" Value="">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
<Setter Property="Visibility" Value="Hidden"/>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,50 @@
<Page x:Class="WeeXnes.Views.DiscordRPC.AddRPCView"
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:WeeXnes.Views.DiscordRPC"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="AddRPCView" Height="Auto" Width="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="45"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<StackPanel Orientation="Vertical">
<ui:TextBox Name="TextboxProcessname" PlaceholderText="Process name" Margin="0,4"/>
<ui:TextBox Name="TextboxClientid" PlaceholderText="Client ID" Margin="0,4"/>
<ui:TextBox Name="TextboxState" PlaceholderText="State" Margin="0,4"/>
<ui:TextBox Name="TextboxDetails" PlaceholderText="Details" Margin="0,4"/>
<ui:TextBox Name="TextboxBigimgkey" PlaceholderText="Big image key" Margin="0,4"/>
<ui:TextBox Name="TextboxBigimgtxt" PlaceholderText="Big image text" Margin="0,4"/>
<ui:TextBox Name="TextboxSmallimgkey" PlaceholderText="Small image key" Margin="0,4"/>
<ui:TextBox Name="TextboxSmallimgtxt" PlaceholderText="Small image text" Margin="0,4"/>
</StackPanel>
</ScrollViewer>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ui:Button
Padding="24,6"
HorizontalAlignment="Center"
Content="Cancel"
Icon="CaretLeft24"
Name="ButtonCancelDialog"
Click="ButtonCancelDialog_OnClick"/>
<ui:Button Grid.Column="1"
Padding="24,6"
HorizontalAlignment="Center"
Content="Add"
Icon="AddCircle32"
Name="ButtonSaveDialog"
Click="ButtonSaveDialog_OnClick"/>
</Grid>
</Grid>
</Page>

View file

@ -0,0 +1,56 @@
using System;
using System.Net.Mime;
using System.Windows;
using System.Windows.Controls;
namespace WeeXnes.Views.DiscordRPC
{
public partial class AddRPCView : Page
{
public AddRPCView()
{
InitializeComponent();
}
private void CloseDialog()
{
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
}
private void ButtonSaveDialog_OnClick(object sender, RoutedEventArgs e)
{
if(String.IsNullOrEmpty(TextboxProcessname.Text))
return;
if(String.IsNullOrEmpty(TextboxClientid.Text))
return;
try
{
//Add new item
Game newGame = new Game(
TextboxProcessname.Text,
TextboxClientid.Text,
TextboxDetails.Text,
TextboxState.Text,
TextboxBigimgkey.Text,
TextboxBigimgtxt.Text,
TextboxSmallimgkey.Text,
TextboxSmallimgtxt.Text
);
DiscordRPCView.Data.Games.Add(newGame);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
CloseDialog();
}
private void ButtonCancelDialog_OnClick(object sender, RoutedEventArgs e)
{
CloseDialog();
}
}
}

View file

@ -0,0 +1,65 @@
<Page x:Class="WeeXnes.Views.DiscordRPC.DiscordRPCView"
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:WeeXnes.Views.DiscordRPC"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="DiscordRPCView" Height="Auto" Width="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="74"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0" Name="ItemboxRpc" Margin="0,0,0,5"
SelectionChanged="ItemboxRpc_OnSelectionChanged">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit"
Name="ButtonContextEdit"
Click="ContextEdit_OnClick"/>
<Separator />
<MenuItem Header="Remove"
Name="ButtonContextRemove"
Click="ContextRemove_OnClick"/>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
<StackPanel Grid.Column="1">
<ui:CardAction Icon="Play28" Grid.Row="1"
Name="ButtonStartRPC"
Margin="5,0,0,0"
Click="ButtonStartRPC_OnClick">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Run RPC"
/>
</StackPanel>
</ui:CardAction>
</StackPanel>
</Grid>
<ui:CardAction Icon="AddCircle32" Grid.Row="1"
Name="ButtonAddProcess"
Click="ButtonAddProcess_OnClick">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Add Process" />
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="add process to configure corresponding RPC" />
</StackPanel>
</ui:CardAction>
</Grid>
</Page>

View file

@ -0,0 +1,67 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using WeeXnes.Core;
namespace WeeXnes.Views.DiscordRPC
{
public partial class DiscordRPCView : Page
{
public static class Data
{
public static BindingList<Game> Games = new BindingList<Game>();
public static Game SelectedItem = null;
}
public DiscordRPCView()
{
InitializeComponent();
ItemboxRpc.ItemsSource = Data.Games;
Data.Games.ListChanged += GamesOnListChanged;
}
private void GamesOnListChanged(object sender, ListChangedEventArgs e)
{
foreach (Game game in Data.Games)
{
//Save Item to disk
game.Save();
}
}
private void ButtonAddProcess_OnClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/DiscordRPC/AddRPCView.xaml",UriKind.Relative));
}
private void ItemboxRpc_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = (ListBox)sender;
Data.SelectedItem = (Game)listBox.SelectedItem;
}
private void ContextEdit_OnClick(object sender, RoutedEventArgs e)
{
if(Data.SelectedItem == null)
return;
NavigationService.Navigate(new Uri("/Views/DiscordRPC/EditRPCView.xaml",UriKind.Relative));
}
private void ContextRemove_OnClick(object sender, RoutedEventArgs e)
{
Game selectedCache = Data.SelectedItem;
if(selectedCache == null)
return;
Data.Games.Remove(selectedCache);
File.Delete(Global.AppDataPathRPC + "\\" + selectedCache.UUID + ".rpc");
}
private void ButtonStartRPC_OnClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/DiscordRPC/RunRPCView.xaml",UriKind.Relative));
}
}
}

View file

@ -0,0 +1,51 @@
<Page x:Class="WeeXnes.Views.DiscordRPC.EditRPCView"
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:WeeXnes.Views.DiscordRPC"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="EditRPCView" Height="Auto" Width="Auto"
Loaded="EditRPCView_OnLoaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="45"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<StackPanel Orientation="Vertical">
<ui:TextBox Name="TextboxProcessname" PlaceholderText="Process name" Margin="0,4"/>
<ui:TextBox Name="TextboxClientid" PlaceholderText="Client ID" Margin="0,4"/>
<ui:TextBox Name="TextboxState" PlaceholderText="State" Margin="0,4"/>
<ui:TextBox Name="TextboxDetails" PlaceholderText="Details" Margin="0,4"/>
<ui:TextBox Name="TextboxBigimgkey" PlaceholderText="Big image key" Margin="0,4"/>
<ui:TextBox Name="TextboxBigimgtxt" PlaceholderText="Big image text" Margin="0,4"/>
<ui:TextBox Name="TextboxSmallimgkey" PlaceholderText="Small image key" Margin="0,4"/>
<ui:TextBox Name="TextboxSmallimgtxt" PlaceholderText="Small image text" Margin="0,4"/>
</StackPanel>
</ScrollViewer>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ui:Button
Padding="24,6"
HorizontalAlignment="Center"
Content="Cancel"
Icon="CaretLeft24"
Name="ButtonCancelDialog"
Click="ButtonCancelDialog_OnClick"/>
<ui:Button Grid.Column="1"
Padding="24,6"
HorizontalAlignment="Center"
Content="Edit"
Icon="AddCircle32"
Name="ButtonSaveDialog"
Click="ButtonSaveDialog_OnClick"/>
</Grid>
</Grid>
</Page>

View file

@ -0,0 +1,55 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace WeeXnes.Views.DiscordRPC
{
public partial class EditRPCView : Page
{
private Game editItem = null;
public EditRPCView()
{
InitializeComponent();
}
private void CloseDialog()
{
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
}
private void ButtonSaveDialog_OnClick(object sender, RoutedEventArgs e)
{
Game editedItem = new Game(
TextboxProcessname.Text,
TextboxClientid.Text,
TextboxDetails.Text,
TextboxState.Text,
TextboxBigimgkey.Text,
TextboxBigimgtxt.Text,
TextboxSmallimgkey.Text,
TextboxSmallimgtxt.Text
);
editedItem.UUID = editItem.UUID;
int listIndex = DiscordRPCView.Data.Games.IndexOf(editItem);
DiscordRPCView.Data.Games[listIndex] = editedItem;
CloseDialog();
}
private void EditRPCView_OnLoaded(object sender, RoutedEventArgs e)
{
editItem = DiscordRPCView.Data.SelectedItem;
TextboxProcessname.Text = editItem.ProcessName;
TextboxClientid.Text = editItem.PresenceClient.ApplicationID;
TextboxState.Text = editItem.State;
TextboxDetails.Text = editItem.Details;
TextboxBigimgkey.Text = editItem.BigImageKey;
TextboxBigimgtxt.Text = editItem.BigImageText;
TextboxSmallimgkey.Text = editItem.SmallImageKey;
TextboxSmallimgtxt.Text = editItem.SmallImageText;
}
private void ButtonCancelDialog_OnClick(object sender, RoutedEventArgs e)
{
CloseDialog();
}
}
}

View file

@ -0,0 +1,202 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;
using DiscordRPC;
using DiscordRPC.Message;
using Nocksoft.IO.ConfigFiles;
using WeeXnes.Core;
using WeeXnes.Views.Settings;
namespace WeeXnes.Views.DiscordRPC
{
public class Game
{
public static class Methods
{
public static Game GameFromIni(INIFile inifile)
{
Game returnval = new Game(
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.ProcessName),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.ClientId),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.Details),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.State),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.BigImageKey),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.BigImageText),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.SmallImageKey),
inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.SmallImageText)
);
returnval.UUID = inifile.GetValue(SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.UUID);
return returnval;
}
}
public string ProcessName { get; set; }
public bool IsRunning { get; set; }
public DiscordRpcClient PresenceClient { get; set; }
public string Details { get; set; }
public string State { get; set; }
public string BigImageKey { get; set; }
public string BigImageText { get; set; }
public string SmallImageKey { get; set; }
public string SmallImageText { get; set; }
public string UUID { get; set; }
private string generateUUID()
{
return Guid.NewGuid().ToString();
}
public Game(
string processName,
string clientId,
string details,
string state,
string bigImageKey,
string bigImageText,
string smallImageKey,
string smallImageText
)
{
this.ProcessName = processName;
this.IsRunning = false;
this.PresenceClient = new DiscordRpcClient(clientId);
this.Details = details;
this.State = state;
this.BigImageKey = bigImageKey;
this.BigImageText = bigImageText;
this.SmallImageKey = smallImageKey;
this.SmallImageText = smallImageText;
this.UUID = generateUUID();
}
public void Start()
{
this.IsRunning = true;
Console.WriteLine("Process started");
if (!this.PresenceClient.IsInitialized)
{
this.PresenceClient.Initialize();
}
this.PresenceClient.OnReady += PresenceClientOnOnReady;
this.PresenceClient.OnPresenceUpdate += PresenceClientOnOnPresenceUpdate;
this.PresenceClient.SetPresence(new RichPresence()
{
Details = this.Details,
State = this.State,
Assets = new Assets()
{
LargeImageKey = this.BigImageKey,
LargeImageText = this.BigImageText,
SmallImageKey = this.SmallImageKey,
SmallImageText = this.SmallImageText
}
});
PresenceClient.UpdateStartTime();
}
public void Stop()
{
this.IsRunning = false;
Console.WriteLine("Process stopped");
if (this.PresenceClient.IsInitialized)
{
this.PresenceClient.ClearPresence();
this.PresenceClient.OnReady -= PresenceClientOnOnReady;
this.PresenceClient.OnPresenceUpdate -= PresenceClientOnOnPresenceUpdate;
}
}
private void PresenceClientOnOnPresenceUpdate(object sender, PresenceMessage args)
{
Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name);
}
private void PresenceClientOnOnReady(object sender, ReadyMessage args)
{
Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username);
}
public void CheckState(Process[] processes)
{
if(String.IsNullOrEmpty(this.ProcessName))
return;
bool processFound = false;
foreach (Process process in processes)
{
if (process.ProcessName == this.ProcessName)
processFound = true;
}
if(!this.IsRunning)
if (processFound)
Start();
if(this.IsRunning)
if(!processFound)
Stop();
}
public void Save()
{
INIFile rpcFile = new INIFile(Global.AppDataPathRPC + "\\" + this.UUID + ".rpc", true);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.ProcessName,
this.ProcessName);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.ClientId,
this.PresenceClient.ApplicationID);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.State,
this.State);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.Details,
this.Details);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.BigImageKey,
this.BigImageKey);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.BigImageText,
this.BigImageText);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.SmallImageKey,
this.SmallImageKey);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.SmallImageText,
this.SmallImageText);
rpcFile.SetValue(
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
SaveSettingsHandler.Data.DiscordRpcFiles.UUID,
this.UUID);
}
public override string ToString()
{
return this.ProcessName + ".exe";
}
}
}

View file

@ -0,0 +1,35 @@
<Page x:Class="WeeXnes.Views.DiscordRPC.RunRPCView"
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:WeeXnes.Views.DiscordRPC"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="RunRPCView" Height="Auto" Width="Auto"
Unloaded="RunRPCView_OnUnloaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70px"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ui:CardAction Grid.Column="1" Icon="CaretLeft24"
Name="ButtonRPCStop"
Click="ButtonRPCStop_OnClick">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Stop RPC"
/>
</StackPanel>
</ui:CardAction>
<RichTextBox Grid.Row="1" Name="RichTextBoxRPCLog">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</Grid>
</Page>

View file

@ -0,0 +1,88 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
namespace WeeXnes.Views.DiscordRPC
{
public partial class RunRPCView : Page
{
BackgroundWorker backgroundWorker = new BackgroundWorker();
public RunRPCView()
{
InitializeComponent();
SetupBackgroundWorker();
}
private void SetupBackgroundWorker()
{
backgroundWorker.WorkerReportsProgress = true;
backgroundWorker.WorkerSupportsCancellation = true;
backgroundWorker.RunWorkerCompleted += BackgroundWorkerOnRunWorkerCompleted;
backgroundWorker.DoWork += BackgroundWorkerOnDoWork;
RunBackgroundWorker();
}
public void RunBackgroundWorker()
{
try
{
if(!backgroundWorker.IsBusy)
backgroundWorker.RunWorkerAsync();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
public void StopBackgroundWorker()
{
try
{
if(backgroundWorker.IsBusy)
backgroundWorker.CancelAsync();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
//Stop RPC
}
private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs e)
{
bool runWorker = true;
while (runWorker)
{
Process[] processes = Process.GetProcesses();
if (backgroundWorker.CancellationPending)
runWorker = false;
foreach (Game game in DiscordRPCView.Data.Games)
{
game.CheckState(processes);
}
Thread.Sleep(2000);
}
}
private void BackgroundWorkerOnRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
foreach (Game game in DiscordRPCView.Data.Games)
game.Stop();
Console.WriteLine("Thread Stopped");
}
private void RunRPCView_OnUnloaded(object sender, RoutedEventArgs e)
{
StopBackgroundWorker();
}
private void ButtonRPCStop_OnClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
}
}
}

View file

@ -0,0 +1,22 @@
<Page x:Class="WeeXnes.Views.Home.HomeView"
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:WeeXnes.Views.Home"
mc:Ignorable="d"
Title="HomeView" Height="Auto" Width="Auto">
<Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<Image RenderOptions.BitmapScalingMode="HighQuality"
Source="/Images/wicon.png" Grid.Row="0"
HorizontalAlignment="Center" Width="200"/>
<TextBlock Text="WeeXnes Hub"
Foreground="White"
FontSize="28"
HorizontalAlignment="Center"
Name="VersionInfo"
Loaded="VersionInfo_OnLoaded"/>
</StackPanel>
</Grid>
</Page>

View file

@ -0,0 +1,19 @@
using System.Windows;
using System.Windows.Controls;
using WeeXnes.Core;
namespace WeeXnes.Views.Home
{
public partial class HomeView : Page
{
public HomeView()
{
InitializeComponent();
}
private void VersionInfo_OnLoaded(object sender, RoutedEventArgs e)
{
VersionInfo.Text = "WeeXnes Hub v" + Information.Version;
}
}
}

View file

@ -0,0 +1,22 @@
using System;
namespace WeeXnes.Views.KeyManager
{
public class KeyItem
{
public string Name { get; set; }
public string Value { get; set; }
public string Filename { get; set; }
public KeyItem(string name, string value)
{
this.Name = name;
this.Value = value;
this.Filename = Guid.NewGuid().ToString() + ".wx";
}
public override string ToString()
{
return this.Name;
}
}
}

View file

@ -0,0 +1,69 @@
<Page x:Class="WeeXnes.Views.KeyManager.KeyManagerView"
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:WeeXnes.Views.KeyManager"
mc:Ignorable="d"
Title="KeyManagerView" Height="Auto" Width="Auto"
Loaded="KeyManagerView_OnLoaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50px"/>
</Grid.RowDefinitions>
<ListView Name="ListviewKeys"
Background="Transparent"
Foreground="White"
BorderThickness="0">
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove"
Name="btn_context_remove"
Click="MenuItem_OnClick"/>
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}"
Grid.Column="0"/>
<TextBlock Text="{Binding Value}"
Grid.Column="1"
Name="KeyValue"
Loaded="KeyValue_OnLoaded"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="100px"/>
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Margin="0,0,5,0"
Name="tb_keyname"/>
<TextBox
Grid.Column="1"
Margin="5,0,0,0"
Name="tb_keyvalue"/>
<Button Grid.Column="2"
Content="Add"
Height="35px"
Width="80px"
HorizontalAlignment="Center"
Name="btn_add"
Click="Btn_add_OnClick"/>
</Grid>
</Grid>
</Page>

View file

@ -0,0 +1,95 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using WeeXnes.Core;
namespace WeeXnes.Views.KeyManager
{
public partial class KeyManagerView : Page
{
public static class Data
{
public static BindingList<KeyItem> KeyItemsList = new BindingList<KeyItem>();
public static UpdateVar<bool> censorKeys = new UpdateVar<bool>();
}
public KeyManagerView()
{
InitializeComponent();
ListviewKeys.ItemsSource = Data.KeyItemsList;
//((INotifyCollectionChanged)listview_keys.Items).CollectionChanged += OnCollectionChanged;
}
private void KeyManagerView_OnLoaded(object sender, RoutedEventArgs e)
{
ListviewKeys.Items.Refresh();
}
private void Btn_add_OnClick(object sender, RoutedEventArgs e)
{
if(String.IsNullOrEmpty(tb_keyname.Text))
return;
if(String.IsNullOrEmpty(tb_keyvalue.Text))
return;
try
{
KeyItem newKey = new KeyItem(
tb_keyname.Text,
tb_keyvalue.Text
);
WXFile wxFile = new WXFile(
Global.AppDataPathKEY + "\\" + newKey.Filename);
WXFile.Methods.WriteFile(newKey, wxFile);
Data.KeyItemsList.Add(newKey);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
ClearInputs();
}
private void ClearInputs()
{
tb_keyname.Text = "";
tb_keyvalue.Text = "";
}
private void DeleteItem(KeyItem removeItem)
{
if(removeItem == null)
return;
Data.KeyItemsList.Remove(removeItem);
try
{
File.Delete(Global.AppDataPathKEY + "\\" + removeItem.Filename);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
private void MenuItem_OnClick(object sender, RoutedEventArgs e)
{
DeleteItem((KeyItem)ListviewKeys.SelectedItem);
}
private void KeyValue_OnLoaded(object sender, RoutedEventArgs e)
{
if (!Data.censorKeys.Value)
return;
TextBlock tb = (TextBlock)sender;
string censoredString = "";
for (int i = 0; i <= tb.Text.Length; i++)
censoredString = censoredString + "•";
tb.Text = censoredString;
}
}
}

View file

@ -0,0 +1,37 @@
using System.Collections.Generic;
namespace WeeXnes.Views.Settings
{
public class GithubApiResponse
{
public string tag_name { get; set; }
public IList<GithubAsset> assets { get; set; }
public GithubApiResponse(string tag_name, IList<GithubAsset> assets)
{
this.tag_name = tag_name;
this.assets = assets;
}
public override string ToString()
{
return this.tag_name + " with " + this.assets.Count;
}
}
public class GithubAsset
{
public string browser_download_url { get; set; }
public string name { get; set; }
public GithubAsset(string browser_download_url, string name)
{
this.browser_download_url = browser_download_url;
this.name = name;
}
public override string ToString()
{
return this.name;
}
}
}

View file

@ -0,0 +1,42 @@
<Page x:Class="WeeXnes.Views.Settings.SettingsView"
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:WeeXnes.Views.Settings"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="SettingsView" Height="Auto" Width="Auto">
<Grid>
<ScrollViewer>
<StackPanel Orientation="Vertical">
<TextBlock Text="General Settings"
HorizontalAlignment="Center"
Foreground="White"/>
<ui:CardAction Icon="Play28"
Name="ButtonCheckForUpdates"
Click="ButtonCheckForUpdates_OnClick">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Check for Updates"
/>
</StackPanel>
</ui:CardAction>
<ui:Dialog Foreground="White"
Name="DialogUpdate"
ButtonLeftClick="DialogUpdate_OnButtonLeftClick"
ButtonRightClick="DialogUpdate_OnButtonRightClick"/>
<TextBlock Text="Key Manager Settings"
HorizontalAlignment="Center"
Foreground="White"/>
<CheckBox Content="Censor Keys Visually"
Name="CheckboxCensorKeys"
Checked="CheckboxCensorKeys_OnChecked"
Unchecked="CheckboxCensorKeys_OnUnchecked"/>
</StackPanel>
</ScrollViewer>
</Grid>
</Page>

View file

@ -0,0 +1,104 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Windows;
using Application = System.Windows.Forms.Application;
using System.Windows.Controls;
using Newtonsoft.Json;
using Nocksoft.IO.ConfigFiles;
using WeeXnes.Core;
using WeeXnes.Views.KeyManager;
namespace WeeXnes.Views.Settings
{
public partial class SettingsView : Page
{
public static class Data
{
public static INIFile settingsFile = new INIFile(Global.AppDataPath + "\\" + Global.SettingsFile, true);
public static GithubApiResponse updateResponse = null;
}
public SettingsView()
{
InitializeComponent();
LoadSettingsToGui();
}
private void LoadSettingsToGui()
{
CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value;
}
private void CheckboxCensorKeys_OnChecked(object sender, RoutedEventArgs e)
{
KeyManagerView.Data.censorKeys.Value = true;
}
private void CheckboxCensorKeys_OnUnchecked(object sender, RoutedEventArgs e)
{
KeyManagerView.Data.censorKeys.Value = false;
}
private void DialogUpdate_OnButtonLeftClick(object sender, RoutedEventArgs e)
{
Console.WriteLine("Do Update");
if(Data.updateResponse == null)
return;
if (File.Exists(Data.updateResponse.assets[0].name))
{
File.Delete(Data.updateResponse.assets[0].name);
}
using(WebClient webClient = new WebClient())
{;
webClient.DownloadFile(
Data.updateResponse.assets[0].browser_download_url,
Data.updateResponse.assets[0].name
);
}
try
{
string path = Application.StartupPath;
string fileName = Path.GetFileName(Application.ExecutablePath);
string pid = Process.GetCurrentProcess().Id.ToString();
Process updateProc = Process.Start("Update.exe", "\"" + path + "\"" + " " + "\"" + fileName + "\"" + " " + "\"" + pid + "\"" + " " + "\"" + Data.updateResponse.assets[0].name + "\"");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
private void DialogUpdate_OnButtonRightClick(object sender, RoutedEventArgs e)
{
DialogUpdate.Hide();
}
private void ButtonCheckForUpdates_OnClick(object sender, RoutedEventArgs e)
{
try
{
using(WebClient webClient = new WebClient())
{;
webClient.Headers.Add("Authorization", "Basic :x-oauth-basic");
webClient.Headers.Add("User-Agent","lk-github-clien");
var downloadString = webClient.DownloadString(Information.ApiUrl);
GithubApiResponse apiResponseData = JsonConvert.DeserializeObject<GithubApiResponse>(downloadString);
if (apiResponseData.tag_name != Information.Version)
{
Console.WriteLine("Update blabla " + apiResponseData.tag_name);
Data.updateResponse = apiResponseData;
DialogUpdate.Content = apiResponseData.tag_name + " is avaiable";
DialogUpdate.Show();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>3.6.5</Version>
<Version>4.0.0</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>
@ -46,6 +46,9 @@
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml">
@ -54,21 +57,43 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Wpf.Ui, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WPF-UI.2.0.3\lib\net48\Wpf.Ui.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Core\ApiResponse.cs" />
<Compile Include="Core\customEvent.cs" />
<Compile Include="Misc\CriticalMessage.xaml.cs">
<DependentUpon>CriticalMessage.xaml</DependentUpon>
<Compile Include="Core\EncryptorLibrary.cs" />
<Compile Include="Core\HandleLaunchArguments.cs" />
<Compile Include="Core\SaveSettingsHandler.cs" />
<Compile Include="Core\WXFile.cs" />
<Compile Include="Views\DiscordRPC\AddRPCView.xaml.cs">
<DependentUpon>AddRPCView.xaml</DependentUpon>
</Compile>
<Compile Include="Misc\UpdateMessage.xaml.cs">
<DependentUpon>UpdateMessage.xaml</DependentUpon>
<Compile Include="Views\DiscordRPC\DiscordRPCView.xaml.cs">
<DependentUpon>DiscordRPCView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DiscordRPC\EditRPCView.xaml.cs">
<DependentUpon>EditRPCView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DiscordRPC\Game.cs" />
<Compile Include="Views\DiscordRPC\RunRPCView.xaml.cs">
<DependentUpon>RunRPCView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Home\HomeView.xaml.cs">
<DependentUpon>HomeView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\KeyManager\KeyItem.cs" />
<Compile Include="Views\KeyManager\KeyManagerView.xaml.cs">
<DependentUpon>KeyManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Settings\ApiResponse.cs" />
<Compile Include="Views\Settings\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="RPC\Game.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -77,42 +102,23 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Core\Globals.cs" />
<Compile Include="Core\ObservableObject.cs" />
<Compile Include="Core\RelayCommand.cs" />
<Compile Include="Keys\KeyItem.cs" />
<Compile Include="Keys\KeyManagerLib.cs" />
<Compile Include="Core\DataTypes.cs" />
<Compile Include="Core\Functions.cs" />
<Compile Include="Core\Global.cs" />
<Compile Include="Core\INIFile.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Misc\CriticalMessage.xaml" />
<Page Include="Misc\Message.xaml" />
<Page Include="Misc\UpdateMessage.xaml" />
<Page Include="MVVM\View\DiscordRpcView.xaml" />
<Page Include="MVVM\View\HomeView.xaml" />
<Page Include="MVVM\View\KeyManagerView.xaml" />
<Page Include="MVVM\View\SettingView.xaml" />
<Page Include="Theme\ControlButtonTheme.xaml" />
<Page Include="Theme\MenuButtonTheme.xaml" />
<Page Include="Theme\ModernCheckbox.xaml" />
<Page Include="Theme\Scrollbar.xaml" />
<Page Include="Theme\TextBoxTheme.xaml" />
<Page Include="Views\DiscordRPC\AddRPCView.xaml" />
<Page Include="Views\DiscordRPC\DiscordRPCView.xaml" />
<Page Include="Views\DiscordRPC\EditRPCView.xaml" />
<Page Include="Views\DiscordRPC\RunRPCView.xaml" />
<Page Include="Views\Home\HomeView.xaml" />
<Page Include="Views\KeyManager\KeyManagerView.xaml" />
<Page Include="Views\Settings\SettingsView.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Misc\EncryptorLibary.cs" />
<Compile Include="Misc\INIFile.cs" />
<Compile Include="Misc\Message.xaml.cs" />
<Compile Include="Misc\wxfile.cs" />
<Compile Include="MVVM\ViewModel\DiscordRpcViewModel.cs" />
<Compile Include="MVVM\ViewModel\HomeViewModel.cs" />
<Compile Include="MVVM\ViewModel\KeyManagerViewModel.cs" />
<Compile Include="MVVM\ViewModel\MainViewModel.cs" />
<Compile Include="MVVM\ViewModel\SettingsViewModel.cs" />
<Compile Include="MVVM\View\DiscordRpcView.xaml.cs" />
<Compile Include="MVVM\View\HomeView.xaml.cs" />
<Compile Include="MVVM\View\KeyManagerView.xaml.cs" />
<Compile Include="MVVM\View\SettingView.xaml.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -131,17 +137,6 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="MVVM\Model" />
</ItemGroup>
<ItemGroup>
<Content Include="Fonts\Poppins-Regular.ttf" />
<Resource Include="Images\green.png" />
<Resource Include="Images\red.png" />
<Resource Include="Images\yellow.png" />
<Resource Include="Images\discord.png" />
<Resource Include="Images\home.png" />
<Resource Include="Images\key.png" />
<Resource Include="Images\settings.png" />
<Content Include="wicns.ico" />
<Resource Include="Images\wicon.png" />
</ItemGroup>

View file

@ -2,4 +2,6 @@
<packages>
<package id="DiscordRichPresence" version="1.0.175" targetFramework="net48" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net48" />
<package id="System.Drawing.Common" version="6.0.0" targetFramework="net48" />
<package id="WPF-UI" version="2.0.3" targetFramework="net48" />
</packages>