private void FilterClick(object sender, EventArgs e)
        {
            WeatherList copy = new WeatherList(_current);

            wlists.Push(copy);           //pushing the copy onto the stack;

            uxUndoButton.Enabled = true; //we can now undo changes, so make button avaliable
            if (uxDateRangeButton.Checked)
            {
                _current.FilterRange(uxMonthCalendar.SelectionStart, uxMonthCalendar.SelectionEnd);
            }
            else if (uxBelowTempButton.Checked)
            {
                _current.FilterTemp(Convert.ToInt32(uxNumericUpDown.Value), true);
            }
            else if (uxAboveTempButton.Checked)
            {
                _current.FilterTemp(Convert.ToInt32(uxNumericUpDown.Value), false);
            }
            else if (uxDateHistory.Checked)
            {
                _current.FilterDateHistory(uxMonthCalendar.SelectionStart);
            }
            else
            {
                MessageBox.Show("Error: Please select a filter first!");
                return;
            }

            uxWeatherListBox.DataSource = null;
            uxWeatherListBox.DataSource = _current;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Button checks radio button and (attempts) to filter listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void uxFilterButton_Click(object sender, EventArgs e)
        {
            if (uxAboveTemp.Checked)
            {
                WeatherList temp = new WeatherList(wd);
                ws.Push(temp);
                wd.FilterTemp(Convert.ToDouble(uxTempSetting.Value), true);
                uxDatesList.DataSource = null;
                uxDatesList.Items.Clear();
                uxDatesList.DataSource = wd;
            }
            else if (uxBelowTemp.Checked)
            {
                WeatherList temp = new WeatherList(wd);
                ws.Push(temp);
                wd.FilterTemp(Convert.ToDouble(uxTempSetting.Value), false);
                uxDatesList.DataSource = null;
                uxDatesList.Items.Clear();
                uxDatesList.DataSource = wd;
            }
            else if (uxDateRange.Checked)
            {
                try
                {
                    WeatherList temp = new WeatherList(wd);
                    ws.Push(temp);
                    wd.FilterRange(uxCalendar.SelectionRange.Start, uxCalendar.SelectionRange.End);
                    uxDatesList.DataSource = null;
                    uxDatesList.Items.Clear();

                    uxDatesList.DataSource = wd;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Must select dates\n" + ex.ToString());
                }
            }
            else if (uxThisDate.Checked)
            {
                try
                {
                    WeatherList temp = new WeatherList(wd);
                    ws.Push(temp);
                    wd.FilterDateHistory(uxCalendar.SelectionRange.Start);
                    uxDatesList.DataSource = null;
                    uxDatesList.Items.Clear();
                    uxDatesList.DataSource = wd;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Must select a date\n" + ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Please select a filter");
            }
        }