示例#1
0
        private void button_renameState_Click(object sender, EventArgs e)
        {
            string originalStateName = listBox_stateNames.Text;
            StateOperationDialog stateOperationDialog = new StateOperationDialog(originalStateName);

            stateOperationDialog.ShowDialog(this);
            string newStateName = stateOperationDialog.StateName;

            if (originalStateName.ToLower().Equals(newStateName.ToLower()))
            {
                return;
            }
            if (_stateNames.Any(item => stateOperationDialog.StateName.ToLower().Equals(item.ToLower())))
            {
                MessageBox.Show("State name already exist", "ViewController", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            _stateNames[_stateNames.IndexOf(originalStateName)]        = newStateName;
            listBox_stateNames.Items[listBox_stateNames.SelectedIndex] = newStateName;
            foreach (ViewControlElement controlElement in _controlElements)
            {
                controlElement.RenameState(originalStateName, newStateName);
            }

            RefreshDataGridViewData(dataGridView_enabledSelect.Rows, 0, ViewControlElement.DefaultValue[0]);
            RefreshDataGridViewData(dataGridView_visibleSelect.Rows, 1, ViewControlElement.DefaultValue[1]);
        }
示例#2
0
        private void button_addState_Click(object sender, EventArgs e)
        {
            StateOperationDialog stateOperationDialog = new StateOperationDialog(string.Empty);

            stateOperationDialog.ShowDialog(this);
            if (_stateNames.Any(item => stateOperationDialog.StateName.ToLower().Equals(item.ToLower())))
            {
                MessageBox.Show("State name already exist", "ViewController", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(stateOperationDialog.StateName))
            {
                return;
            }
            _stateNames.Add(stateOperationDialog.StateName);
            listBox_stateNames.Items.Add(stateOperationDialog.StateName);
            if (1 == _stateNames.Count)
            {
                listBox_stateNames.SelectedIndex = 0;
            }

            RefreshDataGridViewData(dataGridView_enabledSelect.Rows, 0, ViewControlElement.DefaultValue[0]);
            RefreshDataGridViewData(dataGridView_visibleSelect.Rows, 1, ViewControlElement.DefaultValue[1]);
        }