Example #1
0
        /// <summary>
        /// Always generates the entire symbol.
        /// The symbol code should not change very often.
        /// </summary>
        private void GenerateSymbol()
        {
            try
            {
                // Only draw after we have the symbol code, if drawing via method call
                if (this.suppressRefresh)
                {
                    return;
                }

                string symbolCode = this.SymbolCode;

                // Reinitialize
                this.IsDirty  = true;       // set a dirty flag to indicate the symbol needs updating
                this.bounds   = Rect.Empty;
                this.BaseRect = Rect.Empty;
                this.Children.Clear();      // tried to cheap this one out - but that doesn't work well
                this.elements.Clear();

                // Get the base symbol from "the" resource dictionary
                var baseSymbol = new MilSymbolBase(symbolCode, this.LineBrush, this.FillBrush);
                if (baseSymbol.Empty)
                {
                    return;
                }

                this.AddChild("Base", baseSymbol);

                var styles = MilLabels.GetStyles(this.LabelStyle);

                // There is only label decoration for weather codes
                int schemeKey = CodingScheme.GetCode(symbolCode);
                if (schemeKey == CodingScheme.Weather || schemeKey == CodingScheme.TacticalGraphics)
                {
                    this.GenerateLabels(styles);
                    return;
                }

                // Add in the echelon marking.
                // "high" is the maximum height from the decoration
                this.high = Echelon.Generate(this, symbolCode);

                // Draw headquarters, feint dummy, task force, and installation.
                // "high" is the maximum height from the decoration
                this.high = MilHats.Generate(this, symbolCode);

                // Take care of any Joker, Faker, or Exercise character
                this.AddChild(
                    "JFE", MilLabels.GenerateJokerFakerExercise(symbolCode, this.labels, styles[MilLabels.BigLabels]));

                // Add the black ribbon on the base symbol for space
                this.AddChild("Space", MilSymbolBase.GenerateSpace(symbolCode));

                // Indicate whether the entity is damaged or destroyed
                this.AddChild("OC", StatusOperationalCapacity.Generate(symbolCode));

                // Add the mobility to the base of the symbol
                this.AddChild("Mobility", DrawMobility.GenerateMobility(symbolCode));

                // We have to (re)generate the labels because the symbol code extent may be different
                this.GenerateLabels(styles);
            }
            catch (Exception ex)
            {
                Log.WriteMessage(LogLevel.Error, "Unable to construct military symbol", ex);
            }
        }
