Example #1
0
        void vmrc_OnStateChanged(object sender, _IVMRCClientControlEvents_OnStateChangedEvent e)
        {
            if (e.state == VMRCClientControlLib.VMRCState.vmrcState_Connected)
            {
                this.connected = true;
            }
            else if (e.state == VMRCClientControlLib.VMRCState.vmrcState_ConnectionFailed)
            {
                connected = false;
                Terminals.Logging.Log.Fatal("VMRC Connection Lost" + this.Favorite.Name);
                this.connected = false;

                TabControlItem selectedTabPage = (TabControlItem)(this.Parent);
                bool           wasSelected     = selectedTabPage.Selected;
                ParentForm.tcTerminals.RemoveTab(selectedTabPage);
                ParentForm.tcTerminals_TabControlItemClosed(null, EventArgs.Empty);
                if (wasSelected)
                {
                    NativeApi.PostMessage(new HandleRef(this, this.Handle), MainForm.WM_LEAVING_FULLSCREEN, IntPtr.Zero, IntPtr.Zero);
                }
                ParentForm.UpdateControls();
            }
            else if (e.state == VMRCClientControlLib.VMRCState.vmrcState_NotConnected)
            {
                connected = false;
            }
        }
Example #2
0
        void axMsTscAx_OnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent e)
        {
            AxMsRdpClient2 client = (AxMsRdpClient2)sender;

            string error = Functions.GetErrorMessage(e.discReason);

            if (error != null)
            {
//                MessageBox.Show(this, String.Format("Error connecting to {0} ({1})", client.Server, error), "Terminals " + Program.TerminalsVersion.ToString(),MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            TabControlItem selectedTabPage = (TabControlItem)(client.Parent);
            bool           wasSelected     = selectedTabPage.Selected;

            ParentForm.tcTerminals.RemoveTab(selectedTabPage);
            ParentForm.tcTerminals_TabControlItemClosed(null, EventArgs.Empty);
            if (wasSelected)
            {
                NativeApi.PostMessage(new HandleRef(this, this.Handle), MainForm.WM_LEAVING_FULLSCREEN, IntPtr.Zero, IntPtr.Zero);
            }
            ParentForm.UpdateControls();

            if (OnDisconnected != null)
            {
                OnDisconnected(this);
            }
        }
Example #3
0
        private void UpdateAttachedTabTitle(IFavorite updated)
        {
            TabControlItem attachedTab = this.filter.FindAttachedTab(updated);

            if (attachedTab != null)
            {
                attachedTab.Title = updated.Name;
            }
        }
Example #4
0
        private static void DisposeConnection(TabControlItem tabPage)
        {
            var toDispose = tabPage as TerminalTabControlItem;

            if (toDispose != null)
            {
                // Expecting all connections are disposable, because derive from Connection
                toDispose.Connection?.Dispose();
            }
        }
Example #5
0
        private void CloseTabPage(object tabObject, bool checkNullException = true)
        {
            // If the handle has been disposed -> the control is non existent
            // -> we don't need to close it again -> Exception will be thrown -> return.
            try
            {
                // The TabControlItem is of base type Panel.
                // If the control is no panel return.
                if (!(tabObject is Panel))
                {
                    return;
                }

                // The following check is not needed in case of the AutoIt connection.
                if (checkNullException)
                {
                    // Check for a valid and existing handle -> if Zero or exception return.
                    // otherwise continue.
                    if (((Panel)tabObject).Handle == IntPtr.Zero)
                    {
                        return;
                    }
                }
            }
            catch
            {
                return;
            }

            if (!(tabObject is TabControlItem))
            {
                return;
            }

            if (this.ParentForm.InvokeRequired)
            {
                InvokeCloseTabPage d = this.CloseTabPage;
                this.TerminalTabPage.Invoke(d, new object[] { this.TerminalTabPage, checkNullException });
                return;
            }

            TabControlItem tabPage = (TabControlItem)tabObject;

            bool wasSelected = tabPage.Selected;

            this.ParentForm.RemoveTabPage(tabPage);
            if (wasSelected)
            {
                PostMessage(new HandleRef(this, this.Handle), WM_LEAVING_FULLSCREEN, IntPtr.Zero,
                            IntPtr.Zero);
            }

            this.ParentForm.UpdateControls();
        }
Example #6
0
 internal void Disconnect()
 {
     try
     {
         TabControlItem tabToClose = this.tcTerminals.SelectedItem;
         if (this.tcTerminals.Items.Contains(tabToClose))
         {
             this.tcTerminals.CloseTab(tabToClose);
         }
     }
     catch (Exception exc)
     {
         Logging.Error("Disconnecting a tab threw an exception", exc);
     }
 }
Example #7
0
        void rd_ConnectionLost(object sender, EventArgs e)
        {
            Terminals.Logging.Log.Fatal("VNC Connection Lost" + this.Favorite.Name);
            this.connected = false;

            TabControlItem selectedTabPage = (TabControlItem)(this.Parent);
            bool           wasSelected     = selectedTabPage.Selected;

            ParentForm.tcTerminals.RemoveTab(selectedTabPage);
            ParentForm.tcTerminals_TabControlItemClosed(null, EventArgs.Empty);
            if (wasSelected)
            {
                NativeApi.PostMessage(new HandleRef(this, this.Handle), MainForm.WM_LEAVING_FULLSCREEN, IntPtr.Zero, IntPtr.Zero);
            }
            ParentForm.UpdateControls();
        }
Example #8
0
 private void CloseTabControlItem(TabControlItem tabPage)
 {
     DisposeConnection(tabPage);
     this.RestoreWindowAfterLastClosed();
 }
Example #9
0
 public void RemoveTabPage(TabControlItem tabControlToRemove)
 {
 	Log.InsideMethod();
 	
     this.tcTerminals.RemoveTab(tabControlToRemove);
     this.CloseTabControlItem();
 }
Example #10
0
        private void tcTerminals_TabControlMouseOnTitle(TabControlMouseOnTitleEventArgs e)
        {
        	Log.InsideMethod();
            if (Settings.ShowInformationToolTips)
            {
                if (this.currentToolTip == null)
                {
                    this.currentToolTip = new ToolTip {Active = false};
                }
                else if ((this.currentToolTipItem != null) && (this.currentToolTipItem != e.Item) && !currentToolTipItem.IsDisposed && !currentToolTipItem.Disposing)
                {
                    this.currentToolTip.Hide(this.currentToolTipItem);
                    this.currentToolTip.Active = false;
                }

                if (!this.currentToolTip.Active)
                {
                    this.currentToolTip = new ToolTip
                                              {
                                                  ToolTipTitle = "Connection Information",
                                                  ToolTipIcon = ToolTipIcon.Info,
                                                  UseFading = true,
                                                  UseAnimation = true,
                                                  IsBalloon = false
                                              };
                    this.currentToolTip.Show(e.Item.ToolTipText, e.Item, (int)e.Item.StripRect.X, 2);
                    this.currentToolTipItem = e.Item;
                    this.currentToolTip.Active = true;
                }
            }
        }