Beispiel #1
0
        /// <summary>
        /// Navigates to the specified route on the route's router depth with an optional argument.
        /// </summary>
        /// <param name="route">The destination route to navigate to.</param>
        /// <param name="argument">The optional argument to pass to the page (null by default).</param>
        public void NavigateTo(Route route, object?argument = null)
        {
            // Fire off the navigation started event
            var navigationStartedEventArgs = new RouterNavigationCancelEventArgs(route);

            NavigationStarted?.Invoke(this, navigationStartedEventArgs);

            // Cancel the navigation if the event was handled to do so
            if (navigationStartedEventArgs.Cancel)
            {
                NavigationCanceled?.Invoke(this, new RouterNavigationEventArgs(route));
                return;
            }

            // If the specified route doesn't exist or it's already active, raise the navigation error event and cancel the navigation
            if (!mRoutes.Contains(route))
            {
                NavigationError?.Invoke(this, new RouterNavigationErrorEventArgs(route, RouterNavigationError.NonExistingRoute));
                return;
            }
            else if (mActiveRoutes[route.Depth] == route)
            {
                NavigationError?.Invoke(this, new RouterNavigationErrorEventArgs(route, RouterNavigationError.RouteAlreadyActive));
                return;
            }

            // Otherwise set the destination route's argument and make it the active route on its depth
            route.Argument             = argument;
            mActiveRoutes[route.Depth] = route;

            // Raise the navigation completed event as navigation was successful
            NavigationCompleted?.Invoke(this, new RouterNavigationEventArgs(route));
        }
        /// <summary>
        /// Internal Use Only.
        /// </summary>
        /// <param name="type">The type of event</param>
        /// <param name="eventObject">The WVE object to pass</param>
        /// <returns></returns>
        public object InvokeEvent(WebViewEventType type, WebViewDelegate eventObject)
        {
            switch (type)
            {
            case WebViewEventType.NavigationRequested:
                return(NavigationStarted == null ? eventObject as NavigationRequestedDelegate : NavigationStarted.Invoke(eventObject as NavigationRequestedDelegate));

            case WebViewEventType.NavigationComplete:
                NavigationCompleted?.Invoke(eventObject as NavigationCompletedDelegate);
                break;

            case WebViewEventType.JavascriptCallback:
                var            data = (eventObject as JavascriptResponseDelegate).Data;
                ActionResponse ar;
                if (data.ValidateJSON() && (ar = data.AttemptParseActionResponse()) != null)
                {
                    if (RegisteredActions.ContainsKey(ar.Action))
                    {
                        RegisteredActions[ar.Action]?.Invoke(ar.Data);
                    }
                }
                else
                {
                    OnJavascriptResponse?.Invoke(eventObject as JavascriptResponseDelegate);
                }
                break;
            }

            return(eventObject);
        }
Beispiel #3
0
        public virtual void SetCurrentNode(INodeProxy node)
        {
            //put the last focal node into the history before setting the new one
            SetHistory(node.Name, node);
            if (NavigationCompleted != null)
            {
                NavigationCompleted.Invoke(this, new EventArgs());
            }

            //Set the new current focal node.
            FocalNode         = node;
            _currentFocalNode = FocalNode.Id;
        }
Beispiel #4
0
        internal void OnComplete(Uri uri, bool isSuccessful, WebErrorStatus status)
        {
            var args = new WebViewNavigationCompletedEventArgs()
            {
                IsSuccess      = isSuccessful,
                Uri            = uri ?? Source,
                WebErrorStatus = status
            };

            CanGoBack    = _nativeWebView.CanGoBack;
            CanGoForward = _nativeWebView.CanGoForward;

            NavigationCompleted?.Invoke(this, args);
        }
        private void OnTimeoutElapsed(object sender, object e)
        {
            _webView.Stop();

            _stopwatch.Stop();
            _countdownTimer.Stop();

            _navigationAttempt++;
            if (_navigationAttempt > MAX_RETRY_COUNT)
            {
                NavigationCompleted?.Invoke(_webView, new WebViewNavigationSuccessArgs(false, null, Windows.Web.WebErrorStatus.Timeout));
                return;
            }

            Navigate();
        }
Beispiel #6
0
        /// <summary>
        /// Updates the navigation context. The navigation context provided by this class is different
        /// from the <see cref="NavigationContext"/>. Therefore, this method updates the navigation context
        /// to match it to the values of the <paramref name="navigationContext"/>.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public void UpdateNavigationContext(NavigationContext navigationContext)
        {
            lock (_navigationContext)
            {
                if (navigationContext != null)
                {
                    foreach (string key in navigationContext.Values.Keys)
                    {
                        _navigationContext.Values[key] = navigationContext.Values[key];
                    }
                }

                NavigationCompleted?.Invoke(this, EventArgs.Empty);

                OnNavigationCompleted();
            }
        }
Beispiel #7
0
 /// <summary>
 /// This method is only ever called on the intial drawing of the map before any nodes are retrieved.
 /// and when using the breadcrumb bar to go back through the history
 /// </summary>
 /// <param name="nodeId">The NodeUid for the current map node</param>
 public virtual void SetCurrentNode(Guid nodeId)
 {
     if (!_navHistory.HasHistory)
     {
         SetHistory(null, new NodeProxy()
         {
             Id = nodeId
         });
     }
     if (NavigationCompleted != null)
     {
         NavigationCompleted.Invoke(this, new EventArgs());
     }
     _currentFocalNode = nodeId;
     if (_navHistory.HasHistory)
     {
         FocalNode = _navHistory.Stack.Peek().Node;
     }
 }
        private void OnNavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            _stopwatch.Stop();
            _countdownTimer.Stop();

            if (args.IsSuccess)
            {
                NavigationCompleted?.Invoke(sender, new WebViewNavigationSuccessArgs(args));
                return;
            }

            _navigationAttempt++;
            if (_navigationAttempt > MAX_RETRY_COUNT)
            {
                NavigationCompleted?.Invoke(sender, new WebViewNavigationSuccessArgs(args));
                return;
            }

            Navigate();
        }
 private void OnWebViewNavigationCompleted(WebView2 sender, WebView2NavigationCompletedEventArgs args)
 {
     NavigationCompleted?.Invoke(this, args.WebErrorStatus);
 }
 private void OnBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     NavigationCompleted?.Invoke(sender, e);
 }
Beispiel #11
0
 public void OnNavigationCompleted(object sender, EventArgs e)
 {
     NavigationCompleted?.Invoke(sender, e);
 }