private IntegrationTestServiceCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            _package = package;

            var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var startServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStartIntegrationTestService);
                _startServiceMenuCmd = new MenuCommand(StartServiceCallback, startServiceMenuCmdId) {
                    Enabled = true,
                    Supported = true,
                    Visible = true
                };
                commandService.AddCommand(_startServiceMenuCmd);

                var stopServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStopIntegrationTestService);
                _stopServiceMenuCmd = new MenuCommand(StopServiceCallback, stopServiceMenuCmdId) {
                    Enabled = false,
                    Supported = true,
                    Visible = false
                };
                commandService.AddCommand(_stopServiceMenuCmd);
            }

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocatorWindowCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private LocatorWindowCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            _locatorWindow = package.FindToolWindow(typeof(LocatorWindow), 0, true) as LocatorWindow;
            if ((null == _locatorWindow) || (null == _locatorWindow.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            _locator = new Locator();
            _solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            _solution.AdviseSolutionEvents(_locator, out _cookie);
            _locatorWindow.SetLocator(_locator);
            _locator.StartWorkerThread();
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AliaserCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private AliaserCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;
            this.MainService = new AliaserService();

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                CommandID menuToAliasCommandID = new CommandID(MenuGroup, ALIASER_TO_ALIAS_COMMAND_ID);
                CommandID menuToInstanceCommandID = new CommandID(MenuGroup, ALIASER_TO_INSTANCE_COMMAND_ID);

                EventHandler transformAliasToInstace = this.TransformAliasToInstace;
                EventHandler transformInstaceToAlias = this.TransformInstaceToAlias;

                MenuCommand menuItemToInstace = new MenuCommand(transformAliasToInstace, menuToInstanceCommandID);
                MenuCommand menuItemToAlias = new MenuCommand(transformInstaceToAlias, menuToAliasCommandID);

                commandService.AddCommand(menuItemToInstace);
                commandService.AddCommand(menuItemToAlias);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PoorMansTSqlFormatterCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private PoorMansTSqlFormatterCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                _applicationObject = Package.GetGlobalService(typeof(DTE)) as DTE;
                _formattingManager = PoorMansTSqlFormatterPluginShared.Utils.GetFormattingManager(Properties.Settings.Default);
                //Command cmd = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
                //cmd.Bindings = "Text Editor::Ctrl+Shift+D";

                var menuFormatCommandID = new CommandID(CommandSet, FormatCommandId);
                var menuFormatItem = new MenuCommand(this.MenuFormatCallback, menuFormatCommandID);
                commandService.AddCommand(menuFormatItem);

                var menuOptionsCommandID = new CommandID(CommandSet, OptionsCommandId);
                var menuOptionsItem = new MenuCommand(this.MenuOptionsCallback, menuOptionsCommandID);
                commandService.AddCommand(menuOptionsItem);

                _formatCommand = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
                SetFormatHotkey();

            }
        }
		private AddInheritDocCommand(Package package)
		{
			this.package = package;

			OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
			if (commandService != null)
			{
				var menuCommandId = new CommandID(CommandSet, CommandId);
				var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
				commandService.AddCommand(menuItem);

				menuItem.BeforeQueryStatus += (sender, e) =>
					{
						bool visible = false;
						var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
						var classElem = SearchService.FindClass(dte);
						if (classElem != null)
						{
							List<CodeElement> codeElements = SearchService.FindCodeElements(dte);
							if (classElem.ImplementedInterfaces.Count > 0)
							{
								visible = true;
							}
							else
							{
								visible = codeElements.Any(elem => elem.IsInherited() || elem.OverridesSomething());
							}
						}
						((OleMenuCommand)sender).Visible = visible;
					};
			}
		}
