Esempio n. 1
0
        public static int Show(string text, string[] options)
        {
            Menu menu = new Menu(options)
            {
                width = 10, SelectedColor = ConsoleColor.Yellow, fillBackround = false
            };

            int width = 60;

            if (text.Length < 60)
            {
                width = text.Length + 4;
            }

            text = TextBreaker.BreakText(text, width - 4);
            int height = 3 + text.Count(x => x == '\n') + options.Length;

            ConsoleBuffer buf = new ConsoleBuffer(width, height)
            {
                ForegroundColor = ConsoleColor.Yellow
            };

            buf.SetCursorPosition(0, 0);
            buf.Write("/".PadRight(width - 1, '-') + "\\");
            buf.SetCursorPosition(0, height - 1);
            buf.Write("\\".PadRight(width - 1, '-') + "/");

            buf.SetCursorPosition(0, 1);
            buf.WriteVertical("".PadRight(height - 2, '|'));
            buf.SetCursorPosition(width - 1, 1);
            buf.WriteVertical("".PadRight(height - 2, '|'));

            buf.ForegroundColor = ConsoleColor.Gray;

            string[] lines = text.Split('\n');
            for (int i = 0; i < lines.Length; i++)
            {
                buf.SetCursorPosition(2, 1 + i);
                buf.Write(lines[i]);
            }

            menu.BufferX = (80 - width) / 2;
            menu.BufferY = (25 - height) / 2;

            buf.SetCursorPosition(width / 2 - 4, height - 1 - options.Length);
            menu.buffer = buf;
            menu.ReadMenu();

            return(menu.Selected);
        }
        // Token: 0x06000FAC RID: 4012 RVA: 0x0005CAC8 File Offset: 0x0005ACC8
        internal Dictionary <string, int> Scan()
        {
            List <string> list;
            int           num;

            if (!this.GetContent(out list, out num))
            {
                return(null);
            }
            ItemScanner.Tracer.Information <ItemScanner, int>((long)this.GetHashCode(), "{0}: Scanning item using locale id {1}.", this, num);
            TextBreaker textBreaker             = new TextBreaker(num);
            WordFilter  wordFilter              = new WordFilter(num);
            Dictionary <string, int> dictionary = new Dictionary <string, int>(1000);

            foreach (string text in list)
            {
                List <string> list2 = textBreaker.BreakText(text);
                if (list2 != null && list2.Count != 0)
                {
                    List <string> list3 = wordFilter.Filter(list2);
                    foreach (string key in list3)
                    {
                        int num2;
                        if (dictionary.TryGetValue(key, out num2))
                        {
                            dictionary[key] = num2 + 1;
                        }
                        else
                        {
                            dictionary.Add(key, 1);
                        }
                        if (dictionary.Count >= 1000)
                        {
                            return(dictionary);
                        }
                    }
                }
            }
            return(dictionary);
        }