private void OnPointSelected(object sender, PointSelectedEventArgs e) { if (mainVM == null) { mainVM = (MainWindowVM)Application.Current.Windows.OfType <MainWindow>().FirstOrDefault().DataContext; } double width = mainVM.CameraVM.Width; double height = mainVM.CameraVM.Height; if (StartPointChecked) { if (PositionList.Count == 0) { MessageBox.Show("Please select the End point or Calibrate first, then select Start point", "Warning"); return; } StartPoint = new Point(e.Value.X / e.Width * width, e.Value.Y / e.Height * height); AddNewPosition(StartPoint); } else if (EndPointChecked) { if (xyPixelInMMCalculated) { EndPoint = new Point(e.Value.X / e.Width * width, e.Value.Y / e.Height * height); ReplaceRefPosition(EndPoint); } else { MessageBox.Show("Please calibrate the device first", "Warning"); } } }
protected virtual void RaisePointSelectedEvent(PointSelectedEventArgs eventArgs) { PointSelected?.Invoke(this, eventArgs); }