Example #1
0
        /// <summary>
        /// Get the combined modifier code for the coding scheme.
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>a friendly name for the combined modifier code</returns>
        public static string GetName(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(string.Empty);
            }

            char leadCode  = ModifierCode.GetCode(symbolCode);
            char trailCode = Echelon.GetCode(symbolCode);

            if (leadCode == ModifierCode.Mobility || leadCode == ModifierCode.Towed)
            {
                return(Mobility.GetName(symbolCode));
            }

            if (leadCode == ModifierCode.Installation)
            {
                return((trailCode == 'B') ? "Feint Dummy Installation" : "Installation");
            }

            string mod = ModifierCode.GetName(symbolCode);
            string ech = Echelon.GetName(symbolCode);

            if (string.IsNullOrEmpty(mod) || string.IsNullOrEmpty(ech))
            {
                return(string.Empty);
            }

            if (mod == "None" && ech == "None")
            {
                return(string.Empty);
            }

            if (mod == "None")
            {
                return(ech);
            }

            if (ech == "None")
            {
                return(mod);
            }

            return(mod + "\n" + ech);
        }
Example #2
0
        public void EchelonTest()
        {
            char gc = Echelon.GetCode(string.Empty);

            Assert.AreEqual(gc, (char)0);
            gc = Echelon.GetCode(null);
            Assert.AreEqual(gc, (char)0);
            gc = Echelon.GetCode("qqqqqqqqqqqqqqq");
            Assert.AreEqual(gc, 'Q');
            string str = Echelon.GetName(string.Empty);

            Assert.AreEqual(str, string.Empty);
            str = Echelon.GetName(null);
            Assert.AreEqual(str, string.Empty);
            str = Echelon.GetName("qqqqqqqqqqqqqqq");
            Assert.AreEqual(str, string.Empty);
            str = Echelon.GetName("qqpqqqqqqqqhqqq");
            Assert.AreEqual(str, "Brigade");
        }
Example #3
0
        /// <summary>
        /// Generates the correct combination of task force, installation, and feint dummy for a symbol.
        /// </summary>
        /// <param name="ms">
        /// The symbol to which the generated rendering is attached.
        /// </param>
        /// <param name="symbolCode">
        /// The symbol code for the given symbol
        /// </param>
        /// <returns>
        /// The maximum height of the generated rendering.
        /// </returns>
        internal static double Generate(MilSymbol ms, string symbolCode)
        {
            // This is the maximum height generated by this combination of pieces
            Rect r = ms.BaseRect;

            if (r.IsEmpty)
            {
                return(0);
            }

            double height = r.Top;

            if (!SymbolData.Check(ref symbolCode))
            {
                return(height);
            }

            char code = ModifierCode.GetCode(symbolCode);

            switch (code)
            {
            case ModifierCode.Headquarters:     // headquarters
                ms.AddChild("HQ", GenerateHeadquarters(ms));
                break;

            case ModifierCode.TaskForceHeadquarters:     // task force, headquarters
                ms.AddChild("TF", GenerateTaskForce(ms, out height));
                ms.AddChild("HQ", GenerateHeadquarters(ms));
                break;

            case ModifierCode.FeintDummyHeadquarters:     // feint dummy, headquarters
                ms.AddChild("FD", GenerateFeintDummy(ms, ref height));
                ms.AddChild("HQ", GenerateHeadquarters(ms));
                break;

            case ModifierCode.FeintDummyTaskForceHeadquarters:     // feint dummy, task force, headquarters
                ms.AddChild("TF", GenerateTaskForce(ms, out height));
                ms.AddChild("FD", GenerateFeintDummy(ms, ref height));
                ms.AddChild("HQ", GenerateHeadquarters(ms));
                break;

            case ModifierCode.TaskForce:     // task force
                ms.AddChild("TF", GenerateTaskForce(ms, out height));
                break;

            case ModifierCode.FeintDummy:     // feint dummy
                ms.AddChild("FD", GenerateFeintDummy(ms, ref height));
                break;

            case ModifierCode.FeintDummyTaskForce:     // feint dummy/task force
                ms.AddChild("TF", GenerateTaskForce(ms, out height));
                ms.AddChild("FD", GenerateFeintDummy(ms, ref height));
                break;

            case ModifierCode.Installation:     // installation
                ms.AddChild("Installation", GenerateInstallation(ms, out height));

                // There is an unfortunate overloading of the echelon character in the standard
                if (Echelon.GetCode(symbolCode) == 'B')
                {
                    ms.AddChild("FD", GenerateFeintDummy(ms, ref height));
                }

                break;

            case ModifierCode.Mobility:  // mobility
            case ModifierCode.Towed:     // towed
                break;
            }

            return(height);
        }