Ejemplo n.º 1
0
        // TODO Velis
        private void SortEpisodeList(object parameter)
        {
            string sortType = parameter.ToString();

            switch (sortType)
            {
            case "Director":
                Episodes = new ObservableCollection <Episode>(Episodes.OrderBy(x => x.Director));
                break;

            case "Episode":
                Episodes = new ObservableCollection <Episode>(Episodes.OrderBy(x => x.EpisodeNumber));
                break;

            default:

                break;
            }
        }
Ejemplo n.º 2
0
 protected override void OnInit()
 {
     base.OnInit();
     Episodes.OrderBy(ep => ep.AiredEpisodeNumber);
 }
Ejemplo n.º 3
0
 private void OnSortListByDirector(Object parameter)
 {
     Episodes = new ObservableCollection <Episode>(Episodes.OrderBy(x => x.Director).ToList());
 }
Ejemplo n.º 4
0
 private void SortAsc(object parameter)
 {
     Episodes = new ObservableCollection <Episode>(Episodes.OrderBy(x => x.EpisodeNumber).ToList());
 }
Ejemplo n.º 5
0
        private void UpdateAll()
        {
            dgrid.Columns.Clear();
            if (!Episodes.Any())
            {
                return;
            }


            var episodesSorted = Episodes.OrderBy(e => e, EpisodeComparer);                                    //sort Episodes by season, episode
            var uploadsSorted  = episodesSorted.SelectMany(e => e.Downloads.Select(d => d.Upload)).Distinct(); //get a unique collection of the uploads;

            if (Settings.Instance.UseFavorites)
            {
                uploadsSorted = uploadsSorted.OrderBy(u => u, UploadComparer);  //sort by fav/nofav
            }



            List <Header> headers = new List <Header>();

            _cells = new List <Cell>();
            int i = 0;

            //Idea: In the following Loop we create 1 Header instance for ALL Uploads (regardless of the season) which have the same String-Representation

            foreach (var upload in uploadsSorted)
            {
                String title          = BuildUploadTitle(upload);
                var    existingHeader = headers.FirstOrDefault(h => h.Title == title);

                if (existingHeader == null)
                {
                    Header newHeader = new Header();
                    newHeader.Title            = BuildUploadTitle(upload);
                    newHeader.ToggleCommand    = new SimpleCommand <object, string>(s => ToggleColumn(newHeader, s));
                    newHeader.ToggleAllCommand = new SimpleCommand <object, object>(o => ToggleFullColumn(newHeader));
                    newHeader.Hosters          =
                        episodesSorted.SelectMany(e => e.Downloads)
                        .Where(d => d.Upload == upload)
                        .SelectMany(d => d.Links.Keys)
                        .Distinct().ToList();
                    headers.Add(newHeader);

                    DataGridTemplateColumn column = new DataGridTemplateColumn();
                    column.Header                    = newHeader;
                    column.HeaderTemplate            = new DataTemplate();
                    column.HeaderTemplate.VisualTree = new FrameworkElementFactory(typeof(MultiDownloadSelectionHeader));
                    column.HeaderStyle               = (Style)FindResource("CenterGridHeaderStyle");
                    column.CellTemplate              = new DataTemplate();
                    column.CellTemplate.VisualTree   = new FrameworkElementFactory(typeof(MultiDownloadSelectionCell));
                    column.CellTemplate.VisualTree.SetBinding(DataContextProperty, new Binding("Cells[" + i + "]"));

                    dgrid.Columns.Add(column);

                    i++;
                }
                else //there's already an upload existing (maybe in another Season) with the same string represenation
                {
                    existingHeader.Hosters = episodesSorted.SelectMany(e => e.Downloads)
                                             .Where(d => d.Upload == upload)
                                             .SelectMany(d => d.Links.Keys).Union(existingHeader.Hosters)
                                             .Distinct().ToList();
                }
            }

            DataGridTemplateColumn fColumn = new DataGridTemplateColumn();

            fColumn.HeaderStyle = (Style)FindResource("RemovedHeaderContentStyle");
            fColumn.Width       = new DataGridLength(1, DataGridLengthUnitType.Star);
            dgrid.Columns.Add(fColumn);

            List <Row> rows = new List <Row>();

            foreach (var episode in episodesSorted)
            {
                Row r = new Row();
                r.Title = "S" + episode.Season.Number + " E" + episode.Number;
                if (episode.EpisodeInformation != null && !String.IsNullOrWhiteSpace(episode.EpisodeInformation.Title))
                {
                    r.Tooltip = episode.EpisodeInformation.Title;
                }
                r.Cells = new List <Cell>();

                bool singleUpload =
                    (episode.Downloads.Select(d => d.Upload)
                     .Distinct()
                     .Select(BuildUploadTitle)
                     .Distinct()
                     .Count() == 1);                                 //if we only have downloads from one upload for this episode
                bool firstSelected = Settings.Instance.UseFavorites; //initialize state flag with a value from settings
                //if this is set to false, all following headers will not have any checkboxes ticked
                //if this is set to true, the next header from a favorized upload will have its checkboxes checked

                foreach (var header in headers)
                {
                    var c = new Cell();
                    c.Header  = header;
                    c.Entries = new List <CellEntry>();
                    c.Episode = episode;

                    DownloadData dloads   = episode.Downloads.FirstOrDefault(da => BuildUploadTitle(da.Upload) == header.Title);
                    bool         selected = dloads != null && dloads.Upload.Favorized; //select this episode because it's favorized
                    if (firstSelected && selected)
                    {
                        firstSelected = false;
                    }
                    else if (!firstSelected)
                    {
                        selected = false;
                    }


                    foreach (var hoster in header.Hosters)
                    {
                        if (dloads != null && dloads.Links.ContainsKey(hoster))
                        {
                            c.Entries.Add(new CellEntry {
                                Visibility = Visibility.Visible, Enabled = true, Link = dloads.Links[hoster], Checked = selected || singleUpload
                            });
                        }
                        else
                        {
                            c.Entries.Add(new CellEntry {
                                Visibility = Visibility.Hidden, Enabled = false, Link = "", Checked = false
                            });
                        }
                    }
                    _cells.Add(c);
                    r.Cells.Add(c);
                }

                rows.Add(r);
            }
            dgrid.ItemsSource = rows;
        }
 private void OnSortDirector(object parameter)
 {
     Episodes = new ObservableCollection <Episode>(Episodes.OrderBy(x => x.Director));
 }