public void SaveFavoritesToFile() { try { Directory.CreateDirectory(FavoritesStoreRoot); //save screenshots string screenShotsDir = FavoritesStoreRoot + this.CurrentTVSource.ToString(); Directory.CreateDirectory(screenShotsDir); foreach (FavoriteChannelThumbnail t in panelThumbnails.Controls) { t.SaveThumbnailImage(screenShotsDir); } SourceChannelsStore saveAs = new SourceChannelsStore(); foreach (KeyValuePair <TVSource, ChannelCollection> item in AllFavorites) { saveAs.Add(item.Key, item.Value); } saveAs.SaveToFile(FavoritesStoreRoot + FavoritesStoreFile); } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); } }
private void LoadFavoritesFromFile() { try { SourceChannelsStore stored = SourceChannelsStore.LoadFromFile(FavoritesStoreRoot + FavoritesStoreFile); AllFavorites = new Dictionary <TVSource, ChannelCollection>(); foreach (SourceChannelsStoreItem item in stored.Source) { AllFavorites.Add(item.Type, item.Channels); } } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); } }