Beispiel #1
0
        private void pbStationaryWindDirection_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.HighQuality;

            int angle = 250;

            Image greenArrow = Properties.Resources.GreenArrow;

            g.DrawImage(GraphicUtil.RotateImage(greenArrow, angle), 0, 0);
        }
Beispiel #2
0
        private void pbPitchRollVisualization_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.HighQuality;

            /////////////////////////////////////////////////////////////////
            // Virtual horizon & Pitch/Roll current position visualization //
            /////////////////////////////////////////////////////////////////
            g.Clip = new Region(new Rectangle(0, 0, 300, 300));
            g.FillRegion(Brushes.Black, g.Clip);

            Bitmap bezel   = Resources.bezel;
            Bitmap horizon = Resources.horizon;
            Bitmap wings   = Resources.wings;

            Point ptBoule    = new Point(-25, -210); //Ground-Sky initial location
            Point ptRotation = new Point(150, 150);  // Point of rotation

            bezel.MakeTransparent(Color.Yellow);
            wings.MakeTransparent(Color.Yellow);
            horizon.MakeTransparent(Color.Yellow);

            double PitchAngleRadian = FlightHandler.CurrentPitchAngle;
            double RollAngleRadian  = FlightHandler.CurrentRollAngle * Math.PI / 180;

            GraphicUtil.RotateAndTranslate(e, horizon, RollAngleRadian, 0, ptBoule, (double)(4 * PitchAngleRadian), ptRotation, 1);

            g.DrawImage(bezel, 0, 0);
            g.DrawImage(wings, 75, 125);

            ////////////////////////////////////////////
            // Pitch/Roll Control input visualization //
            ////////////////////////////////////////////
            int pitchValue = Util.MapValue(FlightHandler.RawPitchValue, FlightHandler.PitchPulse[0], FlightHandler.PitchPulse[1], 260, 40);
            int rollValue  = Util.MapValue(FlightHandler.RawRollValue, FlightHandler.RollPulse[0], FlightHandler.RollPulse[1], 40, 260);

            g.DrawRectangle(new Pen(Brushes.Black, 4), new Rectangle(new Point(rollValue - 4, pitchValue - 4), new Size(8, 8)));
            Brush b = FlightHandler.AutoPilotActive ? Brushes.LimeGreen : Brushes.Gold;

            g.FillRectangle(b, new Rectangle(new Point(rollValue - 4, pitchValue - 4), new Size(8, 8)));

            g.DrawString("Pitch: " + FlightHandler.PitchValue + "µs", new Font("Arial", 8), Brushes.White, 160, 280);
            g.DrawString("Roll: " + FlightHandler.RollValue + "µs", new Font("Arial", 8), Brushes.White, 25, 280);

            if (FlightHandler.PitchPulse[2] > 0)
            {
                g.DrawString("(+" + FlightHandler.PitchPulse[2] + "µs)", new Font("Arial", 8, FontStyle.Bold), Brushes.LimeGreen, 230, 280);
            }
            else if (FlightHandler.PitchPulse[2] < 0)
            {
                g.DrawString("(" + FlightHandler.PitchPulse[2] + "µs)", new Font("Arial", 8, FontStyle.Bold), Brushes.Red, 230, 280);
            }

            if (FlightHandler.RollPulse[2] > 0)
            {
                g.DrawString("(+" + FlightHandler.RollPulse[2] + "µs)", new Font("Arial", 8, FontStyle.Bold), Brushes.LimeGreen, 90, 280);
            }
            else if (FlightHandler.RollPulse[2] < 0)
            {
                g.DrawString("(" + FlightHandler.RollPulse[2] + "µs)", new Font("Arial", 8, FontStyle.Bold), Brushes.Red, 90, 280);
            }

            ////////////////////////////////////
            /// FlightEnvelope visualization ///
            ////////////////////////////////////

            if (FlightHandler.ProtectionActive)
            {
                // Upper left
                g.DrawLine(new Pen(Brushes.White, 2), 40, 40, 60, 40);
                g.DrawLine(new Pen(Brushes.White, 2), 40, 40, 40, 60);

                // Upper right
                g.DrawLine(new Pen(Brushes.White, 2), 240, 40, 260, 40);
                g.DrawLine(new Pen(Brushes.White, 2), 260, 40, 260, 60);

                // Lower left
                g.DrawLine(new Pen(Brushes.White, 2), 40, 260, 40, 240);
                g.DrawLine(new Pen(Brushes.White, 2), 40, 260, 60, 260);

                // Lower right
                g.DrawLine(new Pen(Brushes.White, 2), 240, 260, 260, 260);
                g.DrawLine(new Pen(Brushes.White, 2), 260, 260, 260, 240);
            }

            ////////////////////////////////////
            /// FlightDirector visualization ///
            ////////////////////////////////////
            ///
            if (FlightHandler.FlightDirectorActive)
            {
                g.DrawLine(new Pen(Color.LimeGreen, 3), 150, 40, 150, 260);
                g.DrawLine(new Pen(Color.LimeGreen, 3), 40, 150, 260, 150);
            }
        }