private void SetPointFlag(RectangleF rect) { Matrix matrix = DisplayMatrix.Clone(); if (!matrix.IsInvertible) { return; } matrix.Invert(); PointF[] fs = new PointF[] { rect.Location, new PointF(rect.Right, rect.Bottom) }; matrix.TransformPoints(fs); PointLayout.PixelToPointMatrix.TransformPoints(fs); RectangleF rectangle = RectangleF.FromLTRB(Math.Min(fs[0].X, fs[1].X), Math.Min(fs[0].Y, fs[1].Y), Math.Max(fs[0].X, fs[1].X), Math.Max(fs[0].Y, fs[1].Y)); foreach (LayoutPoint point in PointLayout.Points) { if (rectangle.Contains((int)Math.Round(point.Point.X), (int)Math.Round(point.Point.Y))) { point.Selected = true; } else { point.Selected = false; } } }
private void SetPointFlag(PointF pixel, float distance) { Matrix matrix = DisplayMatrix.Clone(); if (!matrix.IsInvertible) { return; } matrix.Invert(); PointF[] fs = new PointF[] { pixel }; matrix.TransformPoints(fs); PointLayout.PixelToPointMatrix.TransformPoints(fs); foreach (LayoutPoint point in PointLayout.Points) { point.Selected = false; } foreach (LayoutPoint point in PointLayout.Points) { if (Math.Sqrt(Math.Pow(fs[0].X - point.Point.X, 2) + Math.Pow(fs[0].Y - point.Point.Y, 2)) < distance) { point.Selected = true; break; } } }