public WinFormsWrapper.AXRDPUC GetRdpControl() { if (Ax == null) { Ax = new WinFormsWrapper.AXRDPUC(); Ax.Dock = DockStyle.Fill; } wfHost.Child = Ax; return((WinFormsWrapper.AXRDPUC)wfHost.Child); }
//private void cmdConnect_Click(object sender, RoutedEventArgs e) //{ // ax.rdpControl.Server = _session.GetSessionServer().GetRemoteIP().ToString(); // ax.rdpControl.UserName = _session.GetUserCredentials().GetUsername(); // IMsTscNonScriptable secured = (IMsTscNonScriptable)ax.rdpControl.GetOcx(); // secured.ClearTextPassword = _session.GetUserCredentials().GetPassword(); // ax.rdpControl.Connect(); //} public override void Dispose() { base.Dispose(); if (Ax != null) { if (Ax.rdpControl != null) { Ax.rdpControl.Disconnect(); } Ax.Dispose(); Ax = null; } }
void rdpControl_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e) { //http://msdn.microsoft.com/en-us/library/windows/desktop/aa382170(v=vs.85).aspx _Session.TriggerCloseConnectionEvent(); //Show Errormessage, if a not estimated Disconnection occures if (DisconnectEvents.EventDescription.ContainsKey(e.discReason) && DisconnectEvents.EventDescription[e.discReason].IsEstimated == false) { TopText = String.Format("Disconnected from Host. ({0})\n{1}", e.discReason, DisconnectEvents.EventDescription[e.discReason].ErrorMessage); } else if (!DisconnectEvents.EventDescription.ContainsKey(e.discReason)) { TopText = String.Format("Unknown Error ({0})", e.discReason); } switch (e.discReason) { case 516: // ReSharper disable once ObjectCreationAsStatement new ProtocolException(beRemoteExInfoPackage.MajorInformationPackage, String.Format( "The remote server could not be contacted. Maybe the ip address is invalid or the dns name not solveable ('{0}'. [disconnectReasonSocketConnectFailed 516 (0x204)]", _Session.GetSessionServer().GetRemoteIP())); break; default: Logger.Warning("[Session: " + _Session.GetSessionID() + "] RDP Ctrl received disconnect event! [mstscax-ctrl-evt-id: " + e.discReason + "]", EventId.CloseConnection); break; } try { //If the connection is established: disconnect if (Ax.rdpControl.Connected != 0) { Ax.rdpControl.Disconnect(); } Ax = null; } catch (Exception ex) { Logger.Log(LogEntryType.Verbose, "Exeption on Disconnecting RDP-Connection", ex); } //Close the Tab CloseTab(); }
private void ResizeConnection() { var settings = _Session.GetSessionSettings(); //If it is not "fit to tab" and Smartsizing is true if (settings[IniKey.FITTOTAB].GetProtocolSettingValue().GetValue().ToString() == "false" && settings[IniKey.SMARTSIZE].GetProtocolSettingValue().GetValue().ToString() == "true") { return; } Ax.rdpControl.DesktopHeight = Convert.ToInt32(dockPanel.ActualHeight); Ax.rdpControl.DesktopWidth = Convert.ToInt32(dockPanel.ActualWidth); Ax.rdpControl.Disconnect(); Ax.Dispose(); Ax = null; OpenNewConnection(dockPanel.ActualHeight, dockPanel.ActualWidth, _Username, _Password); }