예제 #1
0
        internal static void DrawEWSDispenserStatus(
            Graphics gfx, RectangleF goNogoRect, StringFormat miscTextStringFormat, Color warnColor, Color okColor, RectangleF rdyRectangle, RectangleF pflRectangle, Color scopeGreenColor, Font font,
            InstrumentState instrumentState)
        {
            if (instrumentState.EWSGo)
            {
                var legendColor = scopeGreenColor;
                using (var legendBrush = new SolidBrush(legendColor)) { StringRenderer.DrawString(gfx, "GO", font, legendBrush, goNogoRect, miscTextStringFormat); }
            }
            else if (instrumentState.EWSNoGo)
            {
                var legendColor = warnColor;
                using (var legendBrush = new SolidBrush(legendColor)) { StringRenderer.DrawString(gfx, "NOGO", font, legendBrush, goNogoRect, miscTextStringFormat); }
            }
            else if (instrumentState.EWSDispenseReady)
            {
                var legendColor = scopeGreenColor;
                using (var legendBrush = new SolidBrush(legendColor)) { StringRenderer.DrawString(gfx, "DISP", font, legendBrush, goNogoRect, miscTextStringFormat); }
            }

            if (instrumentState.EWSDispenseReady)
            {
                var legendColor = okColor;
                using (var legendBrush = new SolidBrush(legendColor)) { StringRenderer.DrawString(gfx, "RDY", font, legendBrush, rdyRectangle, miscTextStringFormat); }
            }

            if (instrumentState.EWSDegraded) //draw PFL legend
            {
                var legendColor = warnColor;
                using (var legendBrush = new SolidBrush(legendColor)) { StringRenderer.DrawString(gfx, "PFL", font, legendBrush, pflRectangle, miscTextStringFormat); }
            }
        }
 internal static bool AreNonVisibleUnknownThreatsDetected(InstrumentState instrumentState)
 {
     return(instrumentState?.Blips != null && (
                from thisBlip
                in instrumentState.Blips
                where thisBlip != null && !thisBlip.Visible && thisBlip.Lethality != 0
                select thisBlip.SymbolID)
            .Any(symbolId => symbolId < 0 || symbolId == 1 || symbolId == 27 || symbolId == 28 || symbolId == 29));
 }
        internal static bool AreNonVisibleNavalThreatsDetected(InstrumentState instrumentState)
        {
            if (instrumentState?.Blips == null)
            {
                return(false);
            }

            return((
                       from thisBlip
                       in instrumentState.Blips
                       where thisBlip != null && thisBlip.Lethality != 0 && !thisBlip.Visible
                       select thisBlip.SymbolID).Any(symbolId => symbolId == 18));
        }
        internal static void DrawPageLegends(int backgroundHeight, Graphics gfx, InstrumentState instrumentState, Font font)
        {
            //Draw the page legends
            var pageLegendStringFormat = new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Near,
                Trimming      = StringTrimming.None,
                FormatFlags   = StringFormatFlags.NoWrap
            };

            const int pageLegendHeight     = 15;
            const int pageLegendWidth      = 35;
            const int pageLegendSeparation = 15;
            var       tacLegendRectangle   = new Rectangle(57, backgroundHeight - pageLegendHeight - 5, pageLegendWidth, pageLegendHeight);
            var       sysLegendRectangle   = new Rectangle(tacLegendRectangle.Right + pageLegendSeparation, tacLegendRectangle.Y, pageLegendWidth, pageLegendHeight);
            var       tstLegendRectangle   = new Rectangle(sysLegendRectangle.Right + pageLegendSeparation, tacLegendRectangle.Y, pageLegendWidth, pageLegendHeight);

            //draw highlighted TAC legend
            gfx.FillRectangle(Brushes.White, tacLegendRectangle);
            StringRenderer.DrawString(gfx, "TAC", font, Brushes.Black, tacLegendRectangle, pageLegendStringFormat);

            //draw non-highlighted SYS legend
            StringRenderer.DrawString(gfx, "SYS", font, Brushes.White, sysLegendRectangle, pageLegendStringFormat);

            if (instrumentState.RWRTest1 || instrumentState.RWRTest2) //Added Falcas 10-11-2012
            {
                //draw highlighted TST legend
                gfx.FillRectangle(Brushes.White, tstLegendRectangle);
                StringRenderer.DrawString(gfx, "TST", font, Brushes.Black, tstLegendRectangle, pageLegendStringFormat);
            }
            else
            {
                //draw non-highlighted TST legend
                StringRenderer.DrawString(gfx, "TST", font, Brushes.White, tstLegendRectangle, pageLegendStringFormat);
            }
        }
        internal static void DrawFlareCount(
            Color severeColor, Color warnColor, Color okColor, Graphics gfx, RectangleF flareCountRectangle, StringFormat chaffFlareCountStringFormat, InstrumentState instrumentState, Font font)
        {
            Color flareCountColor;

            if (instrumentState.FlareCount == 0)
            {
                flareCountColor = severeColor;
            }
            else if (instrumentState.FlareLow)
            {
                flareCountColor = warnColor;
            }
            else
            {
                flareCountColor = okColor;
            }
            using (var flareCountBrush = new SolidBrush(flareCountColor))
            {
                StringRenderer.DrawString(gfx, "FLAR", font, flareCountBrush, flareCountRectangle, chaffFlareCountStringFormat);
                flareCountRectangle.Offset(0, 12);
                StringRenderer.DrawString(gfx, $"{instrumentState.FlareCount:00}", font, flareCountBrush, flareCountRectangle, chaffFlareCountStringFormat);
            }
        }
