/// <summary> /// add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimerAddButton_Click(object sender, RoutedEventArgs e) { //if text matches an amount of time if (timeRegex.IsMatch(TimerAmount.Text)) { //take input string[] s = timeRegex.Match(TimerAmount.Text).Value.Split(splitChArr, 3); int[] values = new int[s.Length]; for (int i = 0; i < s.Length; i++) { values[i] = Convert.ToInt32(s[i]); } //create timespan with input TimeSpan ts = new TimeSpan(values[0], values[1], values[2]); //if a timer is selected add the TimeSpan to it if (TimerListBox.SelectedIndex >= 0) { timerList[TimerListBox.SelectedIndex].Add(ts); TimerListBox.Items[TimerListBox.SelectedIndex] = timerList[TimerListBox.SelectedIndex].TimerFormat(); } //else create a new timer with the TimeSpan else if (TimerListBox.SelectedIndex == -1) { TimerClock temp = new TimerClock(ts); timerList.Add(temp); TimerListBox.Items.Add(temp.TimerFormat()); } } }
private void TimerAddTimerButton_Click(object sender, RoutedEventArgs e) { //if text matches an amount of time if (timeRegex.IsMatch(TimerAmount.Text)) { string[] s = timeRegex.Match(TimerAmount.Text).Value.Split(splitChArr, 3); int[] values = new int[s.Length]; for (int i = 0; i < s.Length; i++) { values[i] = Convert.ToInt32(s[i]); } //create timespan with input TimeSpan ts = new TimeSpan(values[0], values[1], values[2]); //create a new timer with the TimeSpan and add it to the ListBox TimerClock temp = new TimerClock(ts); timerList.Add(temp); TimerListBox.Items.Add(temp.TimerFormat()); } }