コード例 #1
0
        public void UpdateEpisodenNamesFromStorage()
        {
            FileInfo[]         files    = Folder.Files;
            List <EpisodeName> oldNames = episodesNames.ToList();
            ObservableCollection <EpisodeName> names = new ObservableCollection <EpisodeName>();

            foreach (FileInfo datei in files)
            {
                try
                {
                    EpisodeName episodeName = new EpisodeName(datei.FullName);

                    EpisodeName oldName = oldNames.FirstOrDefault(x => x.FullPath == episodeName.FullPath);

                    if (oldName != null)
                    {
                        episodeName.Name = oldName.Name;
                    }

                    int insertIndex = GetInsertIndexWhenOrderedBySeasonAndEpisode(episodeName, names);
                    names.Insert(insertIndex, episodeName);
                }
                catch { }
            }

            EpisodesNames        = names;
            MaxEpisodeNumberText = names.Any() ? names.Max(x => x.EpisodeNumber).ToString() : "0";
        }
コード例 #2
0
        public EpisodenNameWindow(EpisodeName episodeName)
        {
            InitializeComponent();

            this.episodeName = episodeName;

            tblEpisodeFilename.Text = episodeName.FileNameWithoutExtension + ":";
            tbxEpisodeName.Text     = episodeName.Name;
        }
コード例 #3
0
        private int GetInsertIndexWhenOrderedBySeasonAndEpisode(EpisodeName episodeName,
                                                                ObservableCollection <EpisodeName> list)
        {
            int index = 0;

            while (index < list.Count && list[index].SeasonNumber < episodeName.SeasonNumber)
            {
                index++;
            }
            while (index < list.Count && list[index].EpisodeNumber < episodeName.EpisodeNumber)
            {
                index++;
            }

            return(index);
        }