Example #6
0
        private OptionsCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            _package = package;
            OleMenuCommandService commandService = ServiceProvider.GetService(
                typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService == null)
            {
                throw new ArgumentNullException("OleMenuCommandService");
            }

            {
                // Set up hook for context menu.
                CommandID menuCommandID = new CommandID(new Guid(LspAntlr.Constants.guidMenuAndCommandsCmdSet), 0x7007);
                _menu_item1 = new MenuCommand(MenuItemCallback, menuCommandID)
                {
                    Enabled = true,
                    Visible = true
                };
                commandService.AddCommand(_menu_item1);
            }
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
            : base(null)
        {
            this.Caption = "AskTheCode: Control Panel";

            var dte2             = ShellPackageAlias.GetGlobalService(typeof(SDTE)) as EnvDTE80.DTE2;
            var highlightService = ShellPackageAlias.GetGlobalService(typeof(SHighlightService)) as IHighlightService;
            var componentModel   = ShellPackageAlias.GetGlobalService(typeof(SComponentModel)) as IComponentModel;

            // TODO: Avoid throwing InvalidCastException if the user has the LanguageServices library of version 1.1.0.0
            // (It corresponds to Visual Studio Update 1)
            var workspace = componentModel?.GetService <VisualStudioWorkspace>();

            Contract.Assert(dte2 != null);
            Contract.Assert(highlightService != null);
            Contract.Assert(workspace != null);

            var ideServices = new VisualStudioIdeServices(dte2, highlightService, workspace);

            this.ViewModel = new ToolView(ideServices);

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            this.Content = new ToolPanel()
            {
                DataContext = this.ViewModel
            };
        }
Example #8
0
 public Factory(Package package)
     : base()
 {
     this.package = package;
     var solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
     ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
 }
        private CommandWithArguments(Package package)
        {
            if (package == null)
             {
            throw new ArgumentNullException("package");
             }

             this.package = package;

             OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
             if (commandService != null)
             {
            var menuCommandID = new CommandID(CommandSet, CommandId);

            // Step 1: Add the <CommandFlag>AllowParams</CommandFlag> in the .vsct file for the command

            // Step 2: Use an OleMenuCommand, not a MenuCommand
            var oleMenuCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);

            // Step 3: Initialize the ParametersDescription property to the "$" value.
            // That magical value means that the command accepts any kind of values
            oleMenuCommand.ParametersDescription = "$";

            commandService.AddCommand(oleMenuCommand);
             }
        }
Example #10
0
        private AboutCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            _package = package;
            OleMenuCommandService commandService = this.ServiceProvider.GetService(
                typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService == null)
            {
                throw new ArgumentNullException("OleMenuCommandService");
            }

            {
                // Set up hook for context menu.
                var menuCommandID = new CommandID(new Guid(AntlrVSIX.Constants.guidVSPackageCommandCodeWindowContextMenuCmdSet), 0x7010);
                _menu_item1         = new MenuCommand(this.MenuItemCallback, menuCommandID);
                _menu_item1.Enabled = true;
                _menu_item1.Visible = true;
                commandService.AddCommand(_menu_item1);
            }
            {
                // Set up hook for context menu.
                var menuCommandID = new CommandID(new Guid(AntlrVSIX.Constants.guidMenuAndCommandsCmdSet), 0x7010);
                _menu_item2         = new MenuCommand(this.MenuItemCallback, menuCommandID);
                _menu_item2.Enabled = true;
                _menu_item2.Visible = true;
                commandService.AddCommand(_menu_item2);
            }
        }
Example #11
0
        /// <summary>
        /// Open a URL within Visual Studio using the <see cref="IVsWebBrowsingService"/> service
        /// </summary>
        /// <param name="url">The URL to display</param>
        public static void OpenUrl(string url)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            bool useExternalBrowser = false;

            if (String.IsNullOrEmpty(url))
            {
                return;
            }

            var options = SandcastleBuilderPackage.Instance.GeneralOptions;

            if (options != null)
            {
                useExternalBrowser = options.UseExternalWebBrowser;
            }

            if (!useExternalBrowser && MsVsShellPackage.GetGlobalService(typeof(SVsWebBrowsingService)) is IVsWebBrowsingService webBrowsingService)
            {
                ErrorHandler.ThrowOnFailure(webBrowsingService.Navigate(url, 0, out IVsWindowFrame frame));

                if (frame != null)
                {
                    frame.Show();
                }
            }
            else
            {
                System.Diagnostics.Process.Start(url);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildStartProject"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private BuildStartProject(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            // Add a menu item.
            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            // Register as an advisory interface.
            var solutionService = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (solutionService != null)
            {
                solutionService.AdviseSolutionEvents(this, out m_EventSinkCookie);
            }
        }
