示例#1
0
        public override bool HiTest(double double_0, IPoint ipoint_0, out IPoint ipoint_1, ref double double_1,
                                    ref int int_0, ref int int_1, out bool bool_0)
        {
            ipoint_1 = null;
            bool_0   = false;
            bool     flag       = false;
            IHitTest mPGeometry = this.m_pGeometry as IHitTest;

            ipoint_1 = new ESRI.ArcGIS.Geometry.Point();
            bool_0   = false;
            bool flag1 = false;

            if (
                !mPGeometry.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                    ref double_1, ref int_0, ref int_1, ref flag1))
            {
                bool_0 = false;
            }
            else
            {
                flag   = true;
                bool_0 = true;
            }
            return(flag);
        }
示例#2
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            var arc      = shape as ArcShape ?? throw new ArgumentNullException("shape");
            var distance = arc.StartPoint.DistanceTo(arc.Point);

            return(arc.StartPoint.ToRect2(distance).Contains(target) ? shape : null);
        }
 public AGSHasCursorComponent(IGameEvents events, IHitTest hitTest, IGameState state)
 {
     _events  = events;
     _hitTest = hitTest;
     _state   = state;
     events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
 }
示例#4
0
        /// <summary>
        /// 角度同步,点与线的角度同步
        /// </summary>
        /// <param name="pPolyline">线</param>
        /// <param name="pPoint">线附近的点(许可的范围内)</param>
        /// <param name="dAngle">返回点符号的角度</param>
        /// <param name="pRetPoint">返回的在线上的点的位置</param>
        /// <returns>是否可以同步角度(如果距离过大,无法执行角度同步)</returns>
        public static bool SynchronizeAngle(IPolyline pPolyline, IPoint pPoint, ref double dAngle, ref IPoint pRetPoint)
        {
            double   dRadius         = 10;
            IPoint   pHitPoint       = new PointClass();
            IHitTest pHitTest        = pPolyline as IHitTest;
            double   hitDist         = 0.0;
            int      hitPartIndex    = 0;
            int      hitSegmentIndex = 0;
            bool     bRightSide      = false;

            bool bPointOnLine = pHitTest.HitTest(pPoint, dRadius, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint, ref hitDist, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);

            if (bPointOnLine)
            {
                if (distance(pHitPoint, pPoint) < 0.0001)
                {
                    pRetPoint = null;
                }
                else
                {
                    pRetPoint = pHitPoint;
                }

                ISegmentCollection pSegment = pPolyline as ISegmentCollection;
                ILine pLine = pSegment.get_Segment(hitSegmentIndex) as ILine;
                dAngle = pLine.Angle;
                return(true);
            }
            return(false);
        }
示例#5
0
        public bool HitTest(Rect contentRect, Vector2 point)
        {
            if (!contentRect.Contains(point))
            {
                return(false);
            }

            bool flag = false;
            int  cnt  = elements.Count;

            for (int i = 0; i < cnt; i++)
            {
                IHitTest ht = elements[i] as IHitTest;
                if (ht != null)
                {
                    if (ht.HitTest(contentRect, point))
                    {
                        return(true);
                    }
                }
                else
                {
                    flag = true;
                }
            }

            return(flag);
        }
示例#6
0
        //捕捉
        public IPoint Snapping(double x, double y, IFeatureLayer featureLayer)
        {
            IMap          map          = this.axMapControl1.Map;
            IActiveView   activeView   = this.axMapControl1.ActiveView;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IPoint        point        = new PointClass();

            point.PutCoords(x, y);

            IFeature feature     = featureClass.GetFeature(0);
            IPoint   hitPoint1   = new PointClass();
            IPoint   hitPoint2   = new PointClass();
            IHitTest hitTest     = feature.Shape as IHitTest;
            double   hitDist     = 0;
            int      partIndex   = 0;
            int      vertexIndex = 0;
            bool     bVertexHit  = false;

            double tol = ConvertPixelsToMapUnits(activeView, 8);

            if (hitTest.HitTest(point, tol, esriGeometryHitPartType.esriGeometryPartBoundary,
                                hitPoint2, ref hitDist, ref partIndex, ref vertexIndex, ref bVertexHit))
            {
                hitPoint1 = hitPoint2;
            }
            axMapControl1.ActiveView.Refresh();
            return(hitPoint1);
        }
