Пример #1
0
 private void DrawScaleTextArea(Graphics g, float middleY, float rightScaleLeft)
 {
     using (var p = new PointF(rightScaleLeft, middleY)
                    .StartDrawing()
                    .MoveRel(5, -5)
                    .MoveRel(0, -10)
                    .MoveRel(45, 0)
                    .MoveRel(0, 10)
                    .MoveRel(5, 5)
                    .MoveRel(-5, 5)
                    .MoveRel(0, 10)
                    .MoveRel(-45, 0)
                    .MoveRel(0, -10)
                    .MoveRel(-5, -5)
                    .ConvertToPath())
     {
         p.CloseFigure();
         g.DrawPath(new Pen(ScaleNormalColor), p);
     }
     using (var p = new PointF(rightScaleLeft + 1, middleY)
                    .StartDrawing()
                    .MoveRel(5, -5)
                    .MoveRel(0, -9)
                    .MoveRel(43, 0)
                    .MoveRel(0, 9)
                    .MoveRel(5, 5)
                    .MoveRel(-5, 5)
                    .MoveRel(0, 9)
                    .MoveRel(-43, 0)
                    .MoveRel(0, -9)
                    .MoveRel(-5, -5)
                    .ConvertToPath())
     {
         p.CloseFigure();
         g.FillPath(Brushes.Black, p);
     }
 }
Пример #2
0
        private void DrawLeftScale(Graphics g, RectangleF screenRect)
        {
            var middleX        = screenRect.Left + screenRect.Width / 2.0f;
            var middleY        = screenRect.Top + screenRect.Height / 2.0f;
            var halfHeight     = screenRect.Height / 2.0f;
            var leftScaleRight = middleX - WingsThickness * 20.0f - 15;
            var scaleDim       = new SolidBrush(Color.FromArgb(100, Color.Gray));
            var borderPen      = new Pen(Color.FromArgb(200, Color.Gray));

            using (var p = new PointF(leftScaleRight, middleY)
                           .StartDrawing()
                           .MoveRel(0, -15)
                           .MoveRel(-12, 0)
                           .MoveRel(0, -halfHeight + 30)
                           .MoveRel(-30, 0)
                           .MoveRel(0, halfHeight - 30)
                           .MoveRel(-12, 0)
                           .MoveRel(0, 30)
                           .MoveRel(12, 0)
                           .MoveRel(0, halfHeight - 30)
                           .MoveRel(30, 0)
                           .MoveRel(0, -halfHeight + 30)
                           .MoveRel(12, 0)
                           .MoveRel(0, -15)
                           .ConvertToPath())
            {
                p.CloseFigure();
                g.FillPath(scaleDim, p);
                g.DrawPath(borderPen, p);
            }
            var middleText    = leftScaleRight - 27;
            var value         = AirSpeed.ToString(AirSpeedFormat);
            var airSpeedColor = (AirSpeed > AirSpeedSafetyTop || AirSpeed < AirSpeedSafetyBottom) ? AirSpeedColorWarn : ScaleNormalColor;

            using (var p = new PointF(leftScaleRight + 5, middleY)
                           .StartDrawing()
                           .MoveRel(-5, -5)
                           .MoveRel(0, -10)
                           .MoveRel(-54, 0)
                           .MoveRel(0, 30)
                           .MoveRel(54, 0)
                           .MoveRel(0, -10)
                           .MoveRel(5, -5)
                           .ConvertToPath())
            {
                p.CloseFigure();
                g.DrawPath(new Pen(airSpeedColor), p);
            }

            var counter           = 1;
            var normalBrush       = new SolidBrush(ScaleNormalColor);
            var safetyBad         = new HatchBrush(HatchStyle.WideUpwardDiagonal, Color.Orange, Color.Black);
            var safetyGood        = new SolidBrush(Color.Green);
            var normalPen         = new Pen(ScaleNormalColor);
            var middleOfScaleLeft = leftScaleRight - 12;

            for (float up = middleY - 30, down = middleY + 30; up > screenRect.Top + 20; up -= 25, down += 25, counter++)
            {
                var valUp    = AirSpeed + counter * AirSpeedStep;
                var valDown  = AirSpeed - counter * AirSpeedStep;
                var sUp      = valUp.ToString(AirSpeedFormat);
                var sDown    = valDown.ToString(AirSpeedFormat);
                var sizeUp   = g.MeasureString(sUp, ScaleFontSmall);
                var sizeDown = g.MeasureString(sDown, ScaleFontSmall);
                g.DrawString(sUp, ScaleFontSmall, normalBrush, middleText - sizeUp.Width / 2.0f, up - sizeUp.Height / 2.0f);
                g.DrawString(sDown, ScaleFontSmall, normalBrush, middleText - sizeDown.Width / 2.0f, down - sizeDown.Height / 2.0f);
                g.DrawLine(normalPen, middleOfScaleLeft, up, middleOfScaleLeft - 3, up);
                g.DrawLine(normalPen, middleOfScaleLeft, down, middleOfScaleLeft - 3, down);
                var bUp   = (valUp > AirSpeedSafetyTop || valUp < AirSpeedSafetyBottom) ? (Brush)safetyBad : safetyGood;
                var bDown = (valDown > AirSpeedSafetyTop || valDown < AirSpeedSafetyBottom) ? (Brush)safetyBad : safetyGood;
                g.FillRectangle(bUp, middleOfScaleLeft, up - 15, 5, 30);
                g.FillRectangle(bDown, middleOfScaleLeft, down - 15, 5, 30);
            }

            g.FillRectangle(Brushes.Black, middleOfScaleLeft - 29, middleY + halfHeight - 35, 29, 19);
            g.FillRectangle(Brushes.Black, middleOfScaleLeft - 29, middleY - halfHeight + 15, 29, 19);
            var sizeU = g.MeasureString(AirSpeedUnits, ScaleFontSmall);

            g.DrawString(AirSpeedUnits, ScaleFontSmall, Brushes.White, middleText - sizeU.Width / 2.0f, middleY + halfHeight - 27 - sizeU.Height / 2.0f);
            sizeU = g.MeasureString("TAS", ScaleFontSmall);
            g.DrawString("TAS", ScaleFontSmall, Brushes.White, middleText - sizeU.Width / 2.0f, middleY - halfHeight + 24 - sizeU.Height / 2.0f);

            var size = g.MeasureString(value, ScaleFontBig);

            using (var p = new PointF(leftScaleRight + 4, middleY)
                           .StartDrawing()
                           .MoveRel(-5, -5)
                           .MoveRel(0, -9)
                           .MoveRel(-52, 0)
                           .MoveRel(0, 29)
                           .MoveRel(52, 0)
                           .MoveRel(0, -9)
                           .MoveRel(4, -4)
                           .ConvertToPath())
            {
                p.CloseFigure();
                g.FillPath(Brushes.Black, p);
            }

            g.DrawString(value, ScaleFontBig, new SolidBrush(airSpeedColor), middleText - size.Width / 2.0f, middleY - size.Height / 2.0f);
        }
