コード例 #1
0
        protected override void Initialize()
        {
            _instance   = this;
            _dte        = GetService(typeof(DTE)) as DTE2;
            _dispatcher = Dispatcher.CurrentDispatcher;
            Package     = this;
            Options     = (Options)GetDialogPage(typeof(Options));

            Logger.Initialize(this, Vsix.Name);

            Events2 events = _dte.Events as Events2;

            _solutionEvents = events.SolutionEvents;

            _solutionEvents.AfterClosing   += () => { ErrorList.CleanAllErrors(); };
            _solutionEvents.ProjectRemoved += (project) => { ErrorList.CleanAllErrors(); };

            CreateBundle.Initialize(this);
            UpdateBundle.Initialize(this);
            UpdateAllFiles.Initialize(this);
            BundleOnBuild.Initialize(this);
            RemoveBundle.Initialize(this);
            ClearOutputFiles.Initialize(this);
            ToggleProduceOutput.Initialize(this);
            OpenSettings.Initialize(this);
            ProjectEventCommand.Initialize(this);
            ConvertToGulp.Initialize(this);

            base.Initialize();
        }
コード例 #2
0
        public WebResourceList()
        {
            InitializeComponent();
            _dte = Package.GetGlobalService(typeof(DTE)) as DTE;
            if (_dte == null)
                return;

            _solution = _dte.Solution;
            if (_solution == null)
                return;

            _events = _dte.Events;
            var windowEvents = _events.WindowEvents;
            windowEvents.WindowActivated += WindowEventsOnWindowActivated;
            _solutionEvents = _events.SolutionEvents;
            _solutionEvents.BeforeClosing += BeforeSolutionClosing;
            _solutionEvents.Opened += SolutionOpened;
            _solutionEvents.ProjectAdded += SolutionProjectAdded;
            _solutionEvents.ProjectRemoved += SolutionProjectRemoved;
            _solutionEvents.ProjectRenamed += SolutionProjectRenamed;
            _events2 = (Events2)_dte.Events;
            _projectItemsEvents = _events2.ProjectItemsEvents;
            _projectItemsEvents.ItemAdded += ProjectItemAdded;
            _projectItemsEvents.ItemRemoved += ProjectItemRemoved;
            _projectItemsEvents.ItemRenamed += ProjectItemRenamed;
        }
コード例 #3
0
ファイル: Connect.cs プロジェクト: MartinF/Dynamo.AutoTT
		/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
		/// <param term='application'>Root object of the host application.</param>
		/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
		/// <param term='addInInst'>Object representing this Add-in.</param>
		/// <seealso class='IDTExtensibility2' />
		public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
		{
			_application = (DTE2)application;
			_addInInstance = (AddIn)addInInst;

			// Core
			var name = _addInInstance.Name;
			var outputPane = _application.ToolWindows.OutputWindow.OutputWindowPanes.GetPane(name);
			var feedback = new FeedbackManager(name, outputPane);
			_core = new Core(feedback);

			// Events
			_events = (Events2)_application.Events;
			_projectsEvents = _events.ProjectsEvents;
			_projectItemsEvents = _events.ProjectItemsEvents;
			_documentEvents = _events.DocumentEvents;
			_buildEvents = _events.BuildEvents;
			
			AttachEvents();

			// If being connected when Solution is already loaded - try to load all projects
			if (_application.Solution != null)
			{
				_core.Load(_application.Solution);
			}
		}
コード例 #4
0
        // ------------------------------------------------------
        /// <summary>
        /// Unhooks the specified delegates from the code model event sink.
        /// </summary>
        /// <param name="elementAdded">
        /// A delegate that was previously registered to be called when an
        /// element is added to the code model.
        /// </param>
        /// <param name="elementChanged">
        /// A delegate that was previously registered to be called when an
        /// element changes in the code model.
        /// </param>
        /// <param name="elementDeleted">
        /// A delegate that was previously registered to be called when an
        /// element is deleted from the code model.
        /// </param>
        public void UnadviseCodeModelEvents(
            _dispCodeModelEvents_ElementAddedEventHandler elementAdded,
            _dispCodeModelEvents_ElementChangedEventHandler elementChanged,
            _dispCodeModelEvents_ElementDeletedEventHandler elementDeleted)
        {
            // This might be called as a consequence of closing the IDE, in
            // which case this would fail, so wrap it in a try/catch.

            try
            {
                DTE             dte      = (DTE)GetService(typeof(DTE));
                Events2         events   = (Events2)((DTE2)dte).Events;
                CodeModelEvents cmEvents = events.get_CodeModelEvents(null);

                if (cmEvents != null)
                {
                    if (elementAdded != null)
                    {
                        cmEvents.ElementAdded -= elementAdded;
                    }

                    if (elementChanged != null)
                    {
                        cmEvents.ElementChanged -= elementChanged;
                    }

                    if (elementDeleted != null)
                    {
                        cmEvents.ElementDeleted -= elementDeleted;
                    }
                }
            }
            catch (Exception) { }
        }
