mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Fixes due to the merge with Yilanst master
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -134,7 +134,7 @@ 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")
|
||||
if (Settings.GetRegValue("Exp_KeyboardHook", false))
|
||||
{
|
||||
ControlHook = new KVMControlHook();
|
||||
KeyboardCallback = SendKey;
|
||||
@@ -144,7 +144,7 @@ namespace MeshCentralRouter
|
||||
{
|
||||
isHookWanted = false;
|
||||
}
|
||||
if (Settings.GetRegValue("Exp_KeyboardHookPriority", "false").ToLower() == "true")
|
||||
if (Settings.GetRegValue("Exp_KeyboardHookPriority", false))
|
||||
{
|
||||
isHookPriority = true;
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
18
MainForm.cs
18
MainForm.cs
@@ -158,6 +158,12 @@ namespace MeshCentralRouter
|
||||
Version version = Assembly.GetEntryAssembly().GetName().Version;
|
||||
versionLabel.Text = "v" + version.Major + "." + version.Minor + "." + version.Build;
|
||||
|
||||
// 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;
|
||||
@@ -240,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();
|
||||
}
|
||||
|
||||
@@ -316,7 +322,7 @@ namespace MeshCentralRouter
|
||||
}
|
||||
|
||||
// Restore Window Location
|
||||
string locationStr = getRegValue("location", "");
|
||||
string locationStr = Settings.GetRegValue("location", "");
|
||||
if (locationStr != null)
|
||||
{
|
||||
string[] locationSplit = locationStr.Split(',');
|
||||
@@ -372,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)
|
||||
@@ -1221,8 +1227,8 @@ 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;
|
||||
f.Exp_KeyboardHookPriority = Settings.GetRegValue("Exp_KeyboardHookPriority", false);
|
||||
f.Exp_KeyboardHook = Settings.GetRegValue("Exp_KeyboardHook", false);
|
||||
|
||||
if (f.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
@@ -1710,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)
|
||||
{
|
||||
|
||||
@@ -228,7 +228,6 @@
|
||||
<Compile Include="ServerUserControl.Designer.cs">
|
||||
<DependentUpon>ServerUserControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultSettings.cs" />
|
||||
<Compile Include="SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
16
Settings.cs
16
Settings.cs
@@ -13,8 +13,12 @@ namespace MeshCentralRouter
|
||||
{
|
||||
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
|
||||
/// 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>
|
||||
@@ -23,5 +27,15 @@ namespace MeshCentralRouter
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user