private void CommandBinding_OpenFolder(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(AnimeFolderSummary)) { AnimeFolderSummary afs = obj as AnimeFolderSummary; Utils.OpenFolder(afs.FolderName); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void RefreshRecords() { try { IsDataLoading = true; IsDataFinishedLoading = false; AnimeFolderSummaryRecords.Clear(); TotalFileCount = 0; double fileSize = 0; VM_AniDB_Anime anime = DataContext as VM_AniDB_Anime; if (anime == null) { return; } VM_AnimeSeries_User serie = (VM_AnimeSeries_User)VM_ShokoServer.Instance.ShokoServices.GetSeriesForAnime(anime.AnimeID, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (serie == null) { return; } thisSeries = serie; Dictionary <string, AnimeFolderSummary> folders = new Dictionary <string, AnimeFolderSummary>(); foreach (VM_VideoLocal vid in anime.AllVideoLocals) { TotalFileCount++; fileSize += (double)vid.FileSize; foreach (CL_VideoLocal_Place vplace in vid.Places) { if (!folders.ContainsKey(vplace.GetFileDirectory())) { AnimeFolderSummary fs = new AnimeFolderSummary(); fs.FolderName = vplace.GetFileDirectory(); fs.FileCount = 0; fs.TotalFileSize = 0; folders[vplace.GetFileDirectory()] = fs; } folders[vplace.GetFileDirectory()].FileCount = folders[vplace.GetFileDirectory()].FileCount + 1; folders[vplace.GetFileDirectory()].TotalFileSize = folders[vplace.GetFileDirectory()].TotalFileSize + vid.FileSize; } } foreach (AnimeFolderSummary afs in folders.Values) { afs.IsDefaultFolder = false; if (!string.IsNullOrEmpty(thisSeries.DefaultFolder)) { if (thisSeries.DefaultFolder.Equals(afs.FolderName, StringComparison.InvariantCultureIgnoreCase)) { afs.IsDefaultFolder = true; } } } AnimeFolderSummaryRecords.ReplaceRange(folders.Values); TotalFileSize = Formatting.FormatFileSize(fileSize); IsDataLoading = false; IsDataFinishedLoading = true; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }