Exemple #1
0
        public void SelectNearest(Point coord)
        {
            // convert everything to screen coordinates to get the visually closest line
            var           cursor          = coord.DataToScreen(Plotter2D.Transform);
            RadioBandLine closest         = null;
            double        closestDistance = double.MaxValue;

            foreach (var line in GetLines())
            {
                Point  leftPoint  = new Point(line.Start, line.GroupAxisCoord).DataToScreen(Plotter2D.Transform);
                Point  rightPoint = new Point(line.End, line.GroupAxisCoord).DataToScreen(Plotter2D.Transform);
                double distance   = MathHelper.DistancePointToSegment(cursor, (leftPoint, rightPoint)).distance;
                if (distance < closestDistance)
                {
                    closestDistance = distance;
                    closest         = line;
                }
                line.IsSelected = false;
            }
            closest.IsSelected = true;
        }
Exemple #2
0
 public void AddLine(RadioBandLine radioBandLine) => Children.Add(radioBandLine);