Example #1
0
 public void ProjectionClear()
 {
     DartboardProjectionWorkingFrame = DartboardProjectionFrameBackground.Clone();
     mainWindow.Dispatcher.Invoke(() =>
     {
         mainWindow.DartboardProjectionImageBox.Source = ToBitmap(DartboardProjectionFrameBackground);
         mainWindow.PointsBox.Text = string.Empty;
     });
 }
        public void ProjectionDrawLine(PointF point1, PointF point2, MCvScalar color, bool clearBeforeDraw = true)
        {
            if (clearBeforeDraw)
            {
                DartboardProjectionWorkingFrame = DartboardProjectionFrameBackground.Clone();
            }

            DrawLine(DartboardProjectionWorkingFrame, point1, point2, color, poiThickness);

            mainWindow.Dispatcher.Invoke(new Action(() => mainWindow.DartboardProjectionImageBox.Source = ToBitmap(DartboardProjectionWorkingFrame)));
        }
        public void ProjectionDrawThrow(PointF poi, bool exclusiveDraw = true)
        {
            if (exclusiveDraw)
            {
                DartboardProjectionWorkingFrame = DartboardProjectionFrameBackground.Clone();
            }

            DrawCircle(DartboardProjectionWorkingFrame, poi, poiRadius, poiColor, poiThickness);

            mainWindow.Dispatcher.Invoke(new Action(() => mainWindow.DartboardProjectionImageBox.Source = ToBitmap(DartboardProjectionWorkingFrame)));
        }
        public void ProjectionPrepare()
        {
            // Draw dartboard projection
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 7, projectionGridColor, projectionGridThickness);
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 17, projectionGridColor, projectionGridThickness);
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 95, projectionGridColor, projectionGridThickness);
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 105, projectionGridColor, projectionGridThickness);
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 160, projectionGridColor, projectionGridThickness);
            DrawCircle(DartboardProjectionFrameBackground, projectionCenterPoint, projectionCoefficent * 170, projectionGridColor, projectionGridThickness);
            for (var i = 0; i <= 360; i += 9)
            {
                var segmentPoint1 = new PointF((float)(projectionCenterPoint.X + Math.Cos(0.314159 * i - 0.15708) * projectionCoefficent * 170),
                                               (float)(projectionCenterPoint.Y + Math.Sin(0.314159 * i - 0.15708) * projectionCoefficent * 170));
                var segmentPoint2 = new PointF((float)(projectionCenterPoint.X + Math.Cos(0.314159 * i - 0.15708) * projectionCoefficent * 17),
                                               (float)(projectionCenterPoint.Y + Math.Sin(0.314159 * i - 0.15708) * projectionCoefficent * 17));
                DrawLine(DartboardProjectionFrameBackground, segmentPoint1, segmentPoint2, projectionGridColor, projectionGridThickness);
            }

            // Draw digits
            var sectors = new List <int>()
            {
                11, 14, 9, 12, 5,
                20, 1, 18, 4, 13,
                6, 10, 15, 2, 17,
                3, 19, 7, 16, 8
            };
            var startRadSector = -3.14159;
            var radSectorStep  = 0.314159;
            var radSector      = startRadSector;

            foreach (var sector in sectors)
            {
                DrawString(DartboardProjectionFrameBackground,
                           sector.ToString(),
                           (int)(projectionCenterPoint.X - 40 + Math.Cos(radSector) * projectionCoefficent * 190),
                           (int)(projectionCenterPoint.Y + 20 + Math.Sin(radSector) * projectionCoefficent * 190),
                           projectionDigitsScale,
                           projectionDigitsColor,
                           projectionDigitsThickness);
                radSector += radSectorStep;
            }

            DartboardProjectionWorkingFrame = DartboardProjectionFrameBackground.Clone();

            mainWindow.Dispatcher.Invoke(new Action(() => mainWindow.DartboardProjectionImageBox.Source = ToBitmap(DartboardProjectionWorkingFrame)));
        }