示例#1
0
		private async void BrowseButton_Tapped(object sender, RoutedEventArgs e)
		{
			MessageDialog errorDialog = null;

			if (this.EnsureUnsnapped())
			{
				FolderPicker folderPicker = new FolderPicker();
				folderPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
				folderPicker.FileTypeFilter.Add(".");

				StorageFolder folder = await folderPicker.PickSingleFolderAsync();
				if (folder != null)
				{
					VisualStateManager.GoToState(this, "Loading", true);

					// Reset everything just in case first.
					TunesDataSource.Reset(firstRunComplete: true);

					// Application now has read/write access to all content in the picked folder (including other sub-folder content)
					TuneOut.AppData.Settings.SetLibraryLocation(folder);

					bool hasData = await TunesDataSource.Load();
					if (hasData)
					{
						// Completed First-Run
						TuneOut.AppData.Settings.IsFirstRunComplete = true;

						// Go to MainPage
						await App.Current.Navigate(typeof(MainPage), null);
						return;
					}
					else
					{
						// Error: file problem.
						errorDialog = new MessageDialog(TuneOut.AppData.LocalizationManager.GetString("FirstRunPage/FileErrorDialog/Text"), TuneOut.AppData.LocalizationManager.GetString("FirstRunPage/FileErrorDialog/Title"));
					}
				}
				else
				{
					// User cancelled.
					return;
				}
			}
			else
			{
				// Error: cannot unsnap.
				errorDialog = new MessageDialog(TuneOut.AppData.LocalizationManager.GetString("LayoutAwarePage/UnsnapText"));
			}

			VisualStateManager.GoToState(this, "NotLoading", true);
			await errorDialog.ShowAsync();
		}
示例#2
0
        /// <summary>
        /// Invoked when the application is activated to display search results.
        /// </summary>
        /// <param name="args">Details about the activation request.</param>
        protected async override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args)
        {
            // TODO: Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted
            // event in OnWindowCreated to speed up searches once the application is already running
            // Reinitialize the app if a new instance was launched for search

            // Load data silently; if it is not available, just give up!
            await TunesDataSource.Load();

            await Navigate(typeof(SearchResultsPage), args.QueryText, args.PreviousExecutionState, NavigationReplacementMode.AlwaysReplace, false);

            // Clean artwork cache if possible
            AppData.Settings.CleanArtworkCache();

            // Load settings charm
            SettingsUIManager.LoadSettingsCharm();
        }
示例#3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs args)
        {
            bool hasData = await TunesDataSource.Load();

            if (hasData)
            {
                await Navigate(typeof(MainPage), args.Arguments, args.PreviousExecutionState, NavigationReplacementMode.NeverReplace, false);
            }
            else
            {
                await Navigate(typeof(FirstRunPage), args.Arguments, args.PreviousExecutionState, NavigationReplacementMode.ReplaceIfDifferent, false);
            }

            // Clean artwork cache if possible
            AppData.Settings.CleanArtworkCache();

            // Load settings charm
            SettingsUIManager.LoadSettingsCharm();
        }