Esempio n. 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //
            object         newDefIns         = GetInitialDefinitionObject();
            EditDefinition formAddDefinition = new EditDefinition(newDefIns);
            //
            var res = formAddDefinition.ShowDialog();
            T   def = (T)formAddDefinition.Instance;

            if (res == DialogResult.OK)
            {
                StringBuilder errorMessage = new StringBuilder();
                bool          succ         = AddDefinition(def, ref errorMessage);
                if (!succ)
                {
                    MessageBox.Show(errorMessage.ToString(), "添加参数定义出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
        private void EditItem(T item)
        {
            T itemClone = (T)item.Clone();
            //
            EditDefinition formAddDefinition = new EditDefinition(itemClone);
            var            res = formAddDefinition.ShowDialog();

            if (res == DialogResult.OK)
            {
                string errorMessage;
                if (CheckEditDefinition(_definitions, item, itemClone, out errorMessage))
                {
                    _definitions[listBox1.SelectedIndex] = (T)formAddDefinition.Instance;
                }
                else
                {
                    MessageBox.Show(errorMessage, "编辑参数定义出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }