Пример #1
0
        public void FilterBy(SongFilter filter)
        {
            FilteredMediaList.Clear();
            foreach (Song s in MediaList)
            {
                FilteredMediaList.Add(s);
            }

            for (int i = 0; i < FilteredMediaList.Count; i++)
            {
                Song s = FilteredMediaList[i];

                int minYear;
                int maxYear;
                int minRating;
                int maxRating;

                if (s.SongName.Contains(filter.SongName))
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                bool shouldFilter = int.TryParse(filter.MinYear, out minYear);
                if (shouldFilter == true && s.YearReleased < minYear)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MaxYear, out maxYear);
                if (shouldFilter == true && s.YearReleased > maxYear)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MinRating, out minRating);
                if (shouldFilter == true && s.MyRating < minRating)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MaxRating, out maxRating);
                if (shouldFilter == true && s.MyRating > maxRating)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }
            }
        }
Пример #2
0
        public void FilterBy(SongFilter filter)
        {
            FilteredMediaList.Clear();
            foreach (Song s in MediaList)
            {
                FilteredMediaList.Add(s);
            }

            for (int i = 0; i < FilteredMediaList.Count; i++)
            {
                Song s = FilteredMediaList[i];

                int minYear;
                int maxYear;
                int minRating;
                int maxRating;

                if (s.SongName.Contains(filter.SongName))
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                bool shouldFilter = int.TryParse(filter.MinYear, out minYear);
                if (shouldFilter == true && s.YearReleased < minYear)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MaxYear, out maxYear);
                if (shouldFilter == true && s.YearReleased > maxYear)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MinRating, out minRating);
                if (shouldFilter == true && s.MyRating < minRating)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }

                shouldFilter = int.TryParse(filter.MaxRating, out maxRating);
                if (shouldFilter == true && s.MyRating > maxRating)
                {
                    FilteredMediaList.Remove(s);
                    i--;
                    continue;
                }
            }
        }
Пример #3
0
 public FormSongFilter(SongFilter filter)
 {
     InitializeComponent();
     textBoxSongName.Text  = filter.SongName;
     textBoxMinYear.Text   = filter.MinYear;
     textBoxMaxYear.Text   = filter.MaxYear;
     textBoxMinRating.Text = filter.MinRating;
     textBoxMaxRating.Text = filter.MaxRating;
     _SongFilter           = filter;
 }
Пример #4
0
 public FormSongFilter(SongFilter filter)
 {
     InitializeComponent();
     textBoxSongName.Text = filter.SongName;
     textBoxMinYear.Text = filter.MinYear;
     textBoxMaxYear.Text = filter.MaxYear;
     textBoxMinRating.Text = filter.MinRating;
     textBoxMaxRating.Text = filter.MaxRating;
     _SongFilter = filter;
 }
Пример #5
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            SongFilter     S = new SongFilter();
            FormSongFilter SongFormFilter = new FormSongFilter(S);
            DialogResult   Result         = SongFormFilter.ShowDialog();

            if (Result == DialogResult.OK)
            {
                _MediaCollection.FilterBy(S);
                listBox1.DataSource = _MediaCollection.FilteredMediaList;
            }
            else
            {
                listBox1.DataSource = _MediaCollection.MediaList;
            }
        }
Пример #6
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            SongFilter S = new SongFilter();
            FormSongFilter SongFormFilter = new FormSongFilter(S);
            DialogResult Result = SongFormFilter.ShowDialog();

            if (Result == DialogResult.OK)
            {
                _MediaCollection.FilterBy(S);
                listBox1.DataSource = _MediaCollection.FilteredMediaList;
            }
            else
            {
                listBox1.DataSource = _MediaCollection.MediaList;
            }
        }