예제 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.Downloads)
            {
                TransfersPivot.SelectedItem = DownloadsPivot;
            }

            if (navParam == NavigationParameter.PictureSelected)
            {
                NavigationService.RemoveBackEntry();
            }

            if (navParam == NavigationParameter.AlbumSelected || navParam == NavigationParameter.SelfieSelected)
            {
                NavigationService.RemoveBackEntry();
                NavigationService.RemoveBackEntry();
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            // Needed on every UI interaction
            App.MegaSdk.retryPendingConnections();

            TransfersService.UpdateMegaTransfersList(App.MegaTransfers);
            _transfersViewModel.MegaTransfers = App.MegaTransfers;
        }
예제 #2
0
        /// <summary>
        /// Inspects the type of <paramref name="newContent"/> to determine the type of ViewModel to create,
        /// then creates it using <paramref name="container"/> and attaches it as the new page's DataContext.
        /// </summary>
        /// <param name="newContent">The page to wire up.</param>
        /// <param name="navParameter">The parameter used to navigate to the page.</param>
        /// <param name="container">The IoC container.</param>
        /// <param name="viewType">The computed view Type.</param>
        /// <param name="viewModelType">The computed ViewModel Type.</param>
        /// <returns></returns>
        public static IViewModel GenerateViewModel(PassKeepPage newContent, object navParameter, IUnityContainer container, out Type viewType, out Type viewModelType)
        {
            IViewModel contentViewModel = null;

            // Wire up the ViewModel
            // First, we figure out the ViewModel interface type
            viewType = newContent.GetType();
            Type viewBaseType = viewType.GetTypeInfo().BaseType;

            if (viewBaseType.Equals(typeof(PassKeepPage)))
            {
                // This is just a PassKeepPage, not a generic type. No ViewModel construction is necessary.
                DebugHelper.Assert(navParameter == null);
                viewModelType = null;
                return(null);
            }

            Type genericPageType = viewBaseType.GetTypeInfo().BaseType;

            viewModelType = genericPageType.GenericTypeArguments[0];

            TypeInfo viewModelTypeInfo = viewModelType.GetTypeInfo();

            DebugHelper.Assert(typeof(IViewModel).GetTypeInfo().IsAssignableFrom(viewModelTypeInfo));


            if (navParameter != null)
            {
                if (viewModelTypeInfo.IsAssignableFrom(navParameter.GetType().GetTypeInfo()))
                {
                    contentViewModel = (IViewModel)navParameter;
                }
                else
                {
                    NavigationParameter parameter = navParameter as NavigationParameter;
                    DebugHelper.Assert(parameter != null);

                    ResolverOverride[] overrides = parameter.DynamicParameters.ToArray();

                    // We resolve the ViewModel (with overrides) from the container
                    if (String.IsNullOrEmpty(parameter.ConcreteTypeKey))
                    {
                        contentViewModel = (IViewModel)container.Resolve(viewModelType, overrides);
                    }
                    else
                    {
                        contentViewModel =
                            (IViewModel)container.Resolve(viewModelType, parameter.ConcreteTypeKey, overrides);
                    }
                }
            }
            else
            {
                contentViewModel = (IViewModel)container.Resolve(viewModelType);
            }

            contentViewModel.Logger = container.Resolve <IEventLogger>();
            newContent.DataContext  = contentViewModel;
            return(contentViewModel);
        }
예제 #3
0
 public ActionResult <ImageNavigationResultView> PreviousBlank(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter)
 {
     return(Execute(topicId, (topic) =>
     {
         return Navigate(topic, navigationParameter, ENavigationDirection.PreviousBlank);
     }));
 }
예제 #4
0
        private async Task EstablishFromToStationsFromNavigation(NavigationParameter parameter)
        {
            try
            {
                var nearestFrom = await _ridesService.GetInfoForNearestStation();

                var toGeoLocation = new GeoLocation
                {
                    Latitude  = parameter.Latitude,
                    Longitude = parameter.Longitude
                };

                var nearestTo = await _ridesService.GetInfoForNearestStationTo(toGeoLocation);

                _stations = new[] { nearestFrom, nearestTo };

                InitializePinsFromStations(_stations);

                From = CustomPins[0];
                To   = CustomPins[1];
            }
            catch (Exception ex) when(ex is WebException || ex is HttpRequestException)
            {
                await _dialogService.ShowAlertAsync("Communication error", "Error", "Ok");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error loading data in: {ex}");
            }
        }
예제 #5
0
 public ActionResult <ImageLabelNavigationResult> Navigate(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter)
 {
     return(Execute(topicId, (topic) =>
     {
         return Navigate(topic, navigationParameter, ENavigationDirection.Direct);
     }));
 }
예제 #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.Downloads)
            {
                TransfersPivot.SelectedItem = DownloadsPivot;
            }
            else if (navParam == NavigationParameter.Uploads)
            {
                TransfersPivot.SelectedItem = UploadsPivot;
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            // Needed on every UI interaction
            SdkService.MegaSdk.retryPendingConnections();

            _transfersViewModel.Update();
        }
예제 #7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Remove the main page from the stack. If user presses back button it will then exit the application
            // Also removes the login page and the create account page after the user has created the account succesful
            while (NavigationService.CanGoBack)
            {
                NavigationService.RemoveBackEntry();
            }

            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            // Try to avoid display duplicate alerts
            if (isAlertAlreadyDisplayed)
            {
                return;
            }
            isAlertAlreadyDisplayed = true;

            switch (navParam)
            {
            case NavigationParameter.CreateAccount:
                // Show the success message
                new CustomMessageDialog(
                    AppMessages.ConfirmNeeded_Title,
                    AppMessages.ConfirmNeeded,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_ESID:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.SessionIDError_Title,
                    AppMessages.SessionIDError,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_EBLOCKED:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.AM_AccountBlocked_Title,
                    AppMessages.AM_AccountBlocked,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_ESSL:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.SSLKeyError_Title,
                    AppMessages.SSLKeyError,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;
            }
        }
 public TileViewModel(
     string title,
     INavigationService navigationService,
     Func <object> loadFunc,
     NavigationParameter parameter = null)
     : base(title, navigationService, loadFunc, parameter)
 {
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel.Name = NavigationParameter.ToString();

            this.SetBinding(() => ViewModel.Name, () => Name.Text);
        }
예제 #10
0
        public static Uri BuildNavigationUri(Type navPage, NavigationParameter navParam)
        {
            if (navPage == null)
                throw new ArgumentNullException("navPage");

            var queryString = String.Format("?navparam={0}", Enum.GetName(typeof(NavigationParameter), navParam));

            return new Uri(String.Format("{0}{1}.xaml{2}", AppResources.PagesLocation, navPage.Name, queryString), UriKind.Relative);
        }
예제 #11
0
 public static void NavigateTo(Type navPage, NavigationParameter navParam)
 {
     try
     {
         PreviousPage = navPage;
         ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(BuildNavigationUri(navPage, navParam));
     }
     catch (InvalidOperationException) { }
 }
예제 #12
0
        public void LoadParameters(NavigationParameter navigationParameter)
        {
            this.view.EventAggregator = navigationParameter.EventAggregator;
            this.ViewModelLocator     = navigationParameter.ViewModelLocator;

            if (this.isGeneric)
            {
                this.navigationParameter = navigationParameter;
            }
        }
