private void buttonSet_Click(object sender, EventArgs e) { var validationResult = ValueValidator.Validate(textBoxNewValue.Text, _property); errorProviderSetValue.SetError(textBoxNewValue, validationResult); if (!string.IsNullOrEmpty(validationResult)) { // Not a valid value return; } // Notify listeners OnNewValue(this, new NewValueEventArgs(textBoxNewValue.Text)); Close(); }
// Create a 'transform' object to send along with event, so receiver(s) can transform values with it private void buttonTransform_Click(object sender, EventArgs e) { // First validate the value entered var validationResult = ValueValidator.Validate(textBoxTransformValue.Text, _property); errorProviderTransformValue.SetError(textBoxTransformValue, validationResult); if (!string.IsNullOrEmpty(validationResult)) { // Not a valid value return; } // Create transformer var transformValue = textBoxTransformValue.Text; var operation = (TransformValueOperation)comboBoxOperation.SelectedIndex; var transformer = new ValueTransformer(InventoryItem.ItemPropertyType(_property), transformValue, operation); // Notify listeners OnTransformValue(this, new TransformValueEventArgs(transformer)); Close(); }