//        private void deleteRecordButton_Click(object sender, System.EventArgs e)
        //        {
        //            // TODO: Validate
        //            deleteConnectionRecord(editPropertyGrid.SelectedObject as RemoteConnectionConfiguration);
        //            // TODO: separate Gui thing from here
        //            setGuiFromConfig(_connections);
        //        }
        private void initiateNewRecord()
        {
            if (editingMode == RecordEditingMode.New)
            {
                // TODO: offer record to be added
                DialogResult res =
                    MessageBox.Show
                        (
                        this,
                        "There is a new record to add before you start editing the next one.\r\n" +
                        "If you want to add it select Yes.\r\n " +
                        "If you don't want to add it select No.\r\n" +
                        "If you want to return to the record editing before adding select Cancel.",
                        "Confirm adding new record",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1
                        );

                if (res == DialogResult.Cancel) return;

                if (res == DialogResult.Yes)
                {
                    addConnectionRecord(newConfigItem, false);
                }
            }

            editingMode = RecordEditingMode.New;

            newConfigItem = new RemoteConnectionConfiguration();
            newConfigItem.Name = _connections.GetDefaultConnectionName();

            editPropertyGrid.SelectedObject = newConfigItem;
        }
        private void connectionsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (editingMode == RecordEditingMode.New)
            {
                initiateNewRecord();
                editingMode = RecordEditingMode.Edit;
            }

            if (_connections.Count == 0 || connectionsListView.SelectedItems.Count == 0) return;

            // multiselect is not allowed
            RemoteConnectionConfiguration rcc =
                (connectionsListView.SelectedItems[0].Tag as RemoteConnectionInstance).Configuration;

            if (rcc != null)
            {
                editPropertyGrid.SelectedObject = rcc;
            }
            //TODO: Handle null value
        }