public override void Execute(VsCommandEventArgs e) { if (toolWindow != null) { toolWindow.Visible = true; return; } try { object programmableObject = null; DTE2 application = e.Application; AddIn addInInstance = e.Addin; Windows2 windows2 = (Windows2)application.Windows; Type userCtrlType = typeof(SettingsControl); Assembly userCtrlAssembly = userCtrlType.Assembly; string windowGuid = "{858C3FCD-3333-4540-A592-F31C1520B174}"; toolWindow = windows2.CreateToolWindow2(addInInstance, userCtrlAssembly.Location, userCtrlType.FullName, "CSql Settings", windowGuid, ref programmableObject); Type resourcesType = typeof(Resources); string imageResourceRoot = resourcesType.FullName; string imageResourcePath = imageResourceRoot + ".Images.Commands.Settings.bmp"; var icon = new VsCommandIcon(userCtrlAssembly, imageResourcePath); var iconPicture = icon.IconPicture; toolWindow.SetTabPicture(iconPicture); SettingsControl settingsControl = (SettingsControl)toolWindow.Object; settingsControl.SetApplication(application); toolWindow.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "csql addin error"); } }
public override void Execute(VsCommandEventArgs e) { DTE2 application = e.Application; SolutionExplorerFileLocator locator = new SolutionExplorerFileLocator(application); locator.LocateAndSelectCurrentFile(); }
public override void Execute(VsCommandEventArgs e) { DTE2 application = e.Application; FileGrouper grouper = new FileGrouper(application); grouper.GroupProjectItems(); }
public override void Execute(VsCommandEventArgs e) { ExecuteScriptCommand executeCommand = ExecuteScriptCommand.Instance; if (executeCommand == null) { return; } executeCommand.CancelExecution(); }
/// <summary> /// Check if a script is currently executed. /// </summary> /// <returns><c>true</c> if a script is currently executed. <c>false</c> otherwise.</returns> public override bool CanExecute(VsCommandEventArgs e) { ExecuteScriptCommand executeCommand = ExecuteScriptCommand.Instance; if (executeCommand == null) { return(false); } return(executeCommand.IsExecuting); }
public override void Execute(VsCommandEventArgs e) { DTE2 application = e.Application; var activeDocument = application.ActiveDocument; var documentPath = activeDocument.FullName; if (!activeDocument.Saved && !activeDocument.ReadOnly) { activeDocument.Save(documentPath); } var settingsManager = SettingsManager.GetInstance(application); var dbConnectionParameter = CreateDbConnectionParameter(settingsManager.CurrentDbConnectionParameter, activeDocument); var csqGuiParameter = settingsManager.CurrentScriptParameter; var csqlOptions = CreateCSqlOptions(dbConnectionParameter, csqGuiParameter, activeDocument); TextSelection selection = activeDocument.Selection as TextSelection; int fromChar = -1; int toChar = -1; if (selection != null) { var fromPoint = selection.TopPoint; var toPoint = selection.BottomPoint; if (fromPoint != null && toPoint != null) { fromChar = fromPoint.AbsoluteCharOffset - 1; toChar = toPoint.AbsoluteCharOffset - 1; } } if (fromChar >= 0 && toChar > fromChar) { csqlOptions.PreprocessorOptions.SetRange(fromChar, toChar); } var thread = new System.Threading.Thread(Thread_Start); var parameter = new ThreadParameter(); parameter.Application = application; parameter.CSqlOptions = csqlOptions; thread.IsBackground = true; thread.Start(parameter); if (!csqGuiParameter.IsOutputFileEnabled) { settingsManager.SaveDbConnectionParameterInMruHistory(dbConnectionParameter); } }
public override void OnExecute(VsCommandEventArgs e) { if (this.ProjectViewToolWindow == null) { object temp = null; Windows2 windows = (Windows2)e.DTE.Windows; this.ProjectViewToolWindow = windows.CreateToolWindow2(e.AddIn, System.Reflection.Assembly.GetExecutingAssembly().Location, "JianLi.UI.ProjectView", "项目任务", "{DD52FE78-3F3A-4c9d-8828-E78FC75B944F}", ref temp); ProjectView projectView = (ProjectView)temp; projectView.DTE = e.DTE; projectView.ParentWindow = this.ProjectViewToolWindow; this.ProjectViewToolWindow.Visible = true; } else { this.ProjectViewToolWindow.Activate(); } }
public override void OnExecute(VsCommandEventArgs e) { if (this.SolutionListViewToolWindow == null) { object temp = null; Windows2 windows = (Windows2)e.DTE.Windows; this.SolutionListViewToolWindow = windows.CreateToolWindow2(e.AddIn, System.Reflection.Assembly.GetExecutingAssembly().Location, "JianLi.UI.SolutionListView", "解决方案列表", "{6882BEB2-80BB-45f9-BF6F-60BC8DC77F25}", ref temp); SolutionListView codeOutlineView = (SolutionListView)temp; codeOutlineView.DTE = e.DTE; codeOutlineView.ParentWindow = this.SolutionListViewToolWindow; this.SolutionListViewToolWindow.Visible = true; } else { this.SolutionListViewToolWindow.Activate(); } }
public override void OnExecute(VsCommandEventArgs e) { if (this.solutionTagToolWindow == null) { object temp = null; Windows2 windows = (Windows2)e.DTE.Windows; this.solutionTagToolWindow = windows.CreateToolWindow2(e.AddIn, System.Reflection.Assembly.GetExecutingAssembly().Location, "JianLi.UI.SolutionTagView", "解决方案标签视图", "{786FD1AF-97BA-4f44-B73C-021FA6E174BC}", ref temp); SolutionTagView codeOutlineView = (SolutionTagView)temp; codeOutlineView.DTE = e.DTE; codeOutlineView.ParentWindow = this.solutionTagToolWindow; this.solutionTagToolWindow.Visible = true; } else { this.solutionTagToolWindow.Activate(); } }
/// <summary> /// Determines whether the active document is a member of any loaded project. /// </summary> public override bool CanExecute(VsCommandEventArgs e) { DTE2 application = e.Application; // Any document open? Document activeDocument = application.ActiveDocument; if (activeDocument == null) { return(false); } ProjectItem projectItem = activeDocument.ProjectItem; if (projectItem == null) { return(false); } return(true); }
public override bool CanExecute(VsCommandEventArgs e) { if (IsExecuting) { return(false); } DTE2 application = e.Application; Document activeDocument = application.ActiveDocument; if (activeDocument == null) { return(false); } SettingsManager settingsManager = SettingsManager.GetInstance(application); ScriptParameter scriptParameter = settingsManager.CurrentScriptParameter; string fileName = activeDocument.FullName; bool isSqlScript = FileClassification.IsSqlScript(scriptParameter, fileName); return(isSqlScript); }
public override void Execute(VsCommandEventArgs e) { var dialog = new Gui.AboutDialog(); dialog.ShowDialog(); }