/// <summary> /// Raised when a view option changes. /// </summary> private async void View_OptionChanged(object sender, EditorOptionChangedEventArgs e) { if (e.OptionId == DefaultOptions.IndentSizeOptionId.Name) { Analysis = new DocumentAnalyzer( View.TextSnapshot, Theme.Behavior, View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId), View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId) ); GuideBrushCache.Clear(); GlowEffectCache.Clear(); await AnalyzeAndUpdateAdornments(); } }
/// <summary> /// Raised when the theme is updated. /// </summary> private async void Service_ThemesChanged(object sender, EventArgs e) { IIndentGuide service = (IIndentGuide)sender; if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme)) { Theme = service.DefaultTheme; } Analysis = new DocumentAnalyzer( View.TextSnapshot, Theme.Behavior, View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId), View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId) ); GuideBrushCache.Clear(); GlowEffectCache.Clear(); await AnalyzeAndUpdateAdornments(); }
/// <summary> /// Instantiates a new indent guide manager for a view. /// </summary> /// <param name="view">The text view to provide guides for.</param> /// <param name="service">The Indent Guide service.</param> public IndentGuideView(IWpfTextView view, IIndentGuide service) { GuideBrushCache = new Dictionary <Color, Brush>(); GlowEffectCache = new Dictionary <Color, Effect>(); View = view; View.Caret.PositionChanged += Caret_PositionChanged; View.LayoutChanged += View_LayoutChanged; View.Options.OptionChanged += View_OptionChanged; Layer = view.GetAdornmentLayer("IndentGuide"); Canvas = new Canvas(); Canvas.HorizontalAlignment = HorizontalAlignment.Stretch; Canvas.VerticalAlignment = VerticalAlignment.Stretch; Layer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, Canvas, CanvasRemoved); if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme)) { Theme = service.DefaultTheme; } Debug.Assert(Theme != null, "No themes loaded"); if (Theme == null) { Theme = new IndentTheme(); } service.ThemesChanged += Service_ThemesChanged; Analysis = new DocumentAnalyzer( View.TextSnapshot, Theme.Behavior, View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId), View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId) ); GlobalVisible = service.Visible; service.VisibleChanged += Service_VisibleChanged; Task t = AnalyzeAndUpdateAdornments(); }