Esempio n. 1
0
        public static MathListIndex IndexForPoint <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, PointF point) where TFont : IFont <TGlyph>
        {
            // We can be before or after the fraction
            if (point.X < self.Position.X - PixelDelta)
            {
                //We are before the fraction, so
                return(MathListIndex.Level0Index(self.Range.Location));
            }
            else if (point.X > self.Position.X + self.Width + PixelDelta)
            {
                //We are after the fraction
                return(MathListIndex.Level0Index(self.Range.End));
            }

            if (point.Y > self.LinePosition + PixelDelta)
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Numerator, self.Numerator.IndexForPoint(context, point)));
            }
            else if (point.Y < self.LinePosition - PixelDelta)
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Denominator, self.Denominator.IndexForPoint(context, point)));
            }
            if (point.X > self.Position.X + self.Width / 2)
            {
                return(MathListIndex.Level0Index(self.Range.End));
            }

            return(MathListIndex.Level0Index(self.Range.Location));
        }
        public static MathListIndex IndexForPoint <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, PointF point) where TFont : IFont <TGlyph>
        {
            // We can be before or after the fraction
            if (point.X < self.Position.X - PixelDelta)
            {
                //We are before the fraction, so
                return(MathListIndex.Level0Index(self.Range.Location));
            }
            else if (point.X > self.Position.X + self.Width + PixelDelta)
            {
                //We are after the fraction
                return(MathListIndex.Level0Index(self.Range.End));
            }

            //We can be either near the numerator or denominator
            var numeratorDistance   = DistanceFromPointToRect(point, self.Numerator.DisplayBounds);
            var denominatorDistance = DistanceFromPointToRect(point, self.Denominator.DisplayBounds);

            if (numeratorDistance < denominatorDistance)
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, self.Numerator.IndexForPoint(context, point), MathListSubIndexType.Numerator));
            }
            else
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, self.Denominator.IndexForPoint(context, point), MathListSubIndexType.Denominator));
            }
        }
Esempio n. 3
0
 public static void HighlightCharacterAt <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, MathListIndex index, Color color) where TFont : IFont <TGlyph>
 {
     if (index.SubIndexType != MathListSubIndexType.None)
     {
         throw Arg("The subindex must be none to get the highlight a character in it.", nameof(index));
     }
     self.Highlight(color);
 }
 public static PointF?PointForIndex <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, MathListIndex index) where TFont : IFont <TGlyph>
 {
     if (index.SubIndexType != MathListSubIndexType.None)
     {
         throw Arg("The subindex must be none to get the closest point for it.", nameof(index));
     }
     // draw a caret after the fraction
     return(new PointF(self.DisplayBounds.Right, self.Position.Y));
 }
Esempio n. 5
0
   public static PointF?PointForIndex <TFont, TGlyph>(
       this FractionDisplay <TFont, TGlyph> self,
       TypesettingContext <TFont, TGlyph> _,
       MathListIndex index) where TFont : IFont <TGlyph> =>
   index.SubIndexType != MathListSubIndexType.None
 ? throw new ArgumentException
             ("The subindex must be none to get the closest point for it.", nameof(index))
         : index.AtomIndex == self.Range.End
         // draw a caret after the fraction
 ? self.Position.Plus(new PointF(self.DisplayBounds().Right, 0))
         // draw a caret before the fraction
         : self.Position;
Esempio n. 6
0
        public static ListDisplay <TFont, TGlyph> SubListForIndexType <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, MathListSubIndexType type) where TFont : IFont <TGlyph>
        {
            switch (type)
            {
            case MathListSubIndexType.Numerator:
                return(self.Numerator);

            case MathListSubIndexType.Denominator:
                return(self.Denominator);

            default:
                throw ArgOutOfRange("Subindex type is not a fraction subtype.", type, nameof(type));
            }
        }
Esempio n. 7
0
 public static void Highlight <TFont, TGlyph>(this FractionDisplay <TFont, TGlyph> self, Color color) where TFont : IFont <TGlyph>
 {
     self.Numerator.Highlight(color);
     self.Denominator.Highlight(color);
 }