private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                var copy_cell = senderGrid.Rows[e.RowIndex].Cells[3] as DataGridViewButtonCell;

                if (senderGrid.Columns[e.ColumnIndex].Name == "CopyIP")
                {
                    if (!string.IsNullOrWhiteSpace(servers[e.RowIndex].IP))
                    {
                        Clipboard.SetText(servers[e.RowIndex].IP);
                        copyStates[e.RowIndex] = "Copied";
                        copy_cell.Value        = "Copied";
                    }
                }

                if (senderGrid.Columns[e.ColumnIndex].Name == "Start")
                {
                    string command = "ec2 start-instances --instance-ids " + servers[e.RowIndex].Id;
                    string result  = AwsCommandUtility.Call(command);
                    resultTextBox.Text += "\r\n" + result;
                    Refresh();
                    copyStates[e.RowIndex] = "";
                    copy_cell.Value        = "";
                }

                if (senderGrid.Columns[e.ColumnIndex].Name == "Stop")
                {
                    string command = "ec2 stop-instances --instance-ids " + servers[e.RowIndex].Id;
                    string result  = AwsCommandUtility.Call(command);
                    resultTextBox.Text = result;
                    Refresh();
                    copyStates[e.RowIndex] = "";
                    copy_cell.Value        = "";
                }

                if (senderGrid.Columns[e.ColumnIndex].Name == "SSH")
                {
                    string result = AwsCommandUtility.Ssh(servers[e.RowIndex].PublicDns);
                    resultTextBox.Text = result;
                }
            }
        }
 private void Refresh()
 {
     servers = AwsCommandUtility.GetServers();
     bindingSource1.DataSource      = servers;
     lastRefreshToolStripLabel.Text = "Last Refreshed: " + DateTime.Now.ToString();
     for (int i = 0; i < copyStates.Count; i++)
     {
         var copy_cell = dataGridView1.Rows[i].Cells[3] as DataGridViewButtonCell;
         copy_cell.Value = copyStates[i];
     }
     if (copyStates.Count == 0)
     {
         for (int i = 0; i < servers.Count; i++)
         {
             copyStates.Add("");
         }
     }
 }