예제 #1
0
        private void SettingsButton_Click(object sender, EventArgs e)
        {
            Button parent = null;

            if (sender is ToolStripMenuItem)
            {
                parent = (Button)ConnectionMenu.SourceControl;
            }
            else
            {
                Button btn = (Button)sender;
                parent = (Button)btn.Parent;
            }
            Connection           conn = ConnectionsButtons[parent];
            AddNewConnectionForm form = new AddNewConnectionForm(conn);

            form.ShowDialog();
            if (form.DialogResult != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            conn        = form.connection;
            parent.Text = String.Format("{0}\n{1}:{2}", conn.GetName(), conn.GetConnect(), conn.GetPort());
            ConnectionsButtons[parent] = conn;
            SaveListConnections();
        }
예제 #2
0
        private void AddConnection_Click(object sender, EventArgs e)
        {
            Connection conn = null;
            bool       save = false;

            if (sender is Connection)
            {
                conn = (Connection)sender;
            }
            else
            {
                AddNewConnectionForm connectionForm = new AddNewConnectionForm();
                connectionForm.ShowDialog();
                if (connectionForm.DialogResult != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                conn = connectionForm.connection;
                save = true;
            }
            Button ConnectionButton = new Button();

            ConnectionButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
            ConnectionButton.FlatAppearance.BorderColor = System.Drawing.Color.White;
            ConnectionButton.FlatStyle  = System.Windows.Forms.FlatStyle.Flat;
            ConnectionButton.Image      = global::MicroBaseManager.Properties.Resources.ConnectButton;
            ConnectionButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            ConnectionButton.Parent     = PanelOfConnections;
            ConnectionButton.Name       = "ConnectionButton_" + ConnectionButton.ToString();
            ConnectionButton.Size       = new System.Drawing.Size(250, 76);
            ConnectionButton.Text       = String.Format("{0}\n{1}:{2}", conn.GetName(), conn.GetConnect(), conn.GetPort());
            ConnectionButton.TextAlign  = System.Drawing.ContentAlignment.TopRight;
            ConnectionButton.UseVisualStyleBackColor = false;
            ConnectionButton.Click           += new System.EventHandler(this.ConnectionButton_Click);
            ConnectionButton.MouseEnter      += ConnectionButton_MouseEnter;
            ConnectionButton.MouseLeave      += ConnectionButton_MouseLeave;
            ConnectionButton.MouseDown       += ConnectionButton_MouseDown;
            ConnectionButton.ContextMenuStrip = ConnectionMenu;

            Button SettingsButton = new Button();

            SettingsButton.Parent    = ConnectionButton;
            SettingsButton.BackColor = Color.Transparent;
            SettingsButton.FlatAppearance.BorderSize = 0;
            SettingsButton.FlatStyle  = System.Windows.Forms.FlatStyle.Popup;
            SettingsButton.Image      = global::MicroBaseManager.Properties.Resources.settingsOn;
            SettingsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
            SettingsButton.Location   = new System.Drawing.Point(218, 45);
            SettingsButton.Name       = "SettingsButton_" + SettingsButton.ToString();
            SettingsButton.Size       = new System.Drawing.Size(28, 28);
            SettingsButton.UseVisualStyleBackColor = false;
            SettingsButton.MouseEnter += new System.EventHandler(this.SettingsButton_MouseEnter);
            SettingsButton.MouseLeave += new System.EventHandler(this.SettingsButton_MouseLeave);
            SettingsButton.MouseClick += SettingsButton_Click;

            ConnectionsButtons.Add(ConnectionButton, conn);
            ButtonsLocationChange(null, null);
            if (save)
            {
                SaveListConnections();
            }
        }