예제 #1
0
 private void DrawDoubleArrow(DrawingContext dc)
 {
     if (Width < FontSize * 0.8)
     {
         FormattedText text   = FontFactory.GetFormattedText("\u2194", FontType.STIXGeneral, Width * 1.5);
         double        factor = .1;
         do
         {
             text    = FontFactory.GetFormattedText("\u2194", FontType.STIXGeneral, FontSize * factor);
             factor += .1;
         }while (Width > text.GetFullWidth());
         text.DrawTextTopLeftAligned(dc, Location);
     }
     else
     {
         firstSign.DrawTextTopLeftAligned(dc, Location);
         secondSign.DrawTextTopRightAligned(dc, new Point(Right, Top));
         dc.DrawLine(ThinPen, new Point(Left + FontSize * .06, MidY), new Point(Right - FontSize * .06, MidY));
     }
 }
예제 #2
0
        public override void DrawEquation(DrawingContext dc)
        {
            switch (decorationType)
            {
            case DecorationType.Bar:
                dc.DrawLine(ThinPen, Location, new Point(Right, Top));
                break;

            case DecorationType.DoubleBar:
                dc.DrawLine(ThinPen, Location, new Point(Right, Top));
                dc.DrawLine(ThinPen, new Point(Left, Bottom - ThinPen.Thickness),
                            new Point(Right, Bottom - ThinPen.Thickness));
                break;

            case DecorationType.Hat:
                dc.DrawPolyline(new Point(Left, Bottom - FontSize * .02),
                                new PointCollection
                {
                    new Point(MidX, Top + FontSize * .03),
                    new Point(Right, Bottom - FontSize * .02)
                },
                                ThinPen);
                break;

            case DecorationType.LeftArrow:
                firstSign.DrawTextTopLeftAligned(dc, Location);
                dc.DrawLine(ThinPen, new Point(Left + FontSize * .06, MidY), new Point(Right, MidY));
                break;

            case DecorationType.RightArrow:
                firstSign.DrawTextTopRightAligned(dc, new Point(Right, Top));
                dc.DrawLine(ThinPen, new Point(Left, MidY), new Point(Right - FontSize * .06, MidY));
                break;

            case DecorationType.DoubleArrow:
                DrawDoubleArrow(dc);
                break;

            case DecorationType.Parenthesis:
                DrawParentheses(dc);
                break;

            case DecorationType.RightHarpoonUpBarb:
                DrawRightHarpoonUpBarb(dc);
                break;

            case DecorationType.RightHarpoonDownBarb:
                DrawRightHarpoonDownBarb(dc);
                break;

            case DecorationType.LeftHarpoonUpBarb:
                DrawLeftHarpoonUpBarb(dc);
                break;

            case DecorationType.LeftHarpoonDownBarb:
                DrawLeftHarpoonDownBarb(dc);
                break;

            case DecorationType.Tilde:
                firstSign.DrawTextTopLeftAligned(dc, Location);
                break;

            case DecorationType.Tortoise:
                DrawTortoise(dc);
                break;

            case DecorationType.Cross:
                dc.DrawLine(ThinPen, ParentEquation.Location, new Point(Right, ParentEquation.Bottom));
                dc.DrawLine(ThinPen, new Point(Left, ParentEquation.Bottom), new Point(Right, ParentEquation.Top));
                break;

            case DecorationType.LeftCross:
                dc.DrawLine(ThinPen, ParentEquation.Location, new Point(Right, ParentEquation.Bottom));
                break;

            case DecorationType.RightCross:
                dc.DrawLine(ThinPen, new Point(Left, ParentEquation.Bottom), new Point(Right, ParentEquation.Top));
                break;

            case DecorationType.StrikeThrough:
                dc.DrawLine(ThinPen, new Point(Left, ParentEquation.MidY), new Point(Right, ParentEquation.MidY));
                break;
            }
        }