コード例 #5
0
        public async Task <MakeTheSoundEventCatcher> InitAsync(AsyncPackage package, OptionsPage optionsPage)
        {
            if (_package != null)
            {
                return(this);
            }

            OptionsPage = optionsPage;

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _package = package;

            _dte = (DTE2)await _package.GetServiceAsync(typeof(DTE));

            Assumes.Present(_dte);

            _events         = _dte.Events as Events2;
            _buildEvents    = _events.BuildEvents;
            _commands       = _dte.Commands;
            _debuggerEvents = _events.DebuggerEvents;

            await AddActionAsync(IDEEventType.FileSaveAll);
            await AddActionAsync(IDEEventType.FileSave);
            await AddActionAsync(IDEEventType.Building);
            await AddActionAsync(IDEEventType.Breakepoint);
            await AddActionAsync(IDEEventType.Exception);

            return(this);
        }
コード例 #6
0
        protected override void Initialize()
        {
            _dte        = GetService(typeof(DTE)) as DTE2;
            _dispatcher = Dispatcher.CurrentDispatcher;
            Package     = this;
            Options     = (Options)GetDialogPage(typeof(Options));

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

            Events2 events = _dte.Events as Events2;

            _solutionEvents = events.SolutionEvents;

            _solutionEvents.AfterClosing   += () => { ErrorList.CleanAllErrors(); };
            _solutionEvents.ProjectRemoved += (project) => { ErrorList.CleanAllErrors(); };

            CreateBundle.Initialize(this);
            UpdateBundle.Initialize(this);
            UpdateAllFiles.Initialize(this);
            BundleOnBuild.Initialize(this);
            RemoveBundle.Initialize(this);

            base.Initialize();
        }
コード例 #7
0
        void VsShellPropertyEvents_AfterShellPropertyChanged(object sender, VsShellPropertyEventsHandler.ShellPropertyChangeEventArgs e)
        {
            SafeExecute(() =>
            {
                // when zombie state changes to false, finish package initialization
                //! DO NOT USE CODE WHICH MAY EXECUTE FOR LONG TIME HERE

                if ((int)__VSSPROPID.VSSPROPID_Zombie == e.PropId)
                {
                    if ((bool)e.Var == false)
                    {
                        var dte2 = ServiceProvider.GetDte2();

                        Events          = dte2.Events as Events2;
                        DTEEvents       = Events.DTEEvents;
                        SolutionEvents  = Events.SolutionEvents;
                        DocumentEvents  = Events.DocumentEvents;
                        WindowEvents    = Events.WindowEvents;
                        DebuggerEvents  = Events.DebuggerEvents;
                        CommandEvents   = Events.CommandEvents;
                        SelectionEvents = Events.SelectionEvents;

                        DelayedInitialise();
                    }
                }
            });
        }
コード例 #8
0
        public WebResourceList()
        {
            InitializeComponent();
            _dte = Package.GetGlobalService(typeof(DTE)) as DTE;
            if (_dte == null)
            {
                return;
            }

            _solution = _dte.Solution;
            if (_solution == null)
            {
                return;
            }

            _events = _dte.Events;
            var windowEvents = _events.WindowEvents;

            windowEvents.WindowActivated += WindowEventsOnWindowActivated;
            _solutionEvents = _events.SolutionEvents;
            _solutionEvents.BeforeClosing  += BeforeSolutionClosing;
            _solutionEvents.Opened         += SolutionOpened;
            _solutionEvents.ProjectAdded   += SolutionProjectAdded;
            _solutionEvents.ProjectRemoved += SolutionProjectRemoved;
            _solutionEvents.ProjectRenamed += SolutionProjectRenamed;
            _events2                         = (Events2)_dte.Events;
            _projectItemsEvents              = _events2.ProjectItemsEvents;
            _projectItemsEvents.ItemAdded   += ProjectItemAdded;
            _projectItemsEvents.ItemRemoved += ProjectItemRemoved;
            _projectItemsEvents.ItemRenamed += ProjectItemRenamed;
        }