Example #13
0
        private void Init()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            dte = Package.GetGlobalService(typeof(DTE)) as DTE2;

            if (dte != null)
            {
                events = dte.Events as Events2;
                if (events != null)
                {
                    dteEvents                  = events.DTEEvents;
                    solutionEvents             = events.SolutionEvents;
                    dteEvents.OnBeginShutdown += ShutDown;
                    solutionEvents.Opened     += () => SwitchStartupDir("\n====== Solution opening Detected ======\n");
                }
            }

            terminalController.SetShell(OptionMgr.Shell);

            bool createSuccess = terminalController.Init(GetProjectPath());

            if (!createSuccess)
            {
                VsShellUtilities.ShowMessageBox(
                    ServiceProvider.GlobalProvider,
                    "Can not create console process, check your configuration and reopen this window",
                    "Can not create process",
                    OLEMSGICON.OLEMSGICON_CRITICAL,
                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            terminalController.InvokeCmd("\n[Global Init Script ...]\n", OptionMgr.GetGlobalScript());
        }
Example #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializeThisCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="serializerFactory"></param>
        /// <param name="outputHandlers"></param>
        private SerializeThisCommand(Microsoft.VisualStudio.Shell.Package package, ISerializerFactory serializerFactory, IEnumerable <IOutputHandler> outputHandlers)
        {
            _outputHandlers    = outputHandlers.OrderByDescending(o => o.Priority).ToArray();
            _serializerFactory = serializerFactory ?? throw new ArgumentNullException(nameof(serializerFactory));
            _package           = package ?? throw new ArgumentNullException(nameof(package));

            if (ServiceProvider.GetService(typeof(IMenuCommandService)) is IMenuCommandService commandService)
            {
                var menuCommandId = new CommandID(CommandSet, JsonCommandId);
                var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);

                menuCommandId = new CommandID(CommandSet, XmlCommandId);
                menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);

                menuCommandId = new CommandID(CommandSet, CSharpCommandId);
                menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);

                // TODO: let other plugins add their own menu item to this plugin's context menu.
            }

            InitializeOutputHandlers();
        }
Example #15
0
        public static void ProvideToolWindowCommand <TToolWindowPane>(VsPackage package, Guid menuGroup, int commandId)
            where TToolWindowPane : WpfToolWindowPane
        {
            EventHandler handler =
                (object sender, EventArgs e) =>
            {
                try
                {
                    ToolWindowPane pane = package.FindToolWindow(typeof(TToolWindowPane), 0, true);
                    if (pane != null)
                    {
                        ErrorHandler.ThrowOnFailure(((IVsWindowFrame)pane.Frame).Show());
                    }
                }
                catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
                {
                }
            };

            OleMenuCommandService commandService = (OleMenuCommandService)((IServiceProvider)package).GetService(typeof(IMenuCommandService));

            if (commandService != null)
            {
                CommandID   toolWindowCommandId = new CommandID(menuGroup, commandId);
                MenuCommand command             = new MenuCommand(handler, toolWindowCommandId);
                commandService.AddCommand(command);
            }
        }
 public PasteCommandHandler(IVsTextView adapter, ITextView textView, DTE2 dte)
 {
     _textView = textView;
     _dte = dte;
     adapter.AddCommandFilter(this, out _nextCommandTarget);
     this.package = package;
 }
        protected override void Initialize()
        {
            _dte = GetService(typeof(DTE)) as DTE2;
            Package = this;

            Telemetry.SetDeviceName(_dte.Edition);
            Logger.Initialize(this, Constants.VSIX_NAME);

            Events2 events = (Events2)_dte.Events;
            _solutionEvents = events.SolutionEvents;
            _solutionEvents.AfterClosing += () => { TableDataSource.Instance.CleanAllErrors(); };
            _solutionEvents.ProjectRemoved += (project) => { TableDataSource.Instance.CleanAllErrors(); };

            _buildEvents = events.BuildEvents;
            _buildEvents.OnBuildBegin += OnBuildBegin;

            CreateConfig.Initialize(this);
            Recompile.Initialize(this);
            CompileOnBuild.Initialize(this);
            RemoveConfig.Initialize(this);
            CompileAllFiles.Initialize(this);
            CleanOutputFiles.Initialize(this);

            base.Initialize();
        }
