mirror of https://github.com/quasar/Quasar.git
commit
6fecce1ac9
|
@ -54,6 +54,7 @@ private void InitializeComponent()
|
|||
this.btnStart.Name = "btnStart";
|
||||
this.btnStart.Size = new System.Drawing.Size(68, 23);
|
||||
this.btnStart.TabIndex = 1;
|
||||
this.btnStart.TabStop = false;
|
||||
this.btnStart.Text = "Start";
|
||||
this.btnStart.UseVisualStyleBackColor = true;
|
||||
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
|
||||
|
@ -65,6 +66,7 @@ private void InitializeComponent()
|
|||
this.btnStop.Name = "btnStop";
|
||||
this.btnStop.Size = new System.Drawing.Size(68, 23);
|
||||
this.btnStop.TabIndex = 2;
|
||||
this.btnStop.TabStop = false;
|
||||
this.btnStop.Text = "Stop";
|
||||
this.btnStop.UseVisualStyleBackColor = true;
|
||||
this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
|
||||
|
@ -77,6 +79,7 @@ private void InitializeComponent()
|
|||
this.barQuality.Name = "barQuality";
|
||||
this.barQuality.Size = new System.Drawing.Size(76, 45);
|
||||
this.barQuality.TabIndex = 3;
|
||||
this.barQuality.TabStop = false;
|
||||
this.barQuality.Value = 75;
|
||||
this.barQuality.Scroll += new System.EventHandler(this.barQuality_Scroll);
|
||||
//
|
||||
|
@ -105,6 +108,7 @@ private void InitializeComponent()
|
|||
this.btnMouse.Name = "btnMouse";
|
||||
this.btnMouse.Size = new System.Drawing.Size(28, 28);
|
||||
this.btnMouse.TabIndex = 6;
|
||||
this.btnMouse.TabStop = false;
|
||||
this.toolTipButtons.SetToolTip(this.btnMouse, "Enable mouse input.");
|
||||
this.btnMouse.UseVisualStyleBackColor = true;
|
||||
this.btnMouse.Click += new System.EventHandler(this.btnMouse_Click);
|
||||
|
@ -133,6 +137,7 @@ private void InitializeComponent()
|
|||
this.btnKeyboard.Name = "btnKeyboard";
|
||||
this.btnKeyboard.Size = new System.Drawing.Size(28, 28);
|
||||
this.btnKeyboard.TabIndex = 9;
|
||||
this.btnKeyboard.TabStop = false;
|
||||
this.toolTipButtons.SetToolTip(this.btnKeyboard, "Enable keyboard input.");
|
||||
this.btnKeyboard.UseVisualStyleBackColor = true;
|
||||
this.btnKeyboard.Click += new System.EventHandler(this.btnKeyboard_Click);
|
||||
|
@ -145,6 +150,7 @@ private void InitializeComponent()
|
|||
this.cbMonitors.Name = "cbMonitors";
|
||||
this.cbMonitors.Size = new System.Drawing.Size(149, 21);
|
||||
this.cbMonitors.TabIndex = 8;
|
||||
this.cbMonitors.TabStop = false;
|
||||
//
|
||||
// btnHide
|
||||
//
|
||||
|
@ -152,6 +158,7 @@ private void InitializeComponent()
|
|||
this.btnHide.Name = "btnHide";
|
||||
this.btnHide.Size = new System.Drawing.Size(54, 19);
|
||||
this.btnHide.TabIndex = 7;
|
||||
this.btnHide.TabStop = false;
|
||||
this.btnHide.Text = "Hide";
|
||||
this.btnHide.UseVisualStyleBackColor = true;
|
||||
this.btnHide.Click += new System.EventHandler(this.btnHide_Click);
|
||||
|
@ -162,6 +169,7 @@ private void InitializeComponent()
|
|||
this.btnShow.Name = "btnShow";
|
||||
this.btnShow.Size = new System.Drawing.Size(54, 19);
|
||||
this.btnShow.TabIndex = 8;
|
||||
this.btnShow.TabStop = false;
|
||||
this.btnShow.Text = "Show";
|
||||
this.btnShow.UseVisualStyleBackColor = true;
|
||||
this.btnShow.Visible = false;
|
||||
|
|
|
@ -25,9 +25,11 @@ public FrmRemoteDesktop(Client c)
|
|||
_connectClient = c;
|
||||
_connectClient.Value.FrmRdp = this;
|
||||
|
||||
if (!PlatformHelper.RunningOnMono)
|
||||
Subscribe(Hook.GlobalEvents());
|
||||
|
||||
if (PlatformHelper.RunningOnMono)
|
||||
SubscribeMonoEvents();
|
||||
else
|
||||
SubscribeWindowsHookEvents(Hook.GlobalEvents());
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
@ -42,27 +44,38 @@ private void FrmRemoteDesktop_Load(object sender, EventArgs e)
|
|||
btnShow.Location = new Point(377, 0);
|
||||
btnShow.Left = (this.Width / 2) - (btnShow.Width / 2);
|
||||
|
||||
_enableKeyboardInput = false;
|
||||
_keysPressed = new List<Keys>();
|
||||
|
||||
if (_connectClient.Value != null)
|
||||
new Core.Packets.ServerPackets.GetMonitors().Execute(_connectClient);
|
||||
}
|
||||
|
||||
private void Subscribe(IKeyboardMouseEvents events)
|
||||
private void SubscribeWindowsHookEvents(IKeyboardMouseEvents events)
|
||||
{
|
||||
_mEvents = events;
|
||||
_mEvents.MouseWheel += MouseWheelEvent;
|
||||
_mEvents.KeyDown += OnKeyDown;
|
||||
_mEvents.KeyUp += OnKeyUp;
|
||||
_mEvents.KeyDown += Windows_OnKeyDown;
|
||||
_mEvents.KeyUp += Windows_OnKeyUp;
|
||||
}
|
||||
|
||||
private void Unsubscribe()
|
||||
private void SubscribeMonoEvents()
|
||||
{
|
||||
this.KeyDown += new KeyEventHandler(this.Mono_KeyDown);
|
||||
this.KeyUp += new KeyEventHandler(this.Mono_KeyUp);
|
||||
}
|
||||
|
||||
private void UnsubscribeWindowsHookEvents()
|
||||
{
|
||||
if (_mEvents == null) return;
|
||||
_mEvents.MouseWheel -= MouseWheelEvent;
|
||||
_mEvents.KeyDown -= OnKeyDown;
|
||||
_mEvents.KeyUp -= OnKeyUp;
|
||||
_mEvents.KeyDown -= Windows_OnKeyDown;
|
||||
_mEvents.KeyUp -= Windows_OnKeyUp;
|
||||
}
|
||||
|
||||
private void UnsubscribeMonoEvents()
|
||||
{
|
||||
this.KeyDown -= this.Mono_KeyDown;
|
||||
this.KeyUp -= this.Mono_KeyUp;
|
||||
}
|
||||
|
||||
public void AddMonitors(int monitors)
|
||||
|
@ -124,7 +137,8 @@ private void FrmRemoteDesktop_FormClosing(object sender, FormClosingEventArgs e)
|
|||
if (_connectClient.Value != null)
|
||||
_connectClient.Value.FrmRdp = null;
|
||||
|
||||
Unsubscribe();
|
||||
UnsubscribeWindowsHookEvents();
|
||||
UnsubscribeMonoEvents();
|
||||
}
|
||||
|
||||
private void FrmRemoteDesktop_Resize(object sender, EventArgs e)
|
||||
|
@ -305,7 +319,7 @@ private void MouseWheelEvent(object sender, MouseEventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
private void Windows_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
|
||||
{
|
||||
|
@ -321,7 +335,36 @@ private void OnKeyDown(object sender, KeyEventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void OnKeyUp(object sender, KeyEventArgs e)
|
||||
private void Windows_OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
_keysPressed.Remove(e.KeyCode);
|
||||
|
||||
if (_connectClient != null)
|
||||
new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, false).Execute(_connectClient);
|
||||
}
|
||||
}
|
||||
|
||||
private void Mono_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (_keysPressed.Contains(e.KeyCode))
|
||||
return;
|
||||
|
||||
_keysPressed.Add(e.KeyCode);
|
||||
|
||||
if (_connectClient != null)
|
||||
new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, true).Execute(_connectClient);
|
||||
}
|
||||
}
|
||||
|
||||
private void Mono_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue