/// <summary> /// Invoked when the user selects the "Extract Method" command /// </summary> private void ExtractMethodClicked(Object sender, EventArgs e) { try { String newName = "newMethod"; String label = TextHelper.GetString("Label.NewName"); String title = TextHelper.GetString("Title.ExtractMethodDialog"); LineEntryDialog askName = new LineEntryDialog(title, label, newName); var result = askName.ShowDialog(); if (result != DialogResult.OK) { return; } if (askName.Line.Trim().Length > 0 && askName.Line.Trim() != newName) { newName = askName.Line.Trim(); } var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateExtractMethodCommand(newName); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Extract Local Variable" command /// </summary> private void ExtractLocalVariableClicked(Object sender, EventArgs e) { try { var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateExtractLocalVariableCommand(); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Find All References" command /// </summary> private void FindAllReferencesClicked(Object sender, EventArgs e) { try { var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateFindAllReferencesCommand(true); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// /// </summary> private void MoveFile(string oldPath, string newPath) { try { var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateRenameFileCommand(oldPath, newPath); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Organize Imports" command /// </summary> private void OrganizeImportsClicked(Object sender, EventArgs e) { try { var command = (OrganizeImports)CommandFactoryProvider.GetFactoryForCurrentDocument().CreateOrganizeImportsCommand(); command.SeparatePackages = this.settingObject.SeparatePackages; command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Surround with Try/catch block" command /// </summary> private void SurroundWithClicked(Object sender, EventArgs e) { try { var snippet = (sender as ToolStripItem).Text; var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateSurroundWithCommand(snippet); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Delegate Method" command /// </summary> private void DelegateMethodsClicked(Object sender, EventArgs e) { try { ASResult result = ASComplete.CurrentResolvedContext.Result; Dictionary <MemberModel, ClassModel> members = new Dictionary <MemberModel, ClassModel>(); List <String> memberNames = new List <String>(); ClassModel cm = result.Type; cm.ResolveExtends(); while (cm != null && !cm.IsVoid() && cm.Type != "Object") { cm.Members.Sort(); foreach (MemberModel m in cm.Members) { if (((m.Flags & FlagType.Function) > 0 || (m.Flags & FlagType.Getter) > 0 || (m.Flags & FlagType.Setter) > 0) && (m.Access & Visibility.Public) > 0 && (m.Flags & FlagType.Constructor) == 0 && (m.Flags & FlagType.Static) == 0) { string name = m.Name; if ((m.Flags & FlagType.Getter) > 0) { name = "get " + name; } if ((m.Flags & FlagType.Setter) > 0) { name = "set " + name; } if (!memberNames.Contains(name)) { memberNames.Add(name); members[m] = cm; } } } cm = cm.Extends; } var dialog = new DelegateMethodsDialog(); dialog.FillData(members, result.Type); if (dialog.ShowDialog() != DialogResult.OK || dialog.checkedMembers.Count <= 0) { return; } var command = CommandFactoryProvider.GetFactoryForCurrentDocument().CreateDelegateMethodsCommand(result, dialog.checkedMembers); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Invoked when the user selects the "Rename" command /// </summary> private void RenameClicked(Object sender, EventArgs e) { if (InlineRename.InProgress) { return; } try { CommandFactoryProvider.GetFactoryForCurrentDocument().CreateRenameCommandAndExecute(true, settingObject.UseInlineRenaming); } catch (Exception ex) { ErrorManager.ShowError(ex); } }