1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

Desktop Setting Improvements.

This commit is contained in:
Ylian Saint-Hilaire
2022-02-24 14:21:14 -08:00
parent 5e0a9ae108
commit d1091c5e0c
6 changed files with 128 additions and 29 deletions

View File

@@ -40,6 +40,7 @@ namespace MeshCentralRouter
private bool swamMouseButtons = false;
private bool remoteKeyboardMap = false;
private bool autoSendClipboard = false;
public bool AutoReconnect = false;
private double scalefactor = 1;
public List<ushort> displays = new List<ushort>();
public ushort currentDisp = 0;

View File

@@ -32,6 +32,7 @@
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.autoSendClipboardCheckBox = new System.Windows.Forms.CheckBox();
this.remoteKeyboardMapCheckBox = new System.Windows.Forms.CheckBox();
this.swapMouseButtonsCheckBox = new System.Windows.Forms.CheckBox();
this.frameRateComboBox = new System.Windows.Forms.ComboBox();
@@ -42,7 +43,7 @@
this.label3 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label4 = new System.Windows.Forms.Label();
this.autoSendClipboardCheckBox = new System.Windows.Forms.CheckBox();
this.autoReconnectCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
@@ -65,6 +66,7 @@
// groupBox1
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.autoReconnectCheckBox);
this.groupBox1.Controls.Add(this.autoSendClipboardCheckBox);
this.groupBox1.Controls.Add(this.remoteKeyboardMapCheckBox);
this.groupBox1.Controls.Add(this.swapMouseButtonsCheckBox);
@@ -77,6 +79,12 @@
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// autoSendClipboardCheckBox
//
resources.ApplyResources(this.autoSendClipboardCheckBox, "autoSendClipboardCheckBox");
this.autoSendClipboardCheckBox.Name = "autoSendClipboardCheckBox";
this.autoSendClipboardCheckBox.UseVisualStyleBackColor = true;
//
// remoteKeyboardMapCheckBox
//
resources.ApplyResources(this.remoteKeyboardMapCheckBox, "remoteKeyboardMapCheckBox");
@@ -137,11 +145,11 @@
resources.ApplyResources(this.label4, "label4");
this.label4.Name = "label4";
//
// autoSendClipboardCheckBox
// autoReconnectCheckBox
//
resources.ApplyResources(this.autoSendClipboardCheckBox, "autoSendClipboardCheckBox");
this.autoSendClipboardCheckBox.Name = "autoSendClipboardCheckBox";
this.autoSendClipboardCheckBox.UseVisualStyleBackColor = true;
resources.ApplyResources(this.autoReconnectCheckBox, "autoReconnectCheckBox");
this.autoReconnectCheckBox.Name = "autoReconnectCheckBox";
this.autoReconnectCheckBox.UseVisualStyleBackColor = true;
//
// KVMSettingsForm
//
@@ -182,5 +190,6 @@
private System.Windows.Forms.CheckBox swapMouseButtonsCheckBox;
private System.Windows.Forms.CheckBox remoteKeyboardMapCheckBox;
private System.Windows.Forms.CheckBox autoSendClipboardCheckBox;
private System.Windows.Forms.CheckBox autoReconnectCheckBox;
}
}

View File

