private void Connect(string iporhost, RemoteDesktop_CSLibrary.Client c)
        {
            _LastMainViewer = new MainViewer();
            _LastMainViewer.Show(this);
            _LastMainViewer.Hide();

            _LastMainViewer.OnConnectEvent           += OnConnect;
            _LastMainViewer.OnDisconnectEvent        += OnDisconnect;
            _LastMainViewer.OnConnectingAttemptEvent += _LastMainViewer_OnConnectingAttemptEvent;

            _Connecting.FormClosing += _Connecting_FormClosing;
            this.Hide();
            _LastMainViewer.Connect(iporhost, c);
        }
 private void OnDisconnect()
 {
     this.UIThread(() =>
     {
         if (!this.Visible)
         {
             this.Show();
         }
         if (_Connecting.Visible)
         {
             _Connecting.Hide();
         }
         var tmp = _LastMainViewer;
         if (tmp != null)
         {
             tmp.Close();
             _LastMainViewer = null;
         }
     });
 }
        private void Connect(string iporhost, RemoteDesktop_CSLibrary.Client c)
        {
            _LastMainViewer = new MainViewer();
            _LastMainViewer.Show(this);
            _LastMainViewer.Hide();

            _LastMainViewer.OnConnectEvent += OnConnect;
            _LastMainViewer.OnDisconnectEvent += OnDisconnect;
            _LastMainViewer.OnConnectingAttemptEvent += _LastMainViewer_OnConnectingAttemptEvent;

            _Connecting.FormClosing += _Connecting_FormClosing;
            this.Hide();
            _LastMainViewer.Connect(iporhost, c);
        }
        private void OnDisconnect()
        {
            this.UIThread(() =>
            {
                if(!this.Visible)
                    this.Show();
                if(_Connecting.Visible)
                    _Connecting.Hide();
                var tmp = _LastMainViewer;
                if(tmp != null)
                {
                    tmp.Close();
                    _LastMainViewer = null;
                }
            });

        }