コード例 #1
0
        protected void AddRangeBracket(AnnotationMarkerLayoutBox marker)
        {
            Color bracketColor = GetBracketColor();

            Point           topPoint;
            Point           bottomPoint;
            InlineLayoutBox inlineBox = marker;

            if (marker.AssociatedAnnotationMarker is AnnotationRangeStart)
            {
                inlineBox = (InlineLayoutBox)DocumentStructureCollection.GetNextSiblingForDocumentElement(marker, null);

                topPoint = new Point(
                    inlineBox.ControlBoundingRectangle.Left,
                    inlineBox.ControlBoundingRectangle.Top - (inlineBox.LineInfo.BaselineOffset - inlineBox.BaselineOffset));

                bottomPoint = new Point(topPoint.X, topPoint.Y + inlineBox.LineInfo.Height);
            }
            else
            {
                inlineBox = (InlineLayoutBox)DocumentStructureCollection.GetPreviousSiblingForDocumentElement(marker, null);

                topPoint = new Point(
                    inlineBox.ControlBoundingRectangle.Right,
                    inlineBox.ControlBoundingRectangle.Top - (inlineBox.LineInfo.BaselineOffset - inlineBox.BaselineOffset));

                bottomPoint = new Point(topPoint.X, topPoint.Y + inlineBox.LineInfo.Height);
            }


            Polyline polyline = new Polyline();

            Canvas.SetZIndex(polyline, 5);
            polyline.Stroke          = new SolidColorBrush(bracketColor);
            polyline.StrokeThickness = 1;
            if (marker.AssociatedAnnotationMarker is AnnotationRangeStart)
            {
                polyline.Points.Add(new Point(topPoint.X + 2, topPoint.Y));
                polyline.Points.Add(topPoint);
                polyline.Points.Add(bottomPoint);
                polyline.Points.Add(new Point(bottomPoint.X + 2, bottomPoint.Y));
            }
            else
            {
                polyline.Points.Add(new Point(topPoint.X - 2, topPoint.Y));
                polyline.Points.Add(topPoint);
                polyline.Points.Add(bottomPoint);
                polyline.Points.Add(new Point(bottomPoint.X - 2, bottomPoint.Y));
            }

            base.AddDecorationElement(polyline);
        }
コード例 #2
0
        private void FlushBoxes(DocumentPosition startPosition, DocumentPosition endPosition)
        {
            if (startPosition == endPosition)
            {
                return;
            }
            RectangleF rect = new RectangleF();

            rect.X     = startPosition.Location.X;
            rect.Width = endPosition.Location.X - startPosition.Location.X;

            InlineLayoutBox startBox = startPosition.GetCurrentInlineBox();
            InlineLayoutBox endBox   = endPosition.GetCurrentInlineBox();

            float top    = startBox.ControlBoundingRectangle.Top;
            float bottom = startBox.ControlBoundingRectangle.Bottom;

            while (startBox != endBox)
            {
                startBox = DocumentStructureCollection.GetNextSiblingForDocumentElementOnSameLevel(startBox, startBox.AssociatedDocumentElement) as InlineLayoutBox;
                if (startBox == null)
                {
                    break;
                }
                if (startBox.ControlBoundingRectangle.Top < top)
                {
                    top = startBox.ControlBoundingRectangle.Top;
                }
                if (startBox.ControlBoundingRectangle.Bottom < bottom)
                {
                    bottom = startBox.ClippedControlBoundingRectangle.Bottom;
                }
            }
            rect.Y      = top;
            rect.Height = bottom - top;

            this.AddRectangle(rect);
        }