Implemented the text element rename function
This commit is contained in:
2 files changed
+58
-1
No files matched your search
@@ -107,9 +107,36 @@ public partial class TextElements : UserControl
|
||||
|
||||
}
|
||||
|
||||
private void buttonRename_Click(object sender, EventArgs e)
|
||||
private async void buttonRename_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(this.DesignMode)
|
||||
return;
|
||||
|
||||
// Ask the user if he really wants to rename the text element:
|
||||
if(MessageBox.Show("Are you sure, you want to rename the selected text element? If you are already using this element in your code, you will need to manually refactor your code after renaming it.", "Rename text element", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
|
||||
return;
|
||||
|
||||
// Ask the user for the new name:
|
||||
var result = InputDialog.Show(new InputDialog.Options(
|
||||
Message: "Please edit the text element's name.",
|
||||
PreloadedText: this.currentTextElement!.Name,
|
||||
ShowQuestionCheckbox: false,
|
||||
Title: "Rename text element"
|
||||
));
|
||||
|
||||
// If the user canceled, return:
|
||||
if(result.DialogResult == DialogResult.Cancel)
|
||||
return;
|
||||
|
||||
// Rename the text element:
|
||||
var alteredTextElement = await TextElementProcessor.RenameTextElement(this.currentTextElement.Id, result.Text);
|
||||
|
||||
alteredTextElement.ProcessError();
|
||||
if(!alteredTextElement.Successful)
|
||||
return;
|
||||
|
||||
// Reload the text elements:
|
||||
this.LoadTextElements();
|
||||
}
|
||||
|
||||
private async void listTextElements_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||
|
||||
Reference in new issue
Block a user