예제 #6
0
        internal static void DrawChaffCount(
            Color severeColor, Color warnColor, Color okColor, Graphics gfx, RectangleF chaffCountRectangle, StringFormat chaffFlareCountStringFormat, InstrumentState instrumentState, Font font)
        {
            //draw chaff count
            Color chaffCountColor;

            if (instrumentState.ChaffCount == 0)
            {
                chaffCountColor = severeColor;
            }
            else if (instrumentState.ChaffLow)
            {
                chaffCountColor = warnColor;
            }
            else
            {
                chaffCountColor = okColor;
            }
            using (var chaffCountBrush = new SolidBrush(chaffCountColor))
            {
                StringRenderer.DrawString(gfx, "CHAF", font, chaffCountBrush, chaffCountRectangle, chaffFlareCountStringFormat);
                chaffCountRectangle.Offset(0, 12);
                StringRenderer.DrawString(gfx, $"{instrumentState.ChaffCount:00}", font, chaffCountBrush, chaffCountRectangle, chaffFlareCountStringFormat);
            }
        }
예제 #7
0
 internal static void DrawSRCHLegend(Graphics gfx, Rectangle rightLegend2Rectangle, StringFormat verticalOsbLegendRHSFormat, InstrumentState instrumentState, Font font, Brush brush)
 {
     if (instrumentState.RWRPowerOn &&
         (instrumentState.SearchMode || NonVisibleSearchThreatsDetector.AreNonVisibleSearchThreatsDetected(instrumentState) && DateTime.UtcNow.Millisecond % 500 < 250))
     //draw highlighted SRCH legend
     {
         gfx.FillRectangle(brush, rightLegend2Rectangle);
         StringRenderer.DrawString(gfx, "SRCH", font, Brushes.Black, rightLegend2Rectangle, verticalOsbLegendRHSFormat);
     }
     else //draw non-highlighted SRCH legend
     {
         StringRenderer.DrawString(gfx, "SRCH", font, brush, rightLegend2Rectangle, verticalOsbLegendRHSFormat);
     }
 }
