Пример #1
0
        private void BtnActiveClick(object sender, EventArgs e)
        {
            this.colorDialog1.Color = FavoriteConfigurationElement.TranslateColor(this.txtActive.Text);
            DialogResult result = this.colorDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.txtActive.Text = FavoriteConfigurationElement.GetDisplayColor(this.colorDialog1.Color);
            }
        }
Пример #2
0
        private void CursorColorButton_Click(object sender, EventArgs e)
        {
            this.colorDialog1.Color = FavoriteConfigurationElement.TranslateColor(this.CursorColorTextBox.Text);
            DialogResult result = this.colorDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.CursorColorTextBox.Text = FavoriteConfigurationElement.GetDisplayColor(this.colorDialog1.Color);
            }
        }
Пример #3
0
        protected TabControlItem(string caption, string name, Control displayControl)
        {
            ToolTipText = string.Empty;
            StripRect   = Rectangle.Empty;
            CanClose    = true;
            IsDrawn     = false;

            this.TabColor = FavoriteConfigurationElement.TranslateColor(FavoriteConfigurationElement.DefaultColor);

            this.Name        = name;
            this.Selected    = false;
            this.Visible     = true;
            this.BorderStyle = BorderStyle.None;

            this.UpdateText(caption, displayControl);

            //Add to controls
            this.Controls.Add(displayControl);
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        public override Boolean Connect()
        {
            this.connected = false;

            String protocol = "unknown";

            try
            {
                if (typeof(TerminalConnection).IsEqual(this.Favorite.Protocol))
                {
                    protocol = typeof(TerminalConnection).GetProtocolName();
                }
                else
                {
                    protocol = (this.Favorite.Ssh1) ? "SSH1" : "SSH2";
                }

                this.InvokeIfNecessary(delegate { this.term = new TerminalEmulator(); });

                this.Embed(this.term);

                this.term.BackColor  = FavoriteConfigurationElement.TranslateColor(this.Favorite.ConsoleBackColor);
                this.term.ForeColor  = FavoriteConfigurationElement.TranslateColor(this.Favorite.ConsoleTextColor);
                this.term.BlinkColor = this.term.CursorColor = FavoriteConfigurationElement.TranslateColor(this.Favorite.ConsoleCursorColor);

                if (this.term.InvokeRequired)
                {
                    this.term.Invoke(new MethodInvoker(delegate { this.term.Font = FontParser.FromString(this.Favorite.ConsoleFont); }));
                }
                else
                {
                    this.term.Font = FontParser.FromString(this.Favorite.ConsoleFont);
                }

                this.term.Rows    = this.Favorite.ConsoleRows;
                this.term.Columns = this.Favorite.ConsoleCols;

                this.client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                this.client.Connect(this.Favorite.ServerName, this.Favorite.Port);

                if (!this.Favorite.Credential.IsSetUserName || !this.Favorite.Credential.IsSetPassword)
                {
                    Log.Fatal(string.Format("Please set user name and password in your {0} connection properties.", this.Favorite.Protocol.ToLower()));
                    return(false);
                }

                if (typeof(TerminalConnection).IsEqual(this.Favorite.Protocol))
                {
                    this.ConfigureTelnetConnection(this.Favorite.Credential.UserName, this.Favorite.Credential.Password);
                }
                else
                {
                    this.ConfigureSshConnection(this.Favorite.Credential.UserName, this.Favorite.Credential.Password);
                }

                if (this.term.InvokeRequired)
                {
                    this.term.Invoke(new MethodInvoker(delegate { this.term.Focus(); }));
                }
                else
                {
                    this.term.Focus();
                }

                return(this.connected = true);
            }
            catch (Exception exc)
            {
                Log.Fatal(string.Format("Terminals was unable to create the {0} connection.", protocol), exc);
                return(this.connected = false);
            }
        }