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


C# Point.Where方法代码示例

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


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

示例1: GetNeighbors

    public static IEnumerable<Point> GetNeighbors(Point point, Func<Point, bool> isPassable)
    {
        var neighbors = new Point[] {
            new Point(point.x - 1, point.y),
            new Point(point.x + 1, point.y),
            new Point(point.x, point.y - 1),
            new Point(point.x, point.y + 1)
        };

        return neighbors.Where(n => n.IsOnBoard() && isPassable(n));
    }
开发者ID:BobBuehler,项目名称:megaminerai13,代码行数:11,代码来源:Pather.cs

示例2: _addSeriesAsPolyline

        private IEnumerable<Shape> _addSeriesAsPolyline(Point[] points, Brush color, double storkeThickness,
            bool animate = true)
        {
            if (points.Length < 2) return Enumerable.Empty<Shape>();
            var addedFigures = new List<Shape>();

            var l = 0d;
            for (var i = 1; i < points.Length; i++)
            {
                var p1 = points[i - 1];
                var p2 = points[i];
                l += Math.Sqrt(
                    Math.Pow(Math.Abs(p1.X - p2.X), 2) +
                    Math.Pow(Math.Abs(p1.Y - p2.Y), 2)
                    );
            }

            var f = points.First();
            var p = points.Where(x => x != f);
            var g = new PathGeometry
            {
                Figures = new PathFigureCollection(new List<PathFigure>
                {
                    new PathFigure
                    {
                        StartPoint = f,
                        Segments = new PathSegmentCollection(
                            p.Select(x => new LineSegment {Point = new Point(x.X, x.Y)}))
                    }
                })
            };

            var path = new Path
            {
                Stroke = color,
                StrokeThickness = storkeThickness,
                Data = g,
                StrokeEndLineCap = PenLineCap.Round,
                StrokeStartLineCap = PenLineCap.Round,
                StrokeDashOffset = l,
                StrokeDashArray = new DoubleCollection { l, l },
                ClipToBounds = true
            };

            var sp = points.ToList();
            sp.Add(new Point(points.Max(x => x.X), ToPlotArea(Chart.Min.Y, AxisTags.Y)));

            Chart.Canvas.Children.Add(path);
            addedFigures.Add(path);

            var draw = new DoubleAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromSeconds(0),
                KeyFrames = new DoubleKeyFrameCollection
                {
                    new SplineDoubleKeyFrame
                    {
                        KeyTime = TimeSpan.FromMilliseconds(1),
                        Value = l
                    },
                    new SplineDoubleKeyFrame
                    {
                        KeyTime = TimeSpan.FromMilliseconds(750),
                        Value = 0
                    }
                }
            };
            Storyboard.SetTarget(draw, path);
            Storyboard.SetTargetProperty(draw, new PropertyPath(Shape.StrokeDashOffsetProperty));
            var sbDraw = new Storyboard();
            sbDraw.Children.Add(draw);
            var animated = false;
            if (!Chart.DisableAnimation)
            {
                if (animate)
                {
                    sbDraw.Begin();
                    animated = true;
                }
            }
            if (!animated) path.StrokeDashOffset = 0;
            return addedFigures;
        }
开发者ID:gitter-badger,项目名称:Live-Charts,代码行数:83,代码来源:ScatterSeries.cs

示例3: SetBuilding

    private bool SetBuilding(Vector3 ray, BuildingType type)
    {
        //проверяем блоки по спирали от центра
        int startX, startY;
        GetPosition(ray, out startX, out startY);

        var x = startX;
        var y = startY;

        // задаем границы движения
        var minX = x; var maxX = x; // влево вправо
        var minY = y; var maxY = y; // вверх вниз
        var direction = SpiralDirection.Up; // сначала пойдем вверх

        var n = (int)type;

        var points = new Point[n * n];

        for (var i = 0; i < n * n; i++)
        {
            var result = _cellsController.CheckFree(x, y);
            if (result == null || !result.Value)
            {
                foreach (var point in points.Where(s => s != null))
                {
                    _cellsController.SetFree(point.X, point.Y);
                }
                return false;
            }

            points[i] = new Point {X = x, Y = y};
           _cellsController.SetBusy(x, y);

            FillSpiralStep(ref x, ref y, ref direction, ref minX, ref minY, ref maxX, ref maxY);
        }

        var position = type == BuildingType.Size2X2 ? new Vector3(startX + 0.5f, 0.5f, startY - 0.5f) : new Vector3(startX, 0.5f, startY);

        var buildingObject = (GameObject)Instantiate(Buildings[(int)type - 1], position, Quaternion.identity);
        var building = buildingObject.GetComponent<Building>();
        building.Points = points;

        if (CurrentBuildingSize != BuildingType.None)
            building.SetShadowMode();

        _buildings.Add(building);

        return true;
    }
开发者ID:dampirik,项目名称:ByTrilobiteSoft,代码行数:49,代码来源:MainLogic.cs

示例4: ConvexHull

        public static Point[] ConvexHull(Point[] points)
        {
            if (points.Length < 3)
            {
                throw new ArgumentException("At least 3 points reqired", "points");
            }

            List<Point> hull = new List<Point>();

            // get leftmost point
            Point vPointOnHull = points.Where(p => p.X == points.Min(min => min.X)).First();

            Point vEndpoint;
            do
            {
                hull.Add(vPointOnHull);
                vEndpoint = points[0];

                for (int i = 1; i < points.Length; i++)
                {
                    if ((vPointOnHull == vEndpoint)
                        || (Orientation(vPointOnHull, vEndpoint, points[i]) == -1))
                    {
                        vEndpoint = points[i];
                    }
                }

                vPointOnHull = vEndpoint;
            }
            while (vEndpoint != hull[0]);

            return hull.ToArray();
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:33,代码来源:Divider.cs

示例5: getCroppedRectangle

		Rect getCroppedRectangle(Point [] cachedPoints)
		{
			var xMin = cachedPoints.Where (point => point != new Point (-10000, -10000)).Min (point => point.X) - LineWidth / 2;
			var xMax = cachedPoints.Where (point => point != new Point (-10000, -10000)).Max (point => point.X) + LineWidth / 2;
			var yMin = cachedPoints.Where (point => point != new Point (-10000, -10000)).Min (point => point.Y) - LineWidth / 2;
			var yMax = cachedPoints.Where (point => point != new Point (-10000, -10000)).Max (point => point.Y) + LineWidth / 2;

			xMin = Math.Max (xMin, 0);
			xMax = Math.Min (xMax, ActualWidth);
			yMin = Math.Max (yMin, 0);
			yMax = Math.Min (yMax, ActualHeight);

			return new Rect (xMin, yMin, xMax - xMin, yMax - yMin);
		}
开发者ID:ronrat,项目名称:SignaturePad,代码行数:14,代码来源:SignaturePad.xaml.cs

示例6: ExpandComplete

        private static IEnumerable<Point> ExpandComplete( Point P, int width, int height )
        {
            IEnumerable<Point> Points = new Point[] {
              new Point( P.X - 1, P.Y + 1),
              new Point( P.X + 1, P.Y - 1 ),
              new Point( P.X - 1, P.Y - 1 ),
              new Point( P.X + 1, P.Y + 1 ),

              new Point( P.X - 1, P.Y ),
              new Point( P.X + 1, P.Y ),
              new Point( P.X, P.Y - 1 ),
              new Point( P.X, P.Y + 1 ),
            };

              return Points.Where( p => p.X >= 0 && p.Y >= 0 && p.X < width && p.Y < height );
        }
开发者ID:Mokon,项目名称:mai,代码行数:16,代码来源:ChokepointGridWorldMaker.cs


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