Beispiel #1
0
        public static void GetNamingRulesFromTSD(out NamingMode prefix, out Separator s, out NamingMode suffix, out NamingMode nonPrefix, out bool zeros, out bool invertPrefixSuffix, TransportSystemDefinition tsd)

        {
            if (tsd == TransportSystemDefinition.EVAC_BUS)
            {
                suffix             = NamingMode.Number;
                s                  = Separator.Hyphen;
                prefix             = NamingMode.Roman;
                nonPrefix          = NamingMode.Number;
                zeros              = false;
                invertPrefixSuffix = false;
            }
            else
            {
                var config = tsd.GetConfig();
                suffix             = config.Suffix;
                s                  = config.Separator;
                prefix             = config.Prefix;
                nonPrefix          = config.NonPrefixedNaming;
                zeros              = config.UseLeadingZeros;
                invertPrefixSuffix = config.InvertPrefixSuffix;
            }
        }
Beispiel #2
0
 public static void GetLineNamingParameters(ushort lineIdx, out NamingMode prefix, out Separator s, out NamingMode suffix, out NamingMode nonPrefix, out bool zeros, out bool invertPrefixSuffix) => GetLineNamingParameters(lineIdx, out prefix, out s, out suffix, out nonPrefix, out zeros, out invertPrefixSuffix, out string nil);