예제 #13
0
        public void LoadParameters(NavigationParameter navigationParameter)
        {
            this.view.EventAggregator = navigationParameter.EventAggregator;
            this.ViewModelLocator = navigationParameter.ViewModelLocator;

            if (this.isGeneric)
            {
                this.navigationParameter = navigationParameter;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel = SimpleIoc.Default.GetInstance <PageViewModel>();

            Text.Text = "Parameter: " + NavigationParameter.ToString();

            Close.SetCommand("TouchUpInside", ViewModel.Close);
        }
예제 #15
0
 private void LoadChildsNavigationParameter(NavigationParameter parameter)
 {
     ForEachChildViewModels(this, vm => {
         var viewModel = vm as ViewModel;
         if (viewModel != null)
         {
             viewModel.LoadNavigationParameter(parameter);
         }
     });
 }
예제 #16
0
        public static Uri BuildNavigationUri(Type navPage, NavigationParameter navParam, IDictionary<string, string> extraParams)
        {
            var resultUrl = BuildNavigationUri(navPage, navParam).ToString();
            
            foreach (var extraParam in extraParams)
            {
                resultUrl += String.Format(@"&{0}={1}", extraParam.Key, extraParam.Value);
            }

            return new Uri(resultUrl, UriKind.Relative);
        }
 protected TileViewModelBase(
     string title,
     INavigationService navigationService,
     Func <T> loadFunc,
     NavigationParameter parameter)
 {
     _title              = title;
     _loadFunc           = loadFunc;
     NavigationService   = navigationService;
     NavigationParameter = parameter;
 }
예제 #18
0
        public static Uri BuildNavigationUri(Type navPage, NavigationParameter navParam, IDictionary <string, string> extraParams)
        {
            var resultUrl = BuildNavigationUri(navPage, navParam).ToString();

            foreach (var extraParam in extraParams)
            {
                resultUrl += String.Format(@"&{0}={1}", extraParam.Key, extraParam.Value);
            }

            return(new Uri(resultUrl, UriKind.Relative));
        }
예제 #19
0
        public static Uri BuildNavigationUri(Type navPage, NavigationParameter navParam)
        {
            if (navPage == null)
            {
                throw new ArgumentNullException("navPage");
            }

            var queryString = String.Format("?navparam={0}", Enum.GetName(typeof(NavigationParameter), navParam));

            return(new Uri(String.Format("{0}{1}.xaml{2}", AppResources.PagesLocation, navPage.Name, queryString), UriKind.Relative));
        }
예제 #20
0
        public ActionResult <ImageNavigationResultView> LastBlank(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter)
        {
            return(Execute(topicId, (topic) =>
            {
                if (navigationParameter != null)
                {
                    navigationParameter.Index = 0;
                }

                return Navigate(topic, navigationParameter, ENavigationDirection.LastBlank);
            }));
        }
예제 #21
0
            public async Task Should_Call_Popup_Navigation()
            {
                // Given
                var parameter             = new NavigationParameter();
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation);

                // When
                await sut.PushPopup <NavigableViewModelMock>(parameter);

                // Then
                await navigation.Received(1).PushAsync(Arg.Any <PopupPage>()).ConfigureAwait(false);
            }
예제 #22
0
 public ActionResult <ImageLabelNavigationResult> Blank(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter)
 {
     return(Execute(topicId, (topic) =>
     {
         ImageLabelNavigationResult result = GetImageLabelNavigationResult(topic, navigationParameter, ENavigationDirection.Blank);
         if (result == null)
         {
             // if no next blank image found then stay on current image
             return Navigate(topic, navigationParameter, ENavigationDirection.Direct);
         }
         return Ok(result);
     }));
 }
예제 #23
0
        public override void DetermineNavigationMode(NavigationParameter parameter)
        {
            if (this.GetService <IApplicationService>().GetContext().Device.Kind == DeviceKind.Tablet)
            {
                parameter.NavigationMode          = NavigationMode.Modal;
                parameter.ModalPresentationStyle  = Intersoft.Crosslight.ModalPresentationStyle.FormSheet;
                parameter.EnsureNavigationContext = true;

                var closeButton = new UIBarButtonItem("Close", UIBarButtonItemStyle.Bordered, null);

                this.RegisterViewIdentifier("CloseButton", closeButton);
                this.NavigationItem.RightBarButtonItem = closeButton;
            }
        }