示例#7
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is PathShape path))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var pathShape in path.Shapes)
            {
                var result = pathShape.Bounds?.Overlaps(pathShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    return(result);
                }
            }

            var points = new List <IPointShape>();

            path.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Overlap(points, target) ? shape : null);
        }
        private static bool PointAffectsShape([NotNull] IPoint testPoint,
                                              double searchRadius,
                                              [NotNull] IPointCollection newPoints,
                                              [NotNull] IPoint prevPoint,
                                              [NotNull] IPoint nextPoint,
                                              [NotNull] ILine line,
                                              int pointIndex)
        {
            GetPreviousPoint(newPoints, pointIndex, ref prevPoint);
            GetNextPoint(newPoints, pointIndex, ref nextPoint);
            line.PutCoords(prevPoint, nextPoint);

            double distance = 0;
            var    right    = false;
            IPoint hitPoint = new PointClass();

            var lineHitPartIndex    = 0;
            var lineHitSegmentIndex = 0;

            IHitTest lineHitTest = GeometryUtils.GetHitTest(line, true);

            bool inLine = lineHitTest.HitTest(testPoint, searchRadius,
                                              esriGeometryHitPartType.esriGeometryPartBoundary,
                                              hitPoint, ref distance,
                                              ref lineHitPartIndex,
                                              ref lineHitSegmentIndex, ref right);

            return(!inLine);
        }
示例#9
0
        private void onGameWindowLoaded(TypedParameter settingsParameter, IGameSettings settings)
        {
            TypedParameter gameWindowParameter = new TypedParameter(typeof(IGameWindow), GameWindow);

            Settings = _resolver.Container.Resolve <IRuntimeSettings>(settingsParameter, gameWindowParameter);

            _graphics.ClearColor(0f, 0f, 0f, 1f);

            _graphics.Init();
            _glUtils.GenBuffers();

            Factory = _resolver.Container.Resolve <IGameFactory>();

            IAGSInput input = _resolver.Container.Resolve <IAGSInput>();

            input.Init(settings.VirtualResolution);
            Input = input;
            TypedParameter inputParamater = new TypedParameter(typeof(IInput), Input);
            TypedParameter gameParameter  = new TypedParameter(typeof(IGame), this);

            RenderLoop = _resolver.Container.Resolve <IRendererLoop>(inputParamater, gameParameter, gameWindowParameter);
            updateResolver();
            HitTest       = _resolver.Container.Resolve <IHitTest>();
            AudioSettings = _resolver.Container.Resolve <IAudioSettings>();
            SaveLoad      = _resolver.Container.Resolve <ISaveLoad>();

            _glUtils.AdjustResolution(settings.VirtualResolution.Width, settings.VirtualResolution.Height);

            Events.OnLoad.Invoke();
        }
        private static bool IsValidBoundaryPoint([NotNull] IPoint testPoint,
                                                 [NotNull] IHitTest orgHitTest,
                                                 double searchRadius,
                                                 [NotNull] IHitTest newHitTest,
                                                 out int hitSegmentIndex)
        {
            // init out parameters to invalid value
            int hitPartIndex = -2;

            hitSegmentIndex = 2;

            // If points exists on the original, can not be removed
            bool inOriginal = ExistsInOriginal(testPoint, orgHitTest, searchRadius);

            if (inOriginal)
            {
                return(false);
            }

            // If point doesnt not exists on the new, can not be removed
            bool inNew = ExistsInNew(testPoint, searchRadius, newHitTest,
                                     ref hitPartIndex, ref hitSegmentIndex);

            if (!inNew)
            {
                return(false);
            }

            return(true);
        }
        private static void RemovePoint(IGeometry geometry, IPoint point, double searchRadius)
        {
            double   distance        = 0;
            var      right           = false;
            IPoint   hitPoint        = new PointClass();
            int      hitSegmentIndex = -2;
            int      hitPartIndex    = -2;
            IHitTest hitTest         = GeometryUtils.GetHitTest(geometry, true);

            bool found = hitTest.HitTest(point, searchRadius,
                                         esriGeometryHitPartType.esriGeometryPartVertex, hitPoint,
                                         ref distance, ref hitPartIndex,
                                         ref hitSegmentIndex, ref right);

            if (!found)
            {
                return;
            }

            IGeometry partGeometry = geometry is IGeometryCollection
                                                         ? GeometryUtils.GetHitGeometryPart(
                point, geometry, searchRadius)
                                                         : geometry;

            Assert.NotNull(partGeometry, "Geometry part at point {0} not found",
                           GeometryUtils.ToString(point));

            RemovePoint(geometry, hitPartIndex, hitSegmentIndex, partGeometry);
        }
示例#12
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is CanvasContainer container))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var containerShape in container.Shapes)
            {
                var result = containerShape.Bounds?.Contains(containerShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    return(container);
                }
            }

            var points = new List <IPointShape>();

            container.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
示例#13
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is GroupShape group))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var groupShape in group.Shapes.Reverse())
            {
                var result = groupShape.Bounds?.Contains(groupShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    if (modifier.HasFlag(Modifier.Shift))
                    {
                        return(result);
                    }
                    else
                    {
                        return(group);
                    }
                }
            }

            var points = new List <IPointShape>();

            group.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
示例#14
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            var circle   = shape as CircleShape ?? throw new ArgumentNullException("shape");
            var distance = circle.StartPoint.DistanceTo(circle.Point);

            return(circle.StartPoint.ToRect2(distance).IntersectsWith(target) ? shape : null);
        }
示例#15
0
 public void OnMouseDown(int button, int shift, int x, int y)
 {
     if (button == 1)
     {
         double mouseTolerance;
         IPoint queryPoint = this._viewMap.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         if (queryPoint.SpatialReference != (EditTask.EditLayer.FeatureClass as IGeoDataset).SpatialReference)
         {
             queryPoint.Project((EditTask.EditLayer.FeatureClass as IGeoDataset).SpatialReference);
             queryPoint.SpatialReference = (EditTask.EditLayer.FeatureClass as IGeoDataset).SpatialReference;
             mouseTolerance = ToolConfig.MouseTolerance1;
         }
         else
         {
             mouseTolerance = ToolConfig.MouseTolerance;
         }
         double buffer = this._viewMap.ScreenDisplay.DisplayTransformation.FromPoints(mouseTolerance);
         if (this._isVertexEditing)
         {
             if (this._isSnaped)
             {
                 this._isVertexSelected = true;
                 int      hitSegmentIndex = -1;
                 double   searchRadius    = buffer;
                 IHitTest linageShape     = Editor.UniqueInstance.LinageShape as IHitTest;
                 IPoint   hitPoint        = null;
                 double   hitDistance     = 0.0;
                 bool     bRightSide      = false;
                 int      hitPartIndex    = -1;
                 foreach (LinkArgs args in this._las)
                 {
                     (args.feature.ShapeCopy as IHitTest).HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
                     args.PartIndex = hitPartIndex;
                     args.VertexIndex.Add(hitSegmentIndex);
                 }
                 this._feedBack.Start((Editor.UniqueInstance.LinageShape as IGeometryCollection).get_Geometry(0) as IPath, this._vertexIndex, false);
             }
             else
             {
                 if (!(Editor.UniqueInstance.LinageShape as IRelationalOperator).Equals(this._editOrigShape))
                 {
                     this.SaveEdit();
                     this._viewMap.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, this._editBound.Envelope);
                 }
                 Marshal.ReleaseComObject(this._editOrigShape);
                 Marshal.ReleaseComObject(Editor.UniqueInstance.LinageShape);
                 Editor.UniqueInstance.LinageShape = null;
                 this._editInfoList.Clear();
                 this.InitLinkage(queryPoint, buffer);
             }
         }
         else
         {
             this._editInfoList.Clear();
             this.InitLinkage(queryPoint, buffer);
         }
     }
 }
示例#16
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is IPointShape point))
            {
                throw new ArgumentNullException("shape");
            }

            return(Point2.FromXY(point.X, point.Y).ExpandToRect(radius).IntersectsWith(target) ? shape : null);
        }
示例#17
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is IPointShape point))
            {
                throw new ArgumentNullException("shape");
            }

            return(Point2.FromXY(point.X, point.Y).ExpandToRect(radius).Contains(target.X, target.Y) ? shape : null);
        }
示例#18
0
        public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0)
        {
            bool flag;

            if (EditorLicenseProviderCheck.Check())
            {
                IPoint ipoint0   = ipoint_0;
                double length    = 1000;
                bool   flag1     = false;
                ILine  lineClass = new Line();
                for (int i = 0; i < this.ifeatureCache_0.Count; i++)
                {
                    IGeometry shape = this.ifeatureCache_0.Feature[i].Shape;
                    if (shape is ISegmentCollection)
                    {
                        IHitTest hitTest = (IHitTest)shape;
                        if ((hitTest is IPolyline ? true : hitTest is IPolygon))
                        {
                            double num        = 0;
                            int    num1       = 0;
                            int    num2       = 0;
                            bool   flag2      = true;
                            IPoint pointClass = new ESRI.ArcGIS.Geometry.Point();
                            if (hitTest.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary,
                                                pointClass, ref num, ref num1, ref num2, ref flag2))
                            {
                                ISegment segment =
                                    ((shape as IGeometryCollection).Geometry[num1] as ISegmentCollection).Segment[num2];
                                if (segment is ICircularArc)
                                {
                                    pointClass = ((ICircularArc)segment).CenterPoint;
                                    lineClass.PutCoords(ipoint0, pointClass);
                                    if (!flag1)
                                    {
                                        length = lineClass.Length;
                                        ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                        flag1 = true;
                                    }
                                    else if (length > lineClass.Length)
                                    {
                                        length = lineClass.Length;
                                        ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                        flag1 = true;
                                    }
                                }
                            }
                        }
                    }
                }
                flag = flag1;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
示例#19
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is PathShape path))
            {
                throw new ArgumentNullException("shape");
            }

            if (modifier.HasFlag(Modifier.Shift))
            {
                if (path.Shapes.Count >= 1)
                {
                    foreach (var pathShape in path.Shapes.Reverse())
                    {
                        var pathShapePoints = new List <IPointShape>();
                        pathShape.GetPoints(pathShapePoints);

                        if (HitTestHelper.Contains(pathShapePoints, target))
                        {
                            if (modifier.HasFlag(Modifier.Alt))
                            {
                                var result = pathShape.Bounds?.Contains(pathShape, target, radius, hitTest, modifier);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(pathShape);
                        }
                    }
                }
            }
            else
            {
                foreach (var pathShape in path.Shapes.Reverse())
                {
                    var result = pathShape.Bounds?.Contains(pathShape, target, radius, hitTest, modifier);
                    if (result != null)
                    {
                        if (modifier.HasFlag(Modifier.Alt))
                        {
                            var subResult = result.Bounds?.Contains(result, target, radius, hitTest, Modifier.Shift);
                            if (subResult != null)
                            {
                                return(subResult);
                            }
                        }
                        return(path);
                    }
                }
            }

            var points = new List <IPointShape>();

            path.GetPoints(points);

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
示例#20
0
        public static bool TestGeometryHit(double double_0, IPoint ipoint_0, IGeometry igeometry_0, out IPoint ipoint_1,
                                           ref double double_1, ref int int_0, ref int int_1, out bool bool_0)
        {
            bool     flag;
            bool     flag1      = false;
            IHitTest igeometry0 = igeometry_0 as IHitTest;

            ipoint_1 = new ESRI.ArcGIS.Geometry.Point();
            bool_0   = false;
            bool flag2 = false;

            if (
                !(igeometry_0.GeometryType == esriGeometryType.esriGeometryPoint
                    ? false
                    : igeometry_0.GeometryType != esriGeometryType.esriGeometryMultipoint))
            {
                if (
                    !igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
                {
                    bool_0 = false;
                }
                else
                {
                    flag1  = true;
                    bool_0 = true;
                }
                flag = flag1;
            }
            else if (igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
            {
                bool_0 = true;
                flag   = true;
            }
            else if (igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
            {
                bool_0 = false;
                flag   = true;
            }
            else if ((igeometry_0.GeometryType == esriGeometryType.esriGeometryEnvelope
                         ? false
                         : igeometry_0.GeometryType != esriGeometryType.esriGeometryPolygon) ||
                     !((IRelationalOperator)igeometry_0).Contains(ipoint_0))
            {
                flag = false;
            }
            else
            {
                int_0  = -1;
                bool_0 = false;
                flag   = true;
            }
            return(flag);
        }
示例#21
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            var oval = shape as OvalShape ?? throw new ArgumentNullException("shape");

            return(Rect2.FromPoints(
                       oval.StartPoint.X,
                       oval.StartPoint.Y,
                       oval.Point.X,
                       oval.Point.Y).IntersectsWith(target) ? shape : null);
        }
示例#22
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            var rectangle = shape as RectangleShape ?? throw new ArgumentNullException("shape");

            return(Rect2.FromPoints(
                       rectangle.StartPoint.X,
                       rectangle.StartPoint.Y,
                       rectangle.Point.X,
                       rectangle.Point.Y).Contains(target) ? shape : null);
        }
示例#23
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            if (m_pFeature == null)
            {
                return;
            }
            IPoint pPnt = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            //鼠标在选择集的范围外为选择功能
            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {//若光标不在选择的对象上,为选择功能
                ControlsEditSelFeature clsSelectFeature = new ControlsEditSelFeature();
                clsSelectFeature.OnCreate(m_hookHelper.Hook);
                clsSelectFeature.OnClick();
                m_MapControl.CurrentTool = clsSelectFeature as ITool;
                return;
            }
            //范围内为移动要素功能且不在要素节点上
            else if (ModPublic.MouseOnFeatureVertex(pPnt, m_pFeature, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {
                ControlsMoveSelFeature pControlsMoveSelFeature = new ControlsMoveSelFeature();
                pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                pControlsMoveSelFeature.OnClick();
                m_MapControl.CurrentTool = pControlsMoveSelFeature as ITool;
                return;
            }


            if (m_pVertexFeed == null)
            {
                return;
            }
            //捕捉节点
            if (MoData.v_bSnapStart)
            {
                m_pSnapPoint = ModPublic.SnapPoint(pPnt, m_hookHelper.ActiveView);
            }

            IHitTest pHitTest           = m_pFeature.Shape as IHitTest;
            IPoint   pHitPoint          = new PointClass();
            double   dblHitDistance     = 0;
            int      lPart              = 0;
            int      intHitSegmentIndex = 0;
            bool     bRight             = false;
            bool     bHitTest           = pHitTest.HitTest(pPnt, m_dblTolearance, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref dblHitDistance, ref lPart, ref intHitSegmentIndex, ref bRight);

            if (m_pSnapPoint != null && MoData.v_bSnapStart)
            {
                m_pVertexFeed.MoveTo(m_pSnapPoint);
            }
            else
            {
                m_pVertexFeed.MoveTo(pPnt);
            }
        }
示例#24
0
        private int _inUpdate; //For preventing re-entrancy

        public UIEventsAggregator(IInput input, IHitTest hitTest, IGameEvents gameEvents, IFocusedUI focus)
        {
            _hitTest             = hitTest;
            _focus               = focus;
            _subscribersToAdd    = new ConcurrentQueue <Subscriber>();
            _subscribersToRemove = new ConcurrentQueue <string>();
            _input               = input;
            _gameEvents          = gameEvents;
            _subscribers         = new List <Subscriber>(100);
            gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }
示例#25
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is LineShape line))
            {
                throw new ArgumentNullException("shape");
            }

            var a = new Point2(line.StartPoint.X, line.StartPoint.Y);
            var b = new Point2(line.Point.X, line.Point.Y);

            return(Line2.LineIntersectsWithRect(a, b, target, out _, out _, out _, out _) ? shape : null);
        }