Пример #3
0
        private void DrawRightScale(Graphics g, RectangleF screenRect)
        {
            var middleX        = screenRect.Left + screenRect.Width / 2.0f;
            var middleY        = screenRect.Top + screenRect.Height / 2.0f;
            var halfHeight     = screenRect.Height / 2.0f;
            var scaleDim       = new SolidBrush(Color.FromArgb(100, Color.Gray));
            var borderPen      = new Pen(Color.FromArgb(200, Color.Gray));
            var rightScaleLeft = middleX + WingsThickness * 20.0f + 15;

            using (var p = new PointF(rightScaleLeft + 5, middleY)
                           .StartDrawing()
                           .MoveRel(0, -15)
                           .MoveRel(7, 0)
                           .MoveRel(0, -halfHeight + 30)
                           .MoveRel(32, 0)
                           .MoveRel(0, screenRect.Height - 30)
                           .MoveRel(-32, 0)
                           .MoveRel(0, -halfHeight + 30)
                           .MoveRel(-7, 0)
                           .MoveRel(0, -15)
                           .ConvertToPath())
            {
                p.CloseFigure();
                g.FillPath(scaleDim, p);
                g.DrawPath(borderPen, p);
            }

            using (var p = new PointF(rightScaleLeft + 44, middleY - halfHeight + halfHeight / 5.0f)
                           .StartDrawing()
                           .MoveRel(30, 0)
                           .MoveRel(0, (halfHeight - halfHeight / 5.0f) * 2.0f)
                           .MoveRel(-30, 0)
                           .ConvertToPath())
            {
                p.CloseFigure();
                g.FillPath(scaleDim, p);
                g.DrawPath(borderPen, p);
            }

            var normalPen = new Pen(ScaleNormalColor);

            DrawVerticalSpeedScale(rightScaleLeft, screenRect, middleY, g);
            DrawScaleTextArea(g, middleY, rightScaleLeft);
            DrawAltitudeScale(rightScaleLeft, screenRect, middleY, g);
            g.DrawRectangle(normalPen, rightScaleLeft + 12, screenRect.Bottom - 33, 32, 18);
            g.FillRectangle(Brushes.Black, rightScaleLeft + 12, screenRect.Bottom - 33, 32, 18);
            var size        = g.MeasureString(AltitudeUnits, ScaleFontSmall);
            var normalBursh = new SolidBrush(ScaleNormalColor);

            g.DrawString(AltitudeUnits, ScaleFontSmall, normalBursh, rightScaleLeft + 28 - size.Width / 2.0f, screenRect.Bottom - 33);
            g.DrawRectangle(normalPen, rightScaleLeft + 45, screenRect.Bottom - 51, 29, 18);
            g.FillRectangle(Brushes.Black, rightScaleLeft + 45, screenRect.Bottom - 51, 29, 18);
            size = g.MeasureString(VerticalSpeedUnits, ScaleFontSmall);
            g.DrawString(VerticalSpeedUnits, ScaleFontSmall, normalBursh, rightScaleLeft + 60 - size.Width / 2.0f, screenRect.Bottom - 42 - size.Height / 2.0f);
            g.FillRectangle(Brushes.Black, rightScaleLeft + 12, screenRect.Top + 13, 32, 18);
            size = g.MeasureString("ALT", ScaleFontSmall);
            g.DrawString("ALT", ScaleFontSmall, normalBursh, rightScaleLeft + 29 - size.Width / 2.0f, screenRect.Top + 22 - size.Height / 2.0f);
            g.FillRectangle(Brushes.Black, rightScaleLeft + 44, screenRect.Top + 30, 30, 18);
            size = g.MeasureString("VSI", ScaleFontSmall);
            g.DrawString("VSI", ScaleFontSmall, normalBursh, rightScaleLeft + 59 - size.Width / 2.0f, screenRect.Top + 38 - size.Height / 2.0f);
        }