예제 #24
0
 public ActionResult <ImageLabelNavigationResult> LastBlank(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter)
 {
     return(Execute(topicId, (topic) =>
     {
         ImageLabelNavigationResult result = GetImageLabelNavigationResult(topic, navigationParameter, ENavigationDirection.LastBlank);
         if (result == null)
         {
             // if no last blank image found then navigate to first image
             navigationParameter.Index = 0;
             return Navigate(topic, navigationParameter, ENavigationDirection.Direct);
         }
         return Ok(result);
     }));
 }
예제 #25
0
            public async Task Should_Call_View_Model_Factory()
            {
                // Given
                var parameter        = new NavigationParameter();
                var viewModelFactory = Substitute.For <IViewModelFactory>();

                viewModelFactory.Create <NavigableViewModelMock>(Arg.Any <string>()).Returns(new NavigableViewModelMock());
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithViewModelFactory(viewModelFactory);

                // When
                await sut.PushPopup <NavigableViewModelMock>(parameter);

                // Then
                viewModelFactory.Received(1).Create <NavigableViewModelMock>();
            }
예제 #26
0
            public async Task Should_Observe_Pushed()
            {
                // Given
                bool pushed               = false;
                var  parameter            = new NavigationParameter();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(new PopupNavigationMock());

                sut.Pushed.Select(_ => true).Subscribe(x => pushed = x);

                // When
                await sut.PushPopup <NavigableViewModelMock>(parameter);

                // Then
                pushed.Should().BeTrue();
            }
예제 #27
0
            public async Task Should_Call_View_Locator()
            {
                // Given
                var parameter   = new NavigationParameter();
                var viewModel   = new NavigableViewModelMock();
                var viewLocator = Substitute.For <IViewLocator>();

                viewLocator.ResolveView(Arg.Any <NavigableViewModelMock>(), Arg.Any <string>()).Returns(new PopupMock());
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithViewLocator(viewLocator);

                // When
                await sut.PushPopup <NavigableViewModelMock>(parameter);

                // Then
                viewLocator.Received(1).ResolveView(Arg.Any <IViewModel>());
            }
예제 #28
0
        private ActionResult Navigate(Topic topic, NavigationParameter navigationParameter, ENavigationDirection navigationDirection)
        {
            #region validation

            CheckMandatoryParameter(nameof(navigationParameter), navigationParameter);

            #endregion

            // create naviation result
            ImageNavigationResultView result = GetImageLabelNavigationResult(topic, navigationParameter, navigationDirection);
            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound(Messages.ImageNotFound((uint)navigationParameter.Index)));
        }
예제 #29
0
        public void WrongTest()
        {
            var mockNavigationService = new Mock <INavigationService>();

            var sampleClassInstance = new SamlpeClass(mockNavigationService.Object);

            sampleClassInstance.SampleCommand.Execute(null);

            var parameter = new NavigationParameter
            {
                Prop1 = "value1",
                Prop2 = "value2"
            };

            mockNavigationService.Verify(s => s.Navigate(parameter));
        }
예제 #30
0
            public async Task Should_Call_Navigating_To()
            {
                // Given
                var parameter   = new NavigationParameter();
                var viewLocator = Substitute.For <IViewLocator>();
                var viewModel   = Substitute.For <INavigable>();

                viewLocator.ResolveView(Arg.Any <NavigableViewModelMock>(), Arg.Any <string>()).Returns(new PopupMock());
                var navigation            = Substitute.For <IPopupNavigation>();
                PopupViewStackService sut = new PopupViewStackServiceFixture().WithNavigation(navigation);

                // When
                await sut.PushPopup(viewModel, parameter);

                // Then
                await viewModel.Received(1).WhenNavigatingTo(parameter);
            }
