private void materialFlatButtonTxrAra_Click(object sender, EventArgs e) { { Test3(); } void Test3() { BoyerMooreHorspool bmh = new BoyerMooreHorspool(); string textveri = richTextBox2.Text; Stopwatch sw = new Stopwatch(); sw.Start(); string haystack = textveri; List <int> match = new List <int>(); string needle = patterntextfield.Text; match = bmh.Find(haystack, needle); if (true) { if (match == null) { materialSingleLineTextField1.Text = "Eşleşme Yok!"; return; } materialSingleLineTextField1.Text = listBox1.SelectedItem + ". Karakterde eşleme var"; richTextBox1.Text = haystack; //arbitrary numbers to test for (int i = 0; i < match.Count; i++) { int blockLength = patterntextfield.TextLength; richTextBox1.SelectionStart = match[i]; richTextBox1.SelectionLength = blockLength; richTextBox1.SelectionBackColor = Color.Yellow; } } sw.Stop(); string ExecutionTimeTaken = string.Format("{0} dk:{1} sn:{2} milisn", sw.Elapsed.Minutes, sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds); materialSingleLineTextField3.Text = ExecutionTimeTaken; materialSingleLineTextField2.Text = haystack.Length.ToString(); int chars = metintextfield.Text.Length; materialSingleLineTextField2.Text = chars.ToString(); materialSingleLineTextField5.Text = bmh.Karsi().ToString(); materialSingleLineTextField6.Text = bmh.Esle().ToString(); listBox1.DataSource = match; } }
public void Test() { BoyerMooreHorspool bmh = new BoyerMooreHorspool(); string haystack = metintextfield.Text; string needle = patterntextfield.Text; //int match = bmh.Find(haystack, needle); List <int> match = new List <int>(); match = bmh.Find(haystack, needle); if (true) { if (match == null) { materialSingleLineTextField1.Text = "Eşleşme Yok!"; return; } materialSingleLineTextField1.Text = listBox1.SelectedItem + ". Karakterde eşleme var"; richTextBox1.Text = haystack; //arbitrary numbers to test for (int i = 0; i < match.Count; i++) { int blockLength = patterntextfield.TextLength; richTextBox1.SelectionStart = match[i]; richTextBox1.SelectionLength = blockLength; richTextBox1.SelectionBackColor = Color.Yellow; } int chars = metintextfield.Text.Length; materialSingleLineTextField2.Text = chars.ToString(); materialSingleLineTextField5.Text = bmh.Karsi().ToString(); materialSingleLineTextField6.Text = bmh.Esle().ToString(); listBox1.DataSource = match; } }