Exemplo n.º 1
0
    /// <summary>
    /// Creates an <see cref="AppViewInfo"/> from the specified dispatcher.
    /// </summary>
    /// <param name="name">
    /// The name of the view.
    /// </param>
    /// <param name="dispatcher">
    /// The dispatcher to get the view from.
    /// </param>
    /// <returns>
    /// A <see cref="Task"/> that yields the <see cref="AppViewInfo"/> for the current view in the dispatcher.
    /// </returns>
    static public async Task <AppViewInfo> CreateFromDispatcherAsync(string name, CoreDispatcher dispatcher)
    {
        // Validate
        if (string.IsNullOrEmpty(name))
        {
            throw new ArgumentException(nameof(name));
        }
        if (dispatcher == null)
        {
            throw new ArgumentNullException(nameof(dispatcher));
        }

        // Placeholders
        ApplicationView view = null;
        AppViewInfo     info = null;

        // Use dispatcher to get ApplicationView
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            // Get view
            view = ApplicationView.GetForCurrentView();

            // Create info class
            info = new AppViewInfo(view, dispatcher, name);
        });

        // Add to list
        views.Add(info);

        // Done
        return(info);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Starts the login (authentication) process by switching to XAML.
    /// </summary>
    private async Task StartLoginAsync()
    {
        // Get auth view if not already obtained
        if (authView == null)
        {
            authView = AppViewManager.Views["Auth"];
            // authView.Consolidated += AuthView_Consolidated;
        }

        // Switch to auth view
        await authView.SwitchAsync();
    }
Exemplo n.º 3
0
    /// <summary>
    /// Visually replaces the current view with this view.
    /// </summary>
    /// <param name="fromView">
    /// The view you are switching from.
    /// </param>
    /// <param name="options">
    /// Options for the display transition behaviors.
    /// </param>
    /// <returns>
    /// A <see cref="Task"/> that represents the operation.
    /// </returns>
    public async Task SwitchAsync(AppViewInfo fromView, ApplicationViewSwitchingOptions options)
    {
        // From view MUST be passed
        if (fromView == null)
        {
            throw new ArgumentNullException(nameof(fromView));
        }

        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
        {
            await ApplicationViewSwitcher.SwitchAsync(this.view.Id, fromView.view.Id, options);
        });
    }
Exemplo n.º 4
0
    /// <summary>
    /// Visually replaces the current view with this view.
    /// </summary>
    /// <param name="fromView">
    /// The view you are switching from.
    /// </param>
    /// <param name="options">
    /// Options for the display transition behaviors.
    /// </param>
    /// <returns>
    /// A <see cref="Task"/> that represents the operation.
    /// </returns>
    public async Task SwitchAndConsolidateAsync(AppViewInfo fromView, ApplicationViewSwitchingOptions options)
    {
        // From view MUST be passed
        if (fromView == null)
        {
            throw new ArgumentNullException(nameof(fromView));
        }

        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
        {
            ApplicationViewSwitcher.DisableShowingMainViewOnActivation();
            await ApplicationViewSwitcher.SwitchAsync(this.view.Id, fromView.view.Id, options);
            await this.view.TryConsolidateAsync();
        });
    }
Exemplo n.º 5
0
    /// <summary>
    /// Visually replaces the current view with this view.
    /// </summary>
    /// <remarks>
    /// When possible use <see cref="SwitchAsync"/> instead of this method.
    /// <see cref="SwitchAsync"/> will not be visible to Unity behaviors
    /// when in the editor. The async versions require UWP.
    /// </remarks>
    public void SwitchAndConsolidate(AppViewInfo fromView)
    {
#if WINDOWS_UWP
        SwitchAndConsolidateAsync(fromView, Windows.UI.ViewManagement.ApplicationViewSwitchingOptions.SkipAnimation).Wait();
#endif
    }
Exemplo n.º 6
0
 /// <summary>
 /// Visually replaces the current view with this view.
 /// </summary>
 /// <remarks>
 /// When possible use <see cref="SwitchAsync"/> instead of this method.
 /// <see cref="SwitchAsync"/> will not be visible to Unity behaviors
 /// when in the editor. The async versions require UWP.
 /// </remarks>
 public void Switch(AppViewInfo fromView, ApplicationViewSwitchingOptions options)
 {
     SwitchAsync(fromView, options).Wait();
 }