Beispiel #3
0
        public static TransportSystemDefinition GetLineNamingParameters(ushort lineIdx, out NamingMode prefix, out Separator s, out NamingMode suffix, out NamingMode nonPrefix, out bool zeros, out bool invertPrefixSuffix, out string icon)
        {
            var tsd = TransportSystemDefinition.GetDefinitionForLine(lineIdx);

            if (tsd != default)
            {
                GetNamingRulesFromTSD(out prefix, out s, out suffix, out nonPrefix, out zeros, out invertPrefixSuffix, tsd);
            }
            else
            {
                suffix             = default;
                s                  = default;
                prefix             = default;
                nonPrefix          = default;
                zeros              = false;
                invertPrefixSuffix = false;
            }
            icon = GetIconForLine(lineIdx);
            return(tsd);
        }
 public static string GetName(this NamingMode namingMode) => Locale.Get("K45_TLM_MODO_NOMENCLATURA", namingMode.ToString());
        internal static string GetString(NamingMode prefixo, Separator s, NamingMode sufixo, NamingMode naoPrefixado, int numero, bool leadingZeros, bool invertPrefixSuffix)
        {
            string prefixoSaida   = "";
            string separadorSaida = "";
            string sufixoSaida;
            int    prefixNum = 0;

            if (prefixo != NamingMode.None)
            {
                prefixNum = numero / 1000;
                if (prefixNum > 0)
                {
                    prefixoSaida = GetStringFromNameMode(prefixo, prefixNum);
                }

                numero %= 1000;
            }

            if (numero > 0)
            {
                if (prefixoSaida != "")
                {
                    switch (s)
                    {
                    case Separator.Slash:
                        separadorSaida = "/";
                        break;

                    case Separator.Space:
                        separadorSaida = " ";
                        break;

                    case Separator.Hyphen:
                        separadorSaida = "-";
                        break;

                    case Separator.Dot:
                        separadorSaida = ".";
                        break;

                    case Separator.None:
                        if (prefixo == NamingMode.Roman)
                        {
                            separadorSaida = "·";
                        }
                        break;
                    }
                }

                var targetNameModeSuffix = prefixo != NamingMode.None && prefixNum > 0 ? sufixo : naoPrefixado;
                leadingZeros &= targetNameModeSuffix == NamingMode.Number;
                sufixoSaida   = GetStringFromNameMode(targetNameModeSuffix, numero).PadLeft(leadingZeros ? 3 : 0, '0');

                return(invertPrefixSuffix && sufixo == NamingMode.Number && prefixo != NamingMode.Number && prefixo != NamingMode.Roman
                    ? sufixoSaida + separadorSaida + prefixoSaida
                    : prefixoSaida + separadorSaida + sufixoSaida);
            }
            else
            {
                return(prefixoSaida);
            }
        }
 internal static string GetStringFromNameMode(NamingMode mode, int num) =>
 mode == NamingMode.Roman ? NumberingUtils.ToRomanNumeral((ushort)num)
         : mode == NamingMode.Number ? num.ToString("D")
         : NumberingUtils.GetStringFromNumber(SimpleOptionsArrayForNamingType(mode), num + 1);
        internal static List <string> GetPrefixesOptions(TransportSystemDefinition tsd, bool addDefaults = true)
        {
            var        config = tsd.GetConfig();
            NamingMode m      = config.Prefix;

            LogUtils.DoLog("getPrefixesOptions: MODO NOMENCLATURA = " + m);
            var saida = new List <string>();

            if (addDefaults)
            {
                saida.AddRange(new string[] { Locale.Get("K45_TLM_ALL"), Locale.Get("K45_TLM_UNPREFIXED") });
            }
            else
            {
                saida.Add("/");
            }
            switch (m)
            {
            case NamingMode.GreekUpper:
            case NamingMode.GreekUpperNumber:
                saida.AddRange(gregoMaiusculo.Select(x => x.ToString()));
                break;

            case NamingMode.GreekLower:
            case NamingMode.GreekLowerNumber:
                saida.AddRange(gregoMinusculo.Select(x => x.ToString()));
                break;

            case NamingMode.CyrillicUpper:
            case NamingMode.CyrillicUpperUpper:
                saida.AddRange(cirilicoMaiusculo.Select(x => x.ToString()));
                break;

            case NamingMode.CyrillicLower:
            case NamingMode.CyrillicLowerNumber:
                saida.AddRange(cirilicoMinusculo.Select(x => x.ToString()));
                break;

            case NamingMode.LatinUpper:
            case NamingMode.LatinUpperNumber:
                saida.AddRange(latinoMaiusculo.Select(x => x.ToString()));
                break;

            case NamingMode.LatinLower:
            case NamingMode.LatinLowerNumber:
                saida.AddRange(latinoMinusculo.Select(x => x.ToString()));
                break;

            case NamingMode.Number:
                for (int i = 1; i <= 64; i++)
                {
                    saida.Add(i.ToString());
                }
                break;

            case NamingMode.Roman:
                for (ushort i = 1; i <= 64; i++)
                {
                    saida.Add(NumberingUtils.ToRomanNumeral(i));
                }
                break;
            }
            if (TLMLineUtils.m_numberedNamingTypes.Contains(m))
            {
                saida.AddRange(numeros.Select(x => x.ToString()));
            }
            return(saida);
        }
        internal static string[] SimpleOptionsArrayForNamingType(NamingMode prefixNamingMode)
        {
            var saida = new List <string>(new string[1]);

            if (prefixNamingMode == NamingMode.None)
            {
                return(saida.ToArray());
            }
            switch (prefixNamingMode)
            {
            case NamingMode.GreekUpper:
            case NamingMode.GreekUpperNumber:
                saida.AddRange(gregoMaiusculo);
                break;

            case NamingMode.GreekLower:
            case NamingMode.GreekLowerNumber:
                saida.AddRange(gregoMinusculo);
                break;

            case NamingMode.CyrillicUpper:
            case NamingMode.CyrillicUpperUpper:
                saida.AddRange(cirilicoMaiusculo);
                break;

            case NamingMode.CyrillicLower:
            case NamingMode.CyrillicLowerNumber:
                saida.AddRange(cirilicoMinusculo);
                break;

            case NamingMode.LatinUpper:
            case NamingMode.LatinUpperNumber:
                saida.AddRange(latinoMaiusculo);
                break;

            case NamingMode.LatinLower:
            case NamingMode.LatinLowerNumber:
                saida.AddRange(latinoMinusculo);
                break;

            case NamingMode.Number:
                string[] temp = new string[64];
                for (int i = 1; i <= 64; i++)
                {
                    temp[i - 1] = i.ToString();
                }
                saida.AddRange(temp);
                break;

            case NamingMode.Roman:
                string[] tempR = new string[64];
                for (ushort i = 1; i <= 64; i++)
                {
                    tempR[i - 1] = NumberingUtils.ToRomanNumeral(i);
                }
                saida.AddRange(tempR);
                break;
            }
            if (TLMLineUtils.m_numberedNamingTypes.Contains(prefixNamingMode))
            {
                saida.AddRange(numeros);
            }
            return(saida.ToArray());
        }