/// <summary> /// Draws a string that is not a number, at the location specified in <paramref name="origin"/>. /// </summary> /// <param name="text">The text to draw.</param> /// <param name="origin">The location where to start drawing.</param> /// <param name="textStyle">Style to use for the text.</param> /// <param name="isFocused">true if the whole text has the focus.</param> public virtual void DrawText(string text, Point origin, TextStyles textStyle, bool isFocused) { Debug.Assert(WpfDrawingContext != null); if (isFocused && DisplayFocus) { ChangeFlashClockOpacity(isVisible: true); WpfDrawingContext.PushOpacity(1, FlashClock); } Brush Brush = GetBrush(StyleToForegroundBrush(textStyle)); FormattedText ft = CreateFormattedText(text, EmSize, Brush); double X = PagePadding.Left.Draw + origin.X.Draw; double Y = PagePadding.Top.Draw + origin.Y.Draw; double Width = ft.Width; double Height = LineHeight.Draw; if (textStyle == TextStyles.Comment) { X += CommentPadding.Left.Draw; Y += CommentPadding.Top.Draw; } WpfDrawingContext.DrawText(ft, new System.Windows.Point(X, Y)); if (isFocused && DisplayFocus) { WpfDrawingContext.Pop(); IsLastFocusedFullCell = true; } }
/// <summary> /// Draws a number string, at the location specified in <paramref name="origin"/>. /// </summary> /// <param name="text">The text to draw.</param> /// <param name="origin">The location where to start drawing.</param> public virtual void DrawNumber(string text, Point origin) { Debug.Assert(WpfDrawingContext != null); FormattedNumber fn = FormattedNumber.Parse(text); string SignificandPart = fn.SignificandPart; string ExponentString0 = fn.ExponentPart.Length > 0 ? fn.ExponentPart.Substring(0, 1) : string.Empty; string ExponentString1 = fn.ExponentPart.Length > 1 ? fn.ExponentPart.Substring(1) : string.Empty; string InvalidText = fn.InvalidText; Brush Brush; double X = PagePadding.Left.Draw + origin.X.Draw; double Y = PagePadding.Top.Draw + origin.Y.Draw; Brush = GetBrush(BrushSettings.NumberSignificand); FormattedText ftSignificand = CreateFormattedText(SignificandPart, EmSize, Brush); WpfDrawingContext.DrawText(ftSignificand, new System.Windows.Point(X, Y)); X += ftSignificand.WidthIncludingTrailingWhitespace; Brush = GetBrush(BrushSettings.NumberExponent); FormattedText ftExponent0 = CreateFormattedText(ExponentString0, EmSize, Brush); WpfDrawingContext.DrawText(ftExponent0, new System.Windows.Point(X, Y)); X += ftExponent0.WidthIncludingTrailingWhitespace; FormattedText ftExponent1 = CreateFormattedText(ExponentString1, EmSize * SubscriptRatio, Brush); WpfDrawingContext.DrawText(ftExponent1, new System.Windows.Point(X, Y)); X += ftExponent1.WidthIncludingTrailingWhitespace; Brush = GetBrush(BrushSettings.NumberInvalid); FormattedText ftInvalid = CreateFormattedText(InvalidText, EmSize, Brush); WpfDrawingContext.DrawText(ftInvalid, new System.Windows.Point(X, Y)); }
/// <summary></summary> protected virtual void DrawTextSymbol(string text, Point origin, Size size, Padding padding) { Debug.Assert(WpfDrawingContext != null); Brush ForegroundBrush = GetBrush(BrushSettings.Symbol); FormattedText ft = CreateFormattedText(text, EmSize, ForegroundBrush); WpfDrawingContext.DrawText(ft, new System.Windows.Point(PagePadding.Left.Draw + origin.X.Draw + padding.Left.Draw, PagePadding.Top.Draw + origin.Y.Draw + padding.Top.Draw)); }
/// <summary> /// Draws the horizontal separator left of the specified origin and with the specified height. /// </summary> /// <param name="separator">The separator to draw.</param> /// <param name="origin">The location where to draw.</param> /// <param name="height">The separator height.</param> public virtual void DrawHorizontalSeparator(HorizontalSeparators separator, Point origin, Measure height) { Debug.Assert(WpfDrawingContext != null); Brush ForegroundBrush = GetBrush(BrushSettings.Symbol); FormattedText ft; switch (separator) { case HorizontalSeparators.Comma: ft = CreateFormattedText(CommaSeparatorString, EmSize, ForegroundBrush); WpfDrawingContext.DrawText(ft, new System.Windows.Point(PagePadding.Left.Draw + origin.X.Draw - ft.WidthIncludingTrailingWhitespace, PagePadding.Top.Draw + origin.Y.Draw)); break; case HorizontalSeparators.Dot: ft = CreateFormattedText(DotSeparatorString, EmSize, ForegroundBrush); WpfDrawingContext.DrawText(ft, new System.Windows.Point(PagePadding.Left.Draw + origin.X.Draw - ft.WidthIncludingTrailingWhitespace, PagePadding.Top.Draw + origin.Y.Draw)); break; } }