private void LoadShowlist() { sl.LoadShowlist(); for (int j = 0; j < sl.Showlist.Length / 7; j++) { AMediaFile tmp = new AMediaFile(); tmp.Name = sl.Showlist[j, WatchList.NAME]; tmp.MyType = sl.Showlist[j, WatchList.TYPE]; tmp.Version = sl.Showlist[j, WatchList.VERSION]; tmp.MyPath = sl.Showlist[j, WatchList.PATH]; tmp.Watched = Int32.Parse(sl.Showlist[j, WatchList.WATCHED]); tmp.CreatedDate = DateTime.Parse(sl.Showlist[j, WatchList.CREATED]); tmp.Favorite = Int32.Parse(sl.Showlist[j, WatchList.FAVORITE]); MyShowList.Add(tmp); } }
private void picbx_Trash_DragDrop(object sender, DragEventArgs e) { //Remove show from all the lists it is on AMediaFile r = new AMediaFile(System.IO.Path.GetFileNameWithoutExtension(BeingDragged)); //availableshows.Remove(r);// = AMediaFile.RemoveFromList(r, NewestShows); int match = MyShowList.ExactMatch(r); if (match != 9999) MyShowList.Remove(r); ListViewItem item = lstvw_ToWatch.FindItemWithText(r.Name); if (item != null) //if it is on the to watch list { lstvw_ToWatch.Items.Remove(item); } foreach (ListViewItem lvi in lstvw_Display.Items) { if (lvi.Name == BeingDragged) { lstvw_Display.Items.Remove(lvi); break; } } if (System.IO.File.Exists(BeingDragged)) { System.IO.File.SetAttributes(BeingDragged, System.IO.FileAttributes.Normal); FileSystem.DeleteFile(BeingDragged, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } else MessageBox.Show("Couldn't Delete " + BeingDragged + " ! The File Does Not Exist!"); }
private async void bttn_Search_Click(object sender, EventArgs e) { if(!string.IsNullOrEmpty(txt_Search.Text)) { progbarNewestShows.Visible = true; await Task.Run(async() => { AMediaFile mf = new AMediaFile(500); var allfiles = await availableshows.AllFiles; foreach (string s in allfiles) { if (s.IndexOf(txt_Search.Text, StringComparison.OrdinalIgnoreCase) != -1) { AMediaFile tmp = new AMediaFile(Path.GetFileNameWithoutExtension(s)); tmp.MyPath = s; mf.Add(tmp); } } mf.MediaFiles = Utility.Dynamicate(mf.MediaFiles); if (Utility.TaskIsRunning(tskAddtoDisplay)) {//If already started stop and start over cts.Cancel(); cts = new CancellationTokenSource(); } tskAddtoDisplay = Task.Run(() => AddtoDisplayListView(mf, cts.Token)); await tskAddtoDisplay; }); } }
private void StartPlaylist(object sender, EventArgs e) { AMediaFile playlist = new AMediaFile(1); foreach (ListViewItem item in lstvw_ToWatch.Items) { AMediaFile ms = new AMediaFile(item.Text); ms.MyPath = item.Name; playlist.Add(ms); } Utility.Create_PlayList(Utility.PlayListPath, playlist.MediaFiles); System.Diagnostics.Process.Start(Utility.PlayListPath); //System.Windows.Forms.SendKeys.Send("F"); make full screen }
//need to rename to do FileMove or something better cause it does NOT copy private void doFileCopy(string source, string dest) { try { if(File.Exists(source)) FileSystem.MoveFile(source, dest, UIOption.AllDialogs); else if (Directory.Exists(source)) FileSystem.MoveDirectory(source, dest, UIOption.AllDialogs); AMediaFile s = new AMediaFile(Path.GetFileNameWithoutExtension(dest)); int match = MyShowList.ExactMatch(s); if (match != 9999) MyShowList.MediaFiles[match].MyPath = dest; this.Invoke((MethodInvoker)delegate { ListView.ListViewItemCollection items = lstvw_Display.Items; foreach (ListViewItem lvi in items) { if (lvi.Name == BeingDragged) { lstvw_Display.Items.Remove(lvi); lstvw_Display.Update(); break; } } }); } catch { } }
//Get file names and turn to AMediaFile private async Task<AMediaFile> PopulateDisplayList(string thePath, CancellationToken cts) { IEnumerable<string> files; IEnumerable<string> folders; if (thePath == "Newest Shows") { files = await tsklatestshows; folders = new List<string>(1); } else { files = await availableshows.MediaFilesinFolder(thePath); folders = await availableshows.Folders_In_Folder(thePath); } AMediaFile TheDisplayList = new AMediaFile(1); if (files == null) files = new List<string>(1); foreach (string item in folders) { if (item != "Error! Path not a folder or it doesn't exist" & item.IndexOf("no results") == -1 && !cts.IsCancellationRequested) { AMediaFile t = new AMediaFile(Path.GetFileName(item)); t.MyPath = item; if (item.IndexOf("\\TV\\") != -1) t.MyType = "TV"; else if (string.IsNullOrEmpty(t.MyType)) t.MyType = "MOVIE"; TheDisplayList.Add(t); } else if (cts.IsCancellationRequested) { this.Invoke((MethodInvoker)delegate { lstvw_Display.Clear(); }); break; } } foreach (string item in files) { if (item != "Error! Path not a folder or it doesn't exist" & item.IndexOf("no results") == -1) { AMediaFile t = new AMediaFile(System.IO.Path.GetFileNameWithoutExtension(item)); t.MyPath = item; if (item.IndexOf("\\TV\\") != -1) t.MyType = "TV"; else if (string.IsNullOrEmpty(t.MyType)) t.MyType = "MOVIE"; TheDisplayList.Add(t); } } return TheDisplayList; }
//Add show to Display ListView private void AddtoDisplayListView(AMediaFile ShowToAdd, CancellationToken cts) { cts.Register(() => { this.Invoke((MethodInvoker)delegate { lstvw_Display.Clear(); }); }); //Foreach show create the listview item if (ShowToAdd.MediaFiles == null) ShowToAdd.MediaFiles = new AMediaFile[1]; foreach (AMediaFile mf in ShowToAdd.MediaFiles) { if (mf != null) { if (!cts.IsCancellationRequested) { ListViewItem li = new ListViewItem(); AMediaFile color = GetColor(mf); li.BackColor = color.Background; li.ForeColor = color.Foreground; if (mf.MyType != "") li.ImageIndex = GetImageIndex(mf.ToString(), myImgs.LoadedImageList); if (li.ImageIndex == -1) {//No image found if (mf.Name != "Freddy")//Anomolies dont get these pics myImgs.MissingImgsAddMissingImg(mf.Name, mf.MyType, mf.Version); if (li.Text.IndexOf("Trilogy") != -1)//try again removing trilogy li.ImageIndex = GetImageIndex(li.Text.Replace("Trilogy", ""), myImgs.LoadedImageList); if (li.ImageIndex == -1) li.ImageIndex = GetImageIndex("Missing Image", myImgs.LoadedImageList); } li.Name = mf.MyPath; if (Directory.Exists(mf.MyPath)) li.Text = "* " + mf.ToString() + " *"; else if (File.Exists(mf.MyPath)) li.Text = mf.ToString(); this.Invoke((MethodInvoker)delegate { lstvw_Display.Items.Add(li); }); } else //Action canceled { this.Invoke((MethodInvoker)delegate { lstvw_Display.Clear(); }); return; } } else break; } //Add last one so I know it got them all ListViewItem lis = new ListViewItem(); lis.BackColor = System.Drawing.Color.Black; lis.ForeColor = System.Drawing.Color.White; lis.ImageIndex = GetImageIndex("0 The End", myImgs.LoadedImageList); lis.Name = "End of Results"; lis.Text = "End of Results"; this.Invoke((MethodInvoker)delegate { lstvw_Display.Items.Add(lis); progbarNewestShows.Visible = false; }); //Search for missing imgs if (tskMissingImgs == null || tskMissingImgs.IsCompleted) tskMissingImgs = Task.Run(() => myImgs.MissingImgsSearchAll()); //uncomment to get new pics }
/* private AMediaFile UpdateDisplay(AMediaFile ListOfShows) { AMediaFile[] NewUnWatched = new AMediaFile[200]; int newunwatched = 0; AMediaFile[] NewWatched = new AMediaFile[200]; int newwatched = 0; AMediaFile[] OldUnWatched = new AMediaFile[500]; int oldunwatched = 0; AMediaFile[] OldWatched = new AMediaFile[500]; int oldwatched = 0; AMediaFile InOrder = new AMediaFile(ListOfShows.Length); bool empty = true; //lstvw_Display.Clear(); //lstvw_Display.Columns.Add("Shows To Watch"); //Put directories at the top foreach(AMediaFile t in ListOfShows.MediaFiles) { if (t != null) { if (System.IO.Directory.Exists(t.MyPath)) { //AddtoDisplayListView(t, Color.Green, Color.Black); t.Foreground = Color.Green; t.Background = Color.Black; InOrder.Add(t); ListOfShows.Remove(t); empty = false; } } else break; } foreach (AMediaFile t in ListOfShows.MediaFiles) { if (t != null) { empty = false; if (Utility.IsMediaFile(t.MyPath))// || Utility.IsNotImportantFolder(t.MyPath)) { if (t.ToString().IndexOf("Show Not Found") == -1) { int match = ShowList.ExactMatch(t); System.IO.FileInfo fi = new System.IO.FileInfo(t.MyPath); DateTime DaysAgo = DateTime.Now.AddDays(-3); if (match != 9999) { if (ShowList.MediaFiles[match].Watched == 0)//hasn't been watched yet { if (ShowList.MediaFiles[match].CreatedDate == null || ShowList.MediaFiles[match].CreatedDate != null) ShowList.MediaFiles[match].CreatedDate = fi.CreationTime; //is within 3 days old Else never been watched and older than 3 days if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { NewUnWatched[newunwatched] = t; newunwatched++; } else { OldUnWatched[oldunwatched] = t; oldunwatched++; } }//Been watched, but it is only within 3 days old else if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { NewWatched[newwatched] = t; newwatched++; } else if (ShowList.MediaFiles[match].Watched > 0 & DateTime.Compare(fi.CreationTime, DaysAgo) < 0) { OldWatched[oldwatched] = t; oldwatched++; } //old and watched } else//Its not already added to ShowList { //is within 3 days old t.CreatedDate = fi.CreationTime; ShowList.Add(t); if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { NewUnWatched[newunwatched] = t; newunwatched++; } else { OldUnWatched[oldunwatched] = t; oldunwatched++; } } } else { //AddtoDisplayListView(ListOfShows.MediaFiles[0], Color.Red, Color.White); t.Foreground = Color.Red; t.Background = Color.White; InOrder.Add(t); } } } else break; } foreach (AMediaFile t in NewUnWatched) { if (t != null) { //AddtoDisplayListView(t, Color.Red, Color.White); t.Foreground = Color.Red; t.Background = Color.White; InOrder.Add(t); } else break; } foreach (AMediaFile t in NewWatched) { if (t != null) { //AddtoDisplayListView(t, Color.Red, Color.Blue); t.Foreground = Color.Red; t.Background = Color.Blue; InOrder.Add(t); } else break; } foreach (AMediaFile t in OldUnWatched) { if (t != null) { //AddtoDisplayListView(t, Color.Black, Color.White); t.Foreground = Color.Black; t.Background = Color.White; InOrder.Add(t); } else break; } foreach (AMediaFile t in OldWatched) { if (t != null) { int match = ShowList.ExactMatch(t); System.IO.FileInfo fi = new System.IO.FileInfo(t.MyPath); if (match != 9999) { //on the list and watched > 4 if (ShowList.MediaFiles[match].Watched > 4) { //AddtoDisplayListView(t, Color.Black, Color.Blue); t.Foreground = Color.Black; t.Background = Color.Blue; InOrder.Add(t); } else { //AddtoDisplayListView(t, Color.Black, Color.LightBlue); t.Foreground = Color.Black; t.Background = Color.LightBlue; InOrder.Add(t); } } //else if(DisplayWatchedLess4 == true) AddtoDisplayListView(t, Color.Black, Color.LightBlue); //not on the list, but probably watched it } else break; } if (empty) { { } AMediaFile t = new AMediaFile("No Results!", "0000","MOVIE", DateTime.Now, "Unknown",0,0); //AddtoDisplayListView(t, Color.Black, Color.Red); t.Foreground = Color.Black; t.Background = Color.Red; InOrder.Add(t); } InOrder.MediaFiles = Utility.Dynamicate(InOrder.MediaFiles); return InOrder; } */ public AMediaFile GetColor(AMediaFile show) { int match = MyShowList.ExactMatch(show); System.IO.FileInfo fi = new System.IO.FileInfo(show.MyPath); DateTime DaysAgo = DateTime.Now.AddDays(-3); if (match != 9999) { if (MyShowList.MediaFiles[match].Watched == 0)//hasn't been watched yet { if (MyShowList.MediaFiles[match].CreatedDate == null || MyShowList.MediaFiles[match].CreatedDate != null) MyShowList.MediaFiles[match].CreatedDate = fi.CreationTime; //is within 3 days old Else never been watched and older than 3 days if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { show.Foreground = Color.Red; show.Background = Color.White; } else { show.Foreground = Color.Black; show.Background = Color.White; } }//Been watched, but it is only within 3 days old else if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { show.Foreground = Color.Red; show.Background = Color.Blue; } else if (MyShowList.MediaFiles[match].Watched > 0 & DateTime.Compare(fi.CreationTime, DaysAgo) < 0) { if (MyShowList.MediaFiles[match].Watched > 4) { show.Foreground = Color.Black; show.Background = Color.Blue; } else { show.Foreground = Color.Black; show.Background = Color.LightBlue; } } //old and watched } else//Its not already added to ShowList { //is within 3 days old MyShowList.Add(show); if (DateTime.Compare(fi.CreationTime, DaysAgo) > 0) { show.Foreground = Color.Red; show.Background = Color.White; } else { show.Foreground = Color.Black; show.Background = Color.White; } } return show; }
private void UpdateWatched() { //Update showlist to increase watched amount int match = 0; if (lstvw_ToWatch.Items.Count > 0) { foreach (ListViewItem s in lstvw_ToWatch.Items) { if (s != null) { FileInfo fi = new FileInfo(s.Name); try { fi.LastAccessTime = DateTime.Now; } catch { System.IO.File.SetAttributes(s.Name, System.IO.FileAttributes.Normal); fi.LastAccessTime = DateTime.Now; } AMediaFile ms = new AMediaFile(s.Text); match = MyShowList.ExactMatch(ms); if (match == 9999)//not on list so add it { ms.Watched += 1; ms.Favorite = 0; ms.CreatedDate = fi.CreationTime; MyShowList.Add(ms); sl.AddShow(ms.Name, ms.Version, ms.MyType, ms.MyPath, ms.Watched.ToString(), ms.CreatedDate.ToString(), ms.Favorite.ToString()); } else//it is on the list { MyShowList.MediaFiles[match].Watched += 1; ms = MyShowList.MediaFiles[match]; sl.AddShow(ms.Name,ms.Version,ms.MyType,ms.MyPath,ms.Watched.ToString(),ms.CreatedDate.ToString(),ms.Favorite.ToString()); } } } } sl.SaveFavorites(); }
private async void UpdateAfterDownload(ListView.ListViewItemCollection collection) { AMediaFile dlList = new AMediaFile(1); AMediaFile HighestShows = new AMediaFile(50); int HS = 0; foreach (AMediaFile ms in dlList.MediaFiles) { int[] match = dlList.MatchesByName(ms); int highest = 0; if (match[0] != 9999)//if it is on the list { //Get the highest episode bool runonce = true; foreach (int b in match) { if (b != 9999) { if (runonce == true) { runonce = false; highest = b; } if (dlList.MediaFiles[b].Episode >= dlList.MediaFiles[highest].Episode & dlList.MediaFiles[b].Season >= dlList.MediaFiles[highest].Season) highest = b; } else break; } if (HighestShows.ExactMatch(dlList.MediaFiles[highest]) == 9999) { HighestShows.MediaFiles[HS] = dlList.MediaFiles[highest]; HS++; } } else { HighestShows.MediaFiles[HS] = ms; HS++; } } foreach (AMediaFile ms in HighestShows.MediaFiles) { if (ms != null) { AMediaFile latest = await availableShows.LatestShows; int[] match = latest.MatchesByName(ms); //if (match[0] != 9999) // availableShows.LatestShows.MediaFiles[match[0]] = ms; } else break; } }
private void bttn_AddToFavorites_Click(object sender, EventArgs e) { if (lstv_SearchResults.SelectedItems[0] != null) { ListViewItem item = lstv_SearchResults.SelectedItems[0]; AMediaFile ms = new AMediaFile(item.Text); if (lbl_Favorites.ForeColor == this.selected_forecolor) { Favorites.Add(ms); UpdateFavorites(); showlist.SaveFavorites(GetShowsFromListView("Favorites").Shows); } else { WishList.Add(ms); lstvw_WishList.Items.Clear(); foreach (AShow sho in WishList.Shows) lstvw_WishList.Items.Add(sho.ToString()); wishlist.SaveFavorites(GetShowsFromListView("WishList").Shows); } #region oldmethod //ms.Link = item.SubItems[6].Text; /*AShow shows = new AShow(1); //shows.Shows = availableShows.LatestShows.MediaFiles; int[] match = shows.MatchesByName(ms); string[] Remove = new string[10]; int i = 0; if (match[0] != 9999) { // availableShows.LatestShows.MediaFiles[match[0]] = ms; foreach(var li in lstv_Favorites.Items) { if (li.ToString().IndexOf(ms.Name) != -1) { Remove[i] = li.ToString(); i++; } } foreach(string s in Remove) { if (s != null) lstv_Favorites.Items.Remove(lstv_Favorites.Items.Find(s, false)[0]); else break; } } else lstv_Favorites.Items.Add(ms.ToString()); */ #endregion } else lblSearch.Text = "You must select a show to add first!"; }
private void bttn_Download_Click(object sender, EventArgs e) { if (lstv_Downloads.Items.Count > 0) { ATorrent DLList = new ATorrent(100); AMediaFile dlList = new AMediaFile(100); foreach (ListViewItem li in lstv_Downloads.Items) { ATorrent t = new ATorrent(); t.Name = li.Text; t.Seeders = Int32.Parse(li.SubItems[1].Text); t.FileSize = li.SubItems[2].Text; t.Quality = li.SubItems[3].Text; t.DaysOld = li.SubItems[4].Text; t.Language = li.SubItems[5].Text; t.Link = li.SubItems[6].Text; DLList.Add(t); AMediaFile mf = new AMediaFile(li.Text); dlList.Add(mf); } Utility.Download(DLList.Torrents); // UpdateAfterDownload(lstv_Downloads.Items); } //else lblSearch.Text = "You must select shows to download first!"; //update fav box //lstbx_Favorites.Items.Clear(); //foreach (AShow ms in availableShows.LatestShows) // lstbx_Favorites.Items.Add(ms.ToString()); }