Esempio n. 1
0
        private List <ParsedText> ConvertToWords(List <string> TextToParse)
        {
            List <ParsedText> Parsed = ParseText(TextToParse);

            for (int i = 0; i < Parsed.Count; i++)
            {
                ParsedText p = Parsed[i];

                if (p.num > 0)
                {
                    if (i > 0 && p.OrigiNum == Parsed[i - 1].OrigiNum)
                    {
                        //The original number are all the same we should increment them
                        p.num    = Parsed[i - 1].num + 1;
                        p.Number = p.num.ToString();
                    }

                    if (cbConvertToWords.Checked || cbRoman.Checked)
                    {
                        p.Number = cbRoman.Checked ? NumberToWordsConverter.NumberToRoman(p.num)
                    : NumberToWordsConverter.NumberToWords(p.num);
                        //Number = cbUpperCase.Checked ? Number.ToUpper() : Number;
                    }
                }

                p.FinalText = p.Prefix + p.Number + p.Sufix;
            }

            return(Parsed);
        }
Esempio n. 2
0
        private List <ParsedText> ParseText(List <string> TextToParse)
        {
            List <ParsedText> Parsed = new List <ParsedText>();

            for (int i = 0; i < TextToParse.Count; i++)
            {
                string     InText = TextToParse[i];
                ParsedText p      = new ParsedText();

                Regex regexObj = new Regex(@"(?<Prefix>[^\d]*)(?<Number>\d*)(?<Sufix>.*$)");
                p.Prefix = regexObj.Match(InText).Groups["Prefix"].Value;
                p.Number = regexObj.Match(InText).Groups["Number"].Value;
                p.Sufix  = regexObj.Match(InText).Groups["Sufix"].Value;

                int num = 0;
                int.TryParse(p.Number, out num);

                p.num      = num;
                p.OrigiNum = num;

                Parsed.Add(p);
            }

            return(Parsed);
        }
        private List<ParsedText> ParseText(List<string> TextToParse)
        {
            List<ParsedText> Parsed = new List<ParsedText>();

            for (int i = 0; i < TextToParse.Count; i++)
            {
                string InText = TextToParse[i];
                ParsedText p = new ParsedText();

                Regex regexObj = new Regex(@"(?<Prefix>[^\d]*)(?<Number>\d*)(?<Sufix>.*$)");
                p.Prefix = regexObj.Match(InText).Groups["Prefix"].Value;
                p.Number = regexObj.Match(InText).Groups["Number"].Value;
                p.Sufix = regexObj.Match(InText).Groups["Sufix"].Value;

                int num = 0;
                int.TryParse(p.Number, out num);

                p.num = num;
                p.OrigiNum = num;

                Parsed.Add(p);
            }

            return Parsed;
        }