Esempio n. 1
0
        private void txtName_Validating(object sender, CancelEventArgs e)
        {
            if (!locked && member != null)
            {
                try
                {
                    var oldValue = member.Name;

                    var command = new RenameMemberCommand(member, oldValue, txtName.Text, (m, d) => m.Name = d);
                    command.Execute();
                    diagram.TrackCommand(command);

                    errorProvider.SetError(txtName, null);
                    error = false;

                    RefreshValues();
                    if (oldValue != txtName.Text)
                    {
                        OnContentsChanged(EventArgs.Empty);
                    }
                }
                catch (BadSyntaxException ex)
                {
                    e.Cancel = true;
                    errorProvider.SetError(txtName, ex.Message);
                    error = true;
                }
            }
        }
Esempio n. 2
0
 private bool ValidateDeclarationLine()
 {
     if (needValidation && shape.ActiveMember != null)
     {
         try
         {
             var command = new RenameMemberCommand(shape.ActiveMember, shape.ActiveMember.ToString(), txtDeclaration.Text, (m, d) => m.InitFromString(d));
             command.Execute();
             shape.Diagram.TrackCommand(command);
             RefreshValues();
         }
         catch (BadSyntaxException ex)
         {
             SetError(ex.Message);
             return(false);
         }
     }
     return(true);
 }