public void LoadInput(SingleTrajectoryInput inp) { Visible = false; input = inp; LookAtTrajectory(input.Trajectory); foreach (var p in input.Trajectory) { PickManager.AssignPickId(p); } Visible = true; }
private void HandleMouseDown(object sender, MouseEventArgs e) { int pickId = Pick(e.X, e.Y); if (e.Button == MouseButtons.Left) { if (PickManager.PickingHit(pickId)) { //clicked on point lastSelectedPoint = (TPoint2D)PickManager.GetPickedObject(pickId); } else { //clicked on empty space for new point int index = input.Trajectory.IndexOf(lastSelectedPoint); if (!input.Trajectory.Any()) //fresh trajectory { index = -1; } else if (index == -1) //last selected point was removed { index = input.Trajectory.Count - 1; } var worldCoord = GetWorldCoordinates(e.X, e.Y); var point = input.Trajectory.InsertPoint(worldCoord.X, worldCoord.Y, index + 1); PickManager.AssignPickId(point); lastSelectedPoint = point; } draggingPoint = true; } else if (e.Button == MouseButtons.Right) { if (PickManager.PickingHit(pickId)) { //clicked on point TPoint2D pointToBeRemoved = (TPoint2D)PickManager.GetPickedObject(pickId); input.Trajectory.RemovePoint(pointToBeRemoved); } } Refresh(); }