@@ -25,6 +25,7 @@ namespace MeshCentralRouter
{
InitializeComponent();
Translate.TranslateControl(this);
qualityComboBox.Items.Add(new DropListItem(100, "100%"));
qualityComboBox.Items.Add(new DropListItem(90, "90%"));
qualityComboBox.Items.Add(new DropListItem(80, "80%"));
qualityComboBox.Items.Add(new DropListItem(70, "70%"));
@@ -76,17 +77,18 @@ namespace MeshCentralRouter
get { return ((DropListItem)qualityComboBox.SelectedItem).value; }
set
{
if (value >= 90) { qualityComboBox.SelectedIndex = 0; return; }
if (value >= 80) { qualityComboBox.SelectedIndex = 1; return; }
if (value >= 70) { qualityComboBox.SelectedIndex = 2; return; }
if (value >= 60) { qualityComboBox.SelectedIndex = 3; return; }
if (value >= 50) { qualityComboBox.SelectedIndex = 4; return; }
if (value >= 40) { qualityComboBox.SelectedIndex = 5; return; }
if (value >= 30) { qualityComboBox.SelectedIndex = 6; return; }
if (value >= 20) { qualityComboBox.SelectedIndex = 7; return; }
if (value >= 10) { qualityComboBox.SelectedIndex = 8; return; }
if (value >= 5) { qualityComboBox.SelectedIndex = 9; return; }
qualityComboBox.SelectedIndex = 10;
if (value >= 100) { qualityComboBox.SelectedIndex = 0; return; }
if (value >= 90) { qualityComboBox.SelectedIndex = 1; return; }
if (value >= 80) { qualityComboBox.SelectedIndex = 2; return; }
if (value >= 70) { qualityComboBox.SelectedIndex = 3; return; }
if (value >= 60) { qualityComboBox.SelectedIndex = 4; return; }
if (value >= 50) { qualityComboBox.SelectedIndex = 5; return; }
if (value >= 40) { qualityComboBox.SelectedIndex = 6; return; }
if (value >= 30) { qualityComboBox.SelectedIndex = 7; return; }
if (value >= 20) { qualityComboBox.SelectedIndex = 8; return; }
if (value >= 10) { qualityComboBox.SelectedIndex = 9; return; }
if (value >= 5) { qualityComboBox.SelectedIndex = 10; return; }
qualityComboBox.SelectedIndex = 11;
}
}
@@ -135,6 +137,12 @@ namespace MeshCentralRouter
set { autoSendClipboardCheckBox.Checked = value; }
}
public bool AutoReconnect
{
get { return autoReconnectCheckBox.Checked; }
set { autoReconnectCheckBox.Checked = value; }
}
private void okButton_Click(object sender, EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.OK;

View File

@@ -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>312, 254</value>
<value>312, 276</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>231, 254</value>
<value>231, 276</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
@@ -177,6 +177,36 @@
<data name="groupBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="autoReconnectCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="autoReconnectCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="autoReconnectCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>128, 174</value>
</data>
<data name="autoReconnectCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 17</value>
</data>
<data name="autoReconnectCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="autoReconnectCheckBox.Text" xml:space="preserve">
<value>Automatically Reconnect</value>
</data>
<data name="&gt;&gt;autoReconnectCheckBox.Name" xml:space="preserve">
<value>autoReconnectCheckBox</value>
</data>
<data name="&gt;&gt;autoReconnectCheckBox.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="&gt;&gt;autoReconnectCheckBox.Parent" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;autoReconnectCheckBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="autoSendClipboardCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@@ -205,7 +235,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;autoSendClipboardCheckBox.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="remoteKeyboardMapCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -235,7 +265,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;remoteKeyboardMapCheckBox.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="swapMouseButtonsCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -262,7 +292,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;swapMouseButtonsCheckBox.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="frameRateComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
@@ -286,7 +316,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;frameRateComboBox.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -313,7 +343,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="scalingComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
@@ -337,7 +367,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;scalingComboBox.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -364,7 +394,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="qualityComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
@@ -391,7 +421,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;qualityComboBox.ZOrder" xml:space="preserve">
<value>7</value>
<value>8</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -418,13 +448,13 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>8</value>
<value>9</value>
</data>
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 68</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>375, 180</value>
<value>375, 202</value>
</data>
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@@ -502,7 +532,7 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>399, 289</value>
<value>399, 311</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@@ -43,6 +43,8 @@ namespace MeshCentralRouter
public string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
private bool splitMode = false;
private KVMViewerExtra[] extraDisplays = null;
private System.Windows.Forms.Timer delayedConnectionTimer = null;
private bool localAutoReconnect = true;
// Stats
public long bytesIn = 0;
@@ -84,7 +86,19 @@ namespace MeshCentralRouter
mainToolTip.SetToolTip(clipInboundButton, Translate.T(Properties.Resources.PullClipboardFromRemoteDevice, lang));
mainToolTip.SetToolTip(zoomButton, Translate.T(Properties.Resources.ToggleZoomToFitMode, lang));
mainToolTip.SetToolTip(statsButton, Translate.T(Properties.Resources.DisplayConnectionStatistics, lang));
// Load remote desktop settings
int CompressionLevel = 60;
try { CompressionLevel = int.Parse(Settings.GetRegValue("kvmCompression", "60")); } catch (Exception) { }
int ScalingLevel = 1024;
try { ScalingLevel = int.Parse(Settings.GetRegValue("kvmScaling", "1024")); } catch (Exception) { }
int FrameRate = 100;
try { FrameRate = int.Parse(Settings.GetRegValue("kvmFrameRate", "100")); } catch (Exception) { }
kvmControl.SetCompressionParams(CompressionLevel, ScalingLevel, FrameRate);
kvmControl.SwamMouseButtons = Settings.GetRegValue("kvmSwamMouseButtons", "0").Equals("1");
kvmControl.RemoteKeyboardMap = Settings.GetRegValue("kvmSwamMouseButtons", "0").Equals("1");
kvmControl.AutoSendClipboard = Settings.GetRegValue("kvmAutoClipboard", "0").Equals("1");
kvmControl.AutoReconnect = Settings.GetRegValue("kvmAutoReconnect", "0").Equals("1");
}
private void KvmControl_ScreenAreaUpdated(Bitmap desktop, Rectangle r)
@@ -117,6 +131,25 @@ namespace MeshCentralRouter
}
}
public void TryAutoConnect()
{
if ((localAutoReconnect == false) || (kvmControl.AutoReconnect == false)) return;
if ((state == 0) && (wc == null) && (delayedConnectionTimer == null)) {
// Hold half a second before trying to connect
delayedConnectionTimer = new System.Windows.Forms.Timer(this.components);
delayedConnectionTimer.Tick += new EventHandler(updateTimerTick);
delayedConnectionTimer.Interval = 500;
delayedConnectionTimer.Enabled = true;
}
}
private void updateTimerTick(object sender, EventArgs e)
{
delayedConnectionTimer.Dispose();
delayedConnectionTimer = null;
if ((state == 0) && (wc == null)) { MenuItemConnect_Click(this, null); }
}
private void KvmControl_DesktopSizeChanged(object sender, EventArgs e)
{
kvmControl.Visible = true;
@@ -318,6 +351,7 @@ namespace MeshCentralRouter
wc.Dispose();
wc = null;
UpdateStatus();
localAutoReconnect = false;
}
else
{
@@ -325,6 +359,7 @@ namespace MeshCentralRouter
if (sender != null) { consentFlags = 0; }
MenuItemConnect_Click(null, null);
kvmControl.AttachKeyboard();
localAutoReconnect = true;
}
displayMessage(null);
}
@@ -434,11 +469,21 @@ namespace MeshCentralRouter
form.SwamMouseButtons = kvmControl.SwamMouseButtons;
form.RemoteKeyboardMap = kvmControl.RemoteKeyboardMap;
form.AutoSendClipboard = kvmControl.AutoSendClipboard;
form.AutoReconnect = kvmControl.AutoReconnect;
if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
kvmControl.SetCompressionParams(form.Compression, form.Scaling, form.FrameRate);
kvmControl.SwamMouseButtons = form.SwamMouseButtons;
kvmControl.RemoteKeyboardMap = form.RemoteKeyboardMap;
kvmControl.AutoReconnect = form.AutoReconnect;
Settings.SetRegValue("kvmCompression", kvmControl.CompressionLevel.ToString());
Settings.SetRegValue("kvmScaling", kvmControl.ScalingLevel.ToString());
Settings.SetRegValue("kvmFrameRate", kvmControl.FrameRate.ToString());
Settings.SetRegValue("kvmSwamMouseButtons", kvmControl.SwamMouseButtons ? "1" : "0");
Settings.SetRegValue("kvmRemoteKeyboardMap", kvmControl.RemoteKeyboardMap ? "1" : "0");
Settings.SetRegValue("kvmAutoReconnect", kvmControl.AutoReconnect ? "1" : "0");
if (kvmControl.AutoSendClipboard != form.AutoSendClipboard)
{
kvmControl.AutoSendClipboard = form.AutoSendClipboard;

View File

@@ -647,6 +647,12 @@ namespace MeshCentralRouter
// Setup any automatic mappings
if ((fullRefresh == true) && (mappingsToSetup != null)) { setupMappings(); }
// Reconnect any auto-reconnect nodes
foreach (NodeClass node in meshcentral.nodes.Values)
{
if (((node.conn & 1) != 0) && (node.desktopViewer != null)) { node.desktopViewer.TryAutoConnect(); }
}
}
private void updateDeviceList()