예제 #31
0
        /// <summary>
        /// Initializes <see cref="NavigationService"/> instance
        /// </summary>
        /// <param name="mainPageType">The type of the main application page</param>
        /// <param name="parameter">Initial navigation parameter</param>
        public void Initialize(Type mainPageType, NavigationParameter parameter)
        {
            this.mainPageType = mainPageType;
            Frame frame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active.
            if (frame == null)
            {
                logger.LogMessage("NavigationService: No root frame found. Creating the new one.");
                frame = new Frame
                {
                    CacheSize = 1,
                    Language = ApplicationLanguages.Languages[0]
                };
                Window.Current.Content = frame;
                logger.LogMessage("NavigationService: Root frame created successfully.");
            }

            if (frame.Content == null)
            {
                logger.LogMessage("NavigationService: Root frame is empty. Removing transitions for the first-time navigation.");
                if (frame.ContentTransitions != null)
                {
                    transitions = new TransitionCollection();
                    foreach (var c in frame.ContentTransitions)
                    {
                        transitions.Add(c);
                    }
                }

                frame.ContentTransitions = null;
                frame.Navigated -= onRootFrameFirstNavigated;
                frame.Navigated += onRootFrameFirstNavigated;
            }

            this.frame = frame;
            if (!frame.Navigate(mainPageType, parameter))
            {
                string message = "Navigation service initialization error.";
                logger.LogMessage(message, LoggingLevel.Critical);
                throw new Exception(message);
            }

            logger.LogMessage("NavigationService initialized.", LoggingLevel.Information);
        }
예제 #32
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (e.NavigationMode == NavigationMode.Back)
            {
                App.CloudDrive.GoFolderUp();
                navParam = NavigationParameter.Browsing;
            }

            switch (navParam)
            {
            case NavigationParameter.Browsing:
            {
                App.CloudDrive.LoadNodes();
                break;
            }

            case NavigationParameter.Login:
            {
                // Remove the login page from the stack. If user presses back button it will then exit the application
                NavigationService.RemoveBackEntry();

                App.CloudDrive.FetchNodes();
                break;
            }

            case NavigationParameter.Unknown:
            {
                if (!SettingsService.LoadSetting <bool>(SettingsResources.RememberMe))
                {
                    NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal);
                    return;
                }
                else
                {
                    App.MegaSdk.fastLogin(SettingsService.LoadSetting <string>(SettingsResources.UserMegaSession), new FastLoginRequestListener());
                    App.CloudDrive.FetchNodes();
                }
                break;
            }
            }

            base.OnNavigatedTo(e);
        }
예제 #33
0
        private static bool TryGetValueInternal(NavigationParameter navigationParameter, Type type, out object value)
        {
            var success = false;

            value = GetDefault(type);


            if (navigationParameter.Value == null)
            {
                success = true;
            }
            else if (navigationParameter.Type == type)
            {
                success = true;
                value   = navigationParameter.Value;
            }
            else if (type.IsAssignableFrom(navigationParameter.Type))
            {
                success = true;
                value   = navigationParameter.Value;
            }
            else if (type.IsEnum)
            {
                var valueAsString = navigationParameter.Value.ToString();
                if (Enum.IsDefined(type, valueAsString))
                {
                    success = true;
                    value   = Enum.Parse(type, valueAsString);
                }
                else if (int.TryParse(valueAsString, out var numericValue))
                {
                    success = true;
                    value   = Enum.ToObject(type, numericValue);
                }
            }

            if (!success && type.GetInterface("System.IConvertible") != null)
            {
                success = true;
                value   = Convert.ChangeType(navigationParameter.Value, type);
            }

            return(success);
        }