Example #18
0
        /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="TextTipData.TextTipData"]/*' />
        public TextTipData(IServiceProvider site)
        {
            if (site == null)
            {
                throw new System.ArgumentNullException("site");
            }

            //this.textView = view;
            // Create our method tip window (through the local registry)
            Type t    = typeof(IVsTextTipWindow);
            Guid riid = t.GUID;

            Guid clsid = typeof(VsTextTipWindowClass).GUID;

            Microsoft.VisualStudio.Shell.Package pkg = (Microsoft.VisualStudio.Shell.Package)site.GetService(typeof(Microsoft.VisualStudio.Shell.Package));
            if (pkg == null)
            {
                throw new NullReferenceException(typeof(Microsoft.VisualStudio.Shell.Package).FullName);
            }
            this.textTipWindow = (IVsTextTipWindow)pkg.CreateInstance(ref clsid, ref riid, t);
            if (this.textTipWindow == null)
            {
                NativeHelpers.RaiseComError(NativeMethods.E_FAIL);
            }

            NativeMethods.ThrowOnFailure(textTipWindow.SetTextTipData(this));
        }
Example #19
0
		public EditorFactory(Package package, IComponentContext context)
		{
			Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this));

			this.editorPackage = package;
			this.context = context;
		}
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
    {
        EnvDTE.TextSelection ts = DTE.ActiveWindow.Selection as EnvDTE.TextSelection;
        if (ts == null)
        {
            throw new Exception("No Selection");
        }

        EnvDTE.CodeParameter codeParam = ts.ActivePoint.CodeElement[vsCMElement.vsCMElementParameter] as EnvDTE.CodeParameter;
        if (codeParam == null)
        {
            throw new Exception("Not Parameter");
        }

        System.Type tClass     = GetTypeByName(DTE, package, codeParam.Type.AsFullName);
        string      properties = System.Environment.NewLine;

        foreach (var p in tClass.GetProperties())
        {
            properties += codeParam.Name + "." + p.Name + System.Environment.NewLine;
        }

        // Move into the method and dump the properties there
        ts.FindText("{");
        ts.Insert("{" + properties);
    }
Example #21
0
        }                                                                         // Convinient accessor to data.

        #endregion Members

        #region Initialize

        /// <summary>
        ///
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static void Initialize(Microsoft.VisualStudio.Shell.Package package)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (package == null)
            {
                return;
            }

            if (Package != null)
            {
                return; // Protection against double initialization (double subscription to events, double menus etc)
            }
            Package = package;
            Dte     = ServiceProvider.GetService(typeof(DTE)) as EnvDTE80.DTE2;
            Assumes.Present(Dte);

            var svc = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;

            Assumes.Present(svc);

            SolutionEvents = new ParallelBuildsMonitor.Events.SolutionEvents();

            svc.AdviseSolutionEvents(SolutionEvents, out _);

            var svb = ServiceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;

            Assumes.Present(svb);

            BuildEvents = new ParallelBuildsMonitor.Events.BuildEvents();
            svb.AdviseUpdateSolutionEvents(BuildEvents, out _);

            CreateMenu();
        }
        protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package)
        {
            this.package = package;
            this.site    = package;

            // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
            this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site);
        }
Example #23
0
        protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package)
        {
            this.package = package;
            this.site = package;

            // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
            this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site);
        }
        private SolutionEventsListener(Package package)
        {
            if (package == null)
                throw new ArgumentNullException(nameof(package));

            this.package = package;

        }
 public BooLangProjectFactory(Package package)
     : base(package)
 {
     string booBinPath = (string)Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0Exp\Configuration\Packages\{55663be2-a969-4279-82c5-a6f27936f4f7}").GetValue("BooBinPath");
     this.package = (ProjectPackage)package;
     this.BuildEngine.GlobalProperties["BoocToolPath"] = new BuildProperty("BoocToolPath", booBinPath);
     this.BuildEngine.GlobalProperties["BooBinPath"] = new BuildProperty("BooBinPath",booBinPath);
 }
        public DexterFileAnalysisCommand(Package package, int commandId, Guid commandSet, ConfigurationProvider configurationProvider)
            : base(package, commandId, commandSet, configurationProvider)
        {
            WindowEvents events = ((Events2)Dte.Events).WindowEvents;

            events.WindowActivated += OnDocumentWindowActivated;
            events.WindowClosing += OnDocumentWindowClosed;
        }
 public VisualStudioConnection(Package package)
 {
     _package = package;
     _dte = (DTE2)Package.GetGlobalService(typeof(DTE));
     _solutionEvents = ((Events2)_dte.Events).SolutionEvents;
     _buildEvents = ((Events2)_dte.Events).BuildEvents;
     _subject = new Subject<EventType>();
 }
        /// <summary>
        ///   Initializes a new instance of the <see cref = "ClojureProjectNode" /> class.
        /// </summary>
        /// <param name = "package">Value of the project package for initialize internal package field.</param>
        public ClojureProjectNode(Package package)
        {
            this.package = package;

            InitializeImageList();

            CanProjectDeleteItems = true;
        }
 public AttachToAnythingController(Package package, DTE dte, AttachTargetOptionPage options, ProcessWaitSource waitSource, IDiagnosticLogger logger)
 {
     _package = package;
     _dte = dte;
     _options = options;
     _waitSource = waitSource;
     _logger = logger;
 }
Example #30
0
        protected ProjectFactory(Package package)
        {
            Package = package;
            Site = package;

            // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
            buildEngine = Utilities.InitializeMsBuildEngine(buildEngine, Site);
        }
Example #31
0
 public MenuCommandController(Package package)
 {
     _package = package;
     _statusController = new StatusController
                            {
                                StatusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar,
                                OutputWindow = _package.GetOutputPane(VSConstants.GUID_OutWindowGeneralPane, "Lonestar"),
                            };
 }
        public SQLanguageServiceEX(Microsoft.VisualStudio.Shell.Package sp)
        {
            Trace.WriteLine(
                "Constructing a new instance of SQLanguangeService");
            oleserviceProvider = sp;
            _serviceProvider   = sp;

            _errorHandler = new VSQNErrorHandler(sp);
        }
Example #33
0
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
    {
        string className = Microsoft.VisualBasic.Interaction.InputBox("Class name", "Create tests",
                                                                      "VATRate", -1, -1);

        EnvDTE.ProjectItem f = DTE.ItemOperations.AddNewItem("Visual C# Items\\Code\\Class", className + "RepositoryTests.cs");
        EnvDTE.CodeClass   c = FirstClass(FirstNamespace(f.FileCodeModel.CodeElements).Children);
        c.AddFunction("Insert" + className, vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefVoid);
    }
        EnableReloadCommand(Package package, OleMenuCommandService commandService)
        {
            _package = package;

            var id = new CommandID(PackageGuids.guidBrowserReloadCmdSet, PackageIds.EnableReloadCommandId);
            var cmd = new OleMenuCommand(Execute, id);
            cmd.BeforeQueryStatus += BeforeQueryStatus;
            commandService.AddCommand(cmd);
        }
        protected AbstractEditorFactory(Package package)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));
            _componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel));

            _editorAdaptersFactoryService = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
            _contentTypeRegistryService = _componentModel.GetService<IContentTypeRegistryService>();
            _waitIndicator = _componentModel.GetService<IWaitIndicator>();
        }
Example #36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionManager"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private SolutionManager(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this._package = package;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DexterAnalysisCommand"/> class.
 /// Adds our command handlers for menu (commands must exist in the command table file)
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 /// <param name="commandId">Command ID.</param>
 /// <param name="commandSet">Command menu group (command set GUID).</param>
 public DexterAnalysisCommand(Package package, int commandId, Guid commandSet, ConfigurationProvider configurationProvider)
     : base(package,commandId,commandSet)
 {
     AutoEnabled = true;
     dexterInfoValidator = new DexterInfoValidator();
     projectInfoValidator = new ProjectInfoValidator();
     ConfigurationProvider = configurationProvider;
     Refresh();
 }
        public static void Initialize(Package package)
        {
            if (Instance != null)
                Instance.Dispose(false);

            Instance = new SolutionEventsListener(package);

            Instance.AdivseSolutionUpdates();
        }
        private ResetConfigFilesCommand(Package package)
        {
            _package = package;

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            var menuCommandID = new CommandID(PackageGuids.ConfigFileCmdSet, PackageIds.ResetConfigFiles);
            var menuItem = new OleMenuCommand(ResetConfigurationFiles, menuCommandID);
            commandService.AddCommand(menuItem);
        }
Example #40
0
 public static void Initialize(Package package)
 {
     Instance = new MainWindowCommand(package);
     ToolWindowPane window = package.FindToolWindow(typeof(MainWindow), 0, true);
     if ((null == window) || (null == window.Frame))
     {
         throw new NotSupportedException("Cannot create tool window");
     }
     ((MainWindow)window).Initialize(((MainWindowPackage)package).Options);
 }
Example #41
0
        protected override void Initialize()
        {
            Dte = GetService(typeof(DTE)) as DTE2;
            Dispatcher = Dispatcher.CurrentDispatcher;
            Package = this;

            Logger.Initialize(this, Constants.VSIX_NAME);

            base.Initialize();
        }
Example #42
0
        public VsUIServices(ICoreShell coreShell)
        {
            ProgressDialog = new VsProgressDialog(coreShell.Services);
            FileDialog     = new VsFileDialog(coreShell);

            _coreShell = coreShell;
            _vsShell   = VsPackage.GetGlobalService(typeof(SVsShell)) as IVsShell;
            _vsShell.AdviseBroadcastMessages(this, out _vsShellBroadcastEventsCookie);
            _uiShell = VsPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;
        }
Example #43
0
        /// <summary>
        /// Retrieves Visual Studio global service from global VS service provider.
        /// This method is not thread safe and should not be called from async methods.
        /// </summary>
        /// <typeparam name="T">Service interface type such as IVsUiShell</typeparam>
        /// <param name="type">Service type if different from T, such as typeof(SVSUiShell)</param>
        /// <returns>Service instance of null if not found.</returns>
        public T GetGlobalService <T>(Type type = null) where T : class
        {
            this.AssertIsOnMainThread();
            if (IsUnitTestEnvironment)
            {
                System.IServiceProvider sp = RPackage.Current;
                return(sp.GetService(type ?? typeof(T)) as T);
            }

            return(VsPackage.GetGlobalService(type ?? typeof(T)) as T);
        }
        public ToolchainHelper(Package package)
        {
            if (package == null)
                throw new ArgumentNullException(nameof(package));

            this.package = package;
            this.listener = SolutionEventsListener.Instance;

            listener.BuildStartedEvent += Listener_BuildStartedEvent;
            listener.BuildFinishedEvent += Listener_BuildFinishedEvent;
        }
Example #45
0
        public WpfToolWindowPane()
            : base(null)
        {
            GlobalServiceProvider = (IServiceProvider)VsPackage.GetGlobalService(typeof(IServiceProvider));
            if (GlobalServiceProvider == null)
            {
                GlobalServiceProvider = new ServiceProvider((IOleServiceProvider)VsPackage.GetGlobalService(typeof(IOleServiceProvider)));
            }

            this._toolWindowControl = CreateToolWindowControl();
        }
        GraphProviderCommand(Package package)
        {
            ServiceProvider = _package = package;

            var service = (OleMenuCommandService)ServiceProvider.GetService(typeof(IMenuCommandService));

            var cmdId = new CommandID(PackageGuids.guidToggleFeaturesCmdSet, PackageIds.ToggleGraphProvider);
            var button = new OleMenuCommand(ToggleFeature, cmdId);
            button.BeforeQueryStatus += BeforeQueryStatus;
            service.AddCommand(button);
        }
Example #47
0
        private void Initialize()
        {
            _vsShell = (IVsShell)VsPackage.GetGlobalService(typeof(SVsShell));
            VsWpfOverrides.Apply();

            var oleCm = (IOleComponentManager)VsPackage.GetGlobalService(typeof(SOleComponentManager));

            ConfigureIdleSource(oleCm);

            ConfigurePackageServices();
            CheckVsStarted();
        }
Example #48
0
        public FSharpEditorFactory(ShellPackage parentPackage)
        {
            if (parentPackage == null)
            {
                throw new ArgumentNullException(nameof(parentPackage));
            }

            _parentPackage  = parentPackage;
            _componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel));
            _editorAdaptersFactoryService = _componentModel.GetService <IVsEditorAdaptersFactoryService>();
            _contentTypeRegistryService   = _componentModel.GetService <IContentTypeRegistryService>();
        }
Example #49
0
        public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
        {
            EnvDTE.TextSelection ts = DTE.ActiveWindow.Selection as EnvDTE.TextSelection;
            if (ts == null)
            {
                return;
            }
            var codeClass = ts.ActivePoint.CodeElement[vsCMElement.vsCMElementClass]
                            as EnvDTE.CodeClass;

            if (codeClass == null)
            {
                return;
            }
            EnvDTE.Project project   = DTE.ActiveWindow.Project;
            var            resolutor = GetResolutionService(project, Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
            var            a         = project.
                                       var type = resolutor.GetType(codeClass.FullName, true);
            var bases    = new List <Type>();
            var baseType = type.BaseType;

            while (baseType != typeof(object) && baseType != null)
            {
                bases.Add(baseType);
                baseType = baseType.BaseType;
            }
            bases.Insert(0, type);

            var fields_list = new List <PropertyInfo>();

            foreach (var type_base in bases)
            {
                var tmp = type_base.GetProperties(
                    BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Default | BindingFlags.Instance);
                foreach (var fieldInfo in tmp)
                {
                    fields_list.Add(fieldInfo);
                }
            }
            var text = "//numero di fields = ' " + fields_list.Count + " '" + System.Environment.NewLine;

            foreach (var fieldInfo in fields_list)
            {
                if (text.Contains("public " + fieldInfo.PropertyType + " " + fieldInfo.Name + ";"))
                {
                    continue;
                }
                text += "public " + fieldInfo.PropertyType + " " + fieldInfo.Name + ";" + System.Environment.NewLine + System.Environment.NewLine;
            }
            text = text.Replace("+", ".");
            System.Windows.Clipboard.SetText(text);
        }
Example #50
0
        //=====================================================================

        /// <summary>
        /// Get a service from the Sandcastle Help File Builder package
        /// </summary>
        /// <param name="throwOnError">True to throw an exception if the service cannot be obtained,
        /// false to return null.</param>
        /// <typeparam name="TInterface">The interface to obtain</typeparam>
        /// <typeparam name="TService">The service used to get the interface</typeparam>
        /// <returns>The service or null if it could not be obtained</returns>
        public static TInterface GetServiceFromPackage <TInterface, TService>(bool throwOnError)
            where TInterface : class
            where TService : class
        {
            TInterface service = MsVsShellPackage.GetGlobalService(typeof(TService)) as TInterface;

            if (service == null && throwOnError)
            {
                throw new InvalidOperationException("Unable to obtain service of type " + typeof(TService).Name);
            }

            return(service);
        }
Example #51
0
        CopyRefCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            this.package = package;

            var commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.OnMenuInvoked, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
Example #52
0
        private static VsAppShell GetInstance()
        {
            if (_instance != null)
            {
                return(_instance);
            }

            ThreadHelper.ThrowIfNotOnUIThread();

            var componentModel = (IComponentModel)VsPackage.GetGlobalService(typeof(SComponentModel));
            var instance       = (VsAppShell)componentModel.DefaultExportProvider.GetExportedValue <ICoreShell>();

            return(Interlocked.CompareExchange(ref _instance, instance, null) ?? instance);
        }
Example #53
0
        public static IVsPackage EnsurePackageLoaded(Guid guidPackage)
        {
            var        shell = (IVsShell)VsPackage.GetGlobalService(typeof(IVsShell));
            var        guid  = guidPackage;
            IVsPackage package;
            int        hr = ErrorHandler.ThrowOnFailure(shell.IsPackageLoaded(ref guid, out package), VSConstants.E_FAIL);

            guid = guidPackage;
            if (hr != VSConstants.S_OK)
            {
                ErrorHandler.ThrowOnFailure(shell.LoadPackage(ref guid, out package), VSConstants.E_FAIL);
            }
            return(package);
        }
        private Command1(Microsoft.VisualStudio.Shell.Package package)
        {
            this.package = package ?? throw new ArgumentNullException("package");
            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new OleMenuCommand(MenuItemCallback, menuCommandID);
                menuItem.BeforeQueryStatus += MenuItem_BeforeQueryStatus;
                menuItem.Visible            = false;
                commandService.AddCommand(menuItem);
            }
        }
Example #55
0
        private static VsAppShell GetInstance()
        {
            if (_instance != null)
            {
                return(_instance);
            }

            var componentModel = (IComponentModel)VsPackage.GetGlobalService(typeof(SComponentModel));
            var instance       = (VsAppShell)componentModel.DefaultExportProvider.GetExportedValue <IApplicationShell>();

            instance.CompositionService = componentModel.DefaultCompositionService;
            instance.ExportProvider     = componentModel.DefaultExportProvider;
            return(Interlocked.CompareExchange(ref _instance, instance, null) ?? instance);
        }
    private System.Type GetTypeByName(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package, string name)
    {
        System.IServiceProvider serviceProvider = package as System.IServiceProvider;
        Microsoft.VisualStudio.Shell.Design.DynamicTypeService typeService =
            serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Design.DynamicTypeService)) as
            Microsoft.VisualStudio.Shell.Design.DynamicTypeService;

        Microsoft.VisualStudio.Shell.Interop.IVsSolution sln = serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.IVsSolution)) as
                                                               Microsoft.VisualStudio.Shell.Interop.IVsSolution;

        Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hier;
        sln.GetProjectOfUniqueName(DTE.ActiveDocument.ProjectItem.ContainingProject.UniqueName, out hier);

        return(typeService.GetTypeResolutionService(hier).GetType(name, true));
    }
Example #57
0
        private OptionsCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));
            OleMenuCommandService commandService = ((IServiceProvider)ServiceProvider).GetService(
                typeof(IMenuCommandService)) as OleMenuCommandService ?? throw new Exception("Command service not found.");

            {
                CommandID menuCommandID = new CommandID(new Guid(LspAntlr.Constants.guidMenuAndCommandsCmdSet), 0x7007);
                _menu_item1 = new MenuCommand(MenuItemCallback, menuCommandID)
                {
                    Enabled = true,
                    Visible = true
                };
                commandService.AddCommand(_menu_item1);
            }
        }
Example #58
0
 private void CheckVsStarted()
 {
     _vsShell = (IVsShell)VsPackage.GetGlobalService(typeof(SVsShell));
     _vsShell.GetProperty((int)__VSSPROPID4.VSSPROPID_ShellInitialized, out var value);
     if (value is bool)
     {
         if ((bool)value)
         {
             _application.FireStarted();
         }
         else
         {
             _vsShell.AdviseShellPropertyChanges(this, out _vsShellEventsCookie);
         }
     }
 }
Example #59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AddNuSpecCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private AddNuSpecCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
Example #60
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SetILPathCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private SetILPathCommand(Microsoft.VisualStudio.Shell.Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }