public override void Complete(CompletionContext context) { using (EditStringResourceDialog dialog = new EditStringResourceDialog(this.content, this.preEnteredName, null, true)) { dialog.Text = this.Description; if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK) { return; } this.content.Add(dialog.Key, dialog.Value); this.CompleteInternal(context, dialog.Key); } }
/// <summary> /// Present a form to the user where he enters the name for the new /// string resource and then insert the key value into the text editor. /// </summary> /// <param name="textArea">TextArea to insert the completion data in.</param> /// <param name="ch">Character that should be inserted after the completion data. /// \0 when no character should be inserted.</param> /// <returns>Returns true when the insert action has processed the character /// <paramref name="ch"/>; false when the character was not processed.</returns> public override bool InsertAction(TextArea textArea, char ch) { EditStringResourceDialog dialog = new EditStringResourceDialog(this.content, this.preEnteredName, null, true); dialog.Text = this.Description; if (dialog.ShowDialog(WorkbenchSingleton.MainForm) != DialogResult.OK) { return false; } this.Text = dialog.Key; this.content.Add(dialog.Key, dialog.Value); return base.InsertAction(textArea, ch); }
void EditResource(object sender, EventArgs e) { MenuItem item = sender as MenuItem; if (item == null) { return; } ResourceResolveResult result = item.Tag as ResourceResolveResult; if (result == null) { return; } object value; string svalue = null; if (result.ResourceFileContent.TryGetValue(result.Key, out value)) { svalue = value as string; if (svalue == null) { MessageService.ShowWarning("${res:Hornung.ResourceToolkit.ResourceTypeNotSupported}"); return; } } EditStringResourceDialog dialog = new EditStringResourceDialog(result.ResourceFileContent, result.Key, svalue, false); if (svalue == null) { dialog.Text = String.Format(CultureInfo.CurrentCulture, StringParser.Parse("${res:Hornung.ResourceToolkit.CodeCompletion.AddNewDescription}"), result.ResourceFileContent.FileName); } if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { if (svalue == null) { // Add new resource. result.ResourceFileContent.Add(dialog.Key, dialog.Value); } else { // Modify existing resource. result.ResourceFileContent.SetValue(result.Key, dialog.Value); } } }