public void Update(TeXCommentTag tag, LineSpan lineSpan, double?lastLineWidthWithoutStartWhiteSpaces) { bool changed = this.DataTag.Text != tag.Text; this.DataTag = tag; LineSpan = lineSpan; if (lastLineWidthWithoutStartWhiteSpaces.HasValue) { this.lastLineWidthWithoutStartWhiteSpaces = lastLineWidthWithoutStartWhiteSpaces.Value; previewAdorner.OffsetX = -lastLineWidthWithoutStartWhiteSpaces.Value; } if (changed || isInvalidated) { switch (currentState) { case TeXCommentAdornmentState.Rendered: case TeXCommentAdornmentState.Rendering: CurrentState = TeXCommentAdornmentState.Rendering; break; case TeXCommentAdornmentState.EditingWithPreview: case TeXCommentAdornmentState.EditingAndRenderingPreview: CurrentState = TeXCommentAdornmentState.EditingAndRenderingPreview; break; default: break; } OnPropertyChanged(nameof(IsCaretInsideTeXBlock)); isInvalidated = false; } }
public Input(TeXCommentTag dataTag, double zoomScale, wpf.Color foreground, wpf.Color background, Font font, ITextView textView, ITagAdornment tagAdornment) { Content = dataTag.GetTextWithoutCommentMarks(); ZoomScale = zoomScale; Foreground = foreground; Background = background; Font = font; TextView = textView; TagAdornment = tagAdornment; }
public TeXCommentAdornment( IWpfTextView textView, TeXCommentTag tag, LineSpan lineSpan, double lastLineWidthWithoutStartWhiteSpaces, TeXCommentAdornmentState initialState, Action <Span> refreshTags, Action <bool> setIsInEditModeForAllAdornmentsInDocument, Action <TeXCommentTag, string> addAttribute, IRenderingManager renderingManager, IVsSettings vsSettings) { ExtensionSettings.Instance.CustomZoomChanged += CustomZoomChanged; textView.Caret.PositionChanged += Caret_PositionChanged; this.DataTag = tag; this.refreshTags = refreshTags; this.setIsInEditModeForAllAdornmentsInDocument = setIsInEditModeForAllAdornmentsInDocument; this.addAttribute = addAttribute; this.textView = textView; this.lastLineWidthWithoutStartWhiteSpaces = lastLineWidthWithoutStartWhiteSpaces; this.renderingManager = renderingManager; VsSettings = vsSettings; ResourcesManager = ResourcesManager.GetOrCreate(textView); LineSpan = lineSpan; InitializeComponent(); previewAdorner = new PreviewAdorner(this, ResourcesManager, vsSettings); Loaded += (s, e) => { if (previewAdorner.Parent == null) { previewAdorner.OffsetX = -this.lastLineWidthWithoutStartWhiteSpaces; //'this' is important because of lambda closure System.Windows.Documents.AdornerLayer.GetAdornerLayer(this).Add(previewAdorner); } }; //for correctly working binding NameScope.SetNameScope(btnShow.ContextMenu, NameScope.GetNameScope(this)); NameScope.SetNameScope(btnEdit.ContextMenu, NameScope.GetNameScope(this)); NameScope.SetNameScope((ToolTip)imgError.ToolTip, NameScope.GetNameScope(this)); CurrentState = initialState; }