示例#26
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is CubicBezierShape cubicBezier))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            cubicBezier.GetPoints(points);

            return(HitTestHelper.Overlap(points, target) ? shape : null);
        }
示例#27
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is ConicShape conic))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            conic.GetPoints(points);

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
示例#28
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is LineShape line))
            {
                throw new ArgumentNullException("shape");
            }

            var    a        = new Point2(line.StartPoint.X, line.StartPoint.Y);
            var    b        = new Point2(line.Point.X, line.Point.Y);
            var    nearest  = target.NearestOnLine(a, b);
            double distance = target.DistanceTo(nearest);

            return(distance < radius ? shape : null);
        }
示例#29
0
 /// <summary>
 /// 几何形状点击查询测试
 /// </summary>
 /// <param name="geometry">ESRI几何形状接口</param>
 /// <param name="queryPoint">查询点的ESRI几何形状接口</param>
 /// <param name="searchRadius">搜索半径</param>
 /// <param name="geometryPart">搜索命中的几何形状部位</param>
 /// <param name="hitPoint">搜索命中点的ESRI点接口</param>
 /// <param name="hitDistance">搜索命中的距离</param>
 /// <param name="hitPartIndex">搜索命中的几何形状部位索引</param>
 /// <param name="hitSegmentIndex">搜索命中的几何形状部位片段索引</param>
 /// <param name="bRightSide">是否命中几何形状的右方</param>
 /// <param name="hit">是否命中</param>
 public static void GeometryHitTest(IGeometry geometry, IPoint queryPoint, double searchRadius,
                                    out esriGeometryHitPartType geometryPart, out IPoint hitPoint, out double hitDistance,
                                    out int hitPartIndex, out int hitSegmentIndex, out bool bRightSide, out bool hit)
 {
     geometryPart    = esriGeometryHitPartType.esriGeometryPartNone;
     hitPoint        = new ESRI.ArcGIS.Geometry.Point();
     hitDistance     = -1;
     hitPartIndex    = -1;
     hitSegmentIndex = -1;
     bRightSide      = false;
     hit             = false;
     if (IsValidGeometry(geometry) && (geometry is IHitTest))
     {
         IHitTest hitTest = (IHitTest)geometry;
         geometryPart = esriGeometryHitPartType.esriGeometryPartVertex;
         hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                        ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartBoundary;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartMidpoint;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartEndpoint;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartCentroid;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartSurface;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
     }
 }
                public void TestDrop()
                {
                    Point pt = MousePosition;

                    DockPane = DockHelper.PaneAtPoint(pt, DockPanel);

                    if (TestDrop(PanelLeft, pt) != DockStyle.None)
                    {
                        HitTestResult = PanelLeft;
                    }
                    else if (TestDrop(PanelRight, pt) != DockStyle.None)
                    {
                        HitTestResult = PanelRight;
                    }
                    else if (TestDrop(PanelTop, pt) != DockStyle.None)
                    {
                        HitTestResult = PanelTop;
                    }
                    else if (TestDrop(PanelBottom, pt) != DockStyle.None)
                    {
                        HitTestResult = PanelBottom;
                    }
                    else if (TestDrop(PanelFill, pt) != DockStyle.None)
                    {
                        HitTestResult = PanelFill;
                    }
                    else if (TestDrop(PaneDiamond, pt) != DockStyle.None)
                    {
                        HitTestResult = PaneDiamond;
                    }
                    else
                    {
                        HitTestResult = null;
                    }

                    if (HitTestResult != null)
                    {
                        if (HitTestResult is IPaneIndicator)
                        {
                            DragHandler.Outline.Show(DockPane, HitTestResult.Status);
                        }
                        else
                        {
                            DragHandler.Outline.Show(DockPanel, HitTestResult.Status, FullPanelEdge);
                        }
                    }
                }
 private static DockStyle TestDrop(IHitTest hitTest, Point pt)
 {
     return hitTest.Status = hitTest.HitTest(pt);
 }