Exemplo n.º 1
0
        /// <summary>
        /// Show callibration mark on screen - circle and coordinates
        /// </summary>
        /// <param name="mark">Callibration mark as CircleF</param>
        /// <param name="key">Caliibration mark type</param>
        private void ShowCallibrationMark(CircleF mark, eCallibrationMark key)
        {
            switch (key)
            {
            case eCallibrationMark.ButtomLeft:
                UpdateMarkup(Helpers.eMarkupKey.BUTTOM_LEFT_CALLIBRATION_MARK,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                UpdateMarkup(Helpers.eMarkupKey.BUTTOM_LEFT_CALLIBRATION_TEXT,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.TopLeft:
                UpdateMarkup(Helpers.eMarkupKey.TOP_LEFT_CALLIBRATION_MARK,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                UpdateMarkup(Helpers.eMarkupKey.TOP_LEFT_CALLIBRATION_TEXT,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.TopRight:
                UpdateMarkup(Helpers.eMarkupKey.TOP_RIGHT_CALLIBRATION_MARK,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                UpdateMarkup(Helpers.eMarkupKey.TOP_RIGHT_CALLIBRATION_TEXT,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.ButtomRight:
                UpdateMarkup(Helpers.eMarkupKey.BUTTOM_RIGHT_CALLIBRATION_MARK,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                UpdateMarkup(Helpers.eMarkupKey.BUTTOM_RIGHT_CALLIBRATION_TEXT,
                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Show calibration mark on screen - circle and coordinates
        /// </summary>
        /// <param name="mark">Calibration mark as CircleF</param>
        /// <param name="key">Calibration mark type</param>
        public void ShowCalibrationMark(CircleF mark, eCallibrationMark key)
        {
            switch (key)
            {
            case eCallibrationMark.BL:
                Marks.DrawCallibrationCircle(eCallibrationMark.BL,
                                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.TL:
                Marks.DrawCallibrationCircle(eCallibrationMark.TL,
                                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.TR:
                Marks.DrawCallibrationCircle(eCallibrationMark.TR,
                                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;

            case eCallibrationMark.BR:
                Marks.DrawCallibrationCircle(eCallibrationMark.BR,
                                             new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draw the calibration circles on the canvas
        /// </summary>
        /// <param name="mark">The wanted calibration mark for drawing</param>
        /// <param name="center">Center of the given calibration mark</param>
        /// <param name="radius">Radius of the given calibration mark</param>
        /// <param name="circleColor">Optional color [default : Pink]</param>
        /// <param name="textColor">Optional text color [default : OrangeRed]</param>
        /// <param name="fontSize">Optional font size [default : 12 ]</param>
        /// <param name="text"></param>
        public static void DrawCallibrationCircle(eCallibrationMark mark, Point center, int radius,
                                                  SolidColorBrush circleColor = null, SolidColorBrush textColor = null, double fontSize = 12,
                                                  string text = "")
        {
            try
            {
                Point presentationCenter = new Point(center.X * _actualWidthRate, center.Y * _actualHeightRate);
                int   presentationRadius = Convert.ToInt32(radius * ((_actualWidthRate + _actualHeightRate) / 2));

                _dispatcher.Invoke(new ThreadStart(delegate
                {
                    int markNum = 0;
                    int textNum = 0;
                    switch (mark)
                    {
                    case eCallibrationMark.BL:
                        markNum = (int)eMarks.ButtomLeftMark;
                        textNum = (int)eMarks.ButtomLeftText;
                        break;

                    case eCallibrationMark.BR:
                        markNum = (int)eMarks.ButtomRightMark;
                        textNum = (int)eMarks.ButtomRightText;
                        break;

                    case eCallibrationMark.TL:
                        markNum = (int)eMarks.TopLeftMark;
                        textNum = (int)eMarks.TopLeftText;
                        break;

                    case eCallibrationMark.TR:
                        markNum = (int)eMarks.TopRightMark;
                        textNum = (int)eMarks.TopRightText;
                        break;
                    }

                    (_markups[markNum] as Shape).StrokeThickness = 2;
                    (_markups[markNum] as Shape).Stroke          = (circleColor == null) ? Brushes.Pink : circleColor;
                    (_markups[textNum] as TextBlock).FontSize    = fontSize;
                    (_markups[textNum] as TextBlock).Text        = (String.IsNullOrEmpty(text)) ? String.Format("{0}:{1}x{2}", mark, Convert.ToInt32(center.X), Convert.ToInt32(center.Y)) : text;
                    (_markups[textNum] as TextBlock).Foreground  = (textColor == null) ? Brushes.OrangeRed : textColor;

                    _markups[markNum].Width  = presentationRadius * 2;
                    _markups[markNum].Height = presentationRadius * 2;
                    Canvas.SetLeft(_markups[markNum], presentationCenter.X - presentationRadius);
                    Canvas.SetTop(_markups[markNum], presentationCenter.Y - presentationRadius);
                    Canvas.SetLeft(_markups[textNum], presentationCenter.X - presentationRadius);
                    Canvas.SetTop(_markups[textNum], presentationCenter.Y - presentationRadius);
                }));
            }
            catch (Exception e)
            {
                Log.Print(String.Format("Failed to draw calibration mark. Reason: {0}", e.Message), eCategory.Error, LogTag.COMMON);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Convert provided calibration mark to out parameters: mark of circle and text
 /// </summary>
 /// <param name="mark">Calibration mark</param>
 /// <param name="circle">[OUT] circle mark</param>
 /// <param name="text">[OUT] text mark</param>
 protected void TryParseToCalibrationCircleAndTextMark(eCallibrationMark mark, out eMarks circle, out eMarks text)
 {
     circle = eMarks.NA;
     text = eMarks.NA;
     switch (mark)
     {
         case eCallibrationMark.BL:
             circle = eMarks.ButtomLeftMark;
             text = eMarks.ButtomLeftText;
             break;
         case eCallibrationMark.BR:
             circle = eMarks.ButtomRightMark;
             text = eMarks.ButtomRightText;
             break;
         case eCallibrationMark.TL:
             circle = eMarks.TopLeftMark;
             text = eMarks.TopLeftText;
             break;
         case eCallibrationMark.TR:
             circle = eMarks.TopRightMark;
             text = eMarks.TopRightText;
             break;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Show calibration mark on screen - circle and coordinates
 /// </summary>
 /// <param name="mark">Calibration mark as CircleF</param>
 /// <param name="key">Calibration mark type</param>
 public void ShowCalibrationMark(CircleF mark, eCallibrationMark key)
 {
     switch (key)
     {
         case eCallibrationMark.BL:
             Marks.DrawCallibrationCircle(eCallibrationMark.BL,
                 new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
             break;
         case eCallibrationMark.TL:
             Marks.DrawCallibrationCircle(eCallibrationMark.TL,
                 new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
             break;
         case eCallibrationMark.TR:
             Marks.DrawCallibrationCircle(eCallibrationMark.TR,
                 new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
             break;
         case eCallibrationMark.BR:
             Marks.DrawCallibrationCircle(eCallibrationMark.BR,
                 new Point(mark.Center.X, mark.Center.Y), Convert.ToInt32(mark.Radius));
             break;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Draw the calibration circles on the canvas
 /// </summary>
 /// <param name="mark">The wanted calibration mark for drawing</param>
 /// <param name="center">Center of the given calibration mark</param>
 /// <param name="radius">Radius of the given calibration mark</param>
 /// <param name="circleColor">Optional color [default : Pink]</param>
 /// <param name="textColor">Optional text color [default : OrangeRed]</param>
 /// <param name="fontSize">Optional font size [default : 12 ]</param>
 /// <param name="text"></param>
 public static void DrawCallibrationCircle(eCallibrationMark mark, Point center, int radius,
     SolidColorBrush circleColor = null, SolidColorBrush textColor = null, double fontSize = 12,
         string text = "")
 {
     try
     {
         Instance.DrawCallibrationCircle(mark, center, radius, circleColor, textColor, fontSize, text);
     }
     catch (Exception ex)
     {
         Log.Print("Unable to draw calibration mark.", ex, LogTag.COMMON);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Draw calibration mark with text method
        /// Note: this method accepts only frame coordinates type
        /// </summary>
        /// <param name="mark">Calibration mark to draw</param>
        /// <param name="center">Calibration mark center as frame coordinates</param>
        /// <param name="radius">Calibration mark radius in frame dimensions</param>
        /// <param name="circleColor">Calibration mark circle color [Default will be Brushes.Pink]</param>
        /// <param name="textColor">Calibration mark text color [Default will be Brushes.OrangeRed]</param>
        /// <param name="fontSize">Calibration mark text font size [Default will be 12]</param>
        /// <param name="text">Calibration mark text [Default will be Mark Name and coordinates]</param>
        public void DrawCallibrationCircle(eCallibrationMark mark, Point center, int radius,
            SolidColorBrush circleColor = null, SolidColorBrush textColor = null, double fontSize = 12,
                string text = "")
        {
            Point screenCenter = _screen.FrameToScreenCoordinates(center);
            float screenRadius = _screen.FrameToScreenDistance(radius);

            eMarks markNum;
            eMarks textNum;
            TryParseToCalibrationCircleAndTextMark(mark, out markNum, out textNum);

            _dispatcher.Invoke(() =>
            {
                _screen.Element<Shape>(markNum).StrokeThickness = 2;
                _screen.Element<Shape>(markNum).Stroke = (circleColor == null) ? Brushes.Pink : circleColor;
                _screen.Element<Shape>(markNum).Width = screenRadius * 2;
                _screen.Element<Shape>(markNum).Height = screenRadius * 2;
                _screen.Element<TextBlock>(textNum).FontSize = fontSize;
                _screen.Element<TextBlock>(textNum).Text = (String.IsNullOrEmpty(text)) ? String.Format("{0}:{1}x{2}", mark, Convert.ToInt32(center.X), Convert.ToInt32(center.Y)) : text;
                _screen.Element<TextBlock>(textNum).Foreground = (textColor == null) ? Brushes.OrangeRed : textColor;
                _screen.Draw(markNum, screenCenter.X - screenRadius, screenCenter.Y - screenRadius, eCoordinatesType.Screen);
                _screen.Draw(textNum, screenCenter.X - screenRadius, screenCenter.Y - screenRadius, eCoordinatesType.Screen);
            });
        }