public void ListboxSelectionChanged(object sender, EventArgs e) { int selectedIndex = MaterialPropertiesListBoxX.SelectedIndex; if (selectedIndex >= 0) { string selected = MaterialPropertiesListBoxX.Items[MaterialPropertiesListBoxX.SelectedIndex].ToString(); foreach (var materialParameter in materialParameters) { if (selected == materialParameter.Code) { selectedMaterialParameterId = materialParameter.Id; break; } } foreach (var materialParameterValue in materialParametersValues) { if (materialParameterValue.MaterialParameterId == selectedMaterialParameterId) { selectedMaterialParameterValue = materialParameterValue; break; } else { selectedMaterialParameterValue = null; } } } if (selectedMaterialParameterValue != null) { MaterialPropertyValueTextBoxX.Text = selectedMaterialParameterValue.Value; } else { MaterialPropertyValueTextBoxX.Text = ""; } textChanged = false; EnableDisableControls(); }
private void AddModifyProperty() { if (Confirm(TranslationKey.Confirm_UserGroup_Modify, "Modify Material Property", "Are you sure to modify this material property?", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (selectedMaterialParameterValue != null) { selectedMaterialParameterValue.Value = MaterialPropertyValueTextBoxX.Text; new MaterialParameterValues().Modify(selectedMaterialParameterValue); } else { MaterialParameterValue newMaterialParameterValue = new MaterialParameterValue(); newMaterialParameterValue.MaterialId = _selectedMaterial.Id; newMaterialParameterValue.MaterialParameterId = selectedMaterialParameterId; newMaterialParameterValue.Value = MaterialPropertyValueTextBoxX.Text; new MaterialParameterValues().Add(newMaterialParameterValue); } } }