コード例 #9
0
        /// <summary>
        /// Initialize services available from Visual Studio.
        /// </summary>
        /// <param name="dte">Entry object of Visual Studio services.</param>
        public VisualStudioServices(DTE dte)
        {
            Log = new Log();

            _changeWait.Interval = new TimeSpan(0, 0, 1);
            _changeWait.Tick    += flushChanges;

            _solutionWait.Interval = new TimeSpan(0, 0, 1);
            _solutionWait.Tick    += solutionOpenedAfterWait;

            _dte = dte;
            if (_dte == null)
            {
                //create empty services
                return;
            }

            _events           = _dte.Events;
            _events2          = _dte.Events as Events2;
            _textEditorEvents = _events.TextEditorEvents;
            _solutionEvents   = _events.SolutionEvents;
            if (_events2 != null)
            {
                _projectItemEvents = _events2.ProjectItemsEvents;
            }

            _solutionItemEvents = _events.SolutionItemsEvents;
        }
コード例 #10
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _dte    = GetService(typeof(DTE)) as DTE2;
            Package = this;

            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);
        }
コード例 #11
0
        private void RegisterToDTEEvents()
        {
            docEvents.DocumentOpening += DocumentEvents_DocumentOpening;
            docEvents.DocumentSaved   += DocumentEvents_DocumentSaved;
            docEvents.DocumentClosing += DocEvents_DocumentClosing;

            buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
            buildEvents.OnBuildDone  += BuildEvents_OnBuildDone;

            ThreadHelper.ThrowIfNotOnUIThread();

            DTE dte = _package.GetServiceAsync(typeof(DTE)).ConfigureAwait(true).GetAwaiter().GetResult() as EnvDTE.DTE;


            Events2 events2 = dte.Events as Events2;

            if (events2 != null)
            {
                this.projectItemsEvents              = events2.ProjectItemsEvents;
                this.projectItemsEvents.ItemAdded   += ProjectItemsEvents_ItemAdded;
                this.projectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved;
                this.projectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
            }

            this.csharpProjectItemsEvents = dte.Events.GetObject("CSharpProjectItemsEvents") as EnvDTE.ProjectItemsEvents;
            if (this.csharpProjectItemsEvents != null)
            {
                this.csharpProjectItemsEvents.ItemAdded   += ProjectItemsEvents_ItemAdded;
                this.csharpProjectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved;
                this.csharpProjectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
            }
        }
コード例 #12
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            _dte = await GetServiceAsync(typeof(DTE)) as DTE2;

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _instance = this;

            _dispatcher = Dispatcher.CurrentDispatcher;
            Package     = this;
            Options     = (Options)GetDialogPage(typeof(Options));

            Logger.Initialize(this, Vsix.Name);

            Events2 events = _dte.Events as Events2;

            _solutionEvents = events.SolutionEvents;

            _solutionEvents.AfterClosing   += () => { ErrorList.CleanAllErrors(); };
            _solutionEvents.ProjectRemoved += (project) => { ErrorList.CleanAllErrors(); };

            CreateBundle.Initialize(this);
            UpdateBundle.Initialize(this);
            UpdateAllFiles.Initialize(this);
            BundleOnBuild.Initialize(this);
            RemoveBundle.Initialize(this);
            ClearOutputFiles.Initialize(this);
            ToggleProduceOutput.Initialize(this);
            OpenSettings.Initialize(this);
            ProjectEventCommand.Initialize(this);
            ConvertToGulp.Initialize(this);
        }
コード例 #13
0
        protected override void Initialize()
        {
            _dte    = GetService(typeof(DTE)) as DTE2;
            Package = this;

            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();
        }
コード例 #14
0
        public StepTaggerProvider()
        {
            if (_events2 != null)
            {
                return;
            }

            _events2            = GaugePackage.DTE.Events as Events2;
            _codeModelEvents    = _events2.CodeModelEvents;
            _projectItemsEvents = _events2.ProjectItemsEvents;
            _documentEvents     = _events2.DocumentEvents;

            _codeModelEvents.ElementAdded   += element => RefreshUsages();
            _codeModelEvents.ElementChanged += (element, change) => RefreshUsages();
            _codeModelEvents.ElementDeleted += (parent, element) => RefreshUsages();

            _projectItemsEvents.ItemAdded   += item => RefreshUsages();
            _projectItemsEvents.ItemRemoved += item => RefreshUsages();
            _projectItemsEvents.ItemRenamed += (item, name) => RefreshUsages();

            _documentEvents.DocumentSaved += document =>
            {
                if (document.IsGaugeConceptFile() || document.IsGaugeSpecFile())
                {
                    RefreshUsages();
                }
            };
        }
