internal void StartRoute <T>()
        {
            _ViewModel = _ServiceLocator.GetInstance <T>();
            var route = _RouterSolver.SolveRoute <T>();

            Route = route;
            OnNavigated?.Invoke(this, new RoutedEventArgs(_ViewModel, route));
        }
        private void AfterResolve(string routeName)
        {
            var context = _CurrentNavigations.Dequeue();

            if (context.Route != routeName)
            {
                Console.WriteLine($"Navigation inconsistency: from browser {routeName}, from context: {context.Route}. Maybe rerouted?");
            }
            context.Complete();

            Route = routeName;
            OnNavigated?.Invoke(this, new RoutedEventArgs(context));
        }
        public Task Navigate(object viewModel, string routeName)
        {
            var route = routeName ?? _RouterSolver.SolveRoute(viewModel);

            if (Route == route)
            {
                if (!ReferenceEquals(_ViewModel, viewModel))
                {
                    OnNavigated?.Invoke(this, new RoutedEventArgs(viewModel, route));
                }

                _ViewModel = viewModel;
                return(Task.FromResult(0));
            }

            var routeContext = CreateRouteContext(viewModel, route);

            Route = route;
            return(routeContext.Task);
        }
Exemple #4
0
        public void Navigate(string uri, IDictionary <string, object> navigationParameters = null)
        {
            var navigationTarget = _navigationTargets(uri);

            if (navigationTarget is null)
            {
                _logger.Error("No navigation possible to {@uri}", uri);
                Application.Current.Shutdown();
            }
            if (navigationTarget is INavigationAware navigationAware)
            {
                if (!navigationAware.IsNavigationTarget())
                {
                    return;
                }

                navigationAware.OnNavigatedTo(navigationParameters ?? ImmutableDictionary <string, object> .Empty);
            }

            OnNavigated?.Invoke(uri, navigationTarget);
        }
Exemple #5
0
 public void Navigated()
 {
     RefreshItems();
     OnNavigated?.Invoke();
 }
Exemple #6
0
            private void Client_OnEvent(string method, Newtonsoft.Json.Linq.JToken args)
            {
                Frame frame = null;

                switch (method)
                {
                case "Page.navigatedWithinDocument":
                    var newUrl = args["url"].ToString();
                    Frames.TryGetValue(args["frameId"].ToString(), out frame);
                    OnUrlChanged?.Invoke(newUrl, frame);
                    break;

                case "Page.frameNavigated":
                    frame            = args["frame"].ToObject <Frame>();
                    Frames[frame.id] = frame;
                    OnNavigated?.Invoke(frame);
                    break;

                case "Runtime.executionContextsCleared":
                    OnPageDestroyed?.Invoke();
                    IsScreencastStarted = false;
                    break;

                case "Page.frameStartedLoading":
                    OnStartedLoading?.Invoke(args["frameId"].ToString());
                    break;

                case "Page.loadEventFired":
                    OnLoaded?.Invoke();
                    break;

                case "Network.loadingFinished":
                    var reqId = args["requestId"].ToString();
                    if (Responses.TryGetValue(reqId, out Response resp))
                    {
                        OnRequestComplete?.Invoke(resp.Request, resp);
                    }
                    break;

                case "Network.responseReceived":
                    reqId = args["requestId"].ToString();
                    if (Requests.TryGetValue(reqId, out Request req))
                    {
                        Requests.Remove(reqId);
                    }
                    resp             = args["response"].ToObject <Response>();
                    resp.Request     = req;
                    resp.requestId   = reqId;
                    Responses[reqId] = resp;
                    // HACK: Chrome sucks and the response is not actually ready yet.
                    // OnRequestComplete?.Invoke(req, resp);
                    break;

                case "Network.requestWillBeSent":
                    reqId       = args["requestId"].ToString();
                    req         = args.ToObject <Request>();
                    req.frameId = args["frameId"].ToString();
                    Frames.TryGetValue(req.frameId, out req.Frame);
                    req.requestId   = reqId;
                    Requests[reqId] = req;
                    OnRequestStarted?.Invoke(req);
                    break;

                case "Page.screencastFrame":
                    var sessionId = (int)args["sessionId"];
                    var t         = Client.Send("Page.screencastFrameAck", new { sessionId });
                    MostRecentFrameBase64   = args["data"].ToString();
                    MostRecentFrameMetadata = args["metadata"].ToObject <ScreencastFrameMetadata>();
                    OnScreencastFrame?.Invoke(MostRecentFrameBase64, MostRecentFrameMetadata);
                    break;
                }
            }
 void INavigationDispatcher.OnNavigated(INavigationContext context)
 {
     OnNavigated?.Invoke(context);
 }
Exemple #8
0
 void IMenuNavigationHook.InvokeOnNavigated(object sender, object args)
 {
     OnNavigated?.Invoke(sender, args);
 }
        public void NavigateTo(string pageKey, object parameter)
        {
            _innerNavigationService.NavigateTo(pageKey, parameter);

            OnNavigated?.Invoke(this, new OnNavigatedEventArgs(pageKey));
        }
        public void GoBack()
        {
            _innerNavigationService.GoBack();

            OnNavigated?.Invoke(this, new OnNavigatedEventArgs(CurrentPageKey));
        }