Esempio n. 1
0
        private void tsbAddServer_Click(object sender, EventArgs e)
        {
            var addServerDialog = new AddServerForm();

            if (addServerDialog.ShowDialog() == DialogResult.OK)
            {
                dgvServerListBindingSource.AddNew();
                var NewServerIndex = ServerList.Count - 1;
                ServerList[NewServerIndex] = addServerDialog.NewServer;
                SetStartButtonName(NewServerIndex);

                Log.Debug($"Added new server {addServerDialog.NewServer.ServerDisplayName}");
            }
        }
Esempio n. 2
0
        private async void dgvServerList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (SelectedServer != null)
            {
                return;
            }

            var server = ServerList[e.RowIndex];

            if (e.ColumnIndex == ColumnIndexStartServer)
            {
                if (!MouseClickingStartButtonCell)
                {
                    return;
                }

                if (server.SshClientInUse())
                {
                    return;
                }

                var startButtonCell = GetStartButton(e.RowIndex);
                if (startButtonCell != null && startButtonCell.Enabled)
                {
                    DisableColumnButtons(server);

                    if (startButtonCell.Value.ToString() == ButtonStartServerName)
                    {
                        await server.Start(SshCommand_Complete, SshClient_ErrorOccurred);
                    }
                    else
                    {
                        await server.Stop(SshCommand_Complete, SshClient_ErrorOccurred);
                    }

                    if (server.SshException != null)
                    {
                        Log.Debug($"Ssh Exception for {server}: {server.SshException}");

                        EnableColumnButtons(server);
                        ShowServerFailureMessageBox(server, server.SshException.Message);
                    }
                }
            }
            else if (e.ColumnIndex == ColumnIndexEditServer)
            {
                if (!MouseClickingEditButtonCell)
                {
                    return;
                }

                var editButtonCell = GetEditButton(e.RowIndex);
                if (editButtonCell != null && editButtonCell.Enabled)
                {
                    var editServerDialog = new AddServerForm(ServerList[e.RowIndex]);
                    if (editServerDialog.ShowDialog() == DialogResult.OK)
                    {
                        dgvServerListBindingSource.ResetItem(e.RowIndex);
                    }
                }
            }
        }