コード例 #15
0
        public async Task InitializeListenersAsync()
        {
            string MethodName = "InitializeListenersAsync";

            try
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                string PluginVersion = GetVersion();
                Logger.Info(string.Format("Initializing Code Time v{0}", PluginVersion));
                Logger.FileLog("Initializing Code Time", MethodName);

                _statusBarButton = new StatusBarButton();

                await this.InitializeUserInfoAsync();

                // VisualStudio Object
                Events2 events = (Events2)ObjDte.Events;
                _textDocKeyEvent = events.TextDocumentKeyPressEvents;
                _docEvents       = events.DocumentEvents;
                _solutionEvents  = events.SolutionEvents;

                // _solutionEvents.Opened += this.SolutionEventOpenedAsync;
                Task.Delay(3000).ContinueWith((task) =>
                {
                    SolutionEventOpenedAsync();
                });
            }
            catch (Exception ex)
            {
                Logger.Error("Error Initializing SoftwareCo", ex);
            }
        }
コード例 #16
0
ファイル: TddStud10Package.cs プロジェクト: tddstud10/VS
        protected override void Initialize()
        {
            base.Initialize();

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve;

            _solution = Services.GetService <SVsSolution, IVsSolution2>();
            if (_solution != null)
            {
                _solution.AdviseSolutionEvents(this, out solutionEventsCookie).ThrowOnFailure();
            }

            _dte         = Services.GetService <DTE>();
            _events      = (Events2)_dte.Events;
            _buildEvents = _events.BuildEvents;
            _buildEvents.OnBuildBegin += OnBuildBegin;
            _buildEvents.OnBuildDone  += OnBuildDone;
            new PackageCommands(this).AddCommands();

            IconHost = VsStatusBarIconHost.CreateAndInjectIntoVsStatusBar();

            Instance = this;

            TelemetryClient.Initialize(Constants.ProductVersion, _dte.Version, _dte.Edition);

            Logger.LogInfo("Initialized Package successfully.");
        }
コード例 #17
0
        // ------------------------------------------------------
        /// <summary>
        /// Hooks the specified delegates into the code model event sink.
        /// </summary>
        /// <param name="elementAdded">
        /// A delegate to be called when an element is added to the code
        /// model.
        /// </param>
        /// <param name="elementChanged">
        /// A delegate to be called when an element changes in the code model.
        /// </param>
        /// <param name="elementDeleted">
        /// A delegate to be called when an element is deleted from the code
        /// model.
        /// </param>
        public void AdviseCodeModelEvents(
            _dispCodeModelEvents_ElementAddedEventHandler elementAdded,
            _dispCodeModelEvents_ElementChangedEventHandler elementChanged,
            _dispCodeModelEvents_ElementDeletedEventHandler elementDeleted)
        {
            DTE             dte      = (DTE)GetService(typeof(DTE));
            Events2         events   = (Events2)((DTE2)dte).Events;
            CodeModelEvents cmEvents = events.get_CodeModelEvents(null);

            if (cmEvents != null)
            {
                if (elementAdded != null)
                {
                    cmEvents.ElementAdded += elementAdded;
                }

                if (elementChanged != null)
                {
                    cmEvents.ElementChanged += elementChanged;
                }

                if (elementDeleted != null)
                {
                    cmEvents.ElementDeleted += elementDeleted;
                }
            }
        }
コード例 #18
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());
        }