예제 #34
0
        private static NavigationService ConstructNavigationService()
        {
            var ngs = new NavigationService();

            //add login & mainpage
            ngs.Configure(PageKeys.Login.ToString(), typeof(LoginPage));
            ngs.Configure(PageKeys.Welcome.ToString(), typeof(WelcomePage));
            ngs.Configure(PageKeys.Navigation.ToString(), typeof(NavigationPage));
            ngs.Configure(PageKeys.Info.ToString(), typeof(InfoPage));

            //add folder pages
            ngs.Configure(PageKeys.AddFolder.ToString(), typeof(AddFolderPage));
            ngs.Configure(PageKeys.EditFolder.ToString(), typeof(EditFolderPage));

            //entry lookup (connects entries with their View & Edit frame)
            var lookup = new Dictionary <ContentType, Tuple <Type, Type> >()
            {
                { ContentType.Webpage, new Tuple <Type, Type>(typeof(ViewWebpage), typeof(EditWebpage)) },
                { ContentType.Note, new Tuple <Type, Type>(typeof(ViewNote), typeof(EditNote)) },
                { ContentType.CreditCard, new Tuple <Type, Type>(typeof(ViewCreditCard), typeof(EditCreditCard)) },
                { ContentType.OnlineAccount, new Tuple <Type, Type>(typeof(ViewOnlineAccount), typeof(EditOnlineAccount)) },
                { ContentType.Book, new Tuple <Type, Type>(typeof(ViewBook), typeof(EditBook)) },
                { ContentType.Person, new Tuple <Type, Type>(typeof(ViewPerson), typeof(EditPerson)) }
            };

            //add pages of entries
            foreach (var ctm in ContentHelper.GetContentTypeModels())
            {
                if (lookup.ContainsKey(ctm.ContentType))
                {
                    var parameter = new NavigationParameter()
                    {
                        Name          = ctm.Name,
                        ViewModelType = ctm.ViewModelType,
                        ViewFrameType = lookup[ctm.ContentType].Item1,
                        EditFrameType = lookup[ctm.ContentType].Item2
                    };
                    ngs.AddEntryNavigation(ctm.AddPageKey, ctm.EditPageKey, ctm.ViewPageKey, parameter);
                }
            }

            return(ngs);
        }
예제 #35
0
 //转场检测的执行顺序为:前一个场景的退出函数->后一个场景的进入函数->转场广播
 //转场指示发出后将等待[SYSTEM]WINDOW_PAGE_CHANGE,最后触发新场景的进入完成函数
 protected override void Go_Implement(NavigationParameter e)
 {
     if (!e.PreviousScene.Scene_Exit(e.NextScene , e.ExtraData)) return;
     if (!e.NextScene.Scene_Enter(e.PreviousScene, e.ExtraData)) return;
     if (_sceneIndex != _scenes.Count - 1)
         _scenes.RemoveRange(_sceneIndex + 1, _scenes.Count - _sceneIndex + 1);
     _scenes.Add(e.NextScene);
     _sceneIndex = _scenes.Count - 1;
     _dispatcher.Invoke(() => _window.Navigate(e.NextScene.Content(), e.ExtraData));
     Core.API.Message.Wait("[SYSTEM]WINDOW_PAGE_CHANGE");
     e.NextScene.Scene_Entered(e.ExtraData);
 }
예제 #36
0
 public static void NavigateTo(Type navPage, NavigationParameter navParam, IDictionary<string, string> extraParams)
 {
     ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(BuildNavigationUri(navPage, navParam, extraParams));
 }
예제 #37
0
 public static void NavigateTo(Type navPage, NavigationParameter navParam)
 {
     ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(BuildNavigationUri(navPage, navParam));
 }
        private bool Navigate(Type type, object parameter, IViewModel viewModel)
        {
#if WINDOWSCOMMON
            if (viewModel != null)
            {
                if (!(parameter is NavigationParameter))
                    parameter = new NavigationParameter { Id = viewModel.GetViewModelId(), Parameter = parameter };
            }
#endif
            _lastParameter = parameter;
            if (parameter == null)
                return _frame.Navigate(type);
            return _frame.Navigate(type, parameter);
        }
예제 #39
0
 private void LoadChildsNavigationParameter(NavigationParameter parameter)
 {
     ForEachChildViewModels(this, vm => {
         var viewModel = vm as ViewModel;
         if (viewModel != null)
         {
             viewModel.LoadNavigationParameter(parameter);
         }
     });
 }
예제 #40
0
 internal void LoadNavigationParameter(NavigationParameter parameter)
 {
     this.NavigationService = parameter.NavigationService;
     this.EventAggregator = parameter.EventAggregator;
     this.LoadChildsNavigationParameter(parameter);
 }
예제 #41
0
        private void listView_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var _listview = listView as ListView;
            var _weibo = (Weibo)_listview.SelectedItem;
            ListViewItemPresenter originalsource = e.OriginalSource as ListViewItemPresenter;
            if (originalsource == null)
            {
                var advancesource = e.OriginalSource as TextBlock;
                var imageSource = e.OriginalSource as Image;
                var richtextBlock = e.OriginalSource as RichTextBlock;
                if (advancesource != null)
                {
                    if (advancesource.Text == "网页链接")
                    {
                        e.Handled = true;
                    }
                    else if (advancesource.Text.Substring(0, 1) == "#")
                    {
                        string hashtag = advancesource.Text.Substring(1);
                        hashtag = hashtag.Remove(hashtag.Length - 1);
                        //Frame.Navigate(typeof(HashTagPage), hashtag);
                    }
                    else if (advancesource.Text.Substring(0, 1) == "@")
                    {
                        string username = advancesource.Text.Substring(1);
                        NavigationParameter navip = new NavigationParameter(username, "screen_name");
                        Frame.Navigate(typeof(UserView), navip);
                    }
                    else if (_weibo.User.ScreenName != null && advancesource.Text == _weibo.User.ScreenName)
                    {
                        string username = advancesource.Text;
                        NavigationParameter navip = new NavigationParameter(username, "screen_name");
                        Frame.Navigate(typeof(UserView), navip);
                    }
                    else if(advancesource.Text == _weibo.RepostWeibo.User.ScreenName)
                    {
                        string username = advancesource.Text;
                        NavigationParameter navip = new NavigationParameter(username, "screen_name");
                        Frame.Navigate(typeof(UserView), navip);
                    }
                    else
                    {
                        Frame.Navigate(typeof(WeiboDetailView), _weibo);
                    }
                }

                else if (imageSource != null)
                {
                    string username = _weibo.User.ScreenName;
                    NavigationParameter navip = new NavigationParameter(username, "screen_name");
                    Frame.Navigate(typeof(UserView), navip);
                }
                else if (richtextBlock != null)
                {
                    Frame.Navigate(typeof(WeiboDetailView), _weibo);
                }
            }

            else
            {
                Frame.Navigate(typeof(WeiboDetailView), _weibo);
            }
        }
예제 #42
0
        /// <summary>
        /// Navigates to the main application page with passing given parameter to it
        /// </summary>
        /// <param name="parameter">Navigation parameter to pass</param>
        public void Navigate(NavigationParameter parameter)
        {
            if (!isInitialized)
            {
                logger.LogMessage($"NavigationService: Root frame hasn't initialized yet. Schedule navigation with parameter {parameter}.");
                deferredNavigationHandler = (_, __) =>
                {
                    logger.LogMessage("NavigationService: Executing deferred navigation handler.");
                    frame.LayoutUpdated -= deferredNavigationHandler;
                    Navigate(parameter);
                };
                return;
            }

            logger.LogMessage($"NavigationService: Navigating with parameter {parameter}.");

            if (!frame.Navigate(mainPageType, parameter))
            {
                logger.LogMessage("Navigation error.", LoggingLevel.Error);
            }
        }