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; }
/// <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); }
public ActionResult <ImageNavigationResultView> PreviousBlank(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter) { return(Execute(topicId, (topic) => { return Navigate(topic, navigationParameter, ENavigationDirection.PreviousBlank); })); }
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}"); } }
public ActionResult <ImageLabelNavigationResult> Navigate(long topicId, [FromQuery(Name = "")] NavigationParameter navigationParameter) { return(Execute(topicId, (topic) => { return Navigate(topic, navigationParameter, ENavigationDirection.Direct); })); }
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(); }
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); }
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); }
public static void NavigateTo(Type navPage, NavigationParameter navParam) { try { PreviousPage = navPage; ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(BuildNavigationUri(navPage, navParam)); } catch (InvalidOperationException) { } }
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); }
private void LoadChildsNavigationParameter(NavigationParameter parameter) { ForEachChildViewModels(this, vm => { var viewModel = vm as ViewModel; if (viewModel != null) { viewModel.LoadNavigationParameter(parameter); } }); }
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; }
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)); }
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)); }
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); })); }
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); }
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); })); }
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; } }
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); })); }
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>(); }
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(); }
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>()); }
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))); }
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)); }
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); }
/// <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); }
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); }
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); }
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); }
//转场检测的执行顺序为:前一个场景的退出函数->后一个场景的进入函数->转场广播 //转场指示发出后将等待[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); }
public static void NavigateTo(Type navPage, NavigationParameter navParam, IDictionary<string, string> extraParams) { ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(BuildNavigationUri(navPage, navParam, extraParams)); }
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); }
internal void LoadNavigationParameter(NavigationParameter parameter) { this.NavigationService = parameter.NavigationService; this.EventAggregator = parameter.EventAggregator; this.LoadChildsNavigationParameter(parameter); }
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); } }
/// <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); } }