private void OnServiceRobotTrajectorySet(object sender, TrajectorySetEventArguments e) { var robotId = e.RobotDescartesTrajectory.RobotId; var item = RobotMonitoringItems.FirstOrDefault(robotMonitoringItem => robotMonitoringItem.Guid == robotId); if (item != null) { item.StartPoint = e.RobotDescartesTrajectory.Trajectory.First(); item.Trajectory = new PointCollection(e.RobotDescartesTrajectory.Trajectory); item.Title = e.RobotDescartesTrajectory.RobotTitle; } else { var random = new Random(); var robotMonitoringItem = new RobotMonitoringItemViewModel { StartPoint = e.RobotDescartesTrajectory.Trajectory.First(), Trajectory = new PointCollection(e.RobotDescartesTrajectory.Trajectory), Color = Color.FromRgb(Convert.ToByte(random.Next(256)), Convert.ToByte(random.Next(256)), Convert.ToByte(random.Next(256))), Guid = e.RobotDescartesTrajectory.RobotId, Title = e.RobotDescartesTrajectory.RobotTitle }; RobotMonitoringItems.Add(robotMonitoringItem); } }
protected virtual void OnTrajectorySet(TrajectorySetEventArguments e) { RobotTrajectorySet?.Invoke(this, e); }