/JMMClient/JMMClient/ViewModel/DashboardVM.cs

https://bitbucket.org/gibwar/jmm-test · C# · 672 lines · 568 code · 97 blank · 7 comment · 52 complexity · bce88949c9614379528f42a5400d5a67 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using System.Windows.Data;
  7. using System.Windows.Controls;
  8. using System.Collections.ObjectModel;
  9. using System.Collections.Specialized;
  10. using System.IO;
  11. using JMMClient.ViewModel;
  12. using System.Windows;
  13. using JMMClient.UserControls;
  14. using System.Threading;
  15. using JMMClient.ImageDownload;
  16. using NLog;
  17. namespace JMMClient
  18. {
  19. public class DashboardVM : INotifyPropertyChanged
  20. {
  21. private static Logger logger = LogManager.GetCurrentClassLogger();
  22. private static DashboardVM _instance;
  23. //public ICollectionView ViewGroups { get; set; }
  24. public ObservableCollection<AnimeEpisodeVM> EpsWatchNext_Recent { get; set; }
  25. public ICollectionView ViewEpsWatchNext_Recent { get; set; }
  26. public ObservableCollection<AnimeEpisodeVM> EpsWatchedRecently { get; set; }
  27. public ICollectionView ViewEpsWatchedRecently { get; set; }
  28. public ObservableCollection<AnimeSeriesVM> SeriesMissingEps { get; set; }
  29. public ICollectionView ViewSeriesMissingEps { get; set; }
  30. public ObservableCollection<AniDB_AnimeVM> MiniCalendar { get; set; }
  31. public ICollectionView ViewMiniCalendar { get; set; }
  32. public ObservableCollection<object> RecommendationsWatch { get; set; }
  33. public ICollectionView ViewRecommendationsWatch { get; set; }
  34. public ObservableCollection<object> RecommendationsDownload { get; set; }
  35. public ICollectionView ViewRecommendationsDownload { get; set; }
  36. public ObservableCollection<object> TraktActivity { get; set; }
  37. public ICollectionView ViewTraktActivity { get; set; }
  38. public ObservableCollection<object> RecentAdditions { get; set; }
  39. public ICollectionView ViewRecentAdditions { get; set; }
  40. public event PropertyChangedEventHandler PropertyChanged;
  41. private void NotifyPropertyChanged(String propertyName)
  42. {
  43. if (PropertyChanged != null)
  44. {
  45. var args = new PropertyChangedEventArgs(propertyName);
  46. PropertyChanged(this, args);
  47. }
  48. }
  49. public static DashboardVM Instance
  50. {
  51. get
  52. {
  53. if (_instance == null)
  54. {
  55. _instance = new DashboardVM();
  56. }
  57. return _instance;
  58. }
  59. }
  60. private Boolean isReadOnly = true;
  61. public Boolean IsReadOnly
  62. {
  63. get { return isReadOnly; }
  64. set
  65. {
  66. isReadOnly = value;
  67. NotifyPropertyChanged("IsReadOnly");
  68. }
  69. }
  70. private Boolean isBeingEdited = false;
  71. public Boolean IsBeingEdited
  72. {
  73. get { return isBeingEdited; }
  74. set
  75. {
  76. isBeingEdited = value;
  77. NotifyPropertyChanged("IsBeingEdited");
  78. }
  79. }
  80. private Boolean isLoadingData = true;
  81. public Boolean IsLoadingData
  82. {
  83. get { return isLoadingData; }
  84. set
  85. {
  86. isLoadingData = value;
  87. NotifyPropertyChanged("IsLoadingData");
  88. }
  89. }
  90. private DashboardVM()
  91. {
  92. IsLoadingData = false;
  93. EpsWatchNext_Recent = new ObservableCollection<AnimeEpisodeVM>();
  94. ViewEpsWatchNext_Recent = CollectionViewSource.GetDefaultView(EpsWatchNext_Recent);
  95. EpsWatchedRecently = new ObservableCollection<AnimeEpisodeVM>();
  96. ViewEpsWatchedRecently = CollectionViewSource.GetDefaultView(EpsWatchedRecently);
  97. SeriesMissingEps = new ObservableCollection<AnimeSeriesVM>();
  98. ViewSeriesMissingEps = CollectionViewSource.GetDefaultView(SeriesMissingEps);
  99. MiniCalendar = new ObservableCollection<AniDB_AnimeVM>();
  100. ViewMiniCalendar = CollectionViewSource.GetDefaultView(MiniCalendar);
  101. RecommendationsWatch = new ObservableCollection<object>();
  102. ViewRecommendationsWatch = CollectionViewSource.GetDefaultView(RecommendationsWatch);
  103. RecommendationsDownload = new ObservableCollection<object>();
  104. ViewRecommendationsDownload = CollectionViewSource.GetDefaultView(RecommendationsDownload);
  105. TraktActivity = new ObservableCollection<object>();
  106. ViewTraktActivity = CollectionViewSource.GetDefaultView(TraktActivity);
  107. RecentAdditions = new ObservableCollection<object>();
  108. ViewRecentAdditions = CollectionViewSource.GetDefaultView(RecentAdditions);
  109. }
  110. public void RefreshData(bool traktScrobbles, bool traktShouts, bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets, RecentAdditionsType addType)
  111. {
  112. try
  113. {
  114. IsLoadingData = true;
  115. // clear all displayed data
  116. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  117. {
  118. if (refreshContinueWatching) EpsWatchNext_Recent.Clear();
  119. if (refreshRecentAdditions) RecentAdditions.Clear();
  120. if (refreshOtherWidgets)
  121. {
  122. SeriesMissingEps.Clear();
  123. EpsWatchedRecently.Clear();
  124. MiniCalendar.Clear();
  125. RecommendationsWatch.Clear();
  126. RecommendationsDownload.Clear();
  127. TraktActivity.Clear();
  128. }
  129. if (refreshOtherWidgets)
  130. {
  131. ViewEpsWatchedRecently.Refresh();
  132. ViewSeriesMissingEps.Refresh();
  133. ViewMiniCalendar.Refresh();
  134. ViewRecommendationsWatch.Refresh();
  135. ViewRecommendationsDownload.Refresh();
  136. ViewTraktActivity.Refresh();
  137. ViewRecentAdditions.Refresh();
  138. }
  139. if (refreshContinueWatching) ViewEpsWatchNext_Recent.Refresh();
  140. if (refreshRecentAdditions) ViewRecentAdditions.Refresh();
  141. });
  142. DateTime start = DateTime.Now;
  143. MainListHelperVM.Instance.RefreshGroupsSeriesData();
  144. TimeSpan ts = DateTime.Now - start;
  145. logger.Trace("Dashboard Time: RefreshGroupsSeriesData: {0}", ts.TotalMilliseconds);
  146. if (refreshContinueWatching && UserSettingsVM.Instance.DashWatchNextEpExpanded)
  147. RefreshEpsWatchNext_Recent();
  148. if (refreshRecentAdditions && UserSettingsVM.Instance.DashRecentAdditionsExpanded)
  149. RefreshRecentAdditions(addType);
  150. if (refreshOtherWidgets)
  151. {
  152. if (UserSettingsVM.Instance.DashRecentlyWatchEpsExpanded)
  153. RefreshRecentlyWatchedEps();
  154. if (UserSettingsVM.Instance.DashSeriesMissingEpisodesExpanded)
  155. RefreshSeriesMissingEps();
  156. if (UserSettingsVM.Instance.DashMiniCalendarExpanded)
  157. RefreshMiniCalendar();
  158. if (UserSettingsVM.Instance.DashRecommendationsWatchExpanded)
  159. RefreshRecommendationsWatch();
  160. if (UserSettingsVM.Instance.DashRecommendationsDownloadExpanded)
  161. RefreshRecommendationsDownload();
  162. if (UserSettingsVM.Instance.DashTraktFriendsExpanded)
  163. RefreshTraktFriends(traktScrobbles, traktShouts);
  164. }
  165. IsLoadingData = false;
  166. }
  167. catch (Exception ex)
  168. {
  169. Utils.ShowErrorMessage(ex);
  170. }
  171. finally
  172. {
  173. }
  174. }
  175. public void RefreshRecentAdditions(RecentAdditionsType addType)
  176. {
  177. try
  178. {
  179. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  180. {
  181. RecentAdditions.Clear();
  182. });
  183. if (addType == RecentAdditionsType.Episode)
  184. {
  185. List<JMMServerBinary.Contract_AnimeEpisode> epContracts =
  186. JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  187. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  188. {
  189. foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
  190. {
  191. AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
  192. ep.RefreshAnime();
  193. if (ep.AniDB_Anime != null)
  194. {
  195. ep.SetTvDBInfo();
  196. RecentAdditions.Add(ep);
  197. }
  198. }
  199. ViewRecentAdditions.Refresh();
  200. });
  201. }
  202. else
  203. {
  204. List<JMMServerBinary.Contract_AnimeSeries> serContracts =
  205. JMMServerVM.Instance.clientBinaryHTTP.GetSeriesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  206. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  207. {
  208. foreach (JMMServerBinary.Contract_AnimeSeries contract in serContracts)
  209. {
  210. AnimeSeriesVM ser = new AnimeSeriesVM(contract);
  211. RecentAdditions.Add(ser);
  212. }
  213. ViewRecentAdditions.Refresh();
  214. });
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. Utils.ShowErrorMessage(ex);
  220. }
  221. finally
  222. {
  223. }
  224. }
  225. public void RefreshTraktFriends(bool traktScrobbles, bool traktShouts)
  226. {
  227. try
  228. {
  229. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  230. {
  231. TraktActivity.Clear();
  232. });
  233. JMMServerBinary.Contract_Trakt_Activity traktActivity = JMMServerVM.Instance.clientBinaryHTTP.GetTraktFriendInfo(AppSettings.Dash_TraktFriends_Items,
  234. AppSettings.Dash_TraktFriends_AnimeOnly, traktShouts, traktScrobbles);
  235. List<object> activity = new List<object>();
  236. if (traktActivity.HasTraktAccount)
  237. {
  238. foreach (JMMServerBinary.Contract_Trakt_FriendFrequest contractFriend in traktActivity.TraktFriendRequests)
  239. {
  240. Trakt_FriendRequestVM req = new Trakt_FriendRequestVM(contractFriend);
  241. activity.Add(req);
  242. }
  243. foreach (JMMServerBinary.Contract_Trakt_FriendActivity contractAct in traktActivity.TraktFriendActivity)
  244. {
  245. if (contractAct.ActivityAction == (int)TraktActivityAction.Scrobble)
  246. {
  247. Trakt_ActivityScrobbleVM scrobble = new Trakt_ActivityScrobbleVM(contractAct);
  248. if (!string.IsNullOrEmpty(scrobble.UserFullImagePath) && !File.Exists(scrobble.UserFullImagePath))
  249. {
  250. // re-download the friends avatar image
  251. try
  252. {
  253. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  254. {
  255. ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.Trakt_ActivityScrobble, scrobble, true);
  256. MainWindow.imageHelper.DownloadImage(req);
  257. });
  258. }
  259. catch (Exception ex)
  260. {
  261. logger.ErrorException(ex.ToString(), ex);
  262. }
  263. }
  264. activity.Add(scrobble);
  265. }
  266. else if (contractAct.ActivityAction == (int)TraktActivityAction.Shout)
  267. {
  268. if (contractAct.ActivityType == (int)TraktActivityType.Episode)
  269. {
  270. Trakt_ActivityShoutEpisodeVM shoutEp = new Trakt_ActivityShoutEpisodeVM(contractAct);
  271. activity.Add(shoutEp);
  272. }
  273. else
  274. {
  275. Trakt_ActivityShoutShowVM shoutShow = new Trakt_ActivityShoutShowVM(contractAct);
  276. activity.Add(shoutShow);
  277. }
  278. }
  279. }
  280. foreach (JMMServerBinary.Contract_Trakt_Friend contract in traktActivity.TraktFriends)
  281. {
  282. if (contract.WatchedEpisodes != null && contract.WatchedEpisodes.Count > 0)
  283. {
  284. Trakt_FriendVM friend = new Trakt_FriendVM(contract);
  285. activity.Add(friend);
  286. }
  287. }
  288. }
  289. else
  290. {
  291. Trakt_SignupVM signup = new Trakt_SignupVM();
  292. activity.Add(signup);
  293. }
  294. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  295. {
  296. foreach (object act in activity)
  297. TraktActivity.Add(act);
  298. ViewTraktActivity.Refresh();
  299. });
  300. }
  301. catch (Exception ex)
  302. {
  303. logger.ErrorException(ex.ToString(), ex);
  304. }
  305. finally
  306. {
  307. }
  308. }
  309. public void RefreshRecommendationsWatch()
  310. {
  311. try
  312. {
  313. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  314. {
  315. RecommendationsWatch.Clear();
  316. });
  317. List<JMMServerBinary.Contract_Recommendation> contracts =
  318. JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.Dash_RecWatch_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
  319. (int)RecommendationType.Watch);
  320. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  321. {
  322. foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
  323. {
  324. RecommendationVM rec = new RecommendationVM();
  325. rec.Populate(contract);
  326. RecommendationsWatch.Add(rec);
  327. }
  328. // add a dummy object so that we can display a prompt
  329. // for the user to sync thier votes
  330. if (RecommendationsWatch.Count == 0)
  331. RecommendationsWatch.Add(new SyncVotesDummy());
  332. ViewRecommendationsWatch.Refresh();
  333. });
  334. }
  335. catch (Exception ex)
  336. {
  337. Utils.ShowErrorMessage(ex);
  338. }
  339. finally
  340. {
  341. }
  342. }
  343. public void RefreshRecommendationsDownload()
  344. {
  345. try
  346. {
  347. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  348. {
  349. RecommendationsDownload.Clear();
  350. });
  351. List<JMMServerBinary.Contract_Recommendation> contracts =
  352. JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.Dash_RecDownload_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
  353. (int)RecommendationType.Download);
  354. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  355. {
  356. foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
  357. {
  358. RecommendationVM rec = new RecommendationVM();
  359. rec.Populate(contract);
  360. RecommendationsDownload.Add(rec);
  361. }
  362. // add a dummy object so that we can display a prompt
  363. // for the user to sync thier votes
  364. if (RecommendationsDownload.Count == 0)
  365. RecommendationsDownload.Add(new SyncVotesDummy());
  366. ViewRecommendationsDownload.Refresh();
  367. });
  368. }
  369. catch (Exception ex)
  370. {
  371. Utils.ShowErrorMessage(ex);
  372. }
  373. finally
  374. {
  375. }
  376. }
  377. public void GetMissingRecommendationsDownload()
  378. {
  379. try
  380. {
  381. IsLoadingData = true;
  382. foreach (RecommendationVM rec in RecommendationsDownload)
  383. {
  384. if (rec.Recommended_AnimeInfoNotExists)
  385. {
  386. string result = JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(rec.RecommendedAnimeID);
  387. if (string.IsNullOrEmpty(result))
  388. {
  389. JMMServerBinary.Contract_AniDBAnime animeContract = JMMServerVM.Instance.clientBinaryHTTP.GetAnime(rec.RecommendedAnimeID);
  390. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, (Action)delegate()
  391. {
  392. rec.PopulateRecommendedAnime(animeContract);
  393. ViewRecommendationsDownload.Refresh();
  394. });
  395. }
  396. }
  397. }
  398. IsLoadingData = false;
  399. }
  400. catch (Exception ex)
  401. {
  402. Utils.ShowErrorMessage(ex);
  403. }
  404. finally
  405. {
  406. }
  407. }
  408. public void RefreshSeriesMissingEps()
  409. {
  410. try
  411. {
  412. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  413. {
  414. SeriesMissingEps.Clear();
  415. });
  416. List<JMMServerBinary.Contract_AnimeSeries> epSeries =
  417. JMMServerVM.Instance.clientBinaryHTTP.GetSeriesWithMissingEpisodes(UserSettingsVM.Instance.Dash_MissingEps_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  418. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  419. {
  420. foreach (JMMServerBinary.Contract_AnimeSeries contract in epSeries)
  421. {
  422. AnimeSeriesVM ser = new AnimeSeriesVM(contract);
  423. if (JMMServerVM.Instance.CurrentUser.EvaluateSeries(ser))
  424. SeriesMissingEps.Add(ser);
  425. }
  426. ViewSeriesMissingEps.Refresh();
  427. });
  428. }
  429. catch (Exception ex)
  430. {
  431. Utils.ShowErrorMessage(ex);
  432. }
  433. finally
  434. {
  435. }
  436. }
  437. public void RefreshEpsWatchNext_Recent()
  438. {
  439. try
  440. {
  441. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  442. {
  443. EpsWatchNext_Recent.Clear();
  444. });
  445. DateTime start = DateTime.Now;
  446. List<JMMServerBinary.Contract_AnimeEpisode> epContracts =
  447. JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesToWatch_RecentlyWatched(UserSettingsVM.Instance.Dash_WatchNext_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  448. TimeSpan ts = DateTime.Now - start;
  449. logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: contracts: {0}", ts.TotalMilliseconds);
  450. start = DateTime.Now;
  451. List<AnimeEpisodeVM> epList = new List<AnimeEpisodeVM>();
  452. foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
  453. {
  454. AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
  455. string animename = ep.AnimeName; // just do this to force anidb anime detail record to be loaded
  456. ep.RefreshAnime();
  457. ep.SetTvDBInfo();
  458. epList.Add(ep);
  459. }
  460. ts = DateTime.Now - start;
  461. logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: {0}", ts.TotalMilliseconds);
  462. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  463. {
  464. foreach (AnimeEpisodeVM ep in epList)
  465. {
  466. EpsWatchNext_Recent.Add(ep);
  467. }
  468. ViewEpsWatchNext_Recent.Refresh();
  469. });
  470. }
  471. catch (Exception ex)
  472. {
  473. Utils.ShowErrorMessage(ex);
  474. }
  475. finally
  476. {
  477. }
  478. }
  479. public void RefreshEpsWatchNext_Recent_Old()
  480. {
  481. try
  482. {
  483. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  484. {
  485. EpsWatchNext_Recent.Clear();
  486. });
  487. List<JMMServerBinary.Contract_AnimeEpisode> epContracts =
  488. JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesToWatch_RecentlyWatched(UserSettingsVM.Instance.Dash_WatchNext_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  489. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  490. {
  491. foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
  492. {
  493. AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
  494. ep.RefreshAnime();
  495. if (ep.AniDB_Anime != null && JMMServerVM.Instance.CurrentUser.EvaluateAnime(ep.AniDB_Anime))
  496. {
  497. ep.SetTvDBInfo();
  498. EpsWatchNext_Recent.Add(ep);
  499. }
  500. }
  501. ViewEpsWatchNext_Recent.Refresh();
  502. });
  503. }
  504. catch (Exception ex)
  505. {
  506. Utils.ShowErrorMessage(ex);
  507. }
  508. finally
  509. {
  510. }
  511. }
  512. public void RefreshRecentlyWatchedEps()
  513. {
  514. try
  515. {
  516. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  517. {
  518. EpsWatchedRecently.Clear();
  519. });
  520. List<JMMServerBinary.Contract_AnimeEpisode> epContracts =
  521. JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyWatched(UserSettingsVM.Instance.Dash_RecentlyWatchedEp_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
  522. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  523. {
  524. foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
  525. {
  526. AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
  527. ep.RefreshAnime();
  528. if (ep.AniDB_Anime != null && JMMServerVM.Instance.CurrentUser.EvaluateAnime(ep.AniDB_Anime))
  529. {
  530. ep.SetTvDBInfo();
  531. EpsWatchedRecently.Add(ep);
  532. }
  533. }
  534. ViewEpsWatchedRecently.Refresh();
  535. });
  536. }
  537. catch (Exception ex)
  538. {
  539. Utils.ShowErrorMessage(ex);
  540. }
  541. finally
  542. {
  543. }
  544. }
  545. public void RefreshMiniCalendar()
  546. {
  547. try
  548. {
  549. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  550. {
  551. MiniCalendar.Clear();
  552. });
  553. List<JMMServerBinary.Contract_AniDBAnime> contracts =
  554. JMMServerVM.Instance.clientBinaryHTTP.GetMiniCalendar(JMMServerVM.Instance.CurrentUser.JMMUserID.Value, UserSettingsVM.Instance.Dash_MiniCalendarDays);
  555. System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
  556. {
  557. foreach (JMMServerBinary.Contract_AniDBAnime contract in contracts)
  558. {
  559. AniDB_AnimeVM anime = new AniDB_AnimeVM(contract);
  560. if (JMMServerVM.Instance.CurrentUser.EvaluateAnime(anime))
  561. MiniCalendar.Add(anime);
  562. }
  563. ViewEpsWatchNext_Recent.Refresh();
  564. });
  565. }
  566. catch (Exception ex)
  567. {
  568. Utils.ShowErrorMessage(ex);
  569. }
  570. finally
  571. {
  572. }
  573. }
  574. }
  575. }