Ejemplo n.º 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            string text = System.IO.File.ReadAllText(@"D:\tekst.txt");

            T   = text;
            txt = new Tekst(text);
        }
Ejemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)
        {
            string text = Algorytmy.Properties.Resources.DNA;

            T   = text;
            txt = new Tekst(text);
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("Podaj długość tekstu", "Uwaga", MessageBoxButtons.OK);
            }
            else
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();
                progressBar1.Value   = 0;
                progressBar1.Maximum = Convert.ToInt32(textBox3.Text);
                progressBar1.Step    = 1;
                int dlugosc;

                if (textBox2.TextLength > 0)
                {
                    dlugosc = Convert.ToInt32(textBox2.Text);
                    char litera;

                    for (int i = 0; i < Convert.ToInt32(textBox3.Text); i++)
                    {
                        litera = (char)losuj.Next(65, 65 + dlugosc);
                        T     += litera;
                        progressBar1.PerformStep();
                    }
                    txt = new Tekst(T);
                    T   = T.Remove(0);
                    watch.Stop();
                    var elapsedMs = watch.ElapsedMilliseconds;
                    MessageBox.Show("Tekst wygenerowany zajeło to " + Convert.ToString(elapsedMs) + " ms");
                }
                else
                {
                    MessageBox.Show("Wpisz długość alfabetu");
                }
            }
        }
Ejemplo n.º 4
0
        private void button_badaj_Click(object sender, EventArgs e)
        {
            bool wzorzeclosuj = true;

            if (Lbox.Checked)
            {
                string text = Algorytmy.Properties.Resources.tekstLosowy;
                T = text;
            }
            if (DNA_box.Checked)
            {
                string text = Algorytmy.Properties.Resources.DNA;
                T = text;
            }
            if (Tbox.Checked)
            {
                string text = Algorytmy.Properties.Resources.Tadek;
                T = text;
            }
            foreach (var series in chart1.Series)
            {
                series.Points.Clear();
            }
            if (KW_BOX.Checked)
            {
                wzorzeclosuj = false;
                PT           = textBox4.Text;
            }
            foreach (var series in chart2.Series)
            {
                series.Points.Clear();
            }
            char   litera;
            string U;

            if (wzorzeclosuj == true)
            {
                for (int i = 0; i < Convert.ToInt32(Patern_min.Text); i++)
                {
                    litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                    PT    += litera;
                }
            }
            for (int u = Convert.ToInt32(Text_min.Text); u < Convert.ToInt32(Tekst_max.Text); u = u + 1000)
            {
                U   = T;
                U   = U.Remove(u);
                txt = new Tekst(U);
                chart1.Update();

                if (KMP_box.Checked)
                {
                    var watchKMP = System.Diagnostics.Stopwatch.StartNew();
                    txt.KMPSearch(PT);
                    watchKMP.Stop();
                    chart1.Series["KMP"].Points.AddXY((double)u, Convert.ToInt32(watchKMP.ElapsedTicks));
                }
                if (sunday_box.Checked)
                {
                    var watchSunday = System.Diagnostics.Stopwatch.StartNew();
                    txt.SundaySeartch(PT);
                    watchSunday.Stop();
                    chart1.Series["Sunday"].Points.AddXY((double)u, Convert.ToInt32(watchSunday.ElapsedTicks));
                }
                if (BM.Checked)
                {
                    txt.preBM(PT);
                    var watchBM = System.Diagnostics.Stopwatch.StartNew();
                    txt.BMSeartch();
                    watchBM.Stop();
                    chart1.Series["BM"].Points.AddXY((double)u, Convert.ToInt32(watchBM.ElapsedTicks));
                }
            }
            ////////////////////Wzorzec
            PT = PT.Remove(0);
            if (wzorzeclosuj)
            {
                for (int i = 0; i < Convert.ToInt32(Patern_min.Text); i++)
                {
                    litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                    PT    += litera;
                }

                for (int u = Convert.ToInt32(Patern_min.Text); u < Convert.ToInt32(Patern_Max.Text); u = u + 10)
                {
                    for (int i = PT.Length; i < u; i++)
                    {
                        litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                        PT    += litera;
                    }

                    chart2.Update();

                    if (KMP_box.Checked)
                    {
                        var watchKMP = System.Diagnostics.Stopwatch.StartNew();
                        txt.KMPSearch(PT);
                        watchKMP.Stop();
                        chart2.Series["KMP"].Points.AddXY((double)u, Convert.ToInt32(watchKMP.ElapsedTicks));
                    }
                    if (sunday_box.Checked)
                    {
                        var watchSunday = System.Diagnostics.Stopwatch.StartNew();
                        txt.SundaySeartch(PT);
                        watchSunday.Stop();
                        chart2.Series["Sunday"].Points.AddXY((double)u, Convert.ToInt32(watchSunday.ElapsedTicks));
                    }
                    if (BM.Checked)
                    {
                        BMSearch.BoyerMoore BM = new BMSearch.BoyerMoore(textBox1.Text);
                        txt.preBM(PT);
                        var watchBM = System.Diagnostics.Stopwatch.StartNew();
                        txt.BMSeartch();
                        watchBM.Stop();
                        chart2.Series["BM"].Points.AddXY((double)u, Convert.ToInt32(watchBM.ElapsedTicks));
                    }
                }
                PT.Remove(0);
                T.Remove(0);
            }
        }