Ejemplo n.º 1
0
        /// <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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a symbol, at the location specified in <paramref name="origin"/>.
        /// </summary>
        /// <param name="symbol">The symbol to draw.</param>
        /// <param name="origin">The location where to start drawing.</param>
        /// <param name="size">The drawing size, padding included.</param>
        /// <param name="padding">The padding to use when drawing.</param>
        /// <param name="isFocused">true if the symbol text has the focus.</param>
        public virtual void DrawSymbol(Symbols symbol, Point origin, Size size, Padding padding, bool isFocused)
        {
            Debug.Assert(WpfDrawingContext != null);

            if (isFocused && DisplayFocus)
            {
                ChangeFlashClockOpacity(isVisible: true);
                WpfDrawingContext.PushOpacity(1, FlashClock);
            }

            switch (symbol)
            {
            default:
            case Symbols.LeftArrow:
            case Symbols.Dot:
                DrawTextSymbol(SymbolToText(symbol), origin, size, padding);
                break;

            case Symbols.InsertSign:
                if (isFocused && DisplayFocus)
                {
                    DrawTextSymbol(SymbolToText(symbol), origin, size, padding);
                }
                break;

            case Symbols.LeftBracket:
                DrawGeometrySymbol(LeftBracketGeometry, origin, size, padding);
                break;

            case Symbols.RightBracket:
                DrawGeometrySymbol(RightBracketGeometry, origin, size, padding);
                break;

            case Symbols.LeftCurlyBracket:
                DrawGeometrySymbol(LeftCurlyBracketGeometry, origin, size, padding);
                break;

            case Symbols.RightCurlyBracket:
                DrawGeometrySymbol(RightCurlyBracketGeometry, origin, size, padding);
                break;

            case Symbols.LeftParenthesis:
                DrawGeometrySymbol(LeftParenthesisGeometry, origin, size, padding);
                break;

            case Symbols.RightParenthesis:
                DrawGeometrySymbol(RightParenthesisGeometry, origin, size, padding);
                break;

            case Symbols.HorizontalLine:
                DrawGeometrySymbol(HorizontalLineGeometry, origin, size, padding);
                break;
            }

            if (isFocused && DisplayFocus)
            {
                WpfDrawingContext.Pop();
                IsLastFocusedFullCell = true;
            }
        }
Ejemplo n.º 3
0
 private void PopOpacity(bool isPushed)
 {
     if (isPushed)
     {
         WpfDrawingContext.Pop();
         IsLastFocusedFullCell = true;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Draws the vertical separator above the specified origin and with the specified width.
 /// </summary>
 /// <param name="region">The region corresponding to the node that has a comment.</param>
 public virtual void DrawCommentIcon(Rect region)
 {
     if (CommentIcon != null)
     {
         WpfDrawingContext.PushOpacity(0.5);
         WpfDrawingContext.DrawImage(CommentIcon, new System.Windows.Rect(PagePadding.Left.Draw + region.X - (CommentIcon.Width / 2), PagePadding.Top.Draw + region.Y - (CommentIcon.Height / 2), CommentIcon.Width, CommentIcon.Height));
         WpfDrawingContext.Pop();
     }
 }
Ejemplo n.º 5
0
        /// <summary></summary>
        protected virtual void ShowNormalCaret(Point origin, string text, TextStyles textStyle, CaretModes mode, int position)
        {
            string LeftText = text.Substring(0, position);

            Brush         Brush = GetBrush(StyleToForegroundBrush(textStyle));
            FormattedText ft    = CreateFormattedText(LeftText, EmSize, Brush);
            double        X     = origin.X.Draw + ft.WidthIncludingTrailingWhitespace;
            double        Y     = origin.Y.Draw;

            if (textStyle == TextStyles.Comment)
            {
                X += CommentPadding.Left.Draw;
                Y += CommentPadding.Top.Draw;
            }

            ChangeFlashClockOpacity(isVisible: true);

            if (mode == CaretModes.Insertion)
            {
                System.Windows.Rect CaretRect = new System.Windows.Rect(PagePadding.Left.Draw + X, PagePadding.Top.Draw + Y, InsertionCaretWidth, LineHeight.Draw);

                WpfDrawingContext.PushOpacity(1, FlashClock);
                WpfDrawingContext.DrawRectangle(GetBrush(BrushSettings.CaretInsertion), GetPen(PenSettings.CaretInsertion), CaretRect);
                WpfDrawingContext.Pop();
            }
            else
            {
                string CaretText = text.Substring(position, 1);
                ft = CreateFormattedText(CaretText, EmSize, GetBrush(BrushSettings.CaretOverride));

                System.Windows.Rect CaretRect = new System.Windows.Rect(PagePadding.Left.Draw + X, PagePadding.Top.Draw + Y, ft.WidthIncludingTrailingWhitespace, LineHeight.Draw);

                WpfDrawingContext.PushOpacity(1, FlashClock);
                WpfDrawingContext.DrawRectangle(GetBrush(BrushSettings.CaretOverride), GetPen(PenSettings.CaretOverride), CaretRect);
                WpfDrawingContext.Pop();
            }
        }
Ejemplo n.º 6
0
        /// <summary></summary>
        protected virtual void ShowNumberCaretParts(FormattedNumber fn, CaretModes mode, int position, double x, double y, double caretEmSize, double caretHeight)
        {
            if (mode == CaretModes.Insertion)
            {
                System.Windows.Rect CaretRect = new System.Windows.Rect(PagePadding.Left.Draw + x, PagePadding.Top.Draw + y, InsertionCaretWidth, caretHeight);

                WpfDrawingContext.PushOpacity(1, FlashClock);
                WpfDrawingContext.DrawRectangle(GetBrush(BrushSettings.CaretInsertion), GetPen(PenSettings.CaretInsertion), CaretRect);
                WpfDrawingContext.Pop();
            }
            else
            {
                string CaretText;

                if (position < fn.SignificandPart.Length)
                {
                    CaretText = fn.SignificandPart.Substring(position, 1);
                }
                else if (position < fn.SignificandPart.Length + fn.ExponentPart.Length)
                {
                    CaretText = fn.ExponentPart.Substring(position - fn.SignificandPart.Length, 1);
                }
                else
                {
                    CaretText = fn.InvalidText.Substring(position - fn.SignificandPart.Length - fn.ExponentPart.Length, 1);
                }

                FormattedText ftCaret = CreateFormattedText(CaretText, caretEmSize, GetBrush(BrushSettings.CaretOverride));

                System.Windows.Rect CaretRect = new System.Windows.Rect(PagePadding.Left.Draw + x, PagePadding.Top.Draw + y, ftCaret.WidthIncludingTrailingWhitespace, caretHeight);

                WpfDrawingContext.PushOpacity(1, FlashClock);
                WpfDrawingContext.DrawRectangle(GetBrush(BrushSettings.CaretOverride), GetPen(PenSettings.CaretOverride), CaretRect);
                WpfDrawingContext.Pop();
            }
        }