示例#1
0
        public void AttachTabFromWindow(TerminalTabControlItem tabControlToAttach)
        {
            this.mainTabControl.AddTab(tabControlToAttach);
            PopupTerminal popupTerminal = tabControlToAttach.FindForm() as PopupTerminal;

            if (popupTerminal != null)
            {
                this.UnRegisterPopUp(popupTerminal);
            }
        }
示例#2
0
        public void DetachTabToNewWindow(TerminalTabControlItem tabControlToOpen)
        {
            if (tabControlToOpen != null)
            {
                this.mainTabControl.Items.SuspendEvents();

                PopupTerminal pop = new PopupTerminal(this);
                this.mainTabControl.RemoveTab(tabControlToOpen);
                pop.AddTerminal(tabControlToOpen);

                this.mainTabControl.Items.ResumeEvents();
                this.detachedWindows.Add(pop);
                pop.Show();
            }
        }
示例#3
0
        private void CreateCaptureManagerTab()
        {
            string captureTitle = "Capture Manager";
            TerminalTabControlItem terminalTabPage = null;

            if (mainForm.InvokeRequired)
            {
                mainForm.Invoke(new MethodInvoker(delegate { terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); }));
            }
            else
            {
                terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle);
            }

            try
            {
                terminalTabPage.AllowDrop    = false;
                terminalTabPage.ToolTipText  = captureTitle;
                terminalTabPage.Favorite     = null;
                terminalTabPage.DoubleClick += this.mainForm.TerminalTabPage_DoubleClick;
                this.AddAndSelect(terminalTabPage);
                this.mainForm.UpdateControls();

                ConnectionBase conn = new CaptureManagerConnection();

                if (conn.InvokeRequired)
                {
                    conn.Invoke(new MethodInvoker(delegate { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; }));
                }
                else
                {
                    conn.TerminalTabPage = terminalTabPage;
                    conn.ParentForm      = this.mainForm;
                }

                conn.Connect();
                conn.BringToFront();
                conn.Update();

                this.mainForm.UpdateControls();
            }
            catch (Exception exc)
            {
                Log.Error("Error loading the Capture Manager Tab Page", exc);
                this.RemoveAndUnSelect(terminalTabPage);
                terminalTabPage.Dispose();
            }
        }
示例#4
0
 public void RemoveAndUnSelect(TerminalTabControlItem toRemove)
 {
     this.mainTabControl.Items.Remove(toRemove);
     this.UnSelect();
 }
示例#5
0
 public void AddAndSelect(TerminalTabControlItem toAdd)
 {
     //this.mainTabControl.Items.Add(toAdd);
     this.mainTabControl.AddTab(toAdd);
     this.Select(toAdd);
 }
示例#6
0
 /// <summary>
 ///     Markes the selected terminal as selected. If it is in mainTabControl,
 ///     then directly selects it, otherwise marks the selected window
 /// </summary>
 /// <param name="toSelect"> new terminal tabControl to assign as selected </param>
 public void Select(TerminalTabControlItem toSelect)
 {
     this.mainTabControl.SelectedItem = toSelect;
 }
示例#7
0
        private static void Code(TerminalTabControlItem terminalTabPage, IHostingForm parentForm, FavoriteConfigurationElement favorite, ConnectionBase conn = null)
        {
            if (conn == null)
            {
                conn = CreateConnection(favorite);
                conn.TerminalTabPage = terminalTabPage;
                terminalTabPage.TabColor = FavoriteConfigurationElement.TranslateColor(favorite.TabColor);
                terminalTabPage.Connection = conn;
            }

            conn.Favorite = favorite;
            conn.ParentForm = parentForm;

            if (conn.Connect())
            {
                if (conn.InvokeRequired)
                    conn.Invoke(new MethodInvoker(delegate
                    {
                        conn.BringToFront();
                        conn.Update();
                    }));
                else
                {
                    conn.BringToFront();
                    conn.Update();
                }
                
                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate
                    {
                        parentForm.UpdateControls();

                        if (favorite.DesktopSize == DesktopSize.FullScreen)
                            parentForm.FullScreen = true;
                    }));
                else
                {
                    parentForm.UpdateControls();

                    if (favorite.DesktopSize == DesktopSize.FullScreen)
                        parentForm.FullScreen = true;
                }

                conn.AfterConnectPlugins();
            }
            else
            {
            	string message = "Sorry, " + AssemblyInfo.Title + " was unable to create the connection. Try again or check the log for more information.";

                Log.Error(message);
                MessageBox.Show(message, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);

                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.RemoveAndUnSelect(terminalTabPage); }));
                else
                    parentForm.RemoveAndUnSelect(terminalTabPage);
            }

            if (conn.Connected && favorite.NewWindow)
            {
                if (parentForm.InvokeRequired)
                    parentForm.Invoke(new MethodInvoker(delegate { parentForm.DetachTabToNewWindow(terminalTabPage); }));
                else
                    parentForm.DetachTabToNewWindow(terminalTabPage);
            }
        }
        public void DetachTabToNewWindow(TerminalTabControlItem tabControlToOpen)
        {
            if (tabControlToOpen != null)
            {
                this.mainTabControl.Items.SuspendEvents();

                PopupTerminal pop = new PopupTerminal(this);
                this.mainTabControl.RemoveTab(tabControlToOpen);
                pop.AddTerminal(tabControlToOpen);

                this.mainTabControl.Items.ResumeEvents();
                this.detachedWindows.Add(pop);
                pop.Show();
            }
        }
