public LineTextPreview() { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Opaque, true); InitializeComponent(); _IndentSize = 4; _Theme = null; Analysis = null; }
public override void Refresh() { base.Refresh(); if (Theme != null && Theme.Behavior != null && IsHandleCreated) { var snapshot = new FakeSnapshot(Text); Analysis = new DocumentAnalyzer(snapshot, Theme.Behavior, IndentSize, IndentSize); Analysis.Reset().ContinueWith(t => { BeginInvoke((Action)Invalidate); }); } }
public override void Refresh() { base.Refresh(); if (Theme != null && Theme.Behavior != null && IsHandleCreated) { var snapshot = new FakeSnapshot(Text); Analysis = new DocumentAnalyzer(snapshot, Theme.Behavior, IndentSize, IndentSize); IndentGuidePackage.JoinableTaskFactory.Run(async delegate { await Analysis.ResetAsync().ContinueWith(_ => BeginInvoke((Action)Invalidate), TaskScheduler.Default).ConfigureAwait(true); }); } }
/// <summary> /// Raised when a view option changes. /// </summary> 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> /// 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) { View = view; if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme)) { Theme = service.DefaultTheme; } if (Theme != null && Theme.Behavior != null && Theme.Behavior.Disabled) { return; } GuideBrushCache = new Dictionary <System.Drawing.Color, Brush>(); GlowEffectCache = new Dictionary <System.Drawing.Color, Effect>(); 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); Debug.Assert(Theme != null, "No themes loaded"); if (Theme == null) { Theme = new IndentTheme(); } service.ThemesChanged += new EventHandler(Service_ThemesChanged); Analysis = new DocumentAnalyzer( View.TextSnapshot, Theme.Behavior, View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId), View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId) ); GlobalVisible = service.Visible; service.VisibleChanged += new EventHandler(Service_VisibleChanged); var t = AnalyzeAndUpdateAdornments(); }
/// <summary> /// Raised when the theme is updated. /// </summary> async void Service_ThemesChanged(object sender, EventArgs e) { var 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(); }