mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Enable size change without reconnect
Use IMsRdpClient9::UpdateSessionDisplaySettings to dynamically update the session display settings without reconnecting. RDP Version needs to be Rdc9 or Highest for this to work. Fixes #1546
This commit is contained in:
@@ -29,7 +29,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
protected set
|
||||
{
|
||||
base.SmartSize = value;
|
||||
ReconnectForResize();
|
||||
DoResizeClient();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
protected set
|
||||
{
|
||||
base.Fullscreen = value;
|
||||
ReconnectForResize();
|
||||
DoResizeClient();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,19 +50,19 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
|
||||
public override void Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (DoResize() && _controlBeginningSize.IsEmpty)
|
||||
if (DoResizeControl() && _controlBeginningSize.IsEmpty)
|
||||
{
|
||||
ReconnectForResize();
|
||||
DoResizeClient();
|
||||
}
|
||||
base.Resize(sender, e);
|
||||
}
|
||||
|
||||
public override void ResizeEnd(object sender, EventArgs e)
|
||||
{
|
||||
DoResize();
|
||||
DoResizeControl();
|
||||
if (!(Control.Size == _controlBeginningSize))
|
||||
{
|
||||
ReconnectForResize();
|
||||
DoResizeClient();
|
||||
}
|
||||
_controlBeginningSize = Size.Empty;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
return new AxMsRdpClient8NotSafeForScripting();
|
||||
}
|
||||
|
||||
private void ReconnectForResize()
|
||||
private void DoResizeClient()
|
||||
{
|
||||
if (!loginComplete)
|
||||
return;
|
||||
@@ -95,7 +95,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
var size = Fullscreen
|
||||
? Screen.FromControl(Control).Bounds.Size
|
||||
: Control.Size;
|
||||
RdpClient8.Reconnect((uint)size.Width, (uint)size.Height);
|
||||
UpdateSessionDisplaySettings((uint)size.Width, (uint)size.Height);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
}
|
||||
}
|
||||
|
||||
private bool DoResize()
|
||||
private bool DoResizeControl()
|
||||
{
|
||||
Control.Location = InterfaceControl.Location;
|
||||
// kmscode - this doesn't look right to me. But I'm not aware of any functionality issues with this currently...
|
||||
@@ -120,5 +120,10 @@ namespace mRemoteNG.Connection.Protocol.RDP
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateSessionDisplaySettings(uint width, uint height)
|
||||
{
|
||||
RdpClient8.Reconnect(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
using System.Windows.Forms;
|
||||
using AxMSTSCLib;
|
||||
using MSTSCLib;
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.RDP
|
||||
{
|
||||
public class RdpProtocol9 : RdpProtocol8
|
||||
{
|
||||
private MsRdpClient9NotSafeForScripting RdpClient9 =>
|
||||
(MsRdpClient9NotSafeForScripting)((AxHost)Control).GetOcx();
|
||||
|
||||
protected override RdpVersion RdpProtocolVersion => RdpVersion.Rdc9;
|
||||
|
||||
protected override AxHost CreateActiveXRdpClientControl()
|
||||
{
|
||||
return new AxMsRdpClient9NotSafeForScripting();
|
||||
}
|
||||
|
||||
protected override void UpdateSessionDisplaySettings(uint width, uint height)
|
||||
{
|
||||
RdpClient9.UpdateSessionDisplaySettings(width, height, width, height, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user