コード例 #19
0
ファイル: EventManager.cs プロジェクト: pjsatou/VSFileNav
        /// <summary>
        /// Attempts to retrieve the DTE;
        /// </summary>
        private DTE GetDTE()
        {
            DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;

            // If events haven't yet been wired up.
            if (dte != null)
            {
                this.solutionEvents                 = dte.Events.SolutionEvents;
                this.solutionEvents.Opened         += () => this.OnSolutionOpened();
                this.solutionEvents.ProjectAdded   += (p) => this.OnProjectAdded(p);
                this.solutionEvents.ProjectRemoved += (p) => this.OnProjectRemoved(p);
                this.solutionEvents.ProjectRenamed += (p, name) => this.OnProjectRenamed(p, name);

                // Obtain all the project events
                Events2 events2 = dte.Events as Events2;
                if (events2 != null)
                {
                    this.projectEvents = events2.ProjectItemsEvents;
                    HookupProjectItemsEventListeners(this.projectEvents);
                }
                this.cSharpProjectEvents = dte.Events.GetObject("CSharpProjectItemsEvents") as ProjectItemsEvents;
                this.vbProjectEvents     = dte.Events.GetObject("VBProjectItemsEvents") as ProjectItemsEvents;
                this.webProjectEvents    = dte.Events.GetObject("WebSiteItemsEvents") as ProjectItemsEvents;

                // Wire up events
                HookupProjectItemsEventListeners(this.projectEvents);
                HookupProjectItemsEventListeners(this.cSharpProjectEvents);
                HookupProjectItemsEventListeners(this.vbProjectEvents);
                HookupProjectItemsEventListeners(this.webProjectEvents);
            }

            return(dte);
        }
コード例 #20
0
        public ProjectChartPoints(string _projName)
        {
            data = CP.Utils.IClassFactory.GetInstance().CreateProjCPsData(_projName);
            DTE2    dte2 = (DTE2)Globals.dte;
            Events2 evs2 = (Events2)dte2.Events;

            cpCodeModel = new CP.Code.Model(data.projName, evs2);
        }
コード例 #21
0
        /// <summary>
        /// Gets the project item events.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns>The item events object.</returns>
        public static ProjectItemsEvents GetProjectItemEvents(this DTE2 instance)
        {
            TraceService.WriteLine("DTEExtensions::GetProjectItemEvents");

            Events2 events2 = instance.Events as Events2;

            return(events2 != null ? events2.ProjectItemsEvents : null);
        }
コード例 #22
0
        public ItemEventHandler(DTE2 applicationObject)
        {
            _applicationObject = applicationObject;

            Events2 events2 = _applicationObject.Events as Events2;

            _projectItemsEvents            = (ProjectItemsEvents)events2.ProjectItemsEvents;
            _projectItemsEvents.ItemAdded += new _dispProjectItemsEvents_ItemAddedEventHandler(ProjectItemsEvents_ItemAdded);
        }
コード例 #23
0
        protected override void Initialize()
        {
            base.Initialize();

            application   = (DTE2)GetService(typeof(DTE));
            events        = (Events2)application.Events;
            publishEvents = events.PublishEvents;

            publishEvents.OnPublishDone += PublishEvents_OnPublishDone;
        }
コード例 #24
0
ファイル: Connect.cs プロジェクト: zcxp/Wind.js-VS-Add-in
		/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
		/// <param term='application'>Root object of the host application.</param>
		/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
		/// <param term='addInInst'>Object representing this Add-in.</param>
		/// <seealso class='IDTExtensibility2' />
		public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
		{
			_applicationObject = (DTE2)application;
			_addInInstance = (AddIn)addInInst;

			this.instance = addInInst as AddIn;
			this.App = application as DTE2;
			this.events = this.App.Events as Events2;
			
		}
コード例 #25
0
 static void Setup(GridControl gridControl)
 {
     _gridControl = gridControl;
     _currentSynchronizationContext = TaskScheduler.FromCurrentSynchronizationContext();
     SetGridDataSource();
     _events = (Events2)DteExtensions.DTE.Events;
     _eventsSolutionEvents               = _events.SolutionEvents;
     _eventsSolutionEvents.Opened       += EventsSolutionEventsOnOpened;
     _eventsSolutionEvents.AfterClosing += EventsSolutionEventsOnAfterClosing;
 }
