private void OnMouseAnyEvent(MouseEventArgs e) { APlotVM viewModel = ViewModel; if (viewModel == null) { return; } Viewport3D viewPort = this.GetViewport(); Point mousePosition = e.GetPosition(this); Ray3D ray = viewPort.GetRay(mousePosition); IList <HitResult> hitResult = viewPort.FindHits(mousePosition); Model3D[] hits = new Model3D[hitResult.Count]; for (int i = 0; i < hitResult.Count; i++) { hits[i] = hitResult[i].Model; } MouseInput mouseInput = new MouseInput(e.LeftButton, e.MiddleButton, e.RightButton, ray.PlaneIntersection(new Point3D(), new Vector3D(0, 0, 1)), hits); viewModel.UserInput(mouseInput); }
private void OnSetViewModel(APlotVM viewModelOld) { if (viewModelOld != null) { viewModelOld.PropertyChanged -= PlotPropertyChanged; } if (ViewModel != null) { ViewModel.PropertyChanged += PlotPropertyChanged; Visual3DModel = ViewModel.Model3d; } else { Visual3DModel = null; } }