void OnOKClicked(object sender, EventArgs e) { try { StringBuilder code = new StringBuilder(); CodeGenerator generator = CodeGenerator.CreateGenerator(editor.Document.MimeType); foreach (KeyValuePair <IType, IEnumerable <TreeIter> > kvp in GetAllClasses()) { if (code.Length > 0) { code.AppendLine(); code.AppendLine(); } //update the target class so that new members don't get inserted in weird locations StringBuilder curImpl = new StringBuilder(); foreach (var pair in YieldImpls(kvp)) { if (curImpl.Length > 0) { curImpl.AppendLine(); curImpl.AppendLine(); } curImpl.Append(generator.CreateMemberImplementation(this.cls, pair.Key, pair.Value != null).Code); } if (kvp.Key.ClassType == ClassType.Interface) { code.Append(generator.WrapInRegions(kvp.Key.Name + " implementation", curImpl.ToString())); } else { code.Append(curImpl.ToString()); } } InsertionCursorEditMode mode = new InsertionCursorEditMode(editor, HelperMethods.GetInsertionPoints(editor.Document, this.cls)); ModeHelpWindow helpWindow = new ModeHelpWindow(); helpWindow.TransientFor = IdeApp.Workbench.RootWindow; helpWindow.TitleText = GettextCatalog.GetString("<b>Override -- Targeting</b>"); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Key</b>"), GettextCatalog.GetString("<b>Behavior</b>"))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Up</b>"), GettextCatalog.GetString("Move to <b>previous</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Down</b>"), GettextCatalog.GetString("Move to <b>next</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Enter</b>"), GettextCatalog.GetString("<b>Declare overrides</b> at target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Esc</b>"), GettextCatalog.GetString("<b>Cancel</b> this refactoring."))); mode.HelpWindow = helpWindow; mode.CurIndex = mode.InsertionPoints.Count - 1; mode.StartMode(); mode.Exited += delegate(object s, InsertionCursorEventArgs args) { if (args.Success) { args.InsertionPoint.Insert(editor, code.ToString()); } }; } finally { ((Widget)this).Destroy(); } }