Esempio n. 1
0
        internal static void DrawFromFlag(Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image fromFlagMaskedImage)
        {
            //draw the FROM flag
            if (!instrumentState.ShowToFromFlag || !instrumentState.FromFlag)
            {
                return;
            }

            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            destinationGraphics.TranslateTransform(centerX, centerY);
            destinationGraphics.RotateTransform(-instrumentState.MagneticHeadingDegrees);
            destinationGraphics.RotateTransform(instrumentState.DesiredCourseDegrees);
            destinationGraphics.TranslateTransform(-centerX, -centerY);
            destinationGraphics.DrawImageFast(fromFlagMaskedImage, new Point(0, 0));
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
        internal static void DrawDesiredCourse(Graphics destinationGraphics, ref GraphicsState basicState, InstrumentState instrumentState, FontGraphic rangeFontGraphic)
        {
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            var desiredCourseString        = $"{instrumentState.DesiredCourseDegrees:000}";
            var desiredCourseHundreds      = desiredCourseString[0];
            var desiredCourseTens          = desiredCourseString[1];
            var desiredCourseOnes          = desiredCourseString[2];
            var desiredCourseHundredsImage = rangeFontGraphic.GetCharImage(desiredCourseHundreds);
            var desiredCourseTensImage     = rangeFontGraphic.GetCharImage(desiredCourseTens);
            var desiredCourseOnesImage     = rangeFontGraphic.GetCharImage(desiredCourseOnes);

            var       currentX      = 182;
            const int y             = 45;
            const int spacingPixels = -5;

            destinationGraphics.DrawImageFast(desiredCourseHundredsImage, new Point(currentX, y));
            currentX += desiredCourseHundredsImage.Width + spacingPixels;
            destinationGraphics.DrawImageFast(desiredCourseTensImage, new Point(currentX, y));
            currentX += desiredCourseTensImage.Width + spacingPixels;
            destinationGraphics.DrawImageFast(desiredCourseOnesImage, new Point(currentX, y));

            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
Esempio n. 3
0
 internal static void DrawCourseDeviationInvalidFlag(
     Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image hsiCDIFlagMaskedImage)
 {
     //draw the CDI flag
     if (instrumentState.DeviationInvalidFlag)
     {
         GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
         destinationGraphics.TranslateTransform(centerX, centerY);
         destinationGraphics.RotateTransform(-instrumentState.MagneticHeadingDegrees);
         destinationGraphics.RotateTransform(instrumentState.DesiredCourseDegrees);
         destinationGraphics.TranslateTransform(-centerX, -centerY);
         destinationGraphics.DrawImageFast(hsiCDIFlagMaskedImage, new Point(0, 0));
         GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
     }
 }
        internal static void DrawCourseDeviationIndicator(
            Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image hsiCourseDeviationIndicatorMaskedImage)
        {
            //draw course deviation indicator
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            destinationGraphics.TranslateTransform(centerX, centerY);
            destinationGraphics.RotateTransform(-instrumentState.MagneticHeadingDegrees);
            destinationGraphics.RotateTransform(instrumentState.DesiredCourseDegrees);
            destinationGraphics.TranslateTransform(-centerX, -centerY);
            var         cdiPct   = instrumentState.CourseDeviationDegrees / instrumentState.CourseDeviationLimitDegrees;
            const float cdiRange = 46.0f;
            var         cdiPos   = cdiPct * cdiRange;

            destinationGraphics.TranslateTransform(cdiPos, -2);
            try { destinationGraphics.DrawImageFast(hsiCourseDeviationIndicatorMaskedImage, new Point(0, 0)); }
            catch (OverflowException) { }
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
 internal static void DrawInnerWheel(Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image innerWheelMaskedImage)
 {
     //draw inner wheel
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
     destinationGraphics.TranslateTransform(centerX, centerY);
     destinationGraphics.RotateTransform(-instrumentState.MagneticHeadingDegrees);
     destinationGraphics.RotateTransform(instrumentState.DesiredCourseDegrees);
     destinationGraphics.TranslateTransform(-centerX, -centerY);
     destinationGraphics.TranslateTransform(0.5f, -2.0f);
     destinationGraphics.DrawImageFast(innerWheelMaskedImage, new Point(0, 0));
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
 }
Esempio n. 6
0
        internal static void DrawOffFlag(Graphics destinationGraphics, ref GraphicsState basicState, InstrumentState instrumentState, Image hsiOffFlagMaskedImage)
        {
            //draw the OFF flag
            if (!instrumentState.OffFlag)
            {
                return;
            }

            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            destinationGraphics.RotateTransform(-25);
            destinationGraphics.TranslateTransform(20, 50);
            destinationGraphics.DrawImageFast(hsiOffFlagMaskedImage, new Point(0, 0));
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
 public HorizontalSituationIndicator()
 {
     InstrumentState = new InstrumentState();
 }
 internal static void DrawCompassRose(Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image compassRoseMaskedImage)
 {
     //draw compass rose
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
     destinationGraphics.TranslateTransform(centerX, centerY);
     destinationGraphics.RotateTransform(-instrumentState.MagneticHeadingDegrees);
     destinationGraphics.TranslateTransform(-centerX, -centerY);
     destinationGraphics.DrawImageFast(compassRoseMaskedImage, new Point(0, 0));
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
 }
 internal static void DrawHeadingBug(Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image hsiHeadingBugMaskedImage)
 {
     //draw heading bug
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
     destinationGraphics.TranslateTransform(centerX, centerY);
     destinationGraphics.RotateTransform(instrumentState.DesiredHeadingDegrees - instrumentState.MagneticHeadingDegrees);
     destinationGraphics.TranslateTransform(-centerX, -centerY);
     destinationGraphics.DrawImageFast(hsiHeadingBugMaskedImage, new Point(0, 0));
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
 }
Esempio n. 10
0
        internal static void DrawRangeFlag(Graphics destinationGraphics, ref GraphicsState basicState, InstrumentState instrumentState, Image hsiRangeFlagMaskedImage)
        {
            //draw the range flag
            if (!instrumentState.DmeInvalidFlag)
            {
                return;
            }

            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            destinationGraphics.DrawImageFast(hsiRangeFlagMaskedImage, new Point(0, 0));
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
Esempio n. 11
0
        internal static void DrawRangeToBeacon(Graphics destinationGraphics, ref GraphicsState basicState, InstrumentState instrumentState, FontGraphic rangeFontGraphic)
        {
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
            var distanceToBeacon = instrumentState.DistanceToBeaconNauticalMiles;

            if (distanceToBeacon > 999.9)
            {
                distanceToBeacon = 999.9f;
            }
            var distanceToBeaconString        = $"{distanceToBeacon:000.0}";
            var distanceToBeaconHundreds      = distanceToBeaconString[0];
            var distanceToBeaconTens          = distanceToBeaconString[1];
            var distanceToBeaconOnes          = distanceToBeaconString[2];
            var distanceToBeaconHundredsImage = rangeFontGraphic.GetCharImage(distanceToBeaconHundreds);
            var distanceToBeaconTensImage     = rangeFontGraphic.GetCharImage(distanceToBeaconTens);
            var distanceToBeaconOnesImage     = rangeFontGraphic.GetCharImage(distanceToBeaconOnes);

            var       currentX      = 29;
            const int y             = 45;
            const int spacingPixels = -5;

            destinationGraphics.DrawImageFast(distanceToBeaconHundredsImage, new Point(currentX, y));
            currentX += distanceToBeaconHundredsImage.Width + spacingPixels;
            destinationGraphics.DrawImageFast(distanceToBeaconTensImage, new Point(currentX, y));
            currentX += distanceToBeaconTensImage.Width + spacingPixels;
            destinationGraphics.DrawImageFast(distanceToBeaconOnesImage, new Point(currentX, y));
            GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
        }
Esempio n. 12
0
 internal static void DrawBearingToBeaconIndicator(
     Graphics destinationGraphics, ref GraphicsState basicState, float centerX, float centerY, InstrumentState instrumentState, Image hsiBearingToBeaconNeedleMaskedImage)
 {
     //draw the bearing to beacon indicator needle
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
     destinationGraphics.TranslateTransform(centerX, centerY);
     destinationGraphics.RotateTransform(-(instrumentState.MagneticHeadingDegrees - instrumentState.BearingToBeaconDegrees));
     destinationGraphics.TranslateTransform(-centerX, -centerY);
     destinationGraphics.TranslateTransform(1, 0);
     destinationGraphics.DrawImageFast(hsiBearingToBeaconNeedleMaskedImage, new Point(0, 0));
     GraphicsUtil.RestoreGraphicsState(destinationGraphics, ref basicState);
 }