示例#9
0
        /// <summary>
        ///     Creates a new connection by spawning a new thread.
        /// </summary>
        /// <param name="favorite"> </param>
        /// <param name="TerminalTabPage"> </param>
        /// <param name="parentForm"> </param>
        /// <remarks>
        ///     This method calls the <see cref="ConnectionBase.Connect" /> method and requires it to be thread safe.
        /// </remarks>
        public static void CreateConnection(FavoriteConfigurationElement favorite, IHostingForm parentForm, bool waitforEnd, TerminalTabControlItem terminalTabPage, ConnectionBase conn = null)
        {
            // This might happen if the user is not allowed to
            // use all available connections e.g. 
            // if the user has a freeware version.
            if (Limit.Contains(favorite.Protocol.ToUpper()) || terminalTabPage == null)
            {
                MessageBox.Show("You are not allowed to use that kind of connection! Please upgrade your license.", AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            
            if (!waitforEnd)
            {
               Thread t = new Thread((ThreadStart)delegate
                                                    {
                                                        Code(terminalTabPage, parentForm, favorite, conn);
                                                    });

                t.SetApartmentState(ApartmentState.STA);
                t.Start();
            }
            else
            {
                Code(terminalTabPage, parentForm, favorite, conn);
            }
        }
 public void RemoveAndUnSelect(TerminalTabControlItem toRemove)
 {
     this.mainTabControl.Items.Remove(toRemove);
     this.UnSelect();
 }
 public void AddAndSelect(TerminalTabControlItem toAdd)
 {
     //this.mainTabControl.Items.Add(toAdd);
     this.mainTabControl.AddTab(toAdd);
     this.Select(toAdd);
 }
 /// <summary>
 ///     Markes the selected terminal as selected. If it is in mainTabControl,
 ///     then directly selects it, otherwise marks the selected window
 /// </summary>
 /// <param name="toSelect"> new terminal tabControl to assign as selected </param>
 public void Select(TerminalTabControlItem toSelect)
 {
     this.mainTabControl.SelectedItem = toSelect;
 }
        private void CreateCaptureManagerTab()
        {
            string captureTitle = "Capture Manager";
            TerminalTabControlItem terminalTabPage = null;

            if (mainForm.InvokeRequired)
                mainForm.Invoke(new MethodInvoker(delegate { terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle); }));
            else
                terminalTabPage = new TerminalTabControlItem(captureTitle, captureTitle);

            try
            {
                terminalTabPage.AllowDrop = false;
                terminalTabPage.ToolTipText = captureTitle;
                terminalTabPage.Favorite = null;
                terminalTabPage.DoubleClick += this.mainForm.TerminalTabPage_DoubleClick;
                this.AddAndSelect(terminalTabPage);
                this.mainForm.UpdateControls();

                ConnectionBase conn = new CaptureManagerConnection();

                if (conn.InvokeRequired)
                    conn.Invoke(new MethodInvoker(delegate { conn.TerminalTabPage = terminalTabPage; conn.ParentForm = this.mainForm; }));
                else
                {
                    conn.TerminalTabPage = terminalTabPage;
                    conn.ParentForm = this.mainForm;
                }

                conn.Connect();
                conn.BringToFront();
                conn.Update();

                this.mainForm.UpdateControls();
            }
            catch (Exception exc)
            {
                Log.Error("Error loading the Capture Manager Tab Page", exc);
                this.RemoveAndUnSelect(terminalTabPage);
                terminalTabPage.Dispose();
            }
        }
        public void AttachTabFromWindow(TerminalTabControlItem tabControlToAttach)
        {
            this.mainTabControl.AddTab(tabControlToAttach);
            PopupTerminal popupTerminal = tabControlToAttach.FindForm() as PopupTerminal;

            if (popupTerminal != null)
                this.UnRegisterPopUp(popupTerminal);
        }