예제 #8
0
 internal static void DrawPRILegend(Graphics gfx, Rectangle leftLegend4Rectangle, StringFormat verticalOsbLegendLHSFormat, InstrumentState instrumentState, Brush brush, Font font)
 {
     if (instrumentState.RWRPowerOn &&
         (instrumentState.PriorityMode && !NonVisiblePriorityThreatsDetector.AreNonVisiblePriorityThreatsDetected(instrumentState) ||
          instrumentState.PriorityMode && NonVisiblePriorityThreatsDetector.AreNonVisiblePriorityThreatsDetected(instrumentState) && DateTime.UtcNow.Millisecond % 500 < 250))
     {
         gfx.FillRectangle(brush, leftLegend4Rectangle);
         StringRenderer.DrawString(gfx, "PRI", font, Brushes.Black, leftLegend4Rectangle, verticalOsbLegendLHSFormat);
     }
     else //draw non-highlighted PRI legend
     {
         StringRenderer.DrawString(gfx, "PRI", font, brush, leftLegend4Rectangle, verticalOsbLegendLHSFormat);
     }
 }
예제 #9
0
 internal static void DrawHOFFLegend(Graphics gfx, Rectangle leftLegend2Rectangle, StringFormat verticalOsbLegendLHSFormat, InstrumentState instrumentState, Font font, Brush brush)
 {
     if (instrumentState.RWRPowerOn && instrumentState.Handoff) //draw highlighted HOFF legend
     {
         gfx.FillRectangle(brush, leftLegend2Rectangle);
         StringRenderer.DrawString(gfx, "HOFF", font, Brushes.Black, leftLegend2Rectangle, verticalOsbLegendLHSFormat);
     }
     else //draw non-highlighted HOFF legend
     {
         StringRenderer.DrawString(gfx, "HOFF", font, brush, leftLegend2Rectangle, verticalOsbLegendLHSFormat);
     }
 }
        internal static void DrawMiddleLethalityRing(Graphics gfx, float middleRingLeft, float middleRingTop, Pen grayPen, float atdMiddleRingDiameter, int lineLength, InstrumentState instrumentState)
        {
            var toRestore = gfx.Transform;

            gfx.TranslateTransform(middleRingLeft, middleRingTop);
            gfx.DrawEllipse(grayPen, 0, 0, atdMiddleRingDiameter, atdMiddleRingDiameter);

            gfx.TranslateTransform(atdMiddleRingDiameter / 2.0f, atdMiddleRingDiameter / 2.0f);
            gfx.RotateTransform(-instrumentState.MagneticHeadingDegrees);
            gfx.TranslateTransform(-atdMiddleRingDiameter / 2.0f, -atdMiddleRingDiameter / 2.0f);

            //draw north line
            gfx.DrawLineFast(grayPen, atdMiddleRingDiameter / 2.0f, -(lineLength * 2), atdMiddleRingDiameter / 2.0f, 0);

            //draw west line
            gfx.DrawLineFast(grayPen, 0, atdMiddleRingDiameter / 2.0f, lineLength, atdMiddleRingDiameter / 2.0f);

            //draw east line
            gfx.DrawLineFast(grayPen, atdMiddleRingDiameter, atdMiddleRingDiameter / 2.0f, atdMiddleRingDiameter - lineLength, atdMiddleRingDiameter / 2.0f);

            //draw south line
            gfx.DrawLineFast(grayPen, atdMiddleRingDiameter / 2.0f, atdMiddleRingDiameter - lineLength, atdMiddleRingDiameter / 2.0f, atdMiddleRingDiameter + lineLength);

            //draw north flag
            gfx.DrawLineFast(grayPen, atdMiddleRingDiameter / 2.0f, -(lineLength * 2), atdMiddleRingDiameter / 2.0f + 7, -(lineLength * 0.75f));
            gfx.DrawLineFast(grayPen, atdMiddleRingDiameter / 2.0f, -(lineLength * 0.75f), atdMiddleRingDiameter / 2.0f + 7, -(lineLength * 0.75f));

            gfx.Transform = toRestore;
        }
