Esempio n. 1
0
        /// <inheritdoc/>
        public void QueueExecution(uint startAddress)
        {
            SynchronousTask emitTask = new SynchronousTask(
                () => Task.Run(() => ExecutionStream.EmitValue(startAddress)));

            emitTask.RunTask();
        }
Esempio n. 2
0
        private void WebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
        {
            SynchronousTask styleTask = new SynchronousTask(
                () => DispatcherService.RunOnUIThreadAsync(
                    () => SetWebViewStyle(sender as WebView2)));

            styleTask.RunTask();
        }
Esempio n. 3
0
        private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            SynchronousTask styleTask = new SynchronousTask(
                () => DispatcherService.RunOnUIThreadAsync(
                    () => SetWebViewStyle(sender)));

            styleTask.RunTask();
        }
Esempio n. 4
0
 /// <summary>
 /// Starts the <see cref="App"/>, activating the needed services and the UI/view-models.
 /// </summary>
 /// <param name="args">The <see cref="IActivatedEventArgs"/> describing how the <see cref="App"/> was started.</param>
 public void Activate(IActivatedEventArgs args)
 {
     if (args is BackgroundActivatedEventArgs backgroundArgs)
     {
         ActivateBackground(backgroundArgs);
     }
     else
     {
         SynchronousTask registerTask = new SynchronousTask(RegisterBackgroundTasks);
         registerTask.RunTask();
         ActivateForeground(args);
     }
 }
Esempio n. 5
0
 /// <inheritdoc/>
 protected override void SetViewInternal(NavigationRequest request, IConsoleView view)
 {
     if (request.Properties.LayerMode == LayerBehavior.Default)
     {
         SynchronousTask syncTask = new SynchronousTask(
             () => view.ShowView());
         syncTask.RunTask();
     }
     else
     {
         throw new ArgumentException($"Console apps currently do not have support for navigation layers.", nameof(request));
     }
 }
Esempio n. 6
0
        /// <inheritdoc/>
        public void Navigate(NavigationRequest request, bool includeHistory = true)
        {
            if (request.IsCloseRequest)
            {
                //// Send close request to IViewProvider.
                ViewProvider.SetView(request, null);
                if (includeHistory)
                {
                    //// Reports request to history.
                    History.HandleNavigation(request, null);
                }
            }
            else
            {
                //// Resolves values from the request.
                IViewModel viewModel             = (IViewModel)LifetimeScope.Resolve(request.ViewModelType);
                Type       viewModelRealizedType = viewModel.GetType();
                Type       viewType = typeof(IView <>).MakeGenericType(viewModelRealizedType);
                IView      view     = (IView)LifetimeScope.Resolve(viewType, new TypedParameter(viewModelRealizedType, viewModel));

                //// Sets the view.
                ViewProvider.SetView(request, view);

                if (includeHistory)
                {
                    //// Reports navigated content to history.
                    History.HandleNavigation(request, viewModel);
                }

                //// Initializes the view-model and view.
                view.Initialize();
                SynchronousTask initViewModelTask =
                    new SynchronousTask(() => viewModel.InitializeAsync(request.Parameter));
                initViewModelTask.RunTask();
            }
        }
Esempio n. 7
0
        private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            SynchronousTask refreshTask = new SynchronousTask(ViewModel.RefreshAsync);

            refreshTask.RunTask();
        }
Esempio n. 8
0
        /// <inheritdoc/>
        protected override void SetViewInternal(NavigationRequest request, UIElement view)
        {
            if (request.IsCloseRequest)
            {
                if (UILayers.Count > 1)
                {
                    if (CurrentElement is ContentDialog dialog)
                    {
                        SynchronousTask hideTask = new SynchronousTask(
                            () => Dispatchers.RunOnUIThreadAsync(
                                () => dialog.Hide()));
                        hideTask.RunTask();
                    }

                    UILayers.RemoveAt(UILayers.Count - 1);
                }
                else
                {
                    throw new InvalidOperationException("Cannot remove root content layer in close operation.");
                }
            }
            else
            {
                if (request.Properties.LayerMode == LayerBehavior.Modal)
                {
                    ContentDialog dialog = new ContentDialog()
                    {
                        Title   = null,
                        Content = view,
                        Padding = new Thickness(0),
                        Margin  = new Thickness(0)
                    };
                    UILayers.Add(dialog);
                    dialog.CloseButtonClick += DialogClosed;

                    SynchronousTask showTask = new SynchronousTask(
                        () => Dispatchers.RunOnUIThreadAsync(
                            () => ShowDialogTask(dialog)));
                    showTask.RunTask();
                }
                else if (request.Properties.LayerMode == LayerBehavior.Default)
                {
                    CurrentElement.Content = view;
                }
                else if (request.Properties.LayerMode == LayerBehavior.Shell)
                {
                    if (view is ILayerContainer container)
                    {
                        CurrentElement.Content = container;
                        UILayers.Add(container.Container);
                    }
                    else
                    {
                        throw new ArgumentException("UWP apps require all new navigation layers be created in ILayerContainers.", nameof(view));
                    }
                }
                else
                {
                    throw new ArgumentException($"UWP apps currently do not have support for the given LayerMode {request.Properties.LayerMode}.", nameof(request));
                }
            }
        }