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; AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) { return; } JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeriesForAnime(anime.AnimeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (contract == null) { return; } thisSeries = new AnimeSeriesVM(contract); Dictionary <string, AnimeFolderSummary> folders = new Dictionary <string, AnimeFolderSummary>(); foreach (VideoLocalVM vid in anime.AllVideoLocals) { TotalFileCount++; fileSize += (double)vid.FileSize; if (!folders.ContainsKey(vid.FileDirectory)) { AnimeFolderSummary fs = new AnimeFolderSummary(); fs.FolderName = vid.FileDirectory; fs.FileCount = 0; fs.TotalFileSize = 0; folders[vid.FileDirectory] = fs; } folders[vid.FileDirectory].FileCount = folders[vid.FileDirectory].FileCount + 1; folders[vid.FileDirectory].TotalFileSize = folders[vid.FileDirectory].TotalFileSize + vid.FileSize; } bool foundDefault = false; 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; foundDefault = true; } } AnimeFolderSummaryRecords.Add(afs); } /*if (!foundDefault) * { * if (!string.IsNullOrEmpty(thisSeries.DefaultFolder)) * { * AnimeFolderSummary afs = new AnimeFolderSummary(); * afs.FolderName = thisSeries.DefaultFolder; * afs.FileCount = 0; * afs.TotalFileSize = 0; * afs.IsDefaultFolder = true; * AnimeFolderSummaryRecords.Add(afs); * } * }*/ TotalFileSize = Utils.FormatFileSize(fileSize); IsDataLoading = false; IsDataFinishedLoading = true; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void RefreshRecords() { try { IsDataLoading = true; IsDataFinishedLoading = false; AnimeFolderSummaryRecords.Clear(); TotalFileCount = 0; double fileSize = 0; AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) return; JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeriesForAnime(anime.AnimeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (contract == null) return; thisSeries = new AnimeSeriesVM(contract); Dictionary<string, AnimeFolderSummary> folders = new Dictionary<string, AnimeFolderSummary>(); foreach (VideoLocalVM vid in anime.AllVideoLocals) { TotalFileCount++; fileSize += (double)vid.FileSize; foreach (VideoLocal_PlaceVM vplace in vid.Places) { if (!folders.ContainsKey(vplace.FileDirectory)) { AnimeFolderSummary fs = new AnimeFolderSummary(); fs.FolderName = vplace.FileDirectory; fs.FileCount = 0; fs.TotalFileSize = 0; folders[vplace.FileDirectory] = fs; } folders[vplace.FileDirectory].FileCount = folders[vplace.FileDirectory].FileCount + 1; folders[vplace.FileDirectory].TotalFileSize = folders[vplace.FileDirectory].TotalFileSize + vid.FileSize; } } bool foundDefault = false; 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; foundDefault = true; } } AnimeFolderSummaryRecords.Add(afs); } /*if (!foundDefault) { if (!string.IsNullOrEmpty(thisSeries.DefaultFolder)) { AnimeFolderSummary afs = new AnimeFolderSummary(); afs.FolderName = thisSeries.DefaultFolder; afs.FileCount = 0; afs.TotalFileSize = 0; afs.IsDefaultFolder = true; AnimeFolderSummaryRecords.Add(afs); } }*/ TotalFileSize = Utils.FormatFileSize(fileSize); IsDataLoading = false; IsDataFinishedLoading = true; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }