Ejemplo n.º 1
0
        internal RdpClient(ContainerControl parent, Size size, EventHandler resizeHandler)
        {
            this.parent = parent;
            this.size   = size;
            try
            {
                rdpControl = rdpClient6 = new MsRdpClient6();
                RDPConfigure(size);

                // CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
                // MsRdpClient6 control cannot be created (there is no appropriate version of dll present)
                parent.Controls.Add(rdpControl);
            }
            catch
            {
                if (parent.Controls.Contains(rdpControl))
                {
                    parent.Controls.Remove(rdpControl);
                }
                rdpClient6 = null;
                rdpControl = rdpClient2 = new MsRdpClient2();
                RDPConfigure(size);
                parent.Controls.Add(rdpControl);
            }
            rdpControl.Resize += resizeHandler;
        }
Ejemplo n.º 2
0
        internal RdpClient(ContainerControl parent, Size size, EventHandler resizeHandler)
        {
            this.parent = parent;
            this.size   = size;
            try
            {
                rdpControl = new MsRdpClient6();
                RDPConfigure(size);

                // CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
                // MsRdpClient6 control cannot be created (there is no appropriate version of dll present)
                parent.Controls.Add(rdpControl);

                RDPSetSettings();

                rdpControl.Resize += resizeHandler;
            }
            catch (Exception ex)
            {
                Log.Error("MsRdpClient6 control cannot be added.", ex);

                if (rdpControl != null)
                {
                    if (parent.Controls.Contains(rdpControl))
                    {
                        parent.Controls.Remove(rdpControl);
                    }

                    rdpControl.Dispose();
                    rdpControl = null;
                }
            }
        }
Ejemplo n.º 3
0
        internal RdpClient(ContainerControl parent, Size size, EventHandler resizeHandler)
        {
            this.parent = parent;
            this.size   = size;
            try
            {
                rdpControl = rdpClient9 = new MsRdpClient9();
                RDPConfigure(size);

                //add event handler for when RDP display is resized
                rdpClient9.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange;

                // CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
                // MsRdpClient8 control cannot be created (there is no appropriate version of dll present)
                parent.Controls.Add(rdpControl);
                allowDisplayUpdate     = true;
                needsRdpVersionWarning = false;
            }
            catch
            {
                //any problems: fall back without thinking too much
                if (parent.Controls.Contains(rdpControl))
                {
                    parent.Controls.Remove(rdpControl);
                }
                rdpClient9 = null;
                rdpControl = rdpClient6 = new MsRdpClient6();
                RDPConfigure(size);
                parent.Controls.Add(rdpControl);
                needsRdpVersionWarning = true;
            }
            rdpControl.Resize += resizeHandler;
        }
Ejemplo n.º 4
0
 public void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (rdpControl != null)
             {
                 // We need to dispose the rdp control. However, doing it immediately (in the control's own
                 // OnDisconnected event) will cause a horrible crash. Instead, start a timer that will
                 // call the dispose method on the GUI thread at the next available opportunity. CA-12902
                 Timer t = new Timer();
                 t.Tick += delegate
                 {
                     try
                     {
                         Log.Debug("RdpClient Dispose(): rdpControl.Dispose() in delegate");
                         rdpControl.Dispose();
                     }
                     catch (Exception)
                     {
                         // We often get NullReferenceException here
                     }
                     t.Stop();
                     RdpCleanupTimers.Remove(t);
                     Log.Debug("RdpClient Dispose(): Timer stopped and removed in delegate");
                 };
                 t.Interval = 1;
                 RdpCleanupTimers.Add(t);
                 Log.DebugFormat("RdpClient Dispose(): Start timer (timers count {0})", RdpCleanupTimers.Count);
                 t.Start();
             }
             else
             {
                 Log.Debug("RdpClient Dispose(): rdpControl == null");
             }
         }
         rdpControl = null;
         Log.Debug("RdpClient Dispose(): disposed = true");
         disposed = true;
     }
 }