コード例 #1
0
        /// <summary>
        /// Test whether object intersects with rectangle
        /// </summary>
        public override bool IntersectsWith(Rect rectangle)
        {
            RectangleGeometry rg = new RectangleGeometry(rectangle);

            LineGeometry lg = new LineGeometry(lineStart, lineEnd);
            PathGeometry widen = lg.GetWidenedPathGeometry(new Pen(Brushes.Black, LineHitTestWidth));

            PathGeometry p = Geometry.Combine(rg, widen, GeometryCombineMode.Intersect, null);

            return (!p.IsEmpty());
        }
コード例 #2
0
ファイル: AnnotationAdorner.cs プロジェクト: BdGL3/CXPortal
        protected void CheckResizeLines(Point cursorPt)
        {
            // Determine if the cursor is over a line for resizing
            ResizeTopLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.TopLeft, _FocusedAnnotation.Marking.Rect.TopRight);
            ResizeLeftLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.TopLeft, _FocusedAnnotation.Marking.Rect.BottomLeft);
            ResizeBottomLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.BottomLeft, _FocusedAnnotation.Marking.Rect.BottomRight);
            ResizeRightLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.TopRight, _FocusedAnnotation.Marking.Rect.BottomRight);

            if (ResizeBottomLine.GetWidenedPathGeometry(_FocusedAnnotation.Pen).StrokeContains(_FocusedAnnotation.Pen, cursorPt))
            {
                this.Cursor = System.Windows.Input.Cursors.SizeNS;
                ResizeTopLine = null;
            }
            else if (ResizeTopLine.GetWidenedPathGeometry(_FocusedAnnotation.Pen).StrokeContains(_FocusedAnnotation.Pen, cursorPt))
            {
                this.Cursor = System.Windows.Input.Cursors.SizeNS;
                ResizeBottomLine = null;
            }
            else
            {
                ResizeBottomLine = null;
                ResizeTopLine = null;
            }

            if (ResizeRightLine.GetWidenedPathGeometry(_FocusedAnnotation.Pen).StrokeContains(_FocusedAnnotation.Pen, cursorPt))
            {
                if (ResizeBottomLine != null)
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeNWSE;
                }
                else if (ResizeTopLine != null)
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeNESW;
                }
                else
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeWE;
                }
                ResizeLeftLine = null;
            }
            else if (ResizeLeftLine.GetWidenedPathGeometry(_FocusedAnnotation.Pen).StrokeContains(_FocusedAnnotation.Pen, cursorPt))
            {

                if (ResizeBottomLine != null)
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeNESW;
                }
                else if (ResizeTopLine != null)
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeNWSE;
                }
                else
                {
                    this.Cursor = System.Windows.Input.Cursors.SizeWE;
                }
                ResizeRightLine = null;
            }
            else
            {
                ResizeRightLine = null;
                ResizeLeftLine = null;
            }
        }