コード例 #26
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            applicationObject = (DTE2)application;
            _addInInstance    = (AddIn)addInInst;

            if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                object [] contextGUIDS  = new object[] { };
                Commands2 commands      = (Commands2)applicationObject.Commands;
                string    toolsMenuName = "Tools";

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)applicationObject.CommandBars)["MenuBar"];

                //Find the Tools command bar on the MenuBar command bar:
                CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarPopup   toolsPopup   = (CommandBarPopup)toolsControl;

                //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
                //  just make sure you also update the QueryStatus/Exec method to include the new command names.
                try
                {
                    //Add a command to the Commands collection:
                    Command command = commands.AddNamedCommand2(_addInInstance, "XnaLevelEditor", "XnaLevelEditor", "Executes the command for XnaLevelEditor", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

                    //Add a control for the command to the tools menu:
                    if ((command != null) && (toolsPopup != null))
                    {
                        command.AddControl(toolsPopup.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException)
                {
                    //If we are here, then the exception is probably because a command with that name
                    //  already exists. If so there is no need to recreate the command and we can
                    //  safely ignore the exception.
                }
            }
            else if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                windows2        = (Windows2)applicationObject.Windows;
                userControlType = typeof(MainUserControl);
                asm             = Assembly.GetAssembly(userControlType);

                mainUserControls = new Dictionary <Window, MainUserControl>();

                Events2 events = (Events2)applicationObject.Events;
                windowVisibilityEvents = events.get_WindowVisibilityEvents();
                windowVisibilityEvents.WindowShowing += new _dispWindowVisibilityEvents_WindowShowingEventHandler(windowVisibilityEvents_WindowShowing);
                windowVisibilityEvents.WindowHiding  += new _dispWindowVisibilityEvents_WindowHidingEventHandler(windowVisibilityEvents_WindowHiding);
            }
        }
コード例 #27
0
        public EventListener(IProjectManager projectManager, ProjectUpdater projectUpdater, IProjectConfigurationManager projectConfigurationManager, IIOWrapper iOWrapper)
        {
            this.projectManager = projectManager ?? throw new ArgumentNullException(nameof(projectManager));
            this.projectUpdater = projectUpdater ?? throw new ArgumentNullException(nameof(projectUpdater));
            this.projectConfigurationManager = projectConfigurationManager ?? throw new ArgumentNullException(nameof(projectConfigurationManager));
            this.iOWrapper = iOWrapper ?? throw new ArgumentNullException(nameof(iOWrapper));

            this.dte2               = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
            this.dteEvents          = dte2.Events as Events2;
            this.projectItemsEvents = dteEvents.ProjectItemsEvents;
            this.selectionEvents    = dteEvents.SelectionEvents;
        }
コード例 #28
0
ファイル: UserControl1.cs プロジェクト: cetinyasar/SaveTabs
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicationObject"></param>
        public void Initialize(DTE2 applicationObject)
        {
            _applicationObject              = applicationObject;
            m_events                        = (Events2)_applicationObject.Events;
            m_solutionEvents                = m_events.SolutionEvents;
            m_solutionEvents.Opened        += SolutionEvents_Opened;
            m_solutionEvents.BeforeClosing += m_solutionEvents_BeforeClosing;

            if (_applicationObject.Solution.FullName != "")
            {
                ProjeAcildiIlkAyarlariYap(Path.GetDirectoryName(_applicationObject.Solution.FullName));
            }
        }
コード例 #29
0
        protected override void Initialize()
        {
            Deploy.Initialize(this);
            base.Initialize();

            var     dte    = GetService(typeof(SDTE)) as DTE2;
            Events2 events = (Events2)dte.Events;

            m_BuildEvents = events.BuildEvents;

            m_BuildEvents.OnBuildBegin          += BuildEvents_OnBuildBegin;
            m_BuildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone;
        }
コード例 #30
0
ファイル: MainPackage.cs プロジェクト: matt40k/vs-net-dte
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            Logger.Initialise();

            this.dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
            this.events = this.dte.Events as Events2;
            this.solutionEvents = this.events.SolutionEvents;
            
            this.solutionEvents.Opened += SolutionEvents_Opened;
            this.solutionEvents.AfterClosing += Solution_AfterClosed;
        }
コード例 #31
0
 public Model(string _projName, Events2 _evs2)
 {
     projName = _projName;
     proj     = GetProject(projName);
     if (proj != null)
     {
         vcCodeModel = (VCCodeModel)proj.CodeModel;
     }
     evs2  = _evs2;
     cmEvs = evs2.CodeModelEvents;
     //cmEvs.ElementChanged += OnElementChanged;
     //cmEvs.ElementDeleted += OnElementDeleted;
     //cmEvs.ElementAdded += OnElementAdded;
 }
