Пример #1
0
        private void testPatternButton_Click(object sender, EventArgs e)
        {
            if (t_GeneratePat == null) //reset in event handler
            {
                openArchiveDialog.Filter = "Pattern File|*.txt";
                if (openArchiveDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                testPatternButton.Enabled = false;

                hashCreator.loadPatterns(openArchiveDialog.FileName);

                //make a copy of the dictionary to avoid conflicts, with only unknown file name to speed up.
                patternDic = new HashDictionary("Hash/PatternDic.txt");
                SortedList <long, HashData> subHashList;
                for (int i = 0; i < hashDic.HashList.Count; i++)
                {
                    subHashList = hashDic.HashList.Values[i];
                    foreach (KeyValuePair <long, HashData> kvp in subHashList)
                    {
                        if (kvp.Value.filename.CompareTo("") == 0)
                        {
                            patternDic.LoadHash(kvp.Value.ph, kvp.Value.sh, kvp.Value.filename, kvp.Value.crc, kvp.Value.archiveName);
                        }
                    }
                }

                hashCreator.event_FilenameTest += FilenameTestEventHandler; //reset in eventhandler

                t_GeneratePat = new Thread(new ParameterizedThreadStart(hashCreator.Patterns));
                t_GeneratePat.Start(patternDic);


                button_Pause.Enabled = true;
                button_Stop.Enabled  = true;
            }
            else
            {
                MessageBox.Show("Already testing! Please wait for completion", "Please wait", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }