private void com_inputSequence_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (string.IsNullOrEmpty(com_inputSequence.SelectedValue.ToString()) || com_inputSequence.Items.Count <= 0) { return; } InitStates(); InputSortList.Clear(); InputSortList = com_inputSequence.SelectedValue.ToString().Split(',').ToList <string>(); }
private void StartBuble() { bool isAllNum = true; foreach (var item in InputSortList) { int num = 0; if (!int.TryParse(item, out num)) { isAllNum = false; break; } } if (isAllNum) { if (rad_BubbleSort.IsChecked == true) { _exchangeSortInt = new BubbleSort <int>(); } if (rad_QuickSort.IsChecked == true) { _exchangeSortInt = new QuickSort <int>(); } //添加事件 _exchangeSortInt.ProcessSortEvent += _bubbleSort_ProcessSortEvent; _exchangeSortInt.EndSortEvent += _bubbleSortInt_EndSortEvent; //如果全是数字 Task.Factory.StartNew(new Action(() => { _exchangeSortInt.ExchangeSort(InputSortList.ConvertAll(x => Convert.ToInt32(x))); })); } else { if (rad_BubbleSort.IsChecked == true) { _exchangeSort = new BubbleSort <string>(); } if (rad_QuickSort.IsChecked == true) { _exchangeSort = new QuickSort <string>(); } _exchangeSort.ProcessSortEvent += _bubbleSort_ProcessSortEvent; _exchangeSort.EndSortEvent += _bubbleSortInt_EndSortEvent; Task.Factory.StartNew(new Action(() => { //如果里面有非数字 _exchangeSort.ExchangeSort(InputSortList); })); } }