private void button_OK_Click(object sender, EventArgs e) { if (element != null) { for (int i = 0; i < manager.getElementCount(); i++) { PropertyElement elementExist = (PropertyElement)manager.getElement(i); if (elementExist.Equals(element)) { continue; } if (elementExist.name.Equals(textBox_name.Text)) { MessageBox.Show("存在相同的单元名称!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } bool needRefreshData = false; if (!element.name.Equals(textBox_name.Text)) { element.name = textBox_name.Text; needRefreshUI = true; if (element.getID() >= 0) { ((PropertiesManager)element.parent).parent.instancesManager.configPropertyName(element); } } if (element.ValueType != types[comboBox_Value.SelectedIndex]) { element.ValueType = types[comboBox_Value.SelectedIndex]; needRefreshUI = true; needRefreshData = true; } if (element.ValueType == Consts.PARAM_PROP && ((element.propertyTypeElementUsed == null) || (element.propertyTypeElementUsed != null && comboBox_Prop.SelectedIndex != element.propertyTypeElementUsed.getID()))) { element.setPropertyType(manager.form_main.propertyTypesManager.getElement(comboBox_Prop.SelectedIndex)); needRefreshUI = true; needRefreshData = true; } if (checkBox_refreshAll.Checked) { needRefreshUI = true; needRefreshData = true; } //默认值 if (element.ValueType == Consts.PARAM_INT) { element.defaultValue = (int)numericUpDown_def.Value; } else if (element.ValueType == Consts.PARAM_STR) { element.defaultValue = textBox_def.Text + ""; } else if (element.ValueType == Consts.PARAM_PROP) { element.defaultValue = (int)comboBox_PropDef.SelectedIndex; } else if (element.ValueType == Consts.PARAM_INT_ID) { element.defaultValue = (int)comboBox_constDef.SelectedIndex; } //刷新 if (needRefreshData && element.getID() >= 0) { ((PropertiesManager)element.parent).parent.instancesManager.configProperty(element); } } this.Close(); }