当前位置: 首页>>代码示例>>C#>>正文


C# BoundingRectangle.ContainsPoint方法代码示例

本文整理汇总了C#中BoundingRectangle.ContainsPoint方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingRectangle.ContainsPoint方法的具体用法?C# BoundingRectangle.ContainsPoint怎么用?C# BoundingRectangle.ContainsPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingRectangle的用法示例。


在下文中一共展示了BoundingRectangle.ContainsPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        /// <summary>
        /// Читает запись представляющую точку.
        /// </summary>
        /// <param name="file">Входной поток</param>
        /// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
        /// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
        public override bool Read(/*BigEndianBinaryReader*/Stream file, BoundingRectangle bounds, ShapeFileRecord record)
        {

            ICoordinate p = PlanimetryEnvironment.NewCoordinate(0, 0);
            p.X = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
            p.Y = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);

            if (bounds != null && !bounds.IsEmpty() && !bounds.ContainsPoint(p))
                return false;

            record.Points.Add(p);

            record.MinX = p.X;
            record.MinY = p.Y;
            record.MaxX = record.MinX;
            record.MaxY = record.MinY;

            return true;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:25,代码来源:PointHandler.cs

示例2: drawPolylineWithIntersectCalculation

        private void drawPolylineWithIntersectCalculation(Graphics g, Feature feature, PolylineStyle style, BoundingRectangle viewBox, double scaleFactor)
        {
            //selection and rims do not contain dashes, so it is better to paint the entire
            if (style.UseOutline || feature.Selected)
            {
                foreach (LinePath path in feature.Polyline.Paths)
                {
                    PointF[] points = new PointF[path.Vertices.Count];

                    for (int j = 0; j < path.Vertices.Count; j++)
                    {
                        points[j].X = (float)((path.Vertices[j].X - viewBox.MinX) * scaleFactor);
                        points[j].Y = (float)((viewBox.MaxY - path.Vertices[j].Y) * scaleFactor);
                    }

                    if (style.UseOutline || feature.Selected)
                        drawLinePathSelectionAndOutline(g, feature.Selected, points, style);
                }
            }

            List<ICoordinate> currentPath = new List<ICoordinate>();

            using (Pen pen = style.GetPen())
            {
                using(Pen annexPen = style.GetAnnexPen())
                foreach (LinePath path in feature.Polyline.Paths)
                {
                    if (path.Vertices.Count < 2)
                        continue;

                    currentPath.Clear();
                    double currentLength = 0;
                    bool isInternalPath = viewBox.ContainsPoint(path.Vertices[0]);
                    ICoordinate previousPoint = path.Vertices[0];
                    IList<ICoordinate> vertices = path.Vertices;

                    for (int j = 0; j < path.Vertices.Count; j++)
                    {
                        if (isInternalPath) // the inside of the polyline
                        {
                            if (viewBox.ContainsPoint(vertices[j])) //stay inside
                            {
                                currentPath.Add(vertices[j]);
                                continue;
                            }
                            else // go outside
                            {
                                // add a point of intersection
                                List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1], viewBox);
                                currentPath.Add(crossPoints[0]);

                                //draw
                                drawVisiblePolylinePartWithStyleDetection(g, currentPath, style, pen, annexPen, feature.Selected, viewBox, scaleFactor, currentLength);

                                // are counting the length of a past
                                currentLength += getPathLength(currentPath);

                                // initialize the array outside of the points, polylines and continue execution
                                currentPath.Clear();
                                currentPath.Add(crossPoints[0]);
                                currentPath.Add(vertices[j]);
                                isInternalPath = false;
                                continue;
                            }
                        }
                        else //the outer part of the polyline
                        {
                            if (viewBox.ContainsPoint(vertices[j])) // go inside
                            {
                                //add a point of intersection
                                List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1], viewBox);
                                currentPath.Add(crossPoints[0]);

                                //are counting the length of a past
                                currentLength += getPathLength(currentPath);

                                // initialize the array of points inside the polyline and continue execution
                                currentPath.Clear();
                                currentPath.Add(crossPoints[0]);
                                currentPath.Add(vertices[j]);
                                isInternalPath = true;
                                continue;
                            }
                            else // cross twice, or remain outside
                            {
                                // look for the point of intersection
                                if (j > 0)
                                {
                                    List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1], viewBox);
                                    if (crossPoints.Count == 0) // remained outside
                                    {
                                        currentPath.Add(vertices[j]);
                                        continue;
                                    }
                                    if (crossPoints.Count == 2) // crossed 2 times
                                    {
                                        //determine which of the points of intersection must be added to the current path
                                        double d0 = PlanimetryAlgorithms.Distance(crossPoints[0], vertices[j - 1]);
                                        double d1 = PlanimetryAlgorithms.Distance(crossPoints[1], vertices[j - 1]);
                                        if (d0 < d1)
//.........这里部分代码省略.........
开发者ID:gkrsu,项目名称:maparound.core,代码行数:101,代码来源:FeatureRendering.cs

示例3: getFollowingTitle

        private FollowingTitle getFollowingTitle(Graphics g, LinePath part, double length, string label, TitleStyle titleStyle, BoundingRectangle viewBox, double scaleFactor)
        {
            StringFormat format = StringFormat.GenericTypographic;
            SizeF sizeF;
            PointF zeroPoint = new PointF(0, 0);

            using (Font f = titleStyle.GetFont())
            {
                sizeF = g.MeasureString(label, f, zeroPoint, format);

                // label length must be less than the length of the line
                if (sizeF.Width / scaleFactor < length)
                {
                    LinePath tempPart = new LinePath();
                    foreach (ICoordinate p in part.Vertices)
                        tempPart.Vertices.Add(p);

                    int vertexNumber = 0;
                    ICoordinate centerPoint = getDistantPoint(tempPart.Vertices, length / 2, out vertexNumber);

                    // if the point of the proposed mid-label misses the display area of ​​the map, the inscription does not appear
                    if (!viewBox.ContainsPoint(centerPoint))
                        return null;

                    // simplify the line
                    tempPart.Weed(sizeF.Height / scaleFactor / 2);

                    //get the center point of the simplified line
                    centerPoint = getDistantPoint(tempPart.Vertices, length / 2, out vertexNumber);

                    List<double> leftPointsRotationDeltas = new List<double>();
                    List<double> rightPointsRotationDeltas = new List<double>();

                    // coordinates of points on the left of the middle of the inscription
                    IList<ICoordinate> leftPoints =
                        getLeftPoints(tempPart.Vertices,
                                      centerPoint,
                                      sizeF.Width / 2 / scaleFactor,
                                      vertexNumber,
                                      sizeF.Height / 2 / scaleFactor,
                                      leftPointsRotationDeltas);

                    // coordinates of the points to the right of the middle of the inscription
                    IList<ICoordinate> rightPoints =
                        getRightPoints(tempPart.Vertices,
                                       centerPoint,
                                       sizeF.Width / 2 / scaleFactor,
                                       vertexNumber,
                                       sizeF.Height / 2 / scaleFactor,
                                       rightPointsRotationDeltas);

                    //coordinates of the vertices of the broken line, which will be located along the inscription
                    List<ICoordinate> points = leftPoints.ToList();
                    points.AddRange(rightPoints);

                    // shifts of the inscriptions associated with break lines
                    List<double> rotationDeltas = leftPointsRotationDeltas;
                    rotationDeltas.AddRange(rightPointsRotationDeltas);

                    for (int i = 0; i < points.Count; i++)
                        points[i] = PlanimetryEnvironment.NewCoordinate((points[i].X - viewBox.MinX) * scaleFactor,
                                               (viewBox.MaxY - points[i].Y) * scaleFactor);

                    for (int i = 0; i < rotationDeltas.Count; i++)
                        rotationDeltas[i] = rotationDeltas[i] * scaleFactor;

                    //determine the direction of following labels (direct or reverse)
                    double forwardWeight = 0;
                    double backwardWeight = 0;

                    for (int i = 1; i < points.Count; i++)
                    {
                        Segment s = new Segment(PlanimetryEnvironment.NewCoordinate(points[i].X, points[i].Y),
                                                PlanimetryEnvironment.NewCoordinate(points[i - 1].X, points[i - 1].Y));
                        int quadNumber = pointQuadrantNumber(PlanimetryEnvironment.NewCoordinate(s.V1.X - s.V2.X, s.V1.Y - s.V2.Y));
                        if (quadNumber == 1 || quadNumber == 4)
                            forwardWeight += s.Length();
                        else
                            backwardWeight += s.Length();
                    }

                    if (backwardWeight > forwardWeight)
                    {
                        points.Reverse();
                        rotationDeltas.Reverse();
                    }

                    // inscriptions along the route should not be a large number of points
                    if (label.Length > points.Count - 2)
                    {
                        List<int> subStringLengths = new List<int>();
                        List<double> deltas = new List<double>();

                        LinePath p1 = new LinePath(points.ToArray());
                        double l = p1.Length();

                        // partition of the inscription on the straight parts, the calculation of displacement
                        int startIndex = 0;
                        for (int i = 1; i < points.Count; i++)
                        {
//.........这里部分代码省略.........
开发者ID:gkrsu,项目名称:maparound.core,代码行数:101,代码来源:FeatureRendering.cs

示例4: TryActivateNodeAt

        /// <summary>
        /// Tries to activate a node at the specified position.
        /// </summary>
        /// <param name="coordinate">A coordinate of node to be activated</param>
        /// <param name="nodeSize">A size of node</param>
        /// <returns>true if the node be activated, false otherwise</returns>
        public bool TryActivateNodeAt(ICoordinate coordinate, double nodeSize)
        {
            IEnumerable<ICoordinate> coordinates = _geometry.ExtractCoordinates();

            int i = 0;
            foreach (ICoordinate coord in coordinates)
            {
                BoundingRectangle br =
                    new BoundingRectangle(coord.X - nodeSize,
                        coord.Y - nodeSize,
                        coord.X + nodeSize,
                        coord.Y + nodeSize);

                if (br.ContainsPoint(coordinate))
                {
                    this.ActiveNodeNumber = i;

                    if (_geometry is Polygon)
                        oldActiveNodeCoordinate = (ICoordinate)(_geometry as Polygon).Contours[_activePatchIndex].Vertices[_activeCoordinateIndex].Clone();

                    if (_geometry is Polyline)
                        oldActiveNodeCoordinate = (ICoordinate)(_geometry as Polyline).Paths[_activePatchIndex].Vertices[_activeCoordinateIndex].Clone();

                    return true;
                }
                i++;
            }

            coordinates = this.GetSecondaryNodes();
            foreach (ICoordinate coord in coordinates)
            {
                BoundingRectangle br =
                    new BoundingRectangle(coord.X - nodeSize,
                        coord.Y - nodeSize,
                        coord.X + nodeSize,
                        coord.Y + nodeSize);

                if (br.ContainsPoint(coordinate))
                {
                    this.TryAddNode(coord);
                    return this.TryActivateNodeAt(coordinate, nodeSize);
                }
            }

            return false;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:52,代码来源:GeometryEditor.cs

示例5: drawPolylineWithIntersectCalculation

        private static void drawPolylineWithIntersectCalculation(JObject g, Feature feature, 
                                                          BoundingRectangle viewBox, double scaleFactor)
        {
            

            List<ICoordinate> currentPath = new List<ICoordinate>();

           
           
                    foreach (LinePath path in feature.Polyline.Paths)
                    {
                        if (path.Vertices.Count < 2)
                            continue;

                        currentPath.Clear();
                      
                        bool isInternalPath = viewBox.ContainsPoint(path.Vertices[0]);
                      
                        IList<ICoordinate> vertices = path.Vertices;

                        for (int j = 0; j < path.Vertices.Count; j++)
                        {
                            if (isInternalPath) // внутренняя часть полилинии
                            {
                                if (viewBox.ContainsPoint(vertices[j])) // остаемся внутри
                                {
                                    currentPath.Add(vertices[j]);
                                    continue;
                                }
                                else // выходим наружу
                                {
                                    // добавляем точку пересечения
                                    List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1], viewBox);
                                    currentPath.Add(crossPoints[0]);

                                    //рисуем
                                    drawVisiblePolylinePartWithStyleDetection(g, currentPath, 
                                                                              viewBox, scaleFactor);


                                    // инициализируем массив точек внешней части полилинии
                                    // и продолжаем выполнение
                                    currentPath.Clear();
                                    currentPath.Add(crossPoints[0]);
                                    currentPath.Add(vertices[j]);
                                    isInternalPath = false;
                                    continue;
                                }
                            }
                            else // внешняя часть полилинии
                            {
                                if (viewBox.ContainsPoint(vertices[j])) // входим внутрь
                                {
                                    // добавляем точку пересечения
                                    List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1], viewBox);
                                    currentPath.Add(crossPoints[0]);


                                    // инициализируем массив точек внутренней части полилинии
                                    // и продолжаем выполнение
                                    currentPath.Clear();
                                    currentPath.Add(crossPoints[0]);
                                    currentPath.Add(vertices[j]);
                                    isInternalPath = true;
                                    continue;
                                }
                                else // пересекаем дважды, либо остаемся снаружи
                                {
                                    // ищем точки пересечения
                                    if (j > 0)
                                    {
                                        List<ICoordinate> crossPoints = getCrossPoints(vertices[j], vertices[j - 1],
                                                                                       viewBox);
                                        if (crossPoints.Count == 0) // остались снаружи
                                        {
                                            currentPath.Add(vertices[j]);
                                            continue;
                                        }
                                        if (crossPoints.Count == 2) // пересекли 2 раза
                                        {
                                            // определяем какую из точек пересечения нужно добавить к текущему пути
                                            double d0 = PlanimetryAlgorithms.Distance(crossPoints[0], vertices[j - 1]);
                                            double d1 = PlanimetryAlgorithms.Distance(crossPoints[1], vertices[j - 1]);
                                            if (d0 < d1)
                                                currentPath.Add(crossPoints[0]);
                                            else
                                                currentPath.Add(crossPoints[1]);


                                            currentPath.Clear();

                                            currentPath.Add(crossPoints[d0 < d1 ? 0 : 1]);
                                            currentPath.Add(crossPoints[d0 < d1 ? 1 : 0]);

                                            // рисуем отрезок
                                            drawVisiblePolylinePartWithStyleDetection(g, currentPath, 
                                                                                      viewBox, scaleFactor
                                                                                      );
                                       

//.........这里部分代码省略.........
开发者ID:gkrsu,项目名称:maparound.core,代码行数:101,代码来源:MapServerBase.cs


注:本文中的BoundingRectangle.ContainsPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。