protected override void Initialize() { base.Initialize(); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); Instance = this; var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel)); VsWorkspace = componentModel.GetService <VisualStudioWorkspace>(); // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != menuCommandService) { new Menus.Cleanup.ActionCustomCodeCleanup(menuCommandService).SetupCommands(); } // Hook up event handlers events = App.DTE.Events; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; docEvents.DocumentSaved += DocumentEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; }
private void Initialize(IServiceProvider serviceProvider) { ThreadHelper.JoinableTaskFactory.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _dte = (EnvDTE.DTE)serviceProvider.GetService(typeof(EnvDTE.DTE)); if (_dte != null) { _dteEvents = _dte.Events; _dteBuildEvents = _dteEvents.BuildEvents; _dteBuildEvents.OnBuildBegin += (scope, action) => StopCoverageProcess(); } if (serviceProvider.GetService(typeof(SVsShell)) is IVsShell shell) { var packageToBeLoadedGuid = new Guid(OutputToolWindowPackage.PackageGuidString); shell.LoadPackage(ref packageToBeLoadedGuid, out var package); var outputWindowInitializedFile = Path.Combine(FCCEngine.AppDataFolder, "outputWindowInitialized"); if (File.Exists(outputWindowInitializedFile)) { OutputToolWindowCommand.Instance.FindToolWindow(); } else { // for first time users, the window is automatically docked OutputToolWindowCommand.Instance.ShowToolWindow(); File.WriteAllText(outputWindowInitializedFile, string.Empty); } } }); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); EnvDTE80.DTE2 dte2 = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2; Microsoft.Assumes.Present(dte2); _events = dte2.Events.SolutionEvents; _events.AfterClosing += delegate { DirectivesCache.Clear(); }; _dte = await GetServiceAsync(typeof(SDTE)) as EnvDTE.DTE; Microsoft.Assumes.Present(_dte); _dteEvents = _dte.Events; _documentEvents = _dteEvents.DocumentEvents; _documentEvents.DocumentSaved += OnDocumentSaved; IVsSolution solution = await GetServiceAsync(typeof(IVsSolution)) as IVsSolution; _projects = GetProjects(solution); await ParseVueTemplate.InitializeAsync(this); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); VSColorTheme.ThemeChanged += _ => { System.Diagnostics.Debug.WriteLine("Theme changed."); ThemeHelper.RefreshThemeCache(); }; SolutionEvents.OnAfterOpenSolution += (s, args) => { Classifiers.SymbolMarkManager.Clear(); }; // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); if ((Config.Instance.DisplayOptimizations & DisplayOptimizations.MainWindow) != 0) { WpfHelper.SetUITextRenderOptions(Application.Current.MainWindow, true); } _dteEvents = DTE2.Events; _buildEvents = _dteEvents.BuildEvents; _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin; _buildEvents.OnBuildDone += BuildEvents_OnBuildEnd; _buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone; //_extenderCookie = DTE.ObjectExtenders.RegisterExtenderProvider(VSConstants.CATID.CSharpFileProperties_string, BuildBots.AutoReplaceExtenderProvider.Name, new BuildBots.AutoReplaceExtenderProvider()); //await Commands.SymbolFinderWindowCommand.InitializeAsync(this); Commands.ScreenshotCommand.Initialize(this); Commands.IncrementVsixVersionCommand.Initialize(this); Commands.NaviBarSearchDeclarationCommand.Initialize(this); }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await base.InitializeAsync(cancellationToken, progress); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); Instance = this; var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)); VsWorkspace = componentModel.GetService <VisualStudioWorkspace>(); // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != menuCommandService) { new ActionCustomCodeCleanup(menuCommandService).SetupCommands(); } // Hook up event handlers events = App.DTE.Events; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; docEvents.DocumentSaved += DocumentEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; }
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); } }; }
private void AsmViewerControl_Loaded(object sender, RoutedEventArgs e) { // Configure save event dteEvents = serviceProvider.GetDTE().Events; dteDocEvents = dteEvents.DocumentEvents; dteTextEditorEvents = dteEvents.TextEditorEvents; dteSelectionEvents = dteEvents.SelectionEvents; dteDocEvents.DocumentSaved += DocumentEvents_DocumentSaved; }
public void AddEvents() { _events = (EnvDTE80.Events2)dte.Events; _events.SolutionItemsEvents.ItemAdded += new EnvDTE._dispProjectItemsEvents_ItemAddedEventHandler(_events_ItemAdded); _docEvents = (EnvDTE.DocumentEvents)_events.get_DocumentEvents(null); _docEvents.DocumentSaved += new EnvDTE._dispDocumentEvents_DocumentSavedEventHandler(_docEvents_DocumentSaved); _slnEvents = (EnvDTE.SolutionEvents)_events.SolutionEvents; _slnEvents.Opened += new EnvDTE._dispSolutionEvents_OpenedEventHandler(_slnEvents_SolutionOpened); _slnEvents.ProjectAdded += new EnvDTE._dispSolutionEvents_ProjectAddedEventHandler(_slnEvents_ProjectAdded); _slnEvents.ProjectRemoved += new EnvDTE._dispSolutionEvents_ProjectRemovedEventHandler(_slnEvents_ProjectRemoved); _slnEvents.BeforeClosing += new EnvDTE._dispSolutionEvents_BeforeClosingEventHandler(_slnEvents_BeforeClosing); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); SolutionEvents.OnAfterOpenSolution += (s, args) => { Taggers.SymbolMarkManager.Clear(); }; // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); if (Config.Instance.DisplayOptimizations.MatchFlags(DisplayOptimizations.CompactMenu)) { Controls.LayoutOverrider.CompactMenu(); } if (Config.Instance.DisplayOptimizations.MatchFlags(DisplayOptimizations.MainWindow)) { WpfHelper.SetUITextRenderOptions(Application.Current.MainWindow, true); } _dteEvents = DTE2.Events; _buildEvents = _dteEvents.BuildEvents; _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin; _buildEvents.OnBuildDone += BuildEvents_OnBuildEnd; _buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone; //_extenderCookie = DTE.ObjectExtenders.RegisterExtenderProvider(VSConstants.CATID.CSharpFileProperties_string, BuildBots.AutoReplaceExtenderProvider.Name, new BuildBots.AutoReplaceExtenderProvider()); //Commands.SymbolFinderWindowCommand.Initialize(); Commands.ScreenshotCommand.Initialize(); Commands.GetContentTypeCommand.Initialize(); Commands.IncrementVsixVersionCommand.Initialize(); Commands.NaviBarSearchDeclarationCommand.Initialize(); if (Config.Instance.InitStatus != InitStatus.Normal) { Config.Instance.SaveConfig(Config.ConfigPath); // save the file to prevent this notification from reoccurrence new Commands.VersionInfoBar(this).Show(Config.Instance.InitStatus); if (Config.Instance.InitStatus == InitStatus.FirstLoad) { // automatically load theme when first load if (ThemeHelper.DocumentPageColor.ToWpfColor().IsDark()) { Config.LoadConfig(Config.DarkTheme, StyleFilters.All); } else { Config.LoadConfig(Config.LightTheme, StyleFilters.All); } } } Commands.SyntaxCustomizerWindowCommand.Initialize(); //ListEditorCommands(); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // replace dte from next line with your dte package // dte = Utilities.Utility.GetEnvDTE(this); events = dte.Events; solutionEvents = events.SolutionEvents; solutionEvents.Opened += SolutionEvents_Opened; solutionEvents.AfterClosing += SolutionEvents_AfterClosing; }
/// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); Log.Initialize(); ProbeEnvironment.Initialize(); TempManager.Init(TempDir); Snippets.SnippetDeploy.DeploySnippets(); CodeModel.SignatureDocumentor.Initialize(); ThreadHelper.ThrowIfNotOnUIThread(); // Proffer the service. http://msdn.microsoft.com/en-us/library/bb166498.aspx var langService = new ProbeLanguageService(this); langService.SetSite(this); (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true); // Register a timer to call our language service during idle periods. var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (_componentId == 0 && mgr != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = mgr.FRegisterComponent(this, crinfo, out _componentId); } _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this); TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie); var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { Commands.InitCommands(mcs); } _functionScanner = new FunctionFileScanning.FFScanner(); // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered. _dteEvents = Shell.DTE.Events; _dteDocumentEvents = _dteEvents.DocumentEvents; _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved; Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; }
/// <summary> /// Initializes a new instance of the <see cref="GitHostWindow"/> class. /// </summary> public GitHostWindow() : base(null) { // save references in order to make event registrations are not GCed _dte2 = (DTE2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SDTE)); _events = _dte2.Events; _events2 = _events.SolutionEvents; _events2.Opened += SolutionEvents_Opened; _events3 = _events.WindowEvents; _events3.WindowActivated += _events3_WindowActivated; this.Caption = "Git Integrated Window"; // 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 = _githost = new GitConsoleExtension.GitHostWindowControl(); }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await base.InitializeAsync(cancellationToken, progress); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); Instance = this; var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)); // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; var cmdidWebFileToggleId = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, 0x101); var cmdidAttacherId = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidAttacher); var otherMenu = menuCommandService.FindCommand(cmdidWebFileToggleId); if (otherMenu != null) { } if (null != menuCommandService) { var menuCommand = new OleMenuCommand(CallAttacher, cmdidAttacherId); menuCommand.BeforeQueryStatus += MenuCommand_BeforeQueryStatus; menuCommandService.AddCommand(menuCommand); } SetCommandBindings(); // Hook up event handlers events = App.DTE.Events; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; docEvents.DocumentSaved += DocumentEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; }
protected override void Initialize() { base.Initialize(); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); Instance = this; var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != menuCommandService) { // var mainMenu = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidMainMenu); // var founded = menuCommandService.FindCommand(mainMenu); // if (founded == null) // { // var menuCommand2 = new OleMenuCommand(null, mainMenu); // menuCommandService.AddCommand(menuCommand2); // menuCommand2.BeforeQueryStatus += MenuCommand2_BeforeQueryStatus; // } // Set up menu items new Menus.Typescript(menuCommandService).SetupCommands(); new Menus.RunBatchFiles(menuCommandService).SetupCommands(); new Menus.OpenRelatedFileF7(menuCommandService).SetupCommands(); } // Hook up event handlers events = App.DTE.Events; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; docEvents.DocumentSaved += DocumentEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; }
protected override async Task InitializeAsync ( CancellationToken Token, IProgress <ServiceProgressData> Progress ) { await base.InitializeAsync(Token, Progress); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(Token); #region Events #region RunningDocumentTable var Table = new RunningDocumentTable(this); Table.Advise(new RunningDocTableEvents()); #endregion #region EnvDTE.Events var DTE = await Utils.GetDTEAsync(); Events = DTE.Events; DocumentEvents = Events.DocumentEvents; DocumentEvents.DocumentClosing += Document => { _ = Task.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (Document.Language != "C/C++") { return; } await TaskScheduler.Default; await File.Structure.Events.OnBeforeDocumentCloseAsync(); }, Token); }; WindowEvents = Events.WindowEvents; WindowEvents.WindowActivated += (GotFocus, LostFocus) => { if (GotFocus == LastWindowThatGotFocus) { return; } _ = Task.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (GotFocus.Document == null) { return; } if (GotFocus.Document.Language != "C/C++") { return; } await TaskScheduler.Default; LastWindowThatGotFocus = GotFocus; await File.Structure.Events.OnAfterWindowActivateAsync(); }, Token); }; #endregion await WindowCommand.InitializeAsync(this); #endregion }
protected override void Initialize() { base.Initialize(); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); Instance = this; var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel)); VsWorkspace = componentModel.GetService <VisualStudioWorkspace>(); // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != menuCommandService) { menuCommandService.AddCommand(new MenuCommand(CallAttacher, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidAttacher))); menuCommandService.AddCommand(new MenuCommand(CallWebFileToggle, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidWebFileToggle))); menuCommandService.AddCommand(new MenuCommand(CallFixtureFileToggle, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidFixtureFileToggle))); menuCommandService.AddCommand(new MenuCommand(CallFileFinder, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidFileFinder))); menuCommandService.AddCommand(new MenuCommand(CallMemberFinder, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidMemberFinder))); menuCommandService.AddCommand(new MenuCommand(CallCssFinder, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidCSSFinder))); menuCommandService.AddCommand(new MenuCommand(CallGotoNextFoundItem, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidGotoNextFoundItem))); menuCommandService.AddCommand(new MenuCommand(CallGotoPreviousFoundItem, new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidGotoPreviousFoundItem))); // Set up menu items new Menus.OpenInMSharp.OpenInMSharpCodeWindow(menuCommandService).SetupCommands(); new Menus.OpenInMSharp.OpenInMSharpSolutionExplorer(menuCommandService).SetupCommands(); new Menus.Typescript(menuCommandService).SetupCommands(); new Menus.RunBatchFiles(menuCommandService).SetupCommands(); new Menus.Cleanup.ActionCustomCodeCleanup(menuCommandService).SetupCommands(); } SetCommandBindings(); // Hook up event handlers events = App.DTE.Events; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; docEvents.DocumentSaved += DocumentEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, false)) await tidyLogWriter.WriteLineAsync("Initialization has begun..."); await base.InitializeAsync(cancellationToken, progress); using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) await tidyLogWriter.WriteLineAsync("Base has initialized"); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) await tidyLogWriter.WriteLineAsync("Switched to main thread"); App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) await tidyLogWriter.WriteLineAsync("App initialized"); Instance = this; var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true); if (componentModel != null) { VsWorkspace = componentModel.GetService <VisualStudioWorkspace>(); } using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) { if (componentModel == null) { await tidyLogWriter.WriteLineAsync("component Model is null"); } else { await tidyLogWriter.WriteLineAsync("component has value"); } } // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true) as OleMenuCommandService; if (null != menuCommandService) { new ActionCustomCodeCleanup(menuCommandService).SetupCommands(); } using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) { if (menuCommandService == null) { await tidyLogWriter.WriteLineAsync("menu Command Service is null"); } else { await tidyLogWriter.WriteLineAsync("menu Command Service has value"); } } // Hook up event handlers events = App.Dte.Events; buildEvent = events.BuildEvents; docEvents = events.DocumentEvents; solEvents = events.SolutionEvents; buildEvent.OnBuildBegin += BuildEvent_OnBuildBegin; docEvents.DocumentSaved += DocEvents_DocumentSaved; solEvents.Opened += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); }; using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true)) await tidyLogWriter.WriteLineAsync("Initialization has finished..."); }
/// <summary> /// Default ctor /// </summary> /// <param name="package"></param> public SpriteContainer(Package package) { _package = package; SettingsManager settingsManager = new ShellSettingsManager(_package); _userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); InitializeComponent(); this.Owner = System.Windows.Application.Current.MainWindow; this.Topmost = false; #region Register event handlers dte = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(SDTE)); events = dte.Events; docEvents = (EnvDTE.DocumentEventsClass)dte.Events.DocumentEvents; buildEvents = (EnvDTE.BuildEventsClass)dte.Events.BuildEvents; RegisterToDTEEvents(); this.Owner.LocationChanged += Owner_LocationChanged; this.Owner.StateChanged += Owner_StateOrSizeChanged; this.Owner.SizeChanged += Owner_StateOrSizeChanged; this.LocationChanged += SpriteContainer_LocationChanged; #endregion #region -- Restore Sprite postion -- double?storedRelativeTop = null; double?storedRelativeLeft = null; double relativeTop = 0; double relativeLeft = 0; try { if (_userSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "RelativeTop")) { storedRelativeTop = Double.Parse(_userSettingsStore.GetString(Constants.SettingsCollectionPath, "RelativeTop")); } if (_userSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "RelativeLeft")) { storedRelativeLeft = Double.Parse(_userSettingsStore.GetString(Constants.SettingsCollectionPath, "RelativeLeft")); } } catch { } if (!storedRelativeTop.HasValue || !storedRelativeLeft.HasValue) { recalculateSpritePosition(out relativeTop, out relativeLeft, true); storedRelativeTop = relativeTop; storedRelativeLeft = relativeLeft; this.RelativeLeft = relativeLeft; this.RelativeTop = relativeTop; storeRelativeSpritePosition(storedRelativeTop.Value, storedRelativeLeft.Value); } else { recalculateSpritePosition(out relativeTop, out relativeLeft); this.RelativeLeft = relativeLeft; this.RelativeTop = relativeTop; } double ownerTop = this.Owner.Top; double ownerLeft = this.Owner.Left; if (this.Owner.WindowState == WindowState.Maximized) { ownerTop = 0; ownerLeft = 0; } this.Top = ownerTop + storedRelativeTop.Value; this.Left = ownerLeft + storedRelativeLeft.Value; #endregion var values = Enum.GetValues(typeof(ClippyAnimations)); //// TEMP: create a voice for each animation in the context menu //var pMenu = (ContextMenu)this.Resources["cmButton"]; //foreach (ClippyAnimations val in values) //{ // var menuItem = new MenuItem() // { // Header = val.ToString(), // Name = "cmd" + val.ToString() // }; // menuItem.Click += cmdTestAnimation_Click; // pMenu.Items.Add(menuItem); //} //// /TEMP _clippy = new Clippy((Canvas)this.FindName("ClippyCanvas")); _clippy.StartAnimation(ClippyAnimations.Idle1_1); }