예제 #3
0
        void PaintRound(DrawingContext dc)
        {
            if (Height < BracketBreakLimit)
            {
                if (SignType == BracketSignType.LeftRound)
                {
                    signText.DrawTextTopLeftAligned(dc, new Point(SignLeft, Top));
                }
                else
                {
                    signText.DrawTextTopRightAligned(dc, new Point(SignRight, Top));
                }
            }
            else
            {
                if (SignType == BracketSignType.LeftRound)
                {
                    double left = Math.Floor(SignLeft);
                    signText.DrawTextTopLeftAligned(dc, new Point(left, Top));
                    signText2.DrawTextBottomLeftAligned(dc, new Point(left, Bottom));
                    double top    = Top + signText.Extent * .9;
                    double bottom = Bottom - signText2.Extent * .9;
                    //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent;
                    double padding  = extension.OverhangLeading;
                    var    geometry = extension.BuildGeometry(new Point(left - padding, 0));

                    PointCollection points = new PointCollection {
                        new Point(geometry.Bounds.Right, top),
                        new Point(geometry.Bounds.Right, bottom),
                        new Point(geometry.Bounds.Left, bottom),
                    };
                    dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points);

                    //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68);
                    //dc.DrawLine(pen, new Point(SignLeft + pen.Thickness * .68, top),
                    //                 new Point(SignLeft + pen.Thickness * .68, bottom));

                    ////double topExtra = extension.Height + extension.OverhangAfter - extension.Extent;
                    ////double padding = extension.OverhangLeading;
                    ////var geometry = extension.BuildGeometry(new Point(SignLeft - padding, top - topExtra));
                    ////Pen pen = new Pen(Brushes.Black, geometry.Bounds.Width);
                    ////dc.DrawLine(pen, new Point(SignLeft + pen.Thickness - padding * 1.2, top),
                    ////                 new Point(SignLeft + LineThickness - padding * 1.2, bottom));
                    //var geometry2 = extension.BuildGeometry(new Point(SignLeft - 10, (top - topExtra)/2));
                    //var geometry3 = extension.BuildGeometry(new Point(SignLeft - 20, 10));
                    //double factor = (bottom - top) / (extension.Extent);
                    //ScaleTransform scale = new ScaleTransform(1.0, factor);
                    //scale.CenterY = extension.Extent / 2;
                    //scale.CenterY = geometry2.Bounds.Height;
                    //geometry2.Transform = scale;
                    //ScaleTransform scale2 = new ScaleTransform(1.0, 3);
                    //geometry3.Transform = scale2;
                    //dc.DrawGeometry(Brushes.Red, null, geometry);
                    //dc.DrawGeometry(Brushes.Blue, null, geometry2);
                    //dc.DrawGeometry(Brushes.Green, null, geometry3);
                    //var geo = Geometry.Combine(geometry, geometry, GeometryCombineMode.Intersect, scale);
                    //dc.DrawGeometry(Brushes.HotPink, null, geo);
                    //dc.PushTransform(scale);
                    //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent;
                    //double padding = extension.OverhangLeading;
                    //dc.DrawText(extension, new Point(SignLeft - padding, top - (topExtra/factor)));
                    //dc.Pop();

                    //while (top < bottom)
                    //{
                    //    extension.DrawTextTopLeftAligned(dc, new Point(SignLeft, top));
                    //    top += extension.Extent *.85;
                    //    double shoot = (top + extension.Extent) - bottom;
                    //    if (shoot > 0)
                    //    {
                    //        top -= shoot;
                    //        extension.DrawTextTopLeftAligned(dc, new Point(SignLeft, top));
                    //        break;
                    //    }
                    //}
                }
                else
                {
                    signText.DrawTextTopRightAligned(dc, new Point(SignRight, Top));
                    signText2.DrawTextBottomRightAligned(dc, new Point(SignRight, Bottom));
                    double top      = Top + signText.Extent * .9;
                    double bottom   = Bottom - signText2.Extent * .9;
                    var    geometry = extension.BuildGeometry(new Point(SignRight - extension.GetFullWidth() - extension.OverhangLeading, 0));

                    PointCollection points = new PointCollection {
                        new Point(geometry.Bounds.Right, top),
                        new Point(geometry.Bounds.Right, bottom),
                        new Point(geometry.Bounds.Left, bottom),
                    };
                    dc.FillPolylineGeometry(new Point(geometry.Bounds.Left, top), points);
                    //double topExtra = extension.Height + extension.OverhangAfter - extension.Extent;
                    ////double padding = extension.OverhangLeading;
                    ////var geometry = extension.BuildGeometry(new Point(SignLeft, top));
                    ////Pen pen = new Pen(Brushes.Black, geometry.Bounds.Width);
                    ////dc.DrawLine(pen, new Point(SignRight - pen.Thickness * .65, top),
                    ////                 new Point(SignRight - pen.Thickness * .65, bottom));
                    //dc.DrawLine(new Pen(Brushes.Red, 1), new Point(SignLeft, Top), new Point(SignLeft, Bottom));
                    //Pen pen = PenManager.GetPen(extension.GetFullWidth() * .68);
                    //dc.DrawLine(pen, new Point(SignRight - pen.Thickness * .68, top),
                    //                 new Point(SignRight - pen.Thickness * .68, bottom));
                    //while (top < bottom)
                    //{
                    //    extension.DrawTextTopRightAligned(dc, new Point(left + signText.GetFullWidth(), top));
                    //    top += extension.Extent * .85;
                    //    double shoot = (top + extension.Extent) - bottom;
                    //    if (shoot > 0)
                    //    {
                    //        top -= shoot;
                    //        extension.DrawTextTopRightAligned(dc, new Point(left + signText.GetFullWidth(), top));
                    //        break;
                    //    }
                    //}
                }
            }
        }