//Insertion sort private void BT_Insertion_Go_Click(object sender, EventArgs e) { //play sound in seperate thread WorkerThread = delegate { snd_button.Play(); }; BeginInvoke(WorkerThread); //Create new output window ascending if (rb_ascending.Checked) { FormThread = delegate { Form = new OutputScreen(array, Sorting.Insertion, true, Bar_Speed.Value) { Text = "Output Insertion Sort Ascending" }; }; BeginInvoke(FormThread); } else { //Create new output window descending FormThread = delegate { Form = new OutputScreen(array, Sorting.Insertion, false, Bar_Speed.Value) { Text = "Output Insertion Sort Descending" }; }; BeginInvoke(FormThread); } GenerateArray(); }
private void Bt_Fibonacci_Click(object sender, EventArgs e) { //play sound in seperate thread WorkerThread = delegate { snd_button.Play(); }; BeginInvoke(WorkerThread); FormThread = delegate { //sort the array Array.Sort(array); //update ui tb_array.Text = string.Join(", ", array); //add "search for" if blank if (this.tb_searchfor.Text == "") { this.tb_searchfor.Text = array[r.Next(array.Count())].ToString(); } //try convert text to string try { decimal.Parse(this.tb_searchfor.Text); } catch (Exception) { return; } //Create new output window Form = new OutputScreen(array, Searching.Fibonacci, decimal.Parse(tb_searchfor.Text), Bar_Speed.Value) { Text = "Output Binary Search" }; }; BeginInvoke(FormThread); }