mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2026-02-22 04:13:24 +00:00
@@ -246,7 +246,7 @@ namespace MeshCentralRouter
|
||||
updateLocalFileView();
|
||||
|
||||
// Restore Window Location
|
||||
string locationStr = getRegValue("filelocation", "");
|
||||
string locationStr = Settings.GetRegValue("filelocation", "");
|
||||
if (locationStr != null)
|
||||
{
|
||||
string[] locationSplit = locationStr.Split(',');
|
||||
@@ -615,7 +615,7 @@ namespace MeshCentralRouter
|
||||
node.fileViewer = null;
|
||||
|
||||
// Save window location
|
||||
setRegValue("filelocation", Location.X + "," + Location.Y + "," + Size.Width + "," + Size.Height);
|
||||
Settings.SetRegValue("filelocation", Location.X + "," + Location.Y + "," + Size.Width + "," + Size.Height);
|
||||
}
|
||||
|
||||
public delegate void displayMessageHandler(string msg);
|
||||
@@ -1216,15 +1216,6 @@ namespace MeshCentralRouter
|
||||
}
|
||||
}
|
||||
|
||||
public void setRegValue(string name, string value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { }
|
||||
}
|
||||
public string getRegValue(string name, string value)
|
||||
{
|
||||
try { return Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value).ToString(); } catch (Exception) { return value; }
|
||||
}
|
||||
|
||||
bool isPointVisibleOnAScreen(Point p)
|
||||
{
|
||||
foreach (Screen s in Screen.AllScreens) { if ((p.X < s.Bounds.Right) && (p.X > s.Bounds.Left) && (p.Y > s.Bounds.Top) && (p.Y < s.Bounds.Bottom)) return true; }
|
||||
|
||||
@@ -48,7 +48,10 @@ namespace MeshCentralRouter
|
||||
public double DpiX = 96;
|
||||
public double DpiY = 96;
|
||||
public KVMViewer parent = null;
|
||||
private readonly KVMControlHook ControlHook;
|
||||
private readonly KVMControlHook.KVMCallback KeyboardCallback;
|
||||
private bool isHookWanted;
|
||||
private bool isHookPriority;
|
||||
private bool keyboardIsAttached;
|
||||
private long killNextKeyPress = 0;
|
||||
|
||||
@@ -131,14 +134,32 @@ namespace MeshCentralRouter
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(KVMControl_MouseWheel);
|
||||
KeyboardCallback = SendKey;
|
||||
if (Settings.GetRegValue("Exp_KeyboardHook", false))
|
||||
{
|
||||
ControlHook = new KVMControlHook();
|
||||
KeyboardCallback = SendKey;
|
||||
isHookWanted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isHookWanted = false;
|
||||
}
|
||||
if (Settings.GetRegValue("Exp_KeyboardHookPriority", false))
|
||||
{
|
||||
isHookPriority = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isHookPriority = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AttachKeyboard()
|
||||
{
|
||||
if (!keyboardIsAttached)
|
||||
Console.WriteLine(isHookWanted);
|
||||
if (!keyboardIsAttached && isHookWanted)
|
||||
{
|
||||
Program.controlHook.AttachCallback(KeyboardCallback);
|
||||
ControlHook.AttachKeyboardHook(SendKey);
|
||||
keyboardIsAttached = true;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +168,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
if (keyboardIsAttached)
|
||||
{
|
||||
Program.controlHook.DetachCallback();
|
||||
ControlHook.DetachKeyboardHook();
|
||||
keyboardIsAttached = false;
|
||||
}
|
||||
}
|
||||
@@ -687,21 +708,30 @@ namespace MeshCentralRouter
|
||||
|
||||
private void KVMControl_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if ((e.KeyCode == Keys.LWin) || (e.KeyCode == Keys.RWin)) return; // Don't process the Windows key
|
||||
SendKey(e, 0);
|
||||
e.Handled = true;
|
||||
if (!isHookPriority)
|
||||
{
|
||||
if ((e.KeyCode == Keys.LWin) || (e.KeyCode == Keys.RWin)) return; // Don't process the Windows key
|
||||
SendKey(e, 0);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void KVMControl_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
SendPress(e, 0);
|
||||
e.Handled = true;
|
||||
if (!isHookPriority)
|
||||
{
|
||||
SendPress(e, 0);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void KVMControl_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
SendKey(e, 1);
|
||||
e.Handled = true;
|
||||
if (!isHookPriority)
|
||||
{
|
||||
SendKey(e, 1);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace MeshCentralRouter
|
||||
internal KVMControlHook()
|
||||
{
|
||||
_proc = HookCallback;
|
||||
AttachKeyboardHook();
|
||||
}
|
||||
|
||||
private void AttachKeyboardHook()
|
||||
internal void AttachKeyboardHook(KVMCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
_hook = KVMKeyboardHook.SetHook(_proc);
|
||||
_callback = callback;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -31,18 +31,9 @@ namespace MeshCentralRouter
|
||||
}
|
||||
}
|
||||
|
||||
internal void AttachCallback(KVMCallback callback)
|
||||
{
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
internal void DetachCallback()
|
||||
internal void DetachKeyboardHook()
|
||||
{
|
||||
_callback = null;
|
||||
}
|
||||
|
||||
internal static void DetachKeyboardHook()
|
||||
{
|
||||
if (_hook != IntPtr.Zero)
|
||||
KVMKeyboardHook.UnhookWindowsHookEx(_hook);
|
||||
}
|
||||
|
||||
22
KVMViewer.cs
22
KVMViewer.cs
@@ -80,7 +80,7 @@ namespace MeshCentralRouter
|
||||
topPanel.Visible = true;
|
||||
|
||||
// Restore Window Location
|
||||
string locationStr = getRegValue("kvmlocation", "");
|
||||
string locationStr = Settings.GetRegValue("kvmlocation", "");
|
||||
if (locationStr != null)
|
||||
{
|
||||
string[] locationSplit = locationStr.Split(',');
|
||||
@@ -319,7 +319,7 @@ namespace MeshCentralRouter
|
||||
closeKvmStats();
|
||||
|
||||
// Save window location
|
||||
setRegValue("kvmlocation", Location.X + "," + Location.Y + "," + Size.Width + "," + Size.Height);
|
||||
Settings.SetRegValue("kvmlocation", Location.X + "," + Location.Y + "," + Size.Width + "," + Size.Height);
|
||||
}
|
||||
|
||||
private void toolStripMenuItem2_DropDownOpening(object sender, EventArgs e)
|
||||
@@ -446,15 +446,6 @@ namespace MeshCentralRouter
|
||||
//kvmControl.SendCharmsKey();
|
||||
}
|
||||
|
||||
public static void saveToRegistry(string name, string value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\OpenSource\MeshRouter", name, value); } catch (Exception) { }
|
||||
}
|
||||
public static string loadFromRegistry(string name)
|
||||
{
|
||||
try { return Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\OpenSource\MeshRouter", name, "").ToString(); } catch (Exception) { return ""; }
|
||||
}
|
||||
|
||||
public delegate void displayMessageHandler(string msg);
|
||||
public void displayMessage(string msg)
|
||||
{
|
||||
@@ -534,15 +525,6 @@ namespace MeshCentralRouter
|
||||
kvmControl.AttachKeyboard();
|
||||
}
|
||||
|
||||
public void setRegValue(string name, string value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { }
|
||||
}
|
||||
public string getRegValue(string name, string value)
|
||||
{
|
||||
try { return Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value).ToString(); } catch (Exception) { return value; }
|
||||
}
|
||||
|
||||
bool isPointVisibleOnAScreen(Point p)
|
||||
{
|
||||
foreach (Screen s in Screen.AllScreens) { if ((p.X < s.Bounds.Right) && (p.X > s.Bounds.Left) && (p.Y > s.Bounds.Top) && (p.Y < s.Bounds.Bottom)) return true; }
|
||||
|
||||
3
MainForm.Designer.cs
generated
3
MainForm.Designer.cs
generated
@@ -612,6 +612,7 @@
|
||||
this.devicesListView.FullRowSelect = true;
|
||||
this.devicesListView.GridLines = true;
|
||||
this.devicesListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.devicesListView.HideSelection = false;
|
||||
this.devicesListView.LargeImageList = this.devicesImageList;
|
||||
resources.ApplyResources(this.devicesListView, "devicesListView");
|
||||
this.devicesListView.MultiSelect = false;
|
||||
@@ -920,7 +921,7 @@
|
||||
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
|
||||
resources.ApplyResources(this.toolStripMenuItem5, "toolStripMenuItem5");
|
||||
//
|
||||
// settingsToolStripMenuItem1
|
||||
// ToolStripMenuItem1
|
||||
//
|
||||
this.settingsToolStripMenuItem1.Name = "settingsToolStripMenuItem1";
|
||||
resources.ApplyResources(this.settingsToolStripMenuItem1, "settingsToolStripMenuItem1");
|
||||
|
||||
62
MainForm.cs
62
MainForm.cs
@@ -87,6 +87,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
if (IsAdministrator() == false)
|
||||
{
|
||||
|
||||
// Restart program and run as admin
|
||||
var exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo(exeName, "-install");
|
||||
@@ -141,14 +142,6 @@ namespace MeshCentralRouter
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)]string lParam);
|
||||
|
||||
public void setRegValue(string name, string value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { }
|
||||
}
|
||||
public string getRegValue(string name, string value)
|
||||
{
|
||||
try {return Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value).ToString(); } catch (Exception) { return value; }
|
||||
}
|
||||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
@@ -165,8 +158,14 @@ namespace MeshCentralRouter
|
||||
Version version = Assembly.GetEntryAssembly().GetName().Version;
|
||||
versionLabel.Text = "v" + version.Major + "." + version.Minor + "." + version.Build;
|
||||
|
||||
serverNameComboBox.Text = getRegValue("ServerName", "");
|
||||
userNameTextBox.Text = getRegValue("UserName", "");
|
||||
// Prevent edgecase where the hook priority can be on and the hook disabled causing havoc
|
||||
if( !Settings.GetRegValue("Exp_KeyboardHook", false) )
|
||||
{
|
||||
Settings.SetRegValue("Exp_KeyboardHookPriority", false);
|
||||
}
|
||||
|
||||
serverNameComboBox.Text = Settings.GetRegValue("ServerName", "");
|
||||
userNameTextBox.Text = Settings.GetRegValue("UserName", "");
|
||||
title = this.Text;
|
||||
|
||||
int argflags = 0;
|
||||
@@ -247,7 +246,7 @@ namespace MeshCentralRouter
|
||||
installButton.Visible = !isRouterHooked();
|
||||
|
||||
// Right click action
|
||||
deviceDoubleClickAction = int.Parse(getRegValue("DevDoubleClickClickAction", "0"));
|
||||
deviceDoubleClickAction = int.Parse(Settings.GetRegValue("DevDoubleClickClickAction", "0"));
|
||||
setDoubleClickDeviceAction();
|
||||
}
|
||||
|
||||
@@ -283,9 +282,9 @@ namespace MeshCentralRouter
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Load registry settings
|
||||
showGroupNamesToolStripMenuItem.Checked = (getRegValue("Show Group Names", "1") == "1");
|
||||
showOfflineDevicesToolStripMenuItem.Checked = (getRegValue("Show Offline Devices", "1") == "1");
|
||||
if (getRegValue("Device Sort", "Name") == "Name") {
|
||||
showGroupNamesToolStripMenuItem.Checked = (Settings.GetRegValue("Show Group Names", "1") == "1");
|
||||
showOfflineDevicesToolStripMenuItem.Checked = (Settings.GetRegValue("Show Offline Devices", "1") == "1");
|
||||
if (Settings.GetRegValue("Device Sort", "Name") == "Name") {
|
||||
sortByNameToolStripMenuItem.Checked = true;
|
||||
sortByGroupToolStripMenuItem.Checked = false;
|
||||
} else {
|
||||
@@ -323,7 +322,7 @@ namespace MeshCentralRouter
|
||||
}
|
||||
|
||||
// Restore Window Location
|
||||
string locationStr = getRegValue("location", "");
|
||||
string locationStr = Settings.GetRegValue("location", "");
|
||||
if (locationStr != null)
|
||||
{
|
||||
string[] locationSplit = locationStr.Split(',');
|
||||
@@ -379,7 +378,7 @@ namespace MeshCentralRouter
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if ((notifyIcon.Visible == true) && (forceExit == false)) { e.Cancel = true; Visible = false; }
|
||||
setRegValue("Location", Location.X + "," + Location.Y);
|
||||
Settings.SetRegValue("Location", Location.X + "," + Location.Y);
|
||||
}
|
||||
|
||||
private void backButton5_Click(object sender, EventArgs e)
|
||||
@@ -423,12 +422,12 @@ namespace MeshCentralRouter
|
||||
}
|
||||
else
|
||||
{
|
||||
string ignoreCert = getRegValue("IgnoreCert", null);
|
||||
string ignoreCert = Settings.GetRegValue("IgnoreCert", null);
|
||||
if (ignoreCert != null) { meshcentral.okCertHash = ignoreCert; }
|
||||
}
|
||||
|
||||
// Load two factor cookie if present
|
||||
string twoFactorCookie = getRegValue("TwoFactorCookie", null);
|
||||
string twoFactorCookie = Settings.GetRegValue("TwoFactorCookie", null);
|
||||
if ((twoFactorCookie != null) && (twoFactorCookie != "")) { twoFactorCookie = "cookie=" + twoFactorCookie; } else { twoFactorCookie = null; }
|
||||
|
||||
Uri serverurl = null;
|
||||
@@ -467,13 +466,13 @@ namespace MeshCentralRouter
|
||||
private void Meshcentral_onTwoFactorCookie(string cookie)
|
||||
{
|
||||
if (this.InvokeRequired) { this.Invoke(new MeshCentralServer.twoFactorCookieHandler(Meshcentral_onTwoFactorCookie), cookie); return; }
|
||||
setRegValue("TwoFactorCookie", cookie);
|
||||
Settings.SetRegValue("TwoFactorCookie", cookie);
|
||||
}
|
||||
|
||||
private void nextButton3_Click(object sender, EventArgs e)
|
||||
{
|
||||
// If we need to remember this certificate
|
||||
if (rememberCertCheckBox.Checked) { setRegValue("IgnoreCert", lastBadConnectCert.GetCertHashString()); }
|
||||
if (rememberCertCheckBox.Checked) { Settings.SetRegValue("IgnoreCert", lastBadConnectCert.GetCertHashString()); }
|
||||
|
||||
// Attempt to login, ignore bad cert.
|
||||
addButton.Enabled = false;
|
||||
@@ -501,7 +500,7 @@ namespace MeshCentralRouter
|
||||
meshcentral.connect(serverurl, null, null, null);
|
||||
} else {
|
||||
// Load two factor cookie if present
|
||||
string twoFactorCookie = getRegValue("TwoFactorCookie", null);
|
||||
string twoFactorCookie = Settings.GetRegValue("TwoFactorCookie", null);
|
||||
if ((twoFactorCookie != null) && (twoFactorCookie != "")) { twoFactorCookie = "cookie=" + twoFactorCookie; } else { twoFactorCookie = null; }
|
||||
int keyIndex = serverNameComboBox.Text.IndexOf("?key=");
|
||||
if (keyIndex >= 0)
|
||||
@@ -816,8 +815,8 @@ namespace MeshCentralRouter
|
||||
addButton.Focus();
|
||||
if (authLoginUrl == null)
|
||||
{
|
||||
setRegValue("ServerName", serverNameComboBox.Text);
|
||||
setRegValue("UserName", userNameTextBox.Text);
|
||||
Settings.SetRegValue("ServerName", serverNameComboBox.Text);
|
||||
Settings.SetRegValue("UserName", userNameTextBox.Text);
|
||||
}
|
||||
if (meshcentral.username != null) {
|
||||
this.Text = title + " - " + meshcentral.username;
|
||||
@@ -1067,7 +1066,7 @@ namespace MeshCentralRouter
|
||||
if (lastBadConnectCert != null) {
|
||||
meshcentral.okCertHash = lastBadConnectCert.GetCertHashString();
|
||||
} else {
|
||||
string ignoreCert = getRegValue("IgnoreCert", null);
|
||||
string ignoreCert = Settings.GetRegValue("IgnoreCert", null);
|
||||
if (ignoreCert != null) { meshcentral.okCertHash = ignoreCert; }
|
||||
}
|
||||
meshcentral.onStateChanged += Meshcentral_onStateChanged;
|
||||
@@ -1228,9 +1227,14 @@ namespace MeshCentralRouter
|
||||
SettingsForm f = new SettingsForm();
|
||||
f.BindAllInterfaces = inaddrany;
|
||||
f.ShowSystemTray = (notifyIcon.Visible == true);
|
||||
f.Exp_KeyboardHookPriority = Settings.GetRegValue("Exp_KeyboardHookPriority", false);
|
||||
f.Exp_KeyboardHook = Settings.GetRegValue("Exp_KeyboardHook", false);
|
||||
|
||||
if (f.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
inaddrany = f.BindAllInterfaces;
|
||||
Settings.SetRegValue("Exp_KeyboardHook", f.Exp_KeyboardHook.ToString().ToLower());
|
||||
Settings.SetRegValue("Exp_KeyboardHookPriority", f.Exp_KeyboardHookPriority.ToString().ToLower());
|
||||
if (f.ShowSystemTray) {
|
||||
notifyIcon.Visible = true;
|
||||
this.ShowInTaskbar = false;
|
||||
@@ -1378,14 +1382,14 @@ namespace MeshCentralRouter
|
||||
private void showGroupNamesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
showGroupNamesToolStripMenuItem.Checked = !showGroupNamesToolStripMenuItem.Checked;
|
||||
setRegValue("Show Group Names", showGroupNamesToolStripMenuItem.Checked ? "1" : "0");
|
||||
Settings.SetRegValue("Show Group Names", showGroupNamesToolStripMenuItem.Checked ? "1" : "0");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
private void hideOfflineDevicesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
showOfflineDevicesToolStripMenuItem.Checked = !showOfflineDevicesToolStripMenuItem.Checked;
|
||||
setRegValue("Show Offline Devices", showOfflineDevicesToolStripMenuItem.Checked?"1":"0");
|
||||
Settings.SetRegValue("Show Offline Devices", showOfflineDevicesToolStripMenuItem.Checked?"1":"0");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
@@ -1393,7 +1397,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
sortByNameToolStripMenuItem.Checked = true;
|
||||
sortByGroupToolStripMenuItem.Checked = false;
|
||||
setRegValue("Device Sort", "Name");
|
||||
Settings.SetRegValue("Device Sort", "Name");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
@@ -1401,7 +1405,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
sortByNameToolStripMenuItem.Checked = false;
|
||||
sortByGroupToolStripMenuItem.Checked = true;
|
||||
setRegValue("Device Sort", "Group");
|
||||
Settings.SetRegValue("Device Sort", "Group");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
@@ -1712,7 +1716,7 @@ namespace MeshCentralRouter
|
||||
if (f.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
deviceDoubleClickAction = f.deviceDoubleClickAction;
|
||||
setRegValue("DevDoubleClickClickAction", deviceDoubleClickAction.ToString());
|
||||
Settings.SetRegValue("DevDoubleClickClickAction", deviceDoubleClickAction.ToString());
|
||||
setDoubleClickDeviceAction();
|
||||
if (f.ShowSystemTray)
|
||||
{
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
<Compile Include="FileViewer.Designer.cs">
|
||||
<DependentUpon>FileViewer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="InstallForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace MeshCentralRouter
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static KVMControlHook controlHook = new KVMControlHook();
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
// Setup settings & visual style
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
41
Settings.cs
Normal file
41
Settings.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MeshCentralRouter
|
||||
{
|
||||
public static class Settings
|
||||
{
|
||||
public static void SetRegValue(string name, string value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { }
|
||||
}
|
||||
public static void SetRegValue(string name, bool value)
|
||||
{
|
||||
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value.ToString()); } catch (Exception) { }
|
||||
}
|
||||
/// <summary>
|
||||
/// This function querys the registry. If the key is found it returns the value as a string
|
||||
/// </summary>
|
||||
/// <param name="name">Keyname</param>
|
||||
/// <param name="value">Return on fail</param>
|
||||
/// <returns></returns>
|
||||
public static string GetRegValue(string name, string value)
|
||||
{
|
||||
try { return Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value).ToString(); } catch (Exception) { return value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// This function querys the registry. If the key is found it returns the value as a boolean
|
||||
/// </summary>
|
||||
/// <param name="name">Keyname</param>
|
||||
/// <param name="value">Return on fail</param>
|
||||
/// <returns></returns>
|
||||
public static bool GetRegValue(string name, bool value)
|
||||
{
|
||||
try { return bool.Parse(GetRegValue(name, value.ToString())); } catch (Exception) { return value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
27
SettingsForm.Designer.cs
generated
27
SettingsForm.Designer.cs
generated
@@ -34,6 +34,9 @@
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.systemTrayCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.allInterfacesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.exp_KeyboardHookCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.exp_KeyboardHookPriorityCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -55,6 +58,9 @@
|
||||
// groupBox1
|
||||
//
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.exp_KeyboardHookPriorityCheckBox);
|
||||
this.groupBox1.Controls.Add(this.exp_KeyboardHookCheckBox);
|
||||
this.groupBox1.Controls.Add(this.systemTrayCheckBox);
|
||||
this.groupBox1.Controls.Add(this.allInterfacesCheckBox);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
@@ -72,6 +78,24 @@
|
||||
this.allInterfacesCheckBox.Name = "allInterfacesCheckBox";
|
||||
this.allInterfacesCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// exp_KeyboardHookCheckBox
|
||||
//
|
||||
resources.ApplyResources(this.exp_KeyboardHookCheckBox, "exp_KeyboardHookCheckBox");
|
||||
this.exp_KeyboardHookCheckBox.Name = "exp_KeyboardHookCheckBox";
|
||||
this.exp_KeyboardHookCheckBox.UseVisualStyleBackColor = true;
|
||||
this.exp_KeyboardHookCheckBox.CheckedChanged += new System.EventHandler(this.exp_KeyboardHookCheckBox_CheckedChanged);
|
||||
//
|
||||
// exp_KeyboardHookPriorityCheckBox
|
||||
//
|
||||
resources.ApplyResources(this.exp_KeyboardHookPriorityCheckBox, "exp_KeyboardHookPriorityCheckBox");
|
||||
this.exp_KeyboardHookPriorityCheckBox.Name = "exp_KeyboardHookPriorityCheckBox";
|
||||
this.exp_KeyboardHookPriorityCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
@@ -98,5 +122,8 @@
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox systemTrayCheckBox;
|
||||
private System.Windows.Forms.CheckBox allInterfacesCheckBox;
|
||||
private System.Windows.Forms.CheckBox exp_KeyboardHookCheckBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.CheckBox exp_KeyboardHookPriorityCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,25 @@ namespace MeshCentralRouter
|
||||
set { systemTrayCheckBox.Checked = value; }
|
||||
}
|
||||
|
||||
public bool Exp_KeyboardHook
|
||||
{
|
||||
get { return exp_KeyboardHookCheckBox.Checked; }
|
||||
set {
|
||||
exp_KeyboardHookCheckBox.Checked = value;
|
||||
if (!value)
|
||||
{
|
||||
exp_KeyboardHookPriorityCheckBox.Checked = false;
|
||||
exp_KeyboardHookPriorityCheckBox.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exp_KeyboardHookPriority
|
||||
{
|
||||
get { return exp_KeyboardHookPriorityCheckBox.Checked; }
|
||||
set { exp_KeyboardHookPriorityCheckBox.Checked = value; }
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
@@ -37,5 +56,17 @@ namespace MeshCentralRouter
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void exp_KeyboardHookCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (exp_KeyboardHookCheckBox.Checked)
|
||||
{
|
||||
exp_KeyboardHookPriorityCheckBox.Enabled = true;
|
||||
} else
|
||||
{
|
||||
exp_KeyboardHookPriorityCheckBox.Checked = false;
|
||||
exp_KeyboardHookPriorityCheckBox.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>231, 94</value>
|
||||
<value>231, 266</value>
|
||||
</data>
|
||||
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>75, 23</value>
|
||||
@@ -151,7 +151,7 @@
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>150, 94</value>
|
||||
<value>150, 266</value>
|
||||
</data>
|
||||
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>75, 23</value>
|
||||
@@ -177,53 +177,102 @@
|
||||
<data name="groupBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name=">>systemTrayCheckBox.Name" xml:space="preserve">
|
||||
<value>systemTrayCheckBox</value>
|
||||
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name=">>systemTrayCheckBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<data name="label1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name=">>systemTrayCheckBox.Parent" xml:space="preserve">
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>10, 139</value>
|
||||
</data>
|
||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>196, 13</value>
|
||||
</data>
|
||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>Experimental Features (Use at own risk!)</value>
|
||||
</data>
|
||||
<data name=">>label1.Name" xml:space="preserve">
|
||||
<value>label1</value>
|
||||
</data>
|
||||
<data name=">>label1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label1.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>systemTrayCheckBox.ZOrder" xml:space="preserve">
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>allInterfacesCheckBox.Name" xml:space="preserve">
|
||||
<value>allInterfacesCheckBox</value>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name=">>allInterfacesCheckBox.Type" xml:space="preserve">
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>13, 155</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>244, 69</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.Text" xml:space="preserve">
|
||||
<value>Override all default keyboard input with
|
||||
the keyboard hook in remote desktop
|
||||
(This is not considered stable use at own risk)
|
||||
This will allow for all key combinations execept
|
||||
CTRL + ALT + DEL
|
||||
</value>
|
||||
</data>
|
||||
<data name=">>exp_KeyboardHookPriorityCheckBox.Name" xml:space="preserve">
|
||||
<value>exp_KeyboardHookPriorityCheckBox</value>
|
||||
</data>
|
||||
<data name=">>exp_KeyboardHookPriorityCheckBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>allInterfacesCheckBox.Parent" xml:space="preserve">
|
||||
<data name=">>exp_KeyboardHookPriorityCheckBox.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>allInterfacesCheckBox.ZOrder" xml:space="preserve">
|
||||
<data name=">>exp_KeyboardHookPriorityCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 12</value>
|
||||
<data name="exp_KeyboardHookCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>294, 76</value>
|
||||
<data name="exp_KeyboardHookCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="exp_KeyboardHookCheckBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>13, 68</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookCheckBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>210, 43</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookCheckBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="groupBox1.Text" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
<data name="exp_KeyboardHookCheckBox.Text" xml:space="preserve">
|
||||
<value>Enable experimental keyboard hook
|
||||
(This may make some antiviruses mad!)
|
||||
This will allow special keys</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Name" xml:space="preserve">
|
||||
<data name=">>exp_KeyboardHookCheckBox.Name" xml:space="preserve">
|
||||
<value>exp_KeyboardHookCheckBox</value>
|
||||
</data>
|
||||
<data name=">>exp_KeyboardHookCheckBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>exp_KeyboardHookCheckBox.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<data name=">>exp_KeyboardHookCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="systemTrayCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -250,7 +299,7 @@
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>systemTrayCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="allInterfacesCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -277,7 +326,31 @@
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>allInterfacesCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 12</value>
|
||||
</data>
|
||||
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>294, 248</value>
|
||||
</data>
|
||||
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="groupBox1.Text" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Name" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>groupBox1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
@@ -286,7 +359,7 @@
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>318, 129</value>
|
||||
<value>318, 301</value>
|
||||
</data>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
Reference in New Issue
Block a user