Example #1
0
        public void MouseUpHandler(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Released)
            {
                if (rectW != 0 && rectH != 0 && currentPoint.X != 0 && currentPoint.Y != 0)
                {
                    if (rectW < 0)
                    {
                        currentPoint.X = currentPoint.X + rectW;
                        rectW          = -rectW;
                    }

                    if (rectH < 0)
                    {
                        currentPoint.Y = currentPoint.Y + rectH;
                        rectH          = -rectH;
                    }
                    //RemoveTempMarker();
                    MainWindow mv = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                    tmpRect = DrawCanvas.Rect(currentPoint.X, currentPoint.Y, (int)rectW, (int)rectH, Brushes.Red, mv.CanvasDraw, 0.3);

                    currentPoint = default(Point);
                    rectW        = 0;
                    rectH        = 0;
                }
            }
        }
Example #2
0
        private void OnRectMaskSelected(object sender, RectMaskEventArgs e)
        {
            if (e.Width == 0 && e.Height == 0 && e.ActuralW == 0 && e.ActuralH == 0)
            {
                RemoveTempMarker();
            }
            else
            {
                RemoveTempMarker();
                MainWindow mv = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                double     x  = e.P.X / e.ActuralW * Width;
                double     y  = e.P.Y / e.ActuralH * Height;
                double     w  = e.Width * Width / e.ActuralW;
                double     h  = e.Height * Height / e.ActuralH;

                tmpRect = DrawCanvas.Rect(x, y, (int)w, (int)h, Brushes.Red, mv.CanvasDraw, 0.3);
            }
        }
Example #3
0
        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);
            }
        }