mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Fixes to Yilanst #13
This commit is contained in:
@@ -47,7 +47,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;
|
||||
|
||||
|
||||
@@ -127,14 +130,32 @@ namespace MeshCentralRouter
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(KVMControl_MouseWheel);
|
||||
if (Settings.GetRegValue("Exp_KeyboardHook", "false").ToLower() == "true")
|
||||
{
|
||||
ControlHook = new KVMControlHook();
|
||||
KeyboardCallback = SendKey;
|
||||
isHookWanted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isHookWanted = false;
|
||||
}
|
||||
if (Settings.GetRegValue("Exp_KeyboardHookPriority", "false").ToLower() == "true")
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +164,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
if (keyboardIsAttached)
|
||||
{
|
||||
Program.controlHook.DetachCallback();
|
||||
ControlHook.DetachKeyboardHook();
|
||||
keyboardIsAttached = false;
|
||||
}
|
||||
}
|
||||
@@ -647,22 +668,31 @@ namespace MeshCentralRouter
|
||||
public static void RecycleByteArray(byte[] obj) { lock (ByteArrayRecycleList) { if (obj != null) ByteArrayRecycleList.Push(obj); } }
|
||||
|
||||
private void KVMControl_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!isHookPriority)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void KVMControl_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
15
MainForm.Designer.cs
generated
15
MainForm.Designer.cs
generated
@@ -93,6 +93,7 @@
|
||||
this.addRelayMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.remoteDesktopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.remoteFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.httpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.httpsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.rdpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -126,7 +127,6 @@
|
||||
this.saveMappingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openMapFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveMapFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.remoteFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.panel5.SuspendLayout();
|
||||
this.mainPanel.SuspendLayout();
|
||||
this.mainTabControl.SuspendLayout();
|
||||
@@ -582,6 +582,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;
|
||||
@@ -640,6 +641,12 @@
|
||||
resources.ApplyResources(this.remoteDesktopToolStripMenuItem, "remoteDesktopToolStripMenuItem");
|
||||
this.remoteDesktopToolStripMenuItem.Click += new System.EventHandler(this.remoteDesktopToolStripMenuItem_Click);
|
||||
//
|
||||
// remoteFilesToolStripMenuItem
|
||||
//
|
||||
this.remoteFilesToolStripMenuItem.Name = "remoteFilesToolStripMenuItem";
|
||||
resources.ApplyResources(this.remoteFilesToolStripMenuItem, "remoteFilesToolStripMenuItem");
|
||||
this.remoteFilesToolStripMenuItem.Click += new System.EventHandler(this.remoteFilesToolStripMenuItem_Click);
|
||||
//
|
||||
// httpToolStripMenuItem
|
||||
//
|
||||
this.httpToolStripMenuItem.Name = "httpToolStripMenuItem";
|
||||
@@ -871,12 +878,6 @@
|
||||
this.saveMapFileDialog.DefaultExt = "mcrouter";
|
||||
resources.ApplyResources(this.saveMapFileDialog, "saveMapFileDialog");
|
||||
//
|
||||
// remoteFilesToolStripMenuItem
|
||||
//
|
||||
this.remoteFilesToolStripMenuItem.Name = "remoteFilesToolStripMenuItem";
|
||||
resources.ApplyResources(this.remoteFilesToolStripMenuItem, "remoteFilesToolStripMenuItem");
|
||||
this.remoteFilesToolStripMenuItem.Click += new System.EventHandler(this.remoteFilesToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
|
||||
48
MainForm.cs
48
MainForm.cs
@@ -84,6 +84,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");
|
||||
@@ -138,14 +139,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)
|
||||
{
|
||||
@@ -159,8 +152,8 @@ 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", "");
|
||||
serverNameComboBox.Text = Settings.GetRegValue("ServerName", "");
|
||||
userNameTextBox.Text = Settings.GetRegValue("UserName", "");
|
||||
title = this.Text;
|
||||
|
||||
int argflags = 0;
|
||||
@@ -206,9 +199,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 {
|
||||
@@ -319,12 +312,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;
|
||||
@@ -363,13 +356,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;
|
||||
@@ -393,7 +386,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; }
|
||||
serverurl = new Uri("wss://" + serverNameComboBox.Text + "/control.ashx");
|
||||
meshcentral.connect(serverurl, userNameTextBox.Text, passwordTextBox.Text, twoFactorCookie);
|
||||
@@ -690,8 +683,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;
|
||||
@@ -927,7 +920,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;
|
||||
@@ -1076,9 +1069,14 @@ namespace MeshCentralRouter
|
||||
SettingsForm f = new SettingsForm();
|
||||
f.BindAllInterfaces = inaddrany;
|
||||
f.ShowSystemTray = (notifyIcon.Visible == true);
|
||||
f.Exp_KeyboardHookPriority = Settings.GetRegValue("Exp_KeyboardHookPriority", "false") == "true" ? true : false;
|
||||
f.Exp_KeyboardHook = Settings.GetRegValue("Exp_KeyboardHook", "false") == "true" ? true : 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;
|
||||
@@ -1223,14 +1221,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();
|
||||
}
|
||||
|
||||
@@ -1238,7 +1236,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
sortByNameToolStripMenuItem.Checked = true;
|
||||
sortByGroupToolStripMenuItem.Checked = false;
|
||||
setRegValue("Device Sort", "Name");
|
||||
Settings.SetRegValue("Device Sort", "Name");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
@@ -1246,7 +1244,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
sortByNameToolStripMenuItem.Checked = false;
|
||||
sortByGroupToolStripMenuItem.Checked = true;
|
||||
setRegValue("Device Sort", "Group");
|
||||
Settings.SetRegValue("Device Sort", "Group");
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,7 +1462,7 @@
|
||||
<value>SCP</value>
|
||||
</data>
|
||||
<data name="devicesContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>171, 230</value>
|
||||
<value>171, 208</value>
|
||||
</data>
|
||||
<data name=">>devicesContextMenuStrip.Name" xml:space="preserve">
|
||||
<value>devicesContextMenuStrip</value>
|
||||
@@ -1478,7 +1478,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADg
|
||||
HQAAAk1TRnQBSQFMAgEBEAEAASgBAAEoAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
HQAAAk1TRnQBSQFMAgEBEAEAATABAAEwAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
AwABUAMAAQEBAAEYBgABPP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AJYAA/0D+AP3A/sD/yEAA/0D+gP5
|
||||
A/wD/xgAAfoB+wH6A/4qAAP9A/8tAAP7A88D1QPbA88D1AO+A9QYAAP8A90D4APjA90D4APUA+MSAAP8
|
||||
AZEBjwF9AU4BaAEhAfQB9QH0JAAD/gPRA8YD+ioAAcYCxwHPAtAB2ALZA90DywPBA68DmgP3FQAD2APd
|
||||
@@ -1645,7 +1645,7 @@
|
||||
<value>2, 88</value>
|
||||
</data>
|
||||
<data name="noSearchResultsLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>438, 52</value>
|
||||
<value>434, 52</value>
|
||||
</data>
|
||||
<data name="noSearchResultsLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
@@ -1684,7 +1684,7 @@
|
||||
<value>2, 88</value>
|
||||
</data>
|
||||
<data name="noDevicesLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>438, 52</value>
|
||||
<value>434, 52</value>
|
||||
</data>
|
||||
<data name="noDevicesLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
@@ -1774,7 +1774,7 @@
|
||||
<value>2, 79</value>
|
||||
</data>
|
||||
<data name="noMapLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>438, 52</value>
|
||||
<value>434, 52</value>
|
||||
</data>
|
||||
<data name="noMapLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
@@ -5814,6 +5814,12 @@ Click "Add" to get started.</value>
|
||||
<data name=">>remoteDesktopToolStripMenuItem.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>remoteFilesToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>remoteFilesToolStripMenuItem</value>
|
||||
</data>
|
||||
<data name=">>remoteFilesToolStripMenuItem.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>httpToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>httpToolStripMenuItem</value>
|
||||
</data>
|
||||
@@ -5916,12 +5922,6 @@ Click "Add" to get started.</value>
|
||||
<data name=">>saveMapFileDialog.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.SaveFileDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>remoteFilesToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>remoteFilesToolStripMenuItem</value>
|
||||
</data>
|
||||
<data name=">>remoteFilesToolStripMenuItem.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>MainForm</value>
|
||||
</data>
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
<Compile Include="FileViewer.Designer.cs">
|
||||
<DependentUpon>FileViewer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="InstallForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -221,6 +222,7 @@
|
||||
<Compile Include="ServerUserControl.Designer.cs">
|
||||
<DependentUpon>ServerUserControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultSettings.cs" />
|
||||
<Compile Include="SettingsForm.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);
|
||||
|
||||
27
Settings.cs
Normal file
27
Settings.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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) { }
|
||||
}
|
||||
/// <summary>
|
||||
/// This function querys the registry. If the key is found it returns the value
|
||||
/// </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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
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,6 +177,103 @@
|
||||
<data name="groupBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<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=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookPriorityCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<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=">>exp_KeyboardHookPriorityCheckBox.Parent" xml:space="preserve">
|
||||
<value>groupBox1</value>
|
||||
</data>
|
||||
<data name=">>exp_KeyboardHookPriorityCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="exp_KeyboardHookCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<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="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=">>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=">>exp_KeyboardHookCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="systemTrayCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
@@ -202,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>
|
||||
@@ -229,13 +326,13 @@
|
||||
<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, 76</value>
|
||||
<value>294, 248</value>
|
||||
</data>
|
||||
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
@@ -262,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