public override void ValidateData() { var newText = txtComment.Text; var changeNameCommand = new ChangePropertyCommand <CommentShape, string>(shape, s => s.Comment.Text, (s, newValue) => s.Comment.Text = newValue, newText); changeNameCommand.Execute(); shape.Diagram.TrackCommand(changeNameCommand); }
protected bool SetBackingField <T>( BackingField <T> field, T value, CommandHistory history, bool combineCommands ) { if ((field != null) && !EqualityComparer <T> .Default.Equals(field, value)) { var command = new ChangePropertyCommand <T>(GetType(), field, value); history.Execute(command, combineCommands); OnPropertyChanged(field.PropertyName); return(true); } return(false); }
private bool TryValidateData() { try { var newName = txtName.Text; var changeNameCommand = new ChangePropertyCommand <Shape, string>(shape, s => s.Entity.Name, (s, newValue) => s.Entity.Name = newValue, newName); changeNameCommand.Execute(); shape.Diagram.TrackCommand(changeNameCommand); errorProvider.SetError(this, null); return(true); } catch (Exception e) { errorProvider.SetError(this, e.Message); return(false); } }
private bool ValidateName() { if (!needValidation) { return(true); } try { var newName = shape.TypeBase.ValidateName(txtName.Text); var changeNameCommand = new ChangePropertyCommand <TypeShape, string>(shape, s => s.TypeBase.Name, (s, newValue) => s.TypeBase.Name = newValue, newName); changeNameCommand.Execute(); shape.Diagram.TrackCommand(changeNameCommand); RefreshValues(); } catch (BadSyntaxException ex) { SetError(ex.Message); return(false); } return(true); }