예제 #1
0
파일: Form1.cs 프로젝트: ostroovok/Task1
        private void RunButton_Click_1(object sender, EventArgs e)
        {
            Conversion    conv         = new Conversion(toOpenPath);
            string        textFromFile = conv.TextFromFile();
            WorkWithFile  wwf          = new WorkWithFile(textFromFile);
            DictHashTable dict         = wwf.FindWordsOfN();
            var           i            = 250;

            foreach (Chain item in dict)
            {
                var temp = new ProgressBar();
                temp.Value    = item.Value * 10;
                temp.Width    = 350;
                temp.Height   = 25;
                temp.Location = new Point(15, i);

                var label = new Label();
                label.Width    = 200;
                label.Height   = 25;
                label.Text     = $"Name: '{item.Key}', Number: --{item.Value}";
                label.Location = new Point(385, i + 3);

                Controls.Add(temp);
                Controls.Add(label);
                i += 30;
            }

            OutBox.Text = "Выполнено";
        }
예제 #2
0
        private bool Find(string word, DictHashTable dict)
        {
            var temp = dict.GetElement(word.ToLower());

            if (temp != null)
            {
                temp.Value += 1;
                return(true);
            }
            return(false);
        }
예제 #3
0
        public DictHashTable FindWordsOfN()
        {
            string[]      words = TextFromFile.Split(new string[] { "\r\n", " " }, StringSplitOptions.None);
            DictHashTable dict  = new DictHashTable();

            dict.Add(words[0].ToLower(), 1);
            for (int i = 1; i < words.Length; i++)
            {
                bool check = Find(words[i], dict);
                if (!check)
                {
                    dict.Add(words[i], 1);
                }
            }
            return(dict);
        }