コード例 #32
0
        // private DocumentEvents documentEvents;

        public void SubscribeToEvents(Events2 events)
        {
            // documentEvents = events.DocumentEvents;
            //documentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            projectItemsEvents            = events.ProjectItemsEvents;
            projectItemsEvents.ItemAdded += Scanner.ScanProjectItem;
            // projectItemsEvents.ItemRemoved += Scanner.RemoveProjectItem;
            // projectItemsEvents.ItemRenamed += Scanner.RenameProjectItem;

            solutionEvents                 = events.SolutionEvents;
            solutionEvents.Opened         += Scanner.ScanSolution;
            solutionEvents.ProjectAdded   += Scanner.ScanProject;
            solutionEvents.ProjectRemoved += Scanner.RemoveProject;
            solutionEvents.ProjectRenamed += Scanner.RenameProject;
        }
コード例 #33
0
ファイル: DTEEventSource.cs プロジェクト: wangchunlei/MyGit
 public DTEEventSource( Events2 events)
 {
     _buildEvents = events.BuildEvents;
     _dteEvents = events.DTEEvents;
     _debuggerEvents = events.DebuggerEvents;
     _debuggerProcessEvents = events.DebuggerProcessEvents;
     _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents;
     _findEvents = events.FindEvents;
     _miscFileEvents = events.MiscFilesEvents;
     _projectItemsEvents = events.ProjectItemsEvents;
     _projectEvents = events.ProjectsEvents;
     _publishEvents = events.PublishEvents;
     _selectionEvents = events.SelectionEvents;
     _solutionEvents = events.SolutionEvents;
     _solutionItemEvents = events.SolutionItemsEvents;            
 }
コード例 #34
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));


            TsWspPackage.Instance = this;

            Events2 events = TsWspPackage.DTE.Events as Events2;

            _solutionEvents = events.SolutionEvents;

            base.Initialize();

            SettingsStore.Load();
            TscCommand.Initialize(this);
        }
コード例 #35
0
 public DTEEventSource(Events2 events)
 {
     _buildEvents           = events.BuildEvents;
     _dteEvents             = events.DTEEvents;
     _debuggerEvents        = events.DebuggerEvents;
     _debuggerProcessEvents = events.DebuggerProcessEvents;
     _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents;
     _findEvents         = events.FindEvents;
     _miscFileEvents     = events.MiscFilesEvents;
     _projectItemsEvents = events.ProjectItemsEvents;
     _projectEvents      = events.ProjectsEvents;
     _publishEvents      = events.PublishEvents;
     _selectionEvents    = events.SelectionEvents;
     _solutionEvents     = events.SolutionEvents;
     _solutionItemEvents = events.SolutionItemsEvents;
 }
コード例 #36
0
ファイル: ASBuildNotifier.cs プロジェクト: gramcha/XFeatures
 public void Init(DTE _dte)
 {
     if (_dte == null)
         return;
     dte = _dte;
     events2 = dte.Events as Events2;
     notifyIcon.BalloonTipClicked += new EventHandler(BalloonTipClicked);
     if (events2 != null)
     {
         bevents = events2.BuildEvents;
         //MessageBox.Show("Attach");
         events2.BuildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(ASBuildNotifier_OnBuildBegin);
         events2.BuildEvents.OnBuildDone += ASBuildNotifier_OnBuildDone;
         events2.BuildEvents.OnBuildProjConfigBegin += new _dispBuildEvents_OnBuildProjConfigBeginEventHandler(ASBuildNotifier_OnBuildProjConfigBegin);
         events2.BuildEvents.OnBuildProjConfigDone += ASBuildNotifier_OnBuildProjConfigDone;
     }
     InitializeTaskbarList();
     projectsBuildReport = new List<string>();
 }
        internal ProjectSpecificDictionaryProvider()
        {
            var dte2 = (DTE2)Package.GetGlobalService(typeof(SDTE));
            
            if (dte2 != null)
            {
                _events = dte2.Events as Events2;
                if (_events != null)
                {
                    _ProjectItemsEvents = _events.ProjectItemsEvents;
                    _ProjectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
                    _ProjectItemsEvents.ItemAdded += ProjectItemsEvents_ItemAddedOrRemoved;
                    _ProjectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemAddedOrRemoved;

                    _SolutionEvents = _events.SolutionEvents;
                    _SolutionEvents.AfterClosing += SolutionEvents_AfterClosing;
                    _SolutionEvents.ProjectRenamed += SolutionEvents_ProjectRenamed;
                    _SolutionEvents.ProjectRemoved += SolutionEvents_ProjectRemoved;
                }
            }

        }
