コード例 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public SettingsPage()
        {
            this.InitializeComponent();
            AppSettings = ((App)Application.Current).GetApplicationSettings();

            toggleVideoRefresh.IsOn = (AppSettings.autoUpdateVideosOnAppStart == true) ? true : false;
        }
コード例 #2
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending         += OnSuspending;
            this.UnhandledException += App_UnhandledException;

            YtFavoritesList       = new ObservableCollection <YtLocalFavChannelList>();
            YtFavoritesListBackup = new ObservableCollection <YtLocalFavChannelList>();
            AppSettings           = new YtApplicationSettings();

            YtOpenFile(FileType.FAVORITES, "favoriteslist.json");
            YtOpenFile(FileType.SETTINGS, "ytsettings.json");
        }
コード例 #3
0
        /// <summary>
        /// Opens a saved file (favorites or settings).
        /// </summary>
        /// <param name="fileType"></param>
        /// <param name="filename"></param>
        private async void YtOpenFile(FileType fileType, string filename)
        {
            Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            Windows.Storage.StorageFile   jsonFile      = (Windows.Storage.StorageFile) await storageFolder.TryGetItemAsync(filename);

            if (jsonFile != null)
            {
                string jsonContent = await Windows.Storage.FileIO.ReadTextAsync(jsonFile);

                if (fileType == FileType.FAVORITES && !string.IsNullOrEmpty(jsonContent))
                {
                    YtFavoritesList = JsonConvert.DeserializeObject <ObservableCollection <YtLocalFavChannelList> >(jsonContent);
                }
                else if (fileType == FileType.SETTINGS && !string.IsNullOrEmpty(jsonContent))
                {
                    AppSettings = JsonConvert.DeserializeObject <YtApplicationSettings>(jsonContent);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            appDataPath = ApplicationData.Current.LocalFolder.Path;
            YtFavoritesDataTemplate.OnNavigateParentReady += myControl_OnNavigateParentReady;

            AppSettings = ((App)Application.Current).GetApplicationSettings();

            RefreshAll.Visibility = Visibility.Visible;
            PageTitle.Text        = "YouTube Favorites";

            if (isVideoListUpdatedOnStartup == false && AppSettings.autoUpdateVideosOnAppStart == true)
            {
                RefeshAllChannels();
            }
            else
            {
                ContentFrame.Navigate(typeof(FavoritesPage));
            }
        }
コード例 #5
0
 /// <summary>
 /// Saves the application settings.
 /// </summary>
 /// <param name="settings"></param>
 public void SetApplicationSettings(YtApplicationSettings settings)
 {
     AppSettings = settings;
     YtSaveFile(FileType.SETTINGS, "ytsettings.json");
 }