コード例 #1
0
        public void populateDefaultVSComObjects()
        {
            VisualStudio_2010.Package           = this;
            VisualStudio_2010.ErrorListProvider = new ErrorListProvider(this);
            VisualStudio_2010.IVsUIShell        = this.getService <IVsUIShell>();
            VisualStudio_2010.DTE2 = this.getService <EnvDTE.DTE, EnvDTE80.DTE2>();
            VisualStudio_2010.OleMenuCommandService = this.getService <OleMenuCommandService>();

            Events = VisualStudio_2010.DTE2.Events;

            BuildEvents         = Events.BuildEvents;
            CommandEvents       = Events.CommandEvents;
            DebuggerEvents      = Events.DebuggerEvents;
            DocumentEvents      = Events.DocumentEvents;
            DTEEvents           = Events.DTEEvents;
            FindEvents          = Events.FindEvents;
            MiscFilesEvents     = Events.MiscFilesEvents;
            OutputWindowEvents  = Events.OutputWindowEvents;
            SelectionEvents     = Events.SelectionEvents;
            SolutionEvents      = Events.SolutionEvents;
            SolutionItemsEvents = Events.SolutionItemsEvents;
            TaskListEvents      = Events.TaskListEvents;
            TextEditorEvents    = Events.TextEditorEvents;
            WindowEvents        = Events.WindowEvents;



            BuildEvents.OnBuildBegin += (scope, action) => VisualStudio_2010.On_BuildBegin.invoke();
            BuildEvents.OnBuildDone  += (scope, action) => VisualStudio_2010.On_BuildDone.invoke();

            BuildEvents.OnBuildProjConfigDone +=
                (Project, ProjectConfig, Platform, SolutionConfig, Success) =>
            {
                //@"On OnBuildProjConfigDone: project: {0} , ProjectConfig: {1} , Platform: {2},  SolutionConfig: {3} , Success: {4}".debug(Project,ProjectConfig, Platform, SolutionConfig,Success);
                if (Success)
                {
                    VisualStudio_2010.On_ProjectBuild_OK.invoke(Project);
                }
                else
                {
                    VisualStudio_2010.On_ProjectBuild_Failed.invoke(Project);
                }
            };

            SolutionEvents.Opened += () => VisualStudio_2010.On_SolutionOpened.invoke();

            DocumentEvents.DocumentOpened  += (document) => VisualStudio_2010.on_DocumentOpened.invoke(document);
            DocumentEvents.DocumentClosing += (document) => VisualStudio_2010.on_DocumentClosing.invoke(document);
            DocumentEvents.DocumentSaved   += (document) => VisualStudio_2010.on_DocumentSaved.invoke(document);
            DocumentEvents.DocumentOpening += (documentPath, readOnly) => VisualStudio_2010.on_DocumentOpening.invoke(documentPath, readOnly);
            TextEditorEvents.LineChanged   += (startPoint, endPoint, hInt) => VisualStudio_2010.on_LineChanged.invoke(startPoint, endPoint);

            WindowEvents.WindowActivated += (windowGotFocus, windowLostFocus) => {
                if (windowGotFocus.Document.notNull())
                {
                    VisualStudio_2010.on_ActiveDocumentChange.invoke(windowGotFocus.Document);
                }
            };
        }
コード例 #2
0
ファイル: VsStatusBar.cs プロジェクト: ktaranov/RTVS
        private void TryAddItemsControlToVisualRoot()
        {
            if (_visualRoot == null)
            {
                _visualRoot = GetRootVisual();
            }

            if (_visualRoot == null && _dteEvents == null)
            {
                var dte = _shell.GetGlobalService <EnvDTE.DTE>();
                if (dte == null)
                {
                    return;
                }

                _dteEvents = dte.Events.DTEEvents;
                _dteEvents.OnStartupComplete += OnStartupComplete;
                return;
            }

            var statusBarControl = _visualRoot.FindFirstVisualChildBreadthFirst <StatusBarControl>();

            if (statusBarControl != null)
            {
                var item = new StatusBarItem {
                    Content             = _itemsControl,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Visibility          = Visibility.Visible
                };
                DockPanel.SetDock(item, Dock.Right);
                statusBarControl.Items.Insert(0, item);
                return;
            }

            // It is possible that StatusBarControl isn't created yet.
            // In this case, we will add ItemsControl directly to the dock panel that holds the StatusBarControl
            // It should be the same panel that holds VsResizeGrip
            var resizeGrip = GetRootVisual().FindFirstVisualChildBreadthFirst <ResizeGrip>();

            var statusBarPanel = resizeGrip?.Parent as DockPanel;

            if (statusBarPanel == null)
            {
                return;
            }

            DockPanel.SetDock(_itemsControl, Dock.Right);
            var resizeGripIndex = statusBarPanel.Children.IndexOf(resizeGrip);

            if (resizeGripIndex == statusBarPanel.Children.Count - 1)
            {
                statusBarPanel.Children.Add(_itemsControl);
            }
            else
            {
                statusBarPanel.Children.Insert(resizeGripIndex + 1, _itemsControl);
            }
        }
コード例 #3
0
 public VersionCheckNotificationForm(VersionCheckPlugin versionCheckPlugin)
 {
     _versionCheckPlugin = versionCheckPlugin;
     InitializeComponent();
     notifyIcon1.Icon = BIDSHelper.Resources.Common.BIDSHelper;
     _events = versionCheckPlugin.ApplicationObject.Events.DTEEvents;
     _events.OnBeginShutdown += new EnvDTE._dispDTEEvents_OnBeginShutdownEventHandler(DTEEvents_OnBeginShutdown);
 }
コード例 #4
0
 public VersionCheckNotificationForm(VersionCheckPlugin versionCheckPlugin)
 {
     _versionCheckPlugin = versionCheckPlugin;
     InitializeComponent();
     notifyIcon1.Icon         = BIDSHelper.Resources.Common.BIDSHelper;
     _events                  = versionCheckPlugin.ApplicationObject.Events.DTEEvents;
     _events.OnBeginShutdown += new EnvDTE._dispDTEEvents_OnBeginShutdownEventHandler(DTEEvents_OnBeginShutdown);
 }
コード例 #5
0
ファイル: VsStatusBar.cs プロジェクト: ktaranov/RTVS
        private void OnStartupComplete()
        {
            _shell.DispatchOnUIThread(() => {
                _dteEvents.OnStartupComplete -= OnStartupComplete;
                _dteEvents = null;

                EnsureItemsControlCreated();
            });
        }
コード例 #6
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()
        {
            base.Initialize();

            var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));

            this.dteEvents = dte.Events.DTEEvents;
            this.dteEvents.OnStartupComplete += OnIdeStartupComplete;
            this.daemon = this.GetMefService <ISonarLintDaemon>();
        }
コード例 #7
0
        protected override void Initialize()
        {
            base.Initialize();

            _dte    = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            _events = _dte.Events.DTEEvents;

            _events.OnStartupComplete += () =>
            {
                _window = (Window)HwndSource.FromHwnd(new IntPtr(_dte.MainWindow.HWnd)).RootVisual;
                _timer  = new Timer(state => _window.Dispatcher.Invoke(ShowIcons), null, 2000, 2000);
            };

            _events.OnBeginShutdown += () =>
            {
                _timer.Dispose();
            };
        }
コード例 #8
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()
        {
            Contract.Ensures(initialized);

            Debug.WriteLine("Entering Initialize() of: {0}", this);
            Debug.WriteLine("Default selected settings file: " + Settings.Default.SelectedSettingsFile);

            base.Initialize();

            AddOptionKey(SettingsOptionKey);

            ReadSettingsDirectory();

            if (settingsDirectory != null)
            {
                var events = Dte.Events;

                Contract.Assume(events != null);

                // A reference to solutionEvents must be stored in a field so that event handlers aren't collected by the GC.
                solutionEvents = events.SolutionEvents;
                dteEvents      = events.DTEEvents;

                Contract.Assume(solutionEvents != null);
                Contract.Assume(dteEvents != null);

                solutionEvents.Opened        += SolutionOpened;
                solutionEvents.Renamed       += SolutionRenamed;
                solutionEvents.BeforeClosing += SolutionClosing;

                dteEvents.OnBeginShutdown += BeginShutdown;

                settingFilesWatcher.Path = settingsDirectory.LocalPath;
                settingFilesWatcher.EnableRaisingEvents = true;

                lock (gate)
                {
                    LoadSettingsFiles();

                    if (selectedSettingsFile == null)
                    {
                        var defaultFile = Settings.Default.SelectedSettingsFile;

                        if (string.IsNullOrWhiteSpace(defaultFile) || !File.Exists(defaultFile) || !settingsDirectory.IsBaseOf(new Uri(defaultFile, UriKind.Absolute)))
                        {
                            if (File.Exists(originalSettingsFile.LocalPath))
                            {
                                Debug.WriteLine("Importing original settings file: " + originalSettingsFile.LocalPath);

                                ImportSettings(originalSettingsFile.LocalPath);
                            }
                            else
                            {
                                Debug.WriteLine("Exporting original settings file: " + originalSettingsFile.LocalPath);

                                ExportCurrentSettings(originalSettingsFile.LocalPath);
                            }
                        }
                        else
                        {
                            Debug.WriteLine("Default settings file found: " + defaultFile);

                            selectedSettingsFile = settingsFiles.FindByFullName(defaultFile);
                        }
                    }
                }
            }

            var menus = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (menus != null)
            {
                foreach (var command in InitializeCommands())
                {
                    menus.AddCommand(command);
                }
            }

            InitializePriorityCommands();
            InitializeToolBar();

            Contract.Assert(settingsDirectory == null || settingsDirectory.IsAbsoluteUri);
            Contract.Assert(settingsDirectory == null || settingsDirectory.IsFile);
            Contract.Assert(autoSettingsFile == null || autoSettingsFile.IsAbsoluteUri);
            Contract.Assert(autoSettingsFile == null || autoSettingsFile.IsFile);
            Contract.Assert(oldAutoSettingsFile == null || oldAutoSettingsFile.IsAbsoluteUri);
            Contract.Assert(oldAutoSettingsFile == null || oldAutoSettingsFile.IsFile);
            Contract.Assert(originalSettingsFile == null || originalSettingsFile.IsAbsoluteUri);
            Contract.Assert(originalSettingsFile == null || originalSettingsFile.IsFile);

            initialized = true;
        }