コード例 #38
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            try
            {
                events = _applicationObject.Events as Events2;
                solutionEvents = events.SolutionEvents;
                solutionEvents.Opened += StartWatchingProjectDirectories;
                solutionEvents.BeforeClosing += StopWatchingProjectDirectories;

                if (_applicationObject.Solution != null)
                {
                    StartWatchingProjectDirectories();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #39
0
ファイル: Connect.cs プロジェクト: MartinF/Dynamo.Jiss
		/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
		/// <param term='application'>Root object of the host application.</param>
		/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
		/// <param term='addInInst'>Object representing this Add-in.</param>
		/// <seealso class='IDTExtensibility2' />
		public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
		{
			_application = (DTE2)application;
			_addIn = (EnvDTE.AddIn)addInInst;

			// Events
			_events = (Events2)_application.Events;
			_projectsEvents = _events.ProjectsEvents;
			_projectItemsEvents = _events.ProjectItemsEvents;
			_documentEvents = _events.DocumentEvents;
			_buildEvents = _events.BuildEvents;

			AttachEvents();
			
			_core = new Core();
			
			// If being connected when Solution is already loaded - try to load all projects
			if (_application.Solution != null)
			{
				_core.Load(_application.Solution);
			}
		}
コード例 #40
0
ファイル: Chirp.cs プロジェクト: cbilson/chirpy
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            try {
                Settings.Saved += this.SettingsSaved;
            }catch(Exception ex)
            {
                this.OutputWindowWriteText("Error in commandBars: " + ex.ToString());
                MessageBox.Show(ex.ToString());
            }

            this.instance = addInInst as AddIn;
            this.App = application as DTE2;
            this.events = this.App.Events as Events2;

            try {
                // http://code.google.com/p/explorer-popup-add-in/source/browse/#svn%2Ftrunk%2FExPopupAddIn
                Command cmdMinifier = CommandHelper.AddCommand(this.App, this.instance, POPUP_MENU_NAME_MINIFIER, 1, POPUP_MENU_CAPTION_MINIFIER, "Mashes, minifies, and validates your javascript, stylesheet, and dotless files.", string.Empty);
                Command cmdJsHint = CommandHelper.AddCommand(this.App, this.instance, POPUP_MENU_NAME_JSHINT, 1, POPUP_MENU_CAPTION_JSHINT, "Validates your javascript", string.Empty);
                Command cmdCssLint = CommandHelper.AddCommand(this.App, this.instance, POPUP_MENU_NAME_CSSLINT, 1, POPUP_MENU_CAPTION_CSSLINT, "Validates your stylesheet", string.Empty);
                CommandBars cmdBars = (CommandBars)this.App.CommandBars;
                var barsNames = new List<string>();
                // http://msdn.microsoft.com/en-us/library/ff697228.aspx
                barsNames.AddRange(new[] { "Item", "Web Item" });

                if (cmdJsHint != null) {
                    foreach (string item in barsNames) {
                        if (cmdBars[item] != null) {
                            cmdJsHint.AddControl(cmdBars[item], 1);
                        }
                    }
                }
                if (cmdCssLint != null) {
                    foreach (string item in barsNames) {
                        if (cmdBars[item] != null) {
                            cmdCssLint.AddControl(cmdBars[item], 1);
                        }
                    }
                }

                if (cmdMinifier != null) {
                    foreach (string item in barsNames) {
                        if (cmdBars[item] != null) {
                            cmdMinifier.AddControl(cmdBars[item], 1);
                        }
                    }
                }
            } catch (Exception ex) {
                this.OutputWindowWriteText("Error in commandBars: " + ex.ToString());
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #41
0
        void VsShellPropertyEvents_AfterShellPropertyChanged(object sender, VsShellPropertyEventsHandler.ShellPropertyChangeEventArgs e)
        {
            SafeExecute(() =>
            {
                // when zombie state changes to false, finish package initialization
                //! DO NOT USE CODE WHICH MAY EXECUTE FOR LONG TIME HERE

                if ((int)__VSSPROPID.VSSPROPID_Zombie == e.PropId)
                {
                    if ((bool)e.Var == false)
                    {

                        var dte2 = ServiceProvider.GetDte2();

                        Events = dte2.Events as Events2;
                        DTEEvents = Events.DTEEvents;
                        SolutionEvents = Events.SolutionEvents;
                        DocumentEvents = Events.DocumentEvents;
                        WindowEvents = Events.WindowEvents;
                        DebuggerEvents = Events.DebuggerEvents;
                        CommandEvents = Events.CommandEvents;
                        SelectionEvents = Events.SelectionEvents;

                        DelayedInitialise();
                    }
                }
            });
        }