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

            //We can be either near the degree or the radicand
            var degreeRect       = self.Degree != null ? new RectangleF(self.Degree.Position, self.Degree.DisplayBounds.Size) : default;
            var radicandRect     = new RectangleF(self.Radicand.Position, self.Radicand.DisplayBounds.Size);
            var degreeDistance   = DistanceFromPointToRect(point, degreeRect);
            var radicandDistance = DistanceFromPointToRect(point, radicandRect);

            if (degreeDistance < radicandDistance)
            {
                if (self.Degree != null)
                {
                    return(MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Degree, self.Degree.IndexForPoint(context, point)));
                }
                return(MathListIndex.Level0Index(self.Range.Location));
            }
            else
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Radicand, self.Radicand.IndexForPoint(context, point)));
            }
        }
コード例 #2
0
ファイル: RadicalDisplay.cs プロジェクト: yoshiask/CSharpMath
 public static void Highlight <TFont, TGlyph>(
     this RadicalDisplay <TFont, TGlyph> self,
     Color color) where TFont : IFont <TGlyph>
 {
     self.Degree?.Highlight(color);
     self.Radicand.Highlight(color);
 }
コード例 #3
0
        public static MathListIndex IndexForPoint <TFont, TGlyph>(this RadicalDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, PointF point) where TFont : IFont <TGlyph>
        {
            // We can be before or after the radical
            if (point.X < self.Position.X - PixelDelta)
            {
                //We are before the radical, so
                return(MathListIndex.Level0Index(self.Range.Location));
            }
            else if (point.X > self.Position.X + self.Width + PixelDelta)
            {
                //We are after the radical
                return(MathListIndex.Level0Index(self.Range.End));
            }

            //We can be either near the degree or the radicand
            var degreeDistance   = DistanceFromPointToRect(point, self.Degree?.DisplayBounds ?? default);
            var radicandDistance = DistanceFromPointToRect(point, self.Radicand.DisplayBounds);

            if (degreeDistance < radicandDistance)
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, self.Degree.IndexForPoint(context, point), MathListSubIndexType.Numerator));
            }
            else
            {
                return(MathListIndex.IndexAtLocation(self.Range.Location, self.Radicand.IndexForPoint(context, point), MathListSubIndexType.Denominator));
            }
        }
コード例 #4
0
 public static void HighlightCharacterAt <TFont, TGlyph>(this RadicalDisplay <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);
 }
コード例 #5
0
 public static PointF?PointForIndex <TFont, TGlyph>(this RadicalDisplay <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 radical
     return(new PointF(self.DisplayBounds.Right, self.Position.Y));
 }
コード例 #6
0
ファイル: RadicalDisplay.cs プロジェクト: yoshiask/CSharpMath
   public static MathListIndex IndexForPoint <TFont, TGlyph>(
       this RadicalDisplay <TFont, TGlyph> self,
       TypesettingContext <TFont, TGlyph> context,
       PointF point) where TFont : IFont <TGlyph> =>
   // We can be before or after the radical
   point.X <self.Position.X - PixelDelta
            //We are before the radical, so
            ?MathListIndex.Level0Index(self.Range.Location)
            : point.X> self.Position.X + self.Width + PixelDelta
   //We are after the radical
 ? MathListIndex.Level0Index(self.Range.End)
   //We can be either near the degree or the radicand
   : DistanceFromPointToRect(point, self.Degree != null ? new RectangleF(self.Degree.Position, self.Degree.DisplayBounds().Size) : default)
   < DistanceFromPointToRect(point, new RectangleF(self.Radicand.Position, self.Radicand.DisplayBounds().Size))
 ? self.Degree != null
   ? MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Degree, self.Degree.IndexForPoint(context, point))
   : MathListIndex.Level0Index(self.Range.Location)
   : MathListIndex.IndexAtLocation(self.Range.Location, MathListSubIndexType.Radicand, self.Radicand.IndexForPoint(context, point));
コード例 #7
0
ファイル: RadicalDisplay.cs プロジェクト: yoshiask/CSharpMath
        public static PointF?PointForIndex <TFont, TGlyph>(
            this RadicalDisplay <TFont, TGlyph> self,
            TypesettingContext <TFont, TGlyph> _,
            MathListIndex index) where TFont : IFont <TGlyph>
        {
            if (index.SubIndexType != MathListSubIndexType.None)
            {
                throw new ArgumentException("The subindex must be none to get the closest point for it.", nameof(index));
            }

            if (index.AtomIndex == self.Range.End)
            {
                // draw a caret after the radical
                return(self.Position.Plus(new PointF(self.DisplayBounds().Right, 0)));
            }
            // draw a caret before the radical
            return(self.Position);
        }
コード例 #8
0
        public static ListDisplay <TFont, TGlyph> SubListForIndexType <TFont, TGlyph>(this RadicalDisplay <TFont, TGlyph> self, MathListSubIndexType type) where TFont : IFont <TGlyph>
        {
            switch (type)
            {
            case MathListSubIndexType.Radicand:
                return(self.Radicand);

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

            default:
                throw ArgOutOfRange("Subindex type is not a radical subtype.", type, nameof(type));
            }
        }
コード例 #9
0
        public static void Highlight <TFont, TGlyph>(this RadicalDisplay <TFont, TGlyph> self, Color color) where TFont : IFont <TGlyph>
        {
#warning Is including Degree intended? It is not present in iosMath
            self.Degree.Highlight(color);
            self.Radicand.Highlight(color);
        }