Esempio n. 1
0
        private void NewMark(HashSet <Mark> marks, HashSet <FigureBBox> bBoxes, FigureBBox overBBox, DoMarksProperties props, double sx, double sy, int directionX, int directionY)
        {
            if (PointOutside(overBBox, sx, sy, props))
            {
                return;
            }

            var height = props.MarkHeight;

            do
            {
                var ex = directionX * height + sx;
                var ey = directionY * height + sy;
                if (PointInside(bBoxes, ex, ey))
                {
                    if (props.CanDecrease)
                    {
                        height -= decrement;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    marks.Add(new Mark(new Point(sx, sy), new Point(ex, ey)));
                    break;
                }
            } while (height > 0);
        }
Esempio n. 2
0
        public void DoSmartTrimMarks(DoMarksProperties props, ShapeRange sr)
        {
            HashSet <FigureBBox> figureBBoxes = GetFigureBBoxes(sr, props);
            FigureBBox           overBBox     = GetOverlapBBox(figureBBoxes);
            HashSet <Mark>       marks        = LayoutMarks(figureBBoxes, overBBox, props);

            DrawMarks(marks, props);
        }
Esempio n. 3
0
        private HashSet <Mark> LayoutMarks(HashSet <FigureBBox> bBoxes, FigureBBox overBBox, DoMarksProperties props)
        {
            var marks = new HashSet <Mark>();

            foreach (var bbox in bBoxes)
            {
                NewMark(marks, bBoxes, overBBox, props, bbox.X, bbox.Top - props.Offset, -1, 0);
                NewMark(marks, bBoxes, overBBox, props, bbox.X, bbox.Y + props.Offset, -1, 0);
                NewMark(marks, bBoxes, overBBox, props, bbox.X + props.Offset, bbox.Y, 0, -1);
                NewMark(marks, bBoxes, overBBox, props, bbox.Right - props.Offset, bbox.Y, 0, -1);
                NewMark(marks, bBoxes, overBBox, props, bbox.Right, bbox.Y + props.Offset, 1, 0);
                NewMark(marks, bBoxes, overBBox, props, bbox.Right, bbox.Top - props.Offset, 1, 0);
                NewMark(marks, bBoxes, overBBox, props, bbox.Right - props.Offset, bbox.Top, 0, 1);
                NewMark(marks, bBoxes, overBBox, props, bbox.X + props.Offset, bbox.Top, 0, 1);
            }
            return(marks);
        }
Esempio n. 4
0
 private bool PointOutside(FigureBBox box, double x, double y, DoMarksProperties props)
 {
     if (props.ExcludeLeftEdge && x < box.X + safeZone)
     {
         return(true);
     }
     if (props.ExcludeRightEdge && x > box.Right - safeZone)
     {
         return(true);
     }
     if (props.ExcludeTopEdge && y > box.Top - safeZone)
     {
         return(true);
     }
     if (props.ExcludeBottomEdge && y < box.Y + safeZone)
     {
         return(true);
     }
     return(false);
 }