public void TextViewCreated(IWpfTextView view) { if (map == null) { map = formatMapService.GetClassificationFormatMap(view); } classificationService.SyncWithConfigs(); Decorate(); }
#pragma warning restore 0649 public ITagger <T> CreateTagger <T>(ITextView view, ITextBuffer buffer) where T : ITag { reg.SyncWithConfigs(); buffer.Changed += Buffer_Changed; return(view.Properties.GetOrCreateSingletonProperty(() => new CommentTagger(reg, aggService.CreateTagAggregator <IClassificationTag>(buffer), buffer.ContentType)) as ITagger <T>); }
#pragma warning restore 0649 public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag { if (buffer == null) { throw new ArgumentNullException("buffer"); } reg.SyncWithConfigs(); var agg = aggService.CreateTagAggregator <IClassificationTag>(buffer); return(buffer.Properties.GetOrCreateSingletonProperty( () => new BookmarkHeaderTagger(buffer, agg, buffer.ContentType)) as ITagger <T>); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); //ToDo move this down - just before command initializations // 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); var dte = (DTE) await GetServiceAsync(typeof(DTE)); Assumes.Present(dte); var dte2 = (DTE2) await GetServiceAsync(typeof(SDTE)); Assumes.Present(dte2); solService = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution; Assumes.Present(solService); var rdt = await GetServiceAsync(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; Assumes.Present(rdt); //! Set globals DteRefs.Package = this; DteRefs.DTE = dte; DteRefs.DTE2 = dte2; DteRefs.Solution = solService; DteRefs.RDT = rdt; //! Activate MEF ActivateMEF(); //! Get VS editor's background color var vsProperties = dte.Properties["FontsAndColors", "TextEditor"]; var fontsAndColors = vsProperties.Item("FontsAndColorsItems").Object as FontsAndColorsItems; var plainText = fontsAndColors.Item("Plain Text"); //! Set VS editor's background in configs var bg = ColorExtensions.FromInt((int)plainText.Background); commentConfigs.Defaults.VSBackground = Color.FromArgb(255, bg.R, bg.G, bg.B); //! Register classifications //? This might be redundant! clsService.SyncWithConfigs(); //! Hook events solService.AdviseSolutionEvents(ViewModelLocator.Instance, out var cookie); var events = dte2.Events as Events2; if (events != null) { ViewModelLocator.Instance.SubscribeToEvents(events); } //! Handle solution load if (await IsSolutionLoadedAsync()) { //todo Remove this if not used //! Only handle it if it's solution, and ignore it if it's a folder. //solService.GetProperty((int)__VSPROPID.VSPROPID_IsSolutionOpen, out var value); //if (await IsSolutionLoadedAsync()) //HandleOpenSolution(); // ViewModelLocator.Instance.Scanner.ScanSolution(); } await BookmarksListCommand.InitializeAsync(this); await SettingsCommand.InitializeAsync(this); }