Skip to content

Commit

Permalink
implemented basic validation for newname, fixed UI behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Mar 26, 2015
1 parent b924209 commit 9a87b50
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
48 changes: 25 additions & 23 deletions RetailCoder.VBE/UI/Refactorings/Rename/RenameDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion RetailCoder.VBE/UI/Refactorings/Rename/RenameDialog.cs
Expand Up @@ -10,6 +10,13 @@ public RenameDialog()
{
InitializeComponent();
OkButton.Click += OkButtonClick;
Activated += RenameDialog_Activated;
}

private void RenameDialog_Activated(object sender, EventArgs e)
{
NewNameBox.SelectAll();
NewNameBox.Focus();
}

private void OkButtonClick(object sender, EventArgs e)
Expand Down Expand Up @@ -55,7 +62,20 @@ public Declaration Target
public string NewName
{
get { return NewNameBox.Text; }
set { NewNameBox.Text = value; }
set
{
NewNameBox.Text = value;
ValidateNewName();
}
}

private void ValidateNewName()
{
OkButton.Enabled = (NewName != Target.IdentifierName)
&& !string.IsNullOrWhiteSpace(NewName)
&& !NewName.StartsWith("_"); // also invalid if it starts with a number...

InvalidNameValidationIcon.Visible = !OkButton.Enabled;
}
}
}

0 comments on commit 9a87b50

Please sign in to comment.