void ShowPhosResults(bool batch = false, bool mappingMeasure = false) { var phosResWindow = new View.PhosResultsWindow(); PhosResultsViewModel phosResultsVM = null; if (batch) { //phosResultsVM = new PhosResultsViewModel(CamResList, SpeResList); if (mappingMeasure) { phosResultsVM = new PhosResultsViewModel(CamResList, SpeResList, PeakInfoListList, DiamondResList, MarkerList, _camResultsPre, true, _cameraVM.GetRectMarker()); } else { phosResultsVM = new PhosResultsViewModel(CamResList, SpeResList, PeakInfoListList, DiamondResList, _cameraVM.GetMarkedPointsList(), _camResultsPre); } } else { //phosResultsVM = new PhosResultsViewModel(_camPhosResults, _spectrometerPhosResults); phosResultsVM = new PhosResultsViewModel(_camPhosResults, _spectrometerPhosResults, _peakInfoList, _diamondResult, _cameraVM.GetMarkedPointsList(), _camResultsPre); } phosResWindow.DataContext = phosResultsVM; phosResWindow.Closing += phosResultsVM.OnWindowClosing; phosResWindow.Closed += OnResultWindowClosed; phosResWindow.Loaded += phosResultsVM.OnWindowLoaded; phosResWindow.Owner = Window.GetWindow(Application.Current.MainWindow); phosResWindow.ShowDialog(); }
void Save(bool all = false) { _busy = true; View.PhosResultsWindow mw = (View.PhosResultsWindow)Application.Current.Windows.OfType <Window>().Last(); Application.Current.Dispatcher.BeginInvoke(new Action(System.Windows.Input.CommandManager.InvalidateRequerySuggested)); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += SaveDoWork; bw.RunWorkerCompleted += SaveCompleted; bw.RunWorkerAsync(new SaveArgs(all, mw.TabSummary)); }
void UpdateMarker() { View.PhosResultsWindow mw = (View.PhosResultsWindow)Application.Current.Windows.OfType <Window>().Last(); mw.CanvasResult.Children.Clear(); Tuple <System.Windows.Shapes.Ellipse, TextBlock, Point> t = MarkerList[(int)CurrentListItem]; string saved = XamlWriter.Save(t.Item1); System.Windows.Shapes.Ellipse ellipse = (System.Windows.Shapes.Ellipse)XamlReader.Load(XmlReader.Create(new StringReader(saved))); ellipse.Width *= CurrentListItem == 0 ? 1 : 2; ellipse.Height *= CurrentListItem == 0 ? 1 : 2; ellipse.SetValue(Canvas.LeftProperty, t.Item3.X - ellipse.Width / 2.0); ellipse.SetValue(Canvas.TopProperty, t.Item3.Y - ellipse.Height / 2.0); mw.CanvasResult.Children.Add(ellipse); }
void UpdateSummary() { View.PhosResultsWindow mw = (View.PhosResultsWindow)Application.Current.Windows.OfType <Window>().Last(); for (int i = 0; i < MarkerList.Count; i++) { if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement") && i == 0) { continue; } Tuple <System.Windows.Shapes.Ellipse, TextBlock, Point> t = MarkerList[i]; string savedEllipse = XamlWriter.Save(t.Item1); string savedText = XamlWriter.Save(t.Item2); System.Windows.Shapes.Ellipse ellipse = (System.Windows.Shapes.Ellipse)XamlReader.Load(XmlReader.Create(new StringReader(savedEllipse))); System.Windows.Controls.TextBlock txt = (TextBlock)XamlReader.Load(XmlReader.Create(new StringReader(savedText))); if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement")) { ellipse.Width *= 2; ellipse.Height *= 2; ellipse.Stroke = ColorLegendList[(int)DiamondResList[i - 1]]; txt.FontSize = 48; txt.Foreground = ColorLegendList[(int)DiamondResList[i - 1]]; } else { ellipse.Stroke = ColorLegendList[(int)DiamondResult]; } ellipse.SetValue(Canvas.LeftProperty, t.Item3.X - ellipse.Width / 2.0); ellipse.SetValue(Canvas.TopProperty, t.Item3.Y - ellipse.Height / 2.0); txt.SetValue(Canvas.LeftProperty, t.Item3.X - 15); txt.SetValue(Canvas.TopProperty, t.Item3.Y - 76); mw.CanvasSummary.Children.Add(ellipse); if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement")) { mw.CanvasSummary.Children.Add(txt); } if (!DisplayName.Equals("PhosResultsViewModelBatchMeasurement") && i == 0) { break; } } if (!mappingMeasure) { double x = 50; double y = 50; for (int i = 0; i < ColorLegendList.Count; i++) { DrawCanvas.Rect(x, y, 30, 30, ColorLegendList[i - 2], mw.CanvasSummary); DrawCanvas.Text(x + 50, y, ResultString(i - 2), true, ColorLegendList[i - 2], mw.CanvasSummary, false); y += 40; } } else { // rectangle mask double x = Canvas.GetLeft(RectMark); double y = Canvas.GetTop(RectMark); double w = RectMark.Width; double h = RectMark.Height; System.Windows.Shapes.Rectangle tmpRect = DrawCanvas.Rect(x, y, (int)w, (int)h, Brushes.Red, mw.CanvasSummary, 0.3); } }