mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-20 10:13:21 +00:00
Added remote desktop split screen mode
This commit is contained in:
63
KVMViewer.cs
63
KVMViewer.cs
@@ -41,6 +41,8 @@ namespace MeshCentralRouter
|
||||
private string lastClipboardSent = null;
|
||||
private DateTime lastClipboardTime = DateTime.MinValue;
|
||||
public string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
|
||||
private bool splitMode = false;
|
||||
private KVMViewerExtra[] extraDisplays = null;
|
||||
|
||||
// Stats
|
||||
public long bytesIn = 0;
|
||||
@@ -69,6 +71,7 @@ namespace MeshCentralRouter
|
||||
kvmControl = resizeKvmControl.KVM;
|
||||
kvmControl.parent = this;
|
||||
kvmControl.DesktopSizeChanged += KvmControl_DesktopSizeChanged;
|
||||
kvmControl.ScreenAreaUpdated += KvmControl_ScreenAreaUpdated;
|
||||
resizeKvmControl.ZoomToFit = true;
|
||||
UpdateStatus();
|
||||
this.MouseWheel += MainForm_MouseWheel;
|
||||
@@ -84,6 +87,12 @@ namespace MeshCentralRouter
|
||||
kvmControl.AutoSendClipboard = Settings.GetRegValue("kvmAutoClipboard", "0").Equals("1");
|
||||
}
|
||||
|
||||
private void KvmControl_ScreenAreaUpdated(Bitmap desktop, Rectangle r)
|
||||
{
|
||||
if (extraDisplays == null) return;
|
||||
foreach (KVMViewerExtra x in extraDisplays) { x.UpdateScreenArea(desktop, r); }
|
||||
}
|
||||
|
||||
private void Parent_ClipboardChanged()
|
||||
{
|
||||
if (state != 3) return;
|
||||
@@ -301,6 +310,8 @@ namespace MeshCentralRouter
|
||||
if (wc != null)
|
||||
{
|
||||
// Disconnect
|
||||
if (splitMode) { splitButton_Click(this, null); }
|
||||
splitButton.Visible = false;
|
||||
state = 0;
|
||||
wc.Dispose();
|
||||
wc = null;
|
||||
@@ -392,6 +403,9 @@ namespace MeshCentralRouter
|
||||
|
||||
// Save window location
|
||||
Settings.SetRegValue("kvmlocation", Location.X + "," + Location.Y + "," + Size.Width + "," + Size.Height);
|
||||
|
||||
// Close any extra windows
|
||||
extraScreenClosed();
|
||||
}
|
||||
|
||||
private void toolStripMenuItem2_DropDownOpening(object sender, EventArgs e)
|
||||
@@ -484,11 +498,15 @@ namespace MeshCentralRouter
|
||||
displaySelectComboBox.Visible = false;
|
||||
displaySelectComboBox.Items.Clear();
|
||||
}
|
||||
|
||||
// If there are many displays and all displays is selected, enable split/join button.
|
||||
splitButton.Visible = ((kvmControl.currentDisp == 65535) && (kvmControl.displays.Count > 1));
|
||||
}
|
||||
|
||||
private void displaySelectComboBox_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
if (kvmControl != null) kvmControl.SendDisplay(((displayTag)displaySelectComboBox.SelectedItem).num);
|
||||
if (splitMode) { splitButton_Click(this, null); }
|
||||
if (kvmControl != null) { kvmControl.SendDisplay(((displayTag)displaySelectComboBox.SelectedItem).num); }
|
||||
}
|
||||
|
||||
private void resizeKvmControl_TouchEnabledChanged(object sender, EventArgs e)
|
||||
@@ -630,5 +648,48 @@ namespace MeshCentralRouter
|
||||
{
|
||||
if (wc != null) { e.Cancel = true; }
|
||||
}
|
||||
|
||||
public void extraScreenClosed()
|
||||
{
|
||||
if (splitMode) { splitButton_Click(this, null); }
|
||||
}
|
||||
|
||||
private void splitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (splitMode)
|
||||
{
|
||||
kvmControl.cropDisplay(Point.Empty, Rectangle.Empty);
|
||||
splitButton.Text = Translate.T(Properties.Resources.Split, lang);
|
||||
splitMode = false;
|
||||
if (extraDisplays != null)
|
||||
{
|
||||
// Close all extra displays
|
||||
for (int i = 0; i < extraDisplays.Length; i++)
|
||||
{
|
||||
KVMViewerExtra extraDisplay = extraDisplays[i];
|
||||
extraDisplay.Close();
|
||||
}
|
||||
extraDisplays = null;
|
||||
}
|
||||
}
|
||||
else if ((kvmControl.displayInfo != null) && (kvmControl.displayInfo.Length > 1))
|
||||
{
|
||||
int minx = 0;
|
||||
int miny = 0;
|
||||
foreach (Rectangle r in kvmControl.displayInfo) { if (r.X < minx) { minx = r.X; } if (r.Y < miny) { miny = r.Y; } }
|
||||
kvmControl.cropDisplay(new Point(minx, miny), kvmControl.displayInfo[0]);
|
||||
splitButton.Text = Translate.T(Properties.Resources.Join, lang);
|
||||
splitMode = true;
|
||||
|
||||
// Open extra displays
|
||||
extraDisplays = new KVMViewerExtra[kvmControl.displayInfo.Length - 1];
|
||||
for (int i = 1; i < kvmControl.displayInfo.Length; i++)
|
||||
{
|
||||
KVMViewerExtra extraDisplay = new KVMViewerExtra(parent, this, node, kvmControl, i);
|
||||
extraDisplays[i - 1] = extraDisplay;
|
||||
extraDisplay.Show(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user