Example #2
0
        /// <summary>
        /// Generate the labels for single point technical graphics.
        /// </summary>
        /// <param name="symbolCode">
        /// The symbol code for the technical graphic.
        /// </param>
        /// <param name="labels">
        /// The dictionary of labels for the technical graphic.
        /// </param>
        /// <param name="style">
        /// The style for the labels.
        /// </param>
        /// <param name="addChild">
        /// The delegate that actually adds the label to the UIElement.
        /// </param>
        internal static void GenerateTacticalGraphics(
            string symbolCode, IDictionary <string, string> labels, Style style, AddChild addChild)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return;
            }

            if (labels == null)
            {
                return;
            }

            string stencil = MilSymbolBase.CodeToStencil(symbolCode);

            double    extraOffset;
            TextBlock tb;

            // These are special case codes that require labels
            switch (stencil)
            {
            case "G_MPNDP":
            case "G_MPNDA":
            case "G_MPNDT":
            case "G_MPNDE":
            case "G_MPNDB":
            case "G_MPNDO":
            case "G_MPNDD":
            case "G_FPPCS":
            case "G_FPPCB":
            case "G_FPPCR":
            case "G_FPPCH":
            case "G_FPPCL":
                TacticalGraphicsPointLabels(labels, addChild, new[] { "H", "N", "T", "W" }, style);
                break;

            case "G_GPGPP":
                TacticalGraphicsPointLabels(labels, addChild, new[] { "H", "H1", "N", "T", "W-" }, style);
                break;

            case "G_GPGPPK":
            case "G_GPGPPL":
            case "G_GPGPPP":
            case "G_GPGPPR":
            case "G_GPGPPE":
            case "G_GPGPPS":
            case "G_GPGPPA":
            case "G_GPOPP":
            case "G_MPBCP":
            case "G_SPPX":
            case "G_SPPC":
            case "G_SPPY":
            case "G_SPPT":
            case "G_SPPD":
            case "G_SPPE":
            case "G_SPPL":
            case "G_SPPM":
            case "G_SPPR":
            case "G_SPPU":
            case "G_SPPO":
            case "G_SPPI":
            case "G_SPPN":
            case "G_SPPSZ":
            case "G_SPPSA":
            case "G_SPPSB":
            case "G_SPPSC":
            case "G_SPPSD":
            case "G_SPPSE":
            case "G_SPPSF":
            case "G_SPPSG":
            case "G_SPPSH":
            case "G_SPPSI":
            case "G_SPPSJ":
            case "G_SPPAS":
            case "G_SPPAT":
                TacticalGraphicsPointLabels(labels, addChild, new[] { "H", "N", "T", "W-" }, style);
                break;

            case "G_GPGPRI":
                GenerateSingleLabel(labels, "T", 0, -246, 0.5, 0.5, style, addChild);
                break;

            case "G_GPGPH":
                GenerateSingleLabel(labels, "H", 0, 0, 0.5, 0.5, style, addChild);
                break;

            case "G_GPGPPC":
                GenerateSingleLabel(labels, "T", 0, -175, 0.5, 0.5, style, addChild);
                break;

            case "G_GPGPPD":
                GenerateSingleLabel(labels, "T", 0, 0, 0.5, 0.25, style, addChild);
                break;

            case "G_GPGPPW":
                GenerateSingleLabel(labels, "T", 50, 0, 0.0, 0.5, style, addChild);
                break;

            case "G_GPAPP":
            case "G_GPAPC":
                GenerateSingleLabel(labels, "T", 0, 0, 0.5, 0.25, style, addChild);
                break;

            case "G_GPDPT":
                GenerateSingleLabel(labels, "T", 87, -87, 0.5, 0.5, style, addChild);
                break;

            case "G_MPOHTL":
                GenerateSingleLabel(labels, "X", 50, -250, 0.0, 0.0, style, addChild);
                break;

            case "G_MPOHTH":
                GenerateSingleLabel(labels, "X", 50, -230, 0.0, 0.0, style, addChild);
                break;

            case "G_MPNZ":
                GenerateSingleLabel(labels, "W", -110, -300, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "V", -110, -200, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "T", -110, -100, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "H", 110, -300, 0.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "N", 110, -100, 0.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "C", 0, -300, 0.5, 1.0, style, addChild);
                tb = GenerateSingleLabel(labels, "Y", 0, 0, 0.5, 0.0, style, addChild);
                tb.FindTextExtent();
                extraOffset = tb != null ? tb.Height : 0.1;
                addChild("Q", GenerateQ(symbolCode, labels, extraOffset));
                break;

            case "G_MPNEB":
                GenerateSingleLabel(labels, "W", -110, -300, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "T", -110, -100, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "H", 110, -300, 0.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "N", 110, -100, 0.0, 0.0, style, addChild);
                tb = GenerateSingleLabel(labels, "Y", 0, 0, 0.5, 0.0, style, addChild);
                tb.FindTextExtent();
                extraOffset = tb != null ? tb.Height : 0.1;
                addChild("Q", GenerateQ(symbolCode, labels, extraOffset));
                break;

            case "G_MPNEC":
                GenerateSingleLabel(labels, "W", -94, -300, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "T", -94, -100, 1.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "H", 94, -300, 0.0, 0.0, style, addChild);
                GenerateSingleLabel(labels, "N", 94, -100, 0.0, 0.0, style, addChild);
                tb = GenerateSingleLabel(labels, "Y", 0, 0, 0.5, 0.0, style, addChild);
                tb.FindTextExtent();
                extraOffset = tb != null ? tb.Height : 0.1;
                addChild("Q", GenerateQ(symbolCode, labels, extraOffset));
                break;

            case "G_FPPTS":
                GenerateSingleLabel(labels, "H", 50, 75, 0.0, 0.5, style, addChild);
                GenerateSingleLabel(labels, "H1", -50, 75, 1.0, 0.5, style, addChild);
                GenerateSingleLabel(labels, "T", 50, -75, 0.0, 0.5, style, addChild);
                break;

            case "G_FPPTN":
                GenerateSingleLabel(labels, "T", 50, -75, 0.0, 0.5, style, addChild);
                break;

            case "G_FPPCF":
                GenerateSingleLabel(labels, "T", 50, 0, 0.0, 0.5, style, addChild);
                break;
            }
        }