public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Pausing engine"); _client.PauseEngine(); Connect._control.Disconnecting(0); Connect._control.ClearList(); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "VS2010TestResultPublisher.Connect.VS2010TestResultPublisher") { handled = true; try { _tfsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt; } catch { } MainPublisherForm mainForm = null; if (_tfsExt == null) { mainForm = new MainPublisherForm(_applicationObject.Solution.FileName); } else { mainForm = new MainPublisherForm(_applicationObject.Solution.FileName, new ProjectSettings(_tfsExt.ActiveProjectContext)); } mainForm.Show(); return; } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { // Only toggle realtime mode in mighty mode if (!_client.IsRunning || _client.MMConfiguration.BuildExecutables.Count() == 0) { return; } var newState = _client.MMConfiguration.RealtimeFeedback ? "off" : "on"; try { var ptr = GetForegroundWindow(); var image = newState == "on" ? "maniac.png" : "mighty.png"; var win = new TransparentImageWindow(image); win.Show(); SetFocus(new HandleRef(null, ptr)); Logger.Write("Toggling realtime mode " + newState); _client.MMConfiguration.OverrideRealtimeFeedback(!_client.MMConfiguration.RealtimeFeedback); _client.RefreshConfig(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary>实现 IDTCommandTarget 接口的 Exec 方法。此方法在调用该命令时调用。</summary> /// <param term='CmdName'>要执行的命令的名称。</param> /// <param term='ExecuteOption'>描述该命令应如何运行。</param> /// <param term='VariantIn'>从调用方传递到命令处理程序的参数。</param> /// <param term='VariantOut'>从命令处理程序传递到调用方的参数。</param> /// <param term='Handled'>通知调用方此命令是否已被处理。</param> /// <seealso class='Exec' /> public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Handled = false; if (ExecuteOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (CmdName == "PasteXmlAsLinq.Connect.PasteXmlAsLinq") { Document doc = applicationObject.ActiveDocument; if (doc != null) { string xml = (string)Clipboard.GetDataObject().GetData(typeof(string)); if (xml != null) { try { string code = Converter.Convert(xml); TextSelection s = (TextSelection)doc.Selection; s.Insert(code, (int)vsInsertFlags.vsInsertFlagsContainNewText); applicationObject.ExecuteCommand("Edit.FormatSelection", ""); } catch (Exception e) { MessageBox.Show("Clipboard does not contain valid XML.\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } Handled = true; return; } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param name='commandName'>The name of the command to execute.</param> /// <param name='executeOption'>Describes how the command should be run.</param> /// <param name='varIn'>Parameters passed from the caller to the command handler.</param> /// <param name='varOut'>Parameters passed from the command handler to the caller.</param> /// <param name='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> void IDTCommandTarget.Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption != vsCommandExecOption.vsCommandExecOptionDoDefault) return; handled = true; switch (commandName) { case "SmartPaster.Connect.Configure": break; case "SmartPaster.Connect.PasteAsComment": smartPaster.PasteAsComment(applicationObject); break; case "SmartPaster.Connect.PasteAsString": smartPaster.PasteAsString(applicationObject); break; case "SmartPaster.Connect.PasteAsStringBuilder": smartPaster.PasteAsStringBuilder(applicationObject); break; case "SmartPaster.Connect.PasteAsRegion": smartPaster.PasteAsRegion(applicationObject); break; default: handled = false; break; } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Getting Sequence diagram"); var methodName = GetMethodNameAtCursor(); if (methodName != null) _client.GetRuntimeTestInformationFor(methodName); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param name='commandName'>The name of the command to execute.</param> /// <param name='executeOption'>Describes how the command should be run.</param> /// <param name='varIn'>Parameters passed from the caller to the command handler.</param> /// <param name='varOut'>Parameters passed from the command handler to the caller.</param> /// <param name='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "FormatAppSettingsPlugin.Connect.FormatAppSettingsPlugin" && _applicationObject.ActiveWindow != null && _applicationObject.ActiveWindow.Caption.Equals(FILE_NAME, StringComparison.InvariantCultureIgnoreCase)) { try { var selection = (TextSelection)_applicationObject.ActiveDocument.Selection; selection.SelectAll(); var formattedText = formatter.Tidy(selection.Text); selection.Insert(formattedText, 1); } catch (Exception e) { MessageBox.Show(String.Format("Error: {0}", e.Message)); } handled = true; return; } MessageBox.Show(string.Format("Please load {0} to run this plugin.",FILE_NAME)); } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called /// when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "FwAddin.Connect.GotoFunctionHeaderDown") { m_commands.GotoFunctionHeaderDown(); handled = true; return; } else if (commandName == "FwAddin.Connect.GotoFunctionHeaderUp") { m_commands.GotoFunctionHeaderUp(); handled = true; return; } else if (commandName == "FwAddin.Connect.InsertMethodHeader") { m_commands.InsertMethodHeader(); handled = true; return; } else if (commandName == "FwAddin.Connect.ToggleHAndCpp") { m_commands.ToggleHAndCpp(); handled = true; return; } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "JsParser.AddIn.Connect.Show") { ShowWindow(); handled = true; return; } if (commandName == "JsParser.AddIn.Connect.Find") { ShowWindow(); var wnd = EnsureWindowCreated(); if (wnd != null) { wnd.NavigationTreeView.Find(); } handled = true; return; } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { //System.Windows.Forms.MessageBox.Show("exec"); handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault && AcceptedCommand(commandName)) { bool bForward = true; if(commandName == "FileSwitch2008.Connect.PrevFile") { bForward = false; } Project fileproject = _addInInstance.DTE.ActiveDocument.ProjectItem.ContainingProject; string fullname =_addInInstance.DTE.ActiveDocument.FullName; FileGroup group = new FileGroup(fileproject, fullname.ToLower()); string newfile = bForward ? group.Next() : group.Prev(); _applicationObject.ItemOperations.OpenFile(newfile, Constants.vsViewKindCode); handled = true; return; } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "LazyBot.Connect.LazyBot") { if (_applicationObject.ActiveDocument != null && _applicationObject.ActiveDocument.Type == "Text") { var currentDocument = (TextDocument)_applicationObject.ActiveDocument.Object(string.Empty); var selection = currentDocument.Selection; var requestKeys = _botParser.GetKeys(selection); var document = _botParser.GetDocument(selection); var response = _botRequest.Put(requestKeys, document); var message = response == "Success" ? "Your bot has been successfully saved :)" : "Something went wrong :( \n" + response; MessageBox.Show(message); } handled = true; return; } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { object docObj = new object(); if (Connect.LastRanTestsWindow == null) { try { Logger.Write("Starting last run tests toolbox"); Connect.LastRanTestsWindow = _applicationObject.Windows.CreateToolWindow(_addInInstance, "ContinuousTests_ListOfRanTests", "ContinuousTests - Last Ran Tests", "{67663444-f874-401c-9e55-053bb0b5bd0b}", ref docObj); Connect.LastRanTestsWindow.IsFloating = false; Connect.LastRanTestsControl = (ContinuousTests_ListOfRanTests)docObj; Connect.LastRanTestsControl.SetApplication(_applicationObject); Connect.LastRanTestsWindow.Activate(); } catch (Exception ex) { Logger.Write(ex); } } else { // toggle window if (!Connect.LastRanTestsControl.IsInFocus()) { Connect.LastRanTestsWindow.Activate(); } else { Connect.LastRanTestsWindow.Close(); } } Handled = true; }
public override void Exec(vsCommandExecOption executeOption, ref object varIn, ref object varOut) { string magicDrawPath = m_addInSettings.UMLModellerPath; if (magicDrawPath != string.Empty && System.IO.File.Exists(magicDrawPath) && System.IO.File.Exists(m_solutionManager.ModelFilePath) ) { try { if (m_addInSettings.AutoMakeModelFileWritable) { System.IO.FileAttributes attr = System.IO.File.GetAttributes(m_solutionManager.ModelFilePath); if ((attr & System.IO.FileAttributes.ReadOnly) != 0) { attr -= System.IO.FileAttributes.ReadOnly; System.IO.File.SetAttributes(m_solutionManager.ModelFilePath, attr); } } //AddInUtils.ShowWarning("Path: " + magicDrawPath + "\nArgs: " + "\"" + m_solutionManager.ModelFilePath + "\""); System.Diagnostics.Process.Start(magicDrawPath, "\"" + m_solutionManager.ModelFilePath + "\""); } catch (Exception e) { AddInUtils.ShowError("An unexpected error occured while trying to launch the external UML modeling tool: " + e.Message); } } else { AddInUtils.ShowError("The external UML modeling tool could not be found. Please ensure the path is correct in the Android/VS options page (Tools | Options | AndroMDA | Tools)"); } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == _cmdPrefix + _switchCommandStr) { SwitchWorking(); } else if (commandName == _cmdPrefix + _execCommandStr) { TextDocument doc = (TextDocument)(_applicationObject.ActiveDocument. Object("TextDocument")); Execute(doc.Selection.TopPoint, doc.Selection.BottomPoint, true); } else if (commandName == _cmdPrefix + _optionsCommandStr) { SettingsForm form = new SettingsForm(AStyle); form.ShowDialog(); } handled = true; return; } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "FormatVariableDefine.Connect.FormatVariableDefine" || commandName == "FormatVariableDefine.Connect.FormatVariableDefineRightClick") { TextSelection select = ((TextSelection)_applicationObject.ActiveDocument.Selection); int nTopLine = select.TopLine; int nBottomLine = select.BottomLine; bool bLastLineEmpty = select.BottomPoint.AtStartOfLine; select.GotoLine(nTopLine, true); select.LineDown(true, nBottomLine - nTopLine); select.EndOfLine(true); if (bLastLineEmpty) select.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, true); string selectedCode = select.Text; string outCode = CodeSmart.AlignText(selectedCode); //对齐选中文本 select.Insert(outCode, (int)vsInsertFlags.vsInsertFlagsCollapseToEnd); handled = true; return; } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "VsExtension.Connect.ProjectDo") { /* var doc = _applicationObject.ActiveDocument; var projectItem = doc.ProjectItem; var project = projectItem.ContainingProject; var evalProject = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadProject(project.FullName); var execProject = evalProject.CreateProjectInstance(); bool success = execProject.Build("CalledFromIde", null); var window = _applicationObject.Windows.Item(Constants.vsWindowKindOutput); var output = (OutputWindow)window.Object; OutputWindowPane pane = output.OutputWindowPanes.Add("BuildAddin"); pane.OutputString(success ? "built /t:CalledFromIde" : "build failed"); */ var projects = _applicationObject.ActiveSolutionProjects as System.Array; if (projects.Length > 0) { var proj = projects.GetValue(0) as Project; } handled = true; return; } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Getting coupling graph"); var methodName = GetMethodNameAtCursor(); if (methodName != null) _client.GetGraphFor(methodName); }
public virtual void Exec(string cmdName , vsCommandExecOption executeOption , ref object variantIn , ref object variantOut , ref bool handled ) { switch (executeOption) { case vsCommandExecOption.vsCommandExecOptionDoDefault: { var x = Util.GetExcelTypeForComObject(_application.Debugger, _application.Debugger.GetType()); var y = Util.GetExcelTypeForComObject(_application.Debugger, typeof(IDebugProperty2)); //in future make this behave as windbg http://msdn.microsoft.com/en-us/library/ff566176(v=vs.85).aspx //for now lets just make it as: // filename address size string commandline = variantIn as string; char[] sp = new char[] { ' ', '\t' }; string[] argv = commandline.Split(sp); bool bRet = ExecuteDefault(argv); var commandWindow = _application.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow).Object as CommandWindow; commandWindow.OutputString(CommandText + " " + (bRet ? "Succeded" : "Failed") + "\r\n"); } break; } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "AutoAttachW3WP.Connect.AutoAttachW3WP") { handled = true; try { foreach (EnvDTE.Process process in _applicationObject.Debugger.LocalProcesses) { if (process.Name.ToLower().IndexOf("w3wp") > 0) { process.Attach(); } } } catch (Exception ex) { } return; } } }
public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { if (ExecuteOption != vsCommandExecOption.vsCommandExecOptionDoDefault || _applicationObject.ActiveDocument == null || CmdName != fullCmdName) { return; } Handled = true; ToggleIsOn(); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Building all projects and running all tests"); if (_client.IsRunning) _client.RunAll(); else manualRunAll(); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { var pos = new OnDemandRunFromCursorPosition(_applicationObject); var types = pos.FromCurrentPosition(); _peek(types); if (!_manualBuild() || _buildRunner.Build(new[] { types.Project })) _runTests(types); }
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption != vsCommandExecOption.vsCommandExecOptionDoDefault) return; handled = GitPlugin.OnCommand(commandName); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { _engine.Eval("emmet.require('actions').run('" + commandName.Replace("Emmet4VsAddin.Connect.", "") + "', editor);"); handled = true; } }
/// <summary> /// Implements the Exec method of the IDTCommandTarget interface. /// This is called when the command is invoked. /// </summary> /// <param term='commandName'> /// The name of the command to execute. /// </param> /// <param term='executeOption'> /// Describes how the command should be run. /// </param> /// <param term='varIn'> /// Parameters passed from the caller to the command handler. /// </param> /// <param term='varOut'> /// Parameters passed from the command handler to the caller. /// </param> /// <param term='handled'> /// Informs the caller if the command was handled or not. /// </param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { // Trace.Write( "Addin.QueryStatus start" ); if (m_addin != null) { m_addin.Exec(commandName, executeOption, ref varIn, ref varOut, ref handled); } // Trace.Write( "Addin.QueryStatus finish" ); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { var method = new ElementNameFromCursorPosition(_application).Get(); if (method == null) return; Logger.Write("Running tests related to " + method); if (_client.IsRunning || _buildRunner.Build()) _client.RunRelatedTestsFor(method); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { var runs = new List<OnDemandRun>(); foreach (Project project in _applicationObject.Solution.Projects) addProjects(runs, project); _peek(runs); if (!_manualBuild() || _buildRunner.Build()) _runTests(runs); }
public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { if(!CmdName.StartsWith("Emacs.Editor.")) { handler.OnUnknownCommand(); } else { handler.OnCommand(CmdName.Substring("Emacs.Editor.".Length)); Handled = true; } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { var dummy = new object(); var dummyBool = false; Logger.Write("Clearing cached tests"); new AutoTestVSStop(_client).Exec(vsCommandExecOption.vsCommandExecOptionDoDefault, ref dummy, ref dummy, ref dummyBool); System.Threading.Thread.Sleep(500); new AutoTestVSStart(_client).Exec(vsCommandExecOption.vsCommandExecOptionDoDefault, ref dummy, ref dummy, ref dummyBool); }
/// <summary> /// Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked. /// </summary> /// <param name="commandName">The name of the command to execute.</param> /// <param name="executeOption">Describes how the command should be run.</param> /// <param name="varIn">Parameters passed from the caller to the command handler.</param> /// <param name="varOut">Parameters passed from the command handler to the caller.</param> /// <param name="handled">Informs the caller if the command was handled or not.</param> /// <seealso class="Exec" /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption != vsCommandExecOption.vsCommandExecOptionDoDefault) return; if (commandName != "SmartPaster2010.Connect.SmartPaster2010") return; handled = true; }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName.Equals("PoorMansTSqlFormatterSSMSAddIn.AddinConnector.FormatSelectionOrActiveWindow")) { string fileExtension = System.IO.Path.GetExtension(_applicationObject.ActiveDocument.FullName); bool isSqlFile = fileExtension.ToUpper().Equals(".SQL"); if (isSqlFile || MessageBox.Show(_generalResourceManager.GetString("FileTypeWarningMessage"), _generalResourceManager.GetString("FileTypeWarningMessageTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes) { string fullText = SelectAllCodeFromDocument(_applicationObject.ActiveDocument); TextSelection selection = (TextSelection)_applicationObject.ActiveDocument.Selection; if (!selection.IsActiveEndGreater) { selection.SwapAnchor(); } if (selection.Text.EndsWith(Environment.NewLine) || selection.Text.EndsWith(" ")) { selection.CharLeft(true, 1); //newline counts as a distance of one. } string selectionText = selection.Text; bool formatSelectionOnly = selectionText.Length > 0 && selectionText.Length != fullText.Length; string textToFormat = formatSelectionOnly ? selectionText : fullText; bool errorsFound = false; string formattedText = _formattingManager.Format(textToFormat, ref errorsFound); bool abortFormatting = false; if (errorsFound) { abortFormatting = MessageBox.Show(_generalResourceManager.GetString("ParseErrorWarningMessage"), _generalResourceManager.GetString("ParseErrorWarningMessageTitle"), MessageBoxButtons.YesNo) != DialogResult.Yes; } if (!abortFormatting) { if (formatSelectionOnly) { selection.Delete(1); selection.Insert(formattedText, (int)EnvDTE.vsInsertFlags.vsInsertFlagsContainNewText); } else { ReplaceAllCodeInDocument(_applicationObject.ActiveDocument, formattedText); } } } handled = true; return; } if (commandName.Equals("PoorMansTSqlFormatterSSMSAddIn.AddinConnector.FormattingOptions")) { GetFormatHotkey(); SettingsForm settings = new SettingsForm(Properties.Settings.Default, Assembly.GetExecutingAssembly(), _generalResourceManager.GetString("ProjectAboutDescription"), new SettingsForm.GetTextEditorKeyBindingScopeName(GetTextEditorKeyBindingScopeName)); if (settings.ShowDialog() == DialogResult.OK) { SetFormatHotkey(); _formattingManager = Utils.GetFormattingManager(Properties.Settings.Default); } settings.Dispose(); } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { _showWindow(); Handled = true; }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "Mfconsulting.Vsprj2make.Connect.CreateMake") { // handled = true; handled = CreateMakefile(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.GenDistUnit") { // handled = true; handled = GenerateDistUnit(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.GenMDFiles") { // handled = true; handled = GenerateMDcmbx(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.PrjxToCsproj") { // handled = true; handled = ImportMDcmbx(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.RunOnMono") { // handled = true; handled = TestInMono(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.Options") { // handled = true; handled = OptionsAndSettings(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.ExploreCurrSln") { // handled = true; handled = ExploreCurrSln(); return; } if (commandName == "Mfconsulting.Vsprj2make.Connect.ExploreCurrDoc") { // handled = true; handled = ExploreCurrDoc(); return; } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { _command(); }
public virtual void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { throw new NotImplementedException(); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Initiating recursive detection run"); _client.RunRecursiveRunDetection(); Connect._control.NotifyAboutUpcomingRecursiveRun(); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Initiating global configuration"); _client.ShowConfiguration(false); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { //ext.Documents.Add(); //ext.Documents.Add(ext.ActiveDocument.Kind.ToString().Replace("{", "").Replace("}", "")); //ext.WindowConfigurations.Add("test window"); //ext.ExecuteCommand("QueryDesigner.Select"); //ext.ExecuteCommand("QueryDesigner.SQL"); //ext.ExecuteCommand("QueryDesigner.ExecuteSQL"); if (commandName == "SSMSAddin.Connect.ViewReferencedValue") { var sqlParser = new SimpleSqlParser(); var ext = ((DTE2)ServiceCache.ExtensibilityModel); IScriptFactory scriptFactory = ServiceCache.ScriptFactory; var window = (Window)ext.ActiveWindow; var scriptWindow = _windowExtensions.ContainsKey(window) ? _windowExtensions[window] : null; var values = scriptWindow?.GetSelectedValues(); foreach (var val in values.Where(v => v?.Values?.Count > 0)) { var s = scriptFactory.CreateNewBlankScript(ScriptType.Sql, scriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo, null); Document document = ext.ActiveDocument; if (document != null) { var sql = scriptWindow.GetQuery(); var table = sqlParser.GetTableFromSql(sql, val.ColumnName); var split = table.Split('.'); var schema = "dbo"; if (split.Length == 3) { schema = split[1].Replace("[", "").Replace("]", ""); table = split[2].Replace("[", "").Replace("]", ""); } else if (split.Length == 2) { schema = split[0].Replace("[", "").Replace("]", ""); table = split[1].Replace("[", "").Replace("]", ""); } else if (split.Length == 1) { table = split[0].Replace("[", "").Replace("]", ""); } var sqlToGetReferences = $@" SELECT S2.name AS SchemaName, T2.name AS TableName, C2.name AS ColumnName FROM sys.tables T JOIN sys.schemas S ON S.schema_id = T.schema_id JOIN sys.columns C ON C.object_id = T.object_id JOIN sys.foreign_key_columns FK ON FK.parent_object_id = T.object_id AND FK.parent_column_id = C.column_id JOIN sys.tables T2 ON T2.object_id = FK.referenced_object_id JOIN sys.columns C2 ON C2.object_id = T2.object_id AND C2.column_id = FK.referenced_column_id JOIN sys.schemas S2 ON S2.schema_id = T2.schema_id WHERE T.name = '{table}' AND S.name = '{schema}' AND C.name = '{val.ColumnName}' "; var conInfo = scriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo; SqlCommand cmd = new SqlCommand(sqlToGetReferences, new SqlConnection($"Server={conInfo.ServerNameNoDot};Database={conInfo.AdvancedOptions["DATABASE"]};Trusted_Connection=True;")); cmd.Connection.Open(); var referencedTable = string.Empty; var referencedSchema = string.Empty; var referencedColumn = string.Empty; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { referencedSchema = (string)reader["SchemaName"]; referencedTable = (string)reader["TableName"]; referencedColumn = (string)reader["ColumnName"]; } } cmd.Connection.Close(); //replace currently selected text if (!string.IsNullOrEmpty(referencedSchema) && !string.IsNullOrEmpty(referencedTable) && !string.IsNullOrEmpty(referencedColumn)) { TextSelection selection = (TextSelection)document.Selection; selection.Insert($"SELECT * FROM [{referencedSchema}].[{referencedTable}] WHERE [{referencedColumn}] {val?.WhereClause()}", (Int32)EnvDTE.vsInsertFlags.vsInsertFlagsContainNewText); ext.ExecuteCommand("Query.Execute"); } } } handled = true; return; } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { // Setup debug Output window. Window w = (Window)this._applicationObject.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); w.Visible = true; OutputWindow ow = (OutputWindow)w.Object; OutputWindowPane owp = ow.OutputWindowPanes.Add("BreakAll tracing"); owp.Activate(); handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "BreakAll.Connect.BreakAll") { if (this._applicationObject.ActiveDocument == null) { return; } List <CodeClass> classes = new List <CodeClass>(); RecursiveClassSearch(this._applicationObject.ActiveDocument.ProjectItem.FileCodeModel.CodeElements, classes); foreach (CodeClass codeClass in classes) { foreach (object targetObject in codeClass.Members) { if (targetObject is CodeFunction) { CodeFunction method = targetObject as CodeFunction; try { this._applicationObject.Debugger.Breakpoints.Add(string.Empty, this._applicationObject.ActiveDocument.FullName, method.GetStartPoint(vsCMPart.vsCMPartBody).Line); } catch (Exception ex) { owp.OutputString("\nException from Debugger.Breakpoints.Add: " + ex.Message); } } else if (targetObject is CodeProperty) { CodeProperty property = targetObject as CodeProperty; try { this._applicationObject.Debugger.Breakpoints.Add(string.Empty, this._applicationObject.ActiveDocument.FullName, property.Getter.GetStartPoint(vsCMPart.vsCMPartBody).Line); } catch (Exception ex) { owp.OutputString("\nException from Debugger.Breakpoints.Add: " + ex.Message); } try { this._applicationObject.Debugger.Breakpoints.Add(string.Empty, this._applicationObject.ActiveDocument.FullName, property.Setter.GetStartPoint(vsCMPart.vsCMPartBody).Line); } catch (Exception ex) { owp.OutputString("\nException from Debugger.Breakpoints.Add: " + ex.Message); } } } } handled = true; return; } else if (commandName == "BreakAll.Connect.BreakNone") { if (this._applicationObject.ActiveDocument == null) { return; } List <Breakpoint> breakpointsInCurrentFile = new List <Breakpoint>(); foreach (Breakpoint breakpoint in _applicationObject.Debugger.Breakpoints) { if (breakpoint.File == this._applicationObject.ActiveDocument.FullName) { breakpointsInCurrentFile.Add(breakpoint); } } foreach (Breakpoint breakpoint in breakpointsInCurrentFile) { breakpoint.Delete(); } handled = true; return; } } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { _client.GetLastAffectedGraph(); }
public override bool CanExecute(vsCommandExecOption executeOption) { return(base.CanExecute(executeOption)); }
public override void Exec(vsCommandExecOption executeOption, ref object varIn, ref object varOut) { m_solutionManager.RunSchemaExport(); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "SSMSAddin.Connect.SSMSAddin") { Document document = ((DTE2)ServiceCache.ExtensibilityModel).ActiveDocument; if (document != null) { //replace currently selected text TextSelection selection = (TextSelection)document.Selection; //selection.Insert(@"xxxxxx", (Int32)EnvDTE.vsInsertFlags.vsInsertFlagsContainNewText); //VisualisationPane myControl = new VisualisationPane(); //Windows2 myWindow = (Windows2) _applicationObject.Windows; //var window = myWindow.CreateToolWindow2(_addInInstance, // System.Reflection.Assembly.GetExecutingAssembly().Location, "SSMSAddin.VisualisationPane", // "xxxx", "{5B7F8C1C-65B9-2aca-1Ac3-12AcBbAF21d5}", myControl); //window.Visible = true; try { RegistryAccess ra = new RegistryAccess("SQLDep", false); // "3c81b7e5-109f-49c0-bfc7-a67c3cb67b62" string userAccountId = ra.Read("userAccountId"); bool execute = false; bool save = false; AskUserForm askUser = new AskUserForm(userAccountId); // Show testDialog as a modal dialog and determine if DialogResult = OK. if (askUser.ShowDialog(null) == DialogResult.OK) { // Read the contents of testDialog's TextBox. execute = true; userAccountId = askUser.UserId; save = askUser.StoreAble; } else { } askUser.Dispose(); if (save) { ra.Write("userAccountId", userAccountId); } if (execute) { string result = ""; string json = "{ \"userAccountId\":\"" + userAccountId + "\", \"dialect\":\"mssql\", \"queries\": [ { \"sourceCode\": \"" + selection.Text + "\" } ] }"; using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/json"; result = client.UploadString("https://sqldep.com/api/rest/sqlset/create/", "POST", json); // REMOVE // MessageBox.Show(result); } // PARSE RESULTS HERE AND DISPLAY ON PANEL XmlDocument doc = JsonConvert.DeserializeXmlNode(result, "Root"); string retUrl = doc["Root"]["urlToVisualisation"].InnerText; // otevre IE (chrome) System.Diagnostics.Process.Start(retUrl); // okenko - take moznost //myControl.webBrowser1.Navigate(retUrl); } } catch (Exception e) { MessageBox.Show(e.Message); } } handled = true; return; } } }
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = commandManager.Exec(commandName); }
/// <summary/> public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { _controller.Exec(CmdName, ExecuteOption, ref VariantIn, ref VariantOut, ref Handled); }
public override void Exec(vsCommandExecOption executeOption, ref object varIn, ref object varOut) { Dialogs.AboutDialog a = new Dialogs.AboutDialog(); a.MDASolutionManager = m_solutionManager; a.ShowDialog(); }
/// <summary> /// Determine if we can execute. /// </summary> /// <param name="executeOption"> /// The execute option. /// </param> /// <returns> /// true if we can execute, otherwise false. /// </returns> public override bool CanExecute(vsCommandExecOption executeOption) { logger.Trace("Entered CanExecute()"); return(base.CanExecute(executeOption) && IsTextSelected()); }
/// <summary> /// Determine if we can execute. /// </summary> /// <seealso cref="M:XamlHelpmeet.Commands.CommandBase.CanExecute(vsCommandExecOption)"/> public override bool CanExecute(vsCommandExecOption executeOption) { return(base.CanExecute(executeOption) && IsTextSelected()); }
/// <summary> /// Execute command. /// </summary> public void Exec(string cmdName, vsCommandExecOption executeOption, ref object variantIn, ref object variantOut, ref bool handled) { manager.Execute(cmdName, ref handled); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("About ContinuousTests"); _client.ShowAboutBox(); return; }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "ReplaceF1.Connect.ReplaceF1") { // Get a reference to Solution Explorer. Window activeWindow = _applicationObject.ActiveWindow; ContextAttributes contextAttributes = activeWindow.DTE.ContextAttributes; contextAttributes.Refresh(); List <string> attributes = new List <string>(); try { ContextAttributes highPri = contextAttributes == null ? null : contextAttributes.HighPriorityAttributes; highPri.Refresh(); if (highPri != null) { foreach (ContextAttribute CA in highPri) { List <string> values = new List <string>(); foreach (string value in (ICollection)CA.Values) { values.Add(value); } string attribute = CA.Name + "=" + String.Join(";", values.ToArray()); attributes.Add(CA.Name + "="); } } } catch (System.Runtime.InteropServices.COMException e) { // ignore this exception-- means there's no High Pri values here string x = e.Message; } catch (System.Reflection.TargetInvocationException e) { // ignore this exception-- means there's no High Pri values here string x = e.Message; } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); // ignore this exception-- means there's no High Pri values here string x = e.Message; } // fetch context attributes that are not high-priority foreach (ContextAttribute CA in contextAttributes) { List <string> values = new List <string>(); foreach (string value in (ICollection)CA.Values) { values.Add(value); } string attribute = CA.Name + "=" + String.Join(";", values.ToArray()); attributes.Add(attribute); } // Replace this call with whatever you want to do with the help context info HelpHandler.HandleF1(attributes); } } }
public override void Exec(vsCommandExecOption executeOption, ref object varIn, ref object varOut) { CodeFunction2 currentMethod = CodeModelUtils.GetCurrentMethod(m_application); if (IsCommandAvailable(currentMethod)) { try { ConversionCodeGenerator codeGenerator = new ConversionCodeGenerator(); CodeParameter2 param = currentMethod.Parameters.Item(1) as CodeParameter2; ArrayList toProperties; ArrayList fromProperties; try { toProperties = CodeModelUtils.GetPropertiesFromType(currentMethod.Type.CodeType); } catch (NotImplementedException) { throw new Exception("Method return type '" + currentMethod.Type.AsString + "' could not be resolved."); } try { fromProperties = CodeModelUtils.GetPropertiesFromType(param.Type.CodeType); } catch (NotImplementedException) { throw new Exception("Method parameter type '" + param.Type.AsString + "' could not be resolved."); } foreach (CodeProperty toProperty in toProperties) { bool mapped = false; string toName = toProperty.Name; string toNameNoDots = toName.Replace(".", string.Empty); string toType = toProperty.Type.AsFullName; foreach (CodeProperty fromProperty in fromProperties) { string fromName = fromProperty.Name; string fromNameNoDots = fromName.Replace(".", string.Empty); if (fromName == toName || fromName == toNameNoDots || fromNameNoDots == toNameNoDots) { string fromType = fromProperty.Type.AsFullName; if (fromType.Replace("?", string.Empty) == toType.Replace("?", string.Empty)) { codeGenerator.AddProperty(toName, toType, fromName, fromType); mapped = true; break; } } } if (!mapped) { codeGenerator.AddProperty(toName, toType); } } AddInUtils.InsertCodeInMethod(currentMethod, codeGenerator.GenerateCode(currentMethod)); m_application.StatusBar.Text = "Android/VS: Code inserted"; } catch (Exception e) { m_application.StatusBar.Text = "Android/VS: Unable to insert code: " + e.Message; m_application.StatusBar.Highlight(true); } } else { m_application.StatusBar.Text = "Android/VS: Unable to insert code"; } }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Resuming engine"); _client.ResumeEngine(); Connect._control.Connecting(0, false); }
public override void Exec(vsCommandExecOption executeOption, ref object varIn, ref object varOut) { Dialogs.MDASolutionWizard wizard = new Dialogs.MDASolutionWizard(m_application, m_solutionManager, m_addInSettings); wizard.ShowDialog(); }
public void Exec(vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { Logger.Write("Initiating local configuration"); new System.Threading.Thread(() => _client.ShowConfiguration(true)).Start(); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param name="CmdName"></param> /// <param name="ExecuteOption"></param> /// <param name="VariantIn"></param> /// <param name="VariantOut"></param> /// <param name="Handled"></param> public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled) { _ssmsAbstract.command_manager.Exec(CmdName, ExecuteOption, ref VariantIn, ref VariantOut, ref Handled); }
/// <summary>实现 IDTCommandTarget 接口的 Exec 方法。此方法在调用该命令时调用。</summary> /// <param term='commandName'>要执行的命令的名称。</param> /// <param term='executeOption'>描述该命令应如何运行。</param> /// <param term='varIn'>从调用方传递到命令处理程序的参数。</param> /// <param term='varOut'>从命令处理程序传递到调用方的参数。</param> /// <param term='handled'>通知调用方此命令是否已被处理。</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { try { if (IsCommand(commandName, "BuffaloEntityConfig")) { SelectedShapesCollection selectedShapes = SelectedShapes; if (selectedShapes == null) { return; } for (int i = 0; i < selectedShapes.Count; i++) { if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape)) { continue; } ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape; if (!(sp.AssociatedType is ClrClass)) { continue; } using (FrmClassDesigner st = new FrmClassDesigner()) { Diagram selDiagram = SelectedDiagram; st.SelectedClass = sp; st.DesignerInfo = GetDesignerInfo(); st.ShowDialog(); } } handled = true; return; } else if (IsCommand(commandName, "BuffaloDBCreater")) { SelectedShapesCollection selectedShapes = SelectedShapes; if (selectedShapes == null) { return; } List <ClrClass> lstClass = new List <ClrClass>(); for (int i = 0; i < selectedShapes.Count; i++) { if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape)) { continue; } ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape; ClrClass classType = sp.AssociatedType as ClrClass; if (classType == null) { continue; } lstClass.Add(classType); } using (FrmDBCreate st = new FrmDBCreate()) { Diagram selDiagram = SelectedDiagram; st.SelectedClass = lstClass; //st.SelectDocView = SelectDocView; //st.CurrentProject = CurrentProject; //st.SelectedDiagram = selDiagram; st.DesignerInfo = GetDesignerInfo(); st.ShowDialog(); } handled = true; return; } else if (IsCommand(commandName, "BuffaloDBToEntity")) { Diagram dia = SelectedDiagram; if (!(dia is ShapeElement)) { return; } using (FrmAllTables frmTables = new FrmAllTables()) { //frmTables.SelectedDiagram = dia; //frmTables.SelectDocView = SelectDocView; //frmTables.CurrentProject = CurrentProject; frmTables.DesignerInfo = GetDesignerInfo(); frmTables.ShowDialog(); } } else if (IsCommand(commandName, "BuffaloShowHideSummery")) { Diagram dia = this.SelectedDiagram; if (dia != null) { VSConfigManager.InitConfig(_applicationObject.Version); ShapeSummaryDisplayer.ShowOrHideSummary(dia, this); this.SelectDocView.CurrentDesigner.ScrollDown(); this.SelectDocView.CurrentDesigner.ScrollUp(); handled = true; } } else if (IsCommand(commandName, "BuffaloDBCreateAll")) { List <ClrClass> lstClass = GetAllClass(SelectedDiagram); if (lstClass == null) { return; } using (FrmDBCreate st = new FrmDBCreate()) { Diagram selDiagram = SelectedDiagram; st.SelectedClass = lstClass; //st.SelectDocView = SelectDocView; //st.CurrentProject = CurrentProject; //st.SelectedDiagram = selDiagram; st.DesignerInfo = GetDesignerInfo(); st.ShowDialog(); } handled = true; return; } else if (IsCommand(commandName, "BuffaloDBSet")) { string dalNamespace = GetDesignerInfo().GetNameSpace() + ".DataAccess"; ShapeElementMoveableCollection nestedChildShapes = SelectedDiagram.NestedChildShapes; FrmDBSetting.ShowConfig(GetDesignerInfo(), dalNamespace); } else if (IsCommand(commandName, "BuffaloEntityRemove")) { SelectedShapesCollection selectedShapes = SelectedShapes; if (selectedShapes == null) { return; } for (int i = 0; i < selectedShapes.Count; i++) { if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape)) { continue; } ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape; if (!(sp.AssociatedType is ClrClass)) { continue; } EntityConfig entity = new EntityConfig(sp.AssociatedType, GetDesignerInfo()); //entity.SelectDocView = SelectDocView; if (MessageBox.Show("是否要删除实体:" + entity.ClassName + " 及其相关的业务类?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { EntityRemoveHelper.RemoveEntity(entity); } } } else if (IsCommand(commandName, "BuffaloUpdateEntityByDB")) { SelectedShapesCollection selectedShapes = SelectedShapes; if (selectedShapes == null) { return; } for (int i = 0; i < selectedShapes.Count; i++) { if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape)) { continue; } ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape; ClrClass curClass = sp.AssociatedType as ClrClass; if (curClass == null) { continue; } EntityConfig entity = EntityConfig.GetEntityConfigByTable(curClass, GetDesignerInfo()); entity.GenerateCode(); } handled = true; return; } if (IsCommand(commandName, "BuffaloUI")) { SelectedShapesCollection selectedShapes = SelectedShapes; if (selectedShapes == null) { return; } for (int i = 0; i < selectedShapes.Count; i++) { if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape)) { continue; } ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape; if (!(sp.AssociatedType is ClrClass)) { continue; } using (FrmUIGenerater st = new FrmUIGenerater()) { Diagram selDiagram = SelectedDiagram; st.CurEntityInfo = new EntityInfo(sp.AssociatedType, GetDesignerInfo()); st.BindTargetProjects(AllProjects); st.ShowDialog(); } } handled = true; return; } if (IsCommand(commandName, "commandGenDal")) { GreanDataAccess(); return; } } catch (Exception ex) { FrmCompileResault.ShowCompileResault(null, ex.ToString(), "错误"); } } }
/// <summary>IDTCommandTarget 인터페이스의 Exec 메서드를 구현합니다. 이 메서드는 명령이 호출되면 호출됩니다.</summary> /// <param term='commandName'>실행할 명령의 이름입니다.</param> /// <param term='executeOption'>명령을 실행하는 방법을 설명합니다.</param> /// <param term='varIn'>호출자에서 명령 처리기로 전달된 매개 변수입니다.</param> /// <param term='varOut'>명령 처리기에서 호출자로 전달된 매개 변수입니다.</param> /// <param term='handled'>명령이 처리되었는지 여부를 호출자에게 알립니다.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { try { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "ZAssist.Connect.About") { About aboutDlg = new About(); aboutDlg.ShowDialog(new WindowWrapper((IntPtr)_applicationObject.MainWindow.HWnd)); } else if (commandName == "ZAssist.Connect.OpenCorrespondingFile") { ZAssistManager.OpenCorrespondingFile(_applicationObject); handled = true; return; } else if (commandName == "ZAssist.Connect.OpenSolutionFolderExplorer") { ZAssistManager.OpenSolutionFolderExplorer(_applicationObject); handled = true; return; } else if (commandName == "ZAssist.Connect.OpenSolutionFolderCmd") { ZAssistManager.OpenSolutionFolderCmd(_applicationObject); handled = true; return; } else if (commandName == "ZAssist.Connect.OpenFileInSolution") { ZAssistManager.OpenFileInSolution(_applicationObject); handled = true; return; } else if (commandName == "ZAssist.Connect.QuickFindFunction") { ZAssistManager.QuickFindFunction(_applicationObject); handled = true; return; } else { System.Diagnostics.Debug.Assert(false); } } } catch (Exception ex) { System.Diagnostics.Debug.Print("ZAssist : Exception ocuured!!! : " + ex.Message); System.Diagnostics.Debug.Assert(false, ex.Message); System.Diagnostics.Debug.Print(ex.Message); } }