예제 #11
0
        internal static void DrawBlip(
            Graphics gfx, ref GraphicsState basicState, Matrix initialTransform, float atdRingOffsetTranslateX, float atdRingOffsetTranslateY, float atdRingScale, int backgroundWidth,
            int backgroundHeight, Color missileColor, float outerRingTop, float innerRingTop, Color scopeGreenColor, Color airborneThreatColor, Color groundThreatColor, Color searchThreatColor,
            Color navalThreatColor, Color unknownThreatColor, Blip blip, InstrumentState instrumentState, Options options, Font missileWarningFont, int width, Font largeFont, Font smallFont)
        {
            GraphicsUtil.RestoreGraphicsState(gfx, ref basicState);

            if (options.Style == AzimuthIndicator.InstrumentStyle.AdvancedThreatDisplay)
            {
                gfx.Transform = initialTransform;
                gfx.TranslateTransform(atdRingOffsetTranslateX, atdRingOffsetTranslateY);
                gfx.ScaleTransform(atdRingScale, atdRingScale);
            }
            //calculate position of symbols
            var lethality  = blip.Lethality;
            var translateY = lethality > 1 ? -((2.0f - lethality) * 100.0f) * 0.95f : -((1.0f - lethality) * 100.0f) * 0.95f;

            if (options.Style == AzimuthIndicator.InstrumentStyle.AdvancedThreatDisplay)
            {
                translateY *= 0.92f;
            }
            //rotate and translate symbol into place
            var angle = -instrumentState.MagneticHeadingDegrees + blip.BearingDegrees;

            if (instrumentState.Inverted)
            {
                angle = -angle;
            }
            //rotate the background image so that this emitter's bearing line points toward the top
            gfx.TranslateTransform(backgroundWidth / 2.0f, backgroundHeight / 2.0f);
            gfx.RotateTransform(angle);
            gfx.TranslateTransform(-(float)backgroundWidth / 2.0f, -(float)backgroundHeight / 2.0f);

            using (var missileWarningBrush = new SolidBrush(missileColor))
                using (var launchLinePen = new Pen(missileColor))
                {
                    var center = new PointF(backgroundWidth / 2.0f, backgroundHeight / 2.0f);

                    MissileLaunchLineRenderer.DrawMissileLaunchLine(gfx, outerRingTop, innerRingTop, center, blip, launchLinePen, angle, missileWarningBrush, options, missileWarningFont);
                }
            //position the emitter symbol at the correct distance from the center of the RWR, given its lethality
            gfx.TranslateTransform(0, translateY);

            //rotate the emitter symbol graphic so that it appears upright when background is rotated back and displayed to user
            gfx.TranslateTransform(backgroundWidth / 2.0f, backgroundHeight / 2.0f);
            gfx.RotateTransform(-angle);
            gfx.TranslateTransform(-backgroundWidth / 2.0f, -backgroundHeight / 2.0f);

            //draw the emitter symbol
            var usePrimarySymbol = DateTime.UtcNow.Millisecond < 500;
            var useLargeSymbol   = DateTime.UtcNow.Millisecond < 500 && blip.NewDetection > 0;

            var emitterColor = EmitterColorChooser.GetEmitterColor(
                scopeGreenColor, missileColor, airborneThreatColor, groundThreatColor, searchThreatColor, navalThreatColor, unknownThreatColor, blip, options);
            var emitterSymbolDestinationRectangle = new RectangleF((int)((backgroundWidth - width) / 2.0f), (int)((backgroundHeight - width) / 2.0f), width, width);

            EmitterSymbolRenderer.DrawEmitterSymbol(blip.SymbolID, gfx, emitterSymbolDestinationRectangle, useLargeSymbol, usePrimarySymbol, emitterColor, largeFont, smallFont, width);

            using (var emitterPen = new Pen(emitterColor))
            {
                gfx.TranslateTransform(-width / 2.0f, -width / 2.0f);
                if (blip.Selected > 0)
                {
                    SelectedThreatDiamondRenderer.DrawSelectedThreatDiamond(gfx, backgroundWidth, backgroundHeight, emitterPen, width);
                }
                if (blip.MissileActivity > 0 && blip.MissileLaunch == 0)
                {
                    MissileActivitySymbolRenderer.DrawMissileActivitySymbol(gfx, backgroundWidth, backgroundHeight, emitterPen, width);
                }
                else if (blip.MissileActivity > 0 && blip.MissileLaunch > 0)
                {
                    MissileLaunchSymbolRenderer.DrawMissileLaunchSymbol(gfx, backgroundWidth, backgroundHeight, emitterPen, width);
                }
            }
            GraphicsUtil.RestoreGraphicsState(gfx, ref basicState);
        }
예제 #12
0
 public AzimuthIndicator()
 {
     Options         = new Options();
     InstrumentState = new InstrumentState();
 }
예제 #13
0
        internal static void DrawEWSMode(
            Color severeColor, Graphics gfx, RectangleF ewmsModeRectangle, StringFormat miscTextStringFormat, Color warnColor, Color okColor, InstrumentState instrumentState, Font font)
        {
            //Added Falcas 10-11-2012.
            instrumentState.EWMSMode = EWSModeRetriever.GetEWMSMode(instrumentState.cmdsMode);
            switch (instrumentState.EWMSMode)
            {
            case EWMSMode.Off:
            {
                EWSModeOffRenderer.DrawEWSModeOff(severeColor, gfx, ewmsModeRectangle, miscTextStringFormat, font);
            }
            break;

            case EWMSMode.Standby:
            {
                EWSModeStandbyRenderer.DrawEWSModeStandby(gfx, ewmsModeRectangle, miscTextStringFormat, warnColor, font);
            }
            break;

            case EWMSMode.Manual:
            {
                EWSModeManualRenderer.DrawEWSModeManual(gfx, ewmsModeRectangle, miscTextStringFormat, okColor, font);
            }
            break;

            case EWMSMode.Semiautomatic:
            {
                EWSModeSemiautomaticRenderer.DrawEWSModeSemiautomatic(gfx, ewmsModeRectangle, miscTextStringFormat, okColor, font);
            }
            break;

            case EWMSMode.Automatic:
            {
                EWSModeAutomaticRenderer.DrawEWSModeAutomatic(gfx, ewmsModeRectangle, miscTextStringFormat, okColor, font);
            }
            break;

            case EWMSMode.Bypass:
            {
                EWSModeBypassRenderer.DrawEWSModeBypass(severeColor, gfx, ewmsModeRectangle, miscTextStringFormat, font);
            }
            break;
            }
        }
예제 #14
0
 internal static void DrawUNKLegend(Graphics gfx, Rectangle leftLegend1Rectangle, StringFormat verticalOsbLegendLHSFormat, InstrumentState instrumentState, Font font, Brush brush)
 {
     if (instrumentState.RWRPowerOn &&
         (instrumentState.UnknownThreatScanMode ||
          NonVisibleUnknownThreatsDetector.AreNonVisibleUnknownThreatsDetected(instrumentState) && DateTime.UtcNow.Millisecond % 500 < 250))       //draw highlighted UNK legend
     {
         gfx.FillRectangle(brush, leftLegend1Rectangle);
         StringRenderer.DrawString(gfx, "UNK", font, Brushes.Black, leftLegend1Rectangle, verticalOsbLegendLHSFormat);
     }
     else //draw non-highlighted UNK legend
     {
         StringRenderer.DrawString(gfx, "UNK", font, brush, leftLegend1Rectangle, verticalOsbLegendLHSFormat);
     }
 }
예제 #15
0
 internal static void DrawALTLegend(Graphics gfx, Rectangle rightLegend3Rectangle, StringFormat verticalOsbLegendRHSFormat, InstrumentState instrumentState, Brush brush, Font font)
 {
     if (instrumentState.RWRPowerOn && instrumentState.LowAltitudeMode) //draw highlighted ALT legend
     {
         gfx.FillRectangle(brush, rightLegend3Rectangle);
         StringRenderer.DrawString(gfx, "ALT", font, Brushes.Black, rightLegend3Rectangle, verticalOsbLegendRHSFormat);
     }
     else //draw non-highlighted ALT legend
     {
         StringRenderer.DrawString(gfx, "ALT", font, brush, rightLegend3Rectangle, verticalOsbLegendRHSFormat);
     }
 }