public static HyperlinkButton AsHyperlinkButton(this NavigationInfo navigationInfo) { HyperlinkButton hb = new HyperlinkButton(); hb.Style = Application.Current.Resources[ResourceDictionaryKeys.LinkStyle] as Style; hb.Content = navigationInfo.Content; hb.Tag = navigationInfo; hb.NavigateUri = new Uri(navigationInfo.NavigationUri, UriKind.Relative); return(hb); }
public static string GetDeniedRolesAsString(this NavigationInfo navigationInfo) { var result = string.Empty; for (int i = 0; i < navigationInfo.Deny.Count; i++) { result = string.Concat(navigationInfo.Deny.ElementAt(i), i == navigationInfo.Deny.Count - 1 ? string.Empty : ","); } return(result); }
public async Task <NavigationDto> GetNavigationsAsync(int navId) { var naviagation = await Task.Run(() => navigationRepositrory.Query(navId)); if (naviagation == null) { naviagation = new NavigationInfo(); } return(ModelConvertUtil <NavigationInfo, NavigationDto> .ModelCopy(naviagation)); }
public bool Remove(NavigationInfo navigation) { var hb = GetHyperlinkButtonFor(navigation); if (hb != null) { return(LinksStackPanel.Children.Remove(hb)); } return(false); }
/// <summary> /// Create a many to one property. /// </summary> /// <param name="typeBuilder"></param> /// <param name="proxyNavInfo"></param> /// <param name="entityNavInfo"></param> /// <returns></returns> private PropertyBuilder CreateManyToOneProperty(TypeBuilder typeBuilder, NavigationInfo proxyNavInfo, NavigationInfo entityNavInfo) { PropertyBuilder propertyBuilder = PropertyHelper.CreatePropertyExplImpl(typeBuilder, proxyNavInfo.PropertyName, proxyNavInfo.NavigationType, proxyNavInfo.DeclaringType, PropertyHelper.PropertyGetSet.Both); GenerateManyToOneGetPropertyBody(propertyBuilder.GetMethod as MethodBuilder, entityNavInfo); GenerateManyToOneSetPropertyBody(propertyBuilder.SetMethod as MethodBuilder, entityNavInfo); return(propertyBuilder); }
public void Update(NavigationInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"update Navigation set ParentId=@ParentId,NavigationType=@NavigationType,Name=@Name,Remark=@Remark, OrderId=@OrderId,ClassType=@ClassType,Url=@Url,ClassId=@ClassId,IsSingle=@IsSingle,ShowType=@ShowType,IsVisible=@IsVisible where Id=@Id"; conn.Execute(sql, entity); } }
private void OnEditProductCommand(object param) { var p = param as Product; if (p != null) { // Opens the ProductEditView on top of ProductEditViewModel // Note that this viewmodel implements IViewKeyAware so that it will have the same ViewKey as its View var navigationInfo = NavigationInfo.CreateComplex(ViewId.ProductEdit, ViewKey, new ProductEditViewModel(p)); Singletons.NavigationService.NavigateTo <ProductEditView>(navigationInfo); } }
public void CanNavigateToNewViewWithViewModel() { // Prepare var fakeViewModel = new FakeViewModel(); var navigationInfo = NavigationInfo.CreateSimple("viewKey", fakeViewModel); // Act var expectedViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo); // Verify Assert.IsNotNull(expectedViewInfo.View.DataContext); }
private void NavigationHelper_OpenNewWindowEvent(object sender, NavigationInfo e) { if (mode == 1) { txtTitle.Text = e.title; frame.Navigate(e.page, e.parameters); } else { OpenNewWindow(e); } }
public void LoadNavigation() { Nodes = new ObservableCollection <NavigationNode>(); Nodes.Add(new ItemNavigationNode { Title = @"Fixing", Label = "Home", IsSelected = true, NavigationInfo = NavigationInfo.FromPage("HomePage") }); }
public void CanNavigateToNewView() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); // Act var expectedViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo); // Verify Assert.AreSame(expectedViewInfo.View, _navigationService.CurrentView.View); Assert.IsTrue(_navigationService.RootPanel.Children.Contains(expectedViewInfo.View)); }
public void CanCloseView() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); var expectedViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo); // Act var closedViewInfo = _navigationService.Close("viewKey"); // Verify Assert.AreSame(expectedViewInfo.View, closedViewInfo.View); Assert.IsTrue(_navigationService.NbOpenedViews == 0); }
private void NavigationHelper_OpenNewWindowEvent(object sender, NavigationInfo e) { if (mode == 1) { txtTitle.Text = e.title; frame.Navigate(e.page, e.parameters); (frame.Content as Page).NavigationCacheMode = NavigationCacheMode.Enabled; } else { OpenNewWindow(e); } }
public void NavigateToActiveAwareViewSupported() { // Prepare var activeAwareViewModelMock = new Mock <IActiveAware>(); var navigationInfo = NavigationInfo.CreateSimple("viewKey", activeAwareViewModelMock.Object); // Act _navigationService.NavigateTo <UserControl>(navigationInfo); // Verify activeAwareViewModelMock.Verify(m => m.OnActivating(), Times.Exactly(1)); activeAwareViewModelMock.Verify(m => m.OnActivated(), Times.Exactly(1)); }
public void CannotNavigateToNonExistantViewUsingViewKeyOnly() { // Prepare var navigationInfo1 = NavigationInfo.CreateSimple("viewKey1"); var navigationInfo2 = NavigationInfo.CreateSimple("viewKey2"); _navigationService.NavigateTo <UserControl>(navigationInfo1); _navigationService.NavigateTo <UserControl>(navigationInfo2); // Act _navigationService.NavigateTo("nonExistantViewKey"); // Verify }
public void CanShowMessageBoxDialog() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); var oldViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo); // Act _navigationService.ShowMessageBox("viewKey", "Lorem ipsum", MessageBoxImage.Warning, MessageBoxButton.OKCancel); // Verify Assert.IsInstanceOfType(_navigationService.CurrentView.View, typeof(ModalHostControl)); Assert.IsTrue(oldViewInfo.View.Visibility == Visibility.Visible); Assert.IsFalse(string.IsNullOrEmpty(((MessageBoxControl)((ModalHostControl)_navigationService.CurrentView.View).ModalContent).Message)); }
public void LoadNavigation() { Nodes = new ObservableCollection <NavigationNode>(); var resourceLoader = new ResourceLoader(); Nodes.Add(new ItemNavigationNode { Title = @"随机", Label = "Home", FontIcon = "\ue10f", IsSelected = true, NavigationInfo = NavigationInfo.FromPage("HomePage") }); Nodes.Add(new ItemNavigationNode { Label = "历史", FontIcon = "\ue1d3", NavigationInfo = NavigationInfo.FromPage("Section1ListPage") }); Nodes.Add(new ItemNavigationNode { Label = "Html", FontIcon = "\ue185", NavigationInfo = NavigationInfo.FromPage("HtmlListPage") }); Nodes.Add(new ItemNavigationNode { Label = "Collection", FontIcon = "\ue1d3", NavigationInfo = NavigationInfo.FromPage("CollectionListPage") }); Nodes.Add(new ItemNavigationNode { Label = "Collection12", FontIcon = "\ue1d3", NavigationInfo = NavigationInfo.FromPage("Collection12ListPage") }); Nodes.Add(new ItemNavigationNode { Label = resourceLoader.GetString("NavigationPanePrivacy"), FontIcon = "\ue1f7", NavigationInfo = new NavigationInfo() { NavigationType = NavigationType.DeepLink, TargetUri = new Uri("http://appstudio.windows.com/home/appprivacyterms", UriKind.Absolute) } }); }
public void CanShowModal() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); var modalNavigationInfo = NavigationInfo.CreateComplex("modalViewKey", navigationInfo.ViewKey); var oldViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo); // Act var modalResult = _navigationService.ShowModal <UserControl, bool>(modalNavigationInfo); // Verify Assert.AreEqual(modalResult.ViewInfo, _navigationService.CurrentView); Assert.IsInstanceOfType(_navigationService.CurrentView.View, typeof(ModalHostControl)); Assert.IsTrue(oldViewInfo.View.Visibility == Visibility.Visible); }
public void CannotNavigateAndAttachNewViewWithNotTopMostParentView() { // Prepare var navigationInfo1 = NavigationInfo.CreateSimple("viewKey1"); var navigationInfo2 = NavigationInfo.CreateComplex("viewKey2", navigationInfo1.ViewKey); var navigationInfo3 = NavigationInfo.CreateComplex("viewKey3", navigationInfo1.ViewKey); _navigationService.NavigateTo <UserControl>(navigationInfo1); _navigationService.NavigateTo <UserControl>(navigationInfo2); // Act _navigationService.NavigateTo <UserControl>(navigationInfo3); // Verify }
public void WhenModalViewIsDisplayedItsParentIsVisibleAndDisabled() { // Prepare var parentNavigationInfo = NavigationInfo.CreateSimple("parentViewKey"); var modalNavigationInfo = NavigationInfo.CreateComplex("modalViewKey", parentNavigationInfo.ViewKey); var parentViewInfo = _navigationService.NavigateTo <UserControl>(parentNavigationInfo); // Act var modalResult = _navigationService.ShowModal <UserControl, bool>(modalNavigationInfo); // Verify Assert.IsTrue(modalResult.ViewInfo.View.Visibility == Visibility.Visible); Assert.IsTrue(parentViewInfo.View.Visibility == Visibility.Visible); Assert.IsFalse(parentViewInfo.View.IsEnabled); }
public async Task <NavigationInfo> Update(NavigationInfo navigationInfo) { var result = await FindById(navigationInfo.Id); if (result == null) { return(null); } result.Path = navigationInfo.Path; result.Text = navigationInfo.Text; result.NavigationType = navigationInfo.NavigationType; await _context.SaveChangesAsync(); return(result); }
public void MessageBoxesAreNotConsideredAsTopMostViewsDuringClosingProcess() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey", new FakeDirtyViewModel()); _navigationService.NavigateTo <UserControl>(navigationInfo); _navigationService.ShowMessageBox("viewKey", "Hello"); // Act _navigationService.CloseApplication(); // Verify Assert.IsInstanceOfType(_navigationService.CurrentView.View, typeof(ModalHostControl)); Assert.IsInstanceOfType(((ModalHostControl)_navigationService.CurrentView.View).ModalContent, typeof(ShutdownApplicationControl)); }
private void SendMailClick(object sender, RoutedEventArgs e) { // HOW TO : open a modal view on top of another one // Here is an example of a modal custom view. // The modal view returns a Task<TResult>, that means that you can use the C#5 async/await pattern to improve this code. // Notice that you have to use TaskScheduler.FromCurrentSynchronizationContext() // in order to use the UI thread synchronization context var navigationInfo = NavigationInfo.CreateComplex(ViewId.SendMail, ViewId.About, false); var modalResult = Singletons.NavigationService.ShowModal <SendMailView, string>(navigationInfo); modalResult.Result.ContinueWith(r => { txtDisplayModalResult.Text = "Modal Result : " + r.Result; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void CanNavigateAndAttachNewViewWithParentView() { // Prepare var parentNavigationInfo = NavigationInfo.CreateSimple("parentViewKey"); var childNavigationInfo = NavigationInfo.CreateComplex("childViewKey", parentNavigationInfo.ViewKey); var oldViewInfo = _navigationService.NavigateTo <UserControl>(parentNavigationInfo); // Act var expectedViewInfo = _navigationService.NavigateTo <UserControl>(childNavigationInfo); // Verify Assert.AreSame(expectedViewInfo.View, _navigationService.CurrentView.View); Assert.IsTrue(_navigationService.RootPanel.Children.Contains(expectedViewInfo.View)); Assert.IsTrue(expectedViewInfo.View.Visibility == Visibility.Visible); Assert.IsTrue(oldViewInfo.View.Visibility == Visibility.Collapsed); }
public void CanNavigateAndAttachNewViewWithViewKeyAwareViewModelToParentView() { // Prepare var fakeViewModel = new FakeViewKeyAwareViewModel(); var parentNavigationInfo = NavigationInfo.CreateSimple("parentViewKey"); var childNavigationInfo = NavigationInfo.CreateComplex("childViewKey", parentNavigationInfo.ViewKey, fakeViewModel); _navigationService.NavigateTo <UserControl>(parentNavigationInfo); // Act var expectedViewInfo = _navigationService.NavigateTo <UserControl>(childNavigationInfo); // Verify Assert.IsNotNull(expectedViewInfo.View.DataContext); Assert.AreEqual(childNavigationInfo.ViewKey, ((IViewKeyAware)expectedViewInfo.View.DataContext).ViewKey); }
public void ShowModalActiveAwareViewSupported() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); var activeAwareViewModelMock = new Mock <IActiveAware>(); var modalNavigationInfo = NavigationInfo.CreateComplex("modalViewKey", navigationInfo.ViewKey, activeAwareViewModelMock.Object); _navigationService.NavigateTo <UserControl>(navigationInfo); // Act _navigationService.ShowModal <UserControl, string>(modalNavigationInfo); // Verify activeAwareViewModelMock.Verify(m => m.OnActivating(), Times.Exactly(1)); activeAwareViewModelMock.Verify(m => m.OnActivated(), Times.Exactly(1)); }
public void CanShowCloseableViewSelection() { // Prepare var navigationInfo1 = NavigationInfo.CreateSimple("viewKey1"); var navigationInfo2 = NavigationInfo.CreateComplex("viewKey2", navigationInfo1.ViewKey, new FakeDirtyViewModel()); _navigationService.NavigateTo <UserControl>(navigationInfo1); _navigationService.NavigateTo <UserControl>(navigationInfo2); // Act _navigationService.CloseApplication(); // Verify Assert.IsInstanceOfType(_navigationService.CurrentView.View, typeof(ModalHostControl)); Assert.IsInstanceOfType(((ModalHostControl)_navigationService.CurrentView.View).ModalContent, typeof(ShutdownApplicationControl)); }
public void CannotCloseNotTopMostView() { // Prepare var navigationInfo1 = NavigationInfo.CreateSimple("viewKey1"); var navigationInfo2 = NavigationInfo.CreateComplex("viewKey2", navigationInfo1.ViewKey); var navigationInfo3 = NavigationInfo.CreateComplex("viewKey3", navigationInfo2.ViewKey); _navigationService.NavigateTo <UserControl>(navigationInfo1); _navigationService.NavigateTo <UserControl>(navigationInfo2); _navigationService.NavigateTo <UserControl>(navigationInfo3); // Act _navigationService.Close("viewKey2"); // Verify }
public void CannotNavigateAndAttachExistingViewWithParentView() { // Prepare var navigationInfo = NavigationInfo.CreateSimple("viewKey"); var parentNavigationInfo = NavigationInfo.CreateSimple("parentViewKey"); _navigationService.NavigateTo <UserControl>(navigationInfo); _navigationService.NavigateTo <UserControl>(parentNavigationInfo); // Act var notAllowedNavigationInfo = NavigationInfo.CreateComplex(navigationInfo.ViewKey, parentNavigationInfo.ViewKey); _navigationService.NavigateTo <UserControl>(notAllowedNavigationInfo); // Verify }
public void CanRaiseClosingApplicationShownEvent() { // Prepare var eventRaised = false; var navigationInfo1 = NavigationInfo.CreateSimple("viewKey1"); var navigationInfo2 = NavigationInfo.CreateComplex("viewKey2", navigationInfo1.ViewKey, new FakeDirtyViewModel()); _navigationService.NavigateTo <UserControl>(navigationInfo1); _navigationService.NavigateTo <UserControl>(navigationInfo2); // Act _navigationService.ShutdownApplicationShown += (sender, e) => eventRaised = true; _navigationService.CloseApplication(); // Verify Assert.IsTrue(eventRaised); }
public static void Publish(NavigationInfo navInfo) { var eventMsg = new NavigatedEventMessage(navInfo); Services.EventAggregator.Publish(eventMsg); }
/// <summary> /// Called by pages when they are navigated to. /// </summary> /// <param name="e"></param> /// <param name="navCtx"></param> public void OnPageNavigatedTo(NavigationEventArgs e, NavigationContext navCtx) { // Discards the navigation if we are recovering from tombstone. if (!e.IsNavigationInitiator) { // Navigates back home. App.Current.ViewModel.NavigationManager.NavigateToAppHome(true); return; } // Marks the page as visible. IsPageVisible = true; // Always perform the common initializations. NavigationInfo nav = new NavigationInfo(navCtx, e.NavigationMode, false); InitFromNavigationInternal(nav); // This view model needs to be init'ed only if the navigation // gets to the associated page for the first time, or if // the app is recovering from being tombstoned. if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh) { InitFromNavigation(nav); } else if (e.NavigationMode == NavigationMode.Back) { OnPageNavigatedBackToOverride(); } }
private void InitFromNavigationInternal(NavigationInfo nav) { // Parses the wherigo id parameter and tries to load its associed object. string rawWidParam; if (nav.NavigationContext.QueryString.TryGetValue("wid", out rawWidParam)) { int WidParam; if (int.TryParse(rawWidParam, out WidParam)) { WherigoObject wObject; if (this.Model.Core.TryGetWherigoObject<WherigoObject>(WidParam, out wObject)) { // The object has been found: keep it. this.WherigoObject = wObject; } } } }
/// <summary> /// Initializes the view model from the navigation context. /// </summary> /// <param name="navCtx"></param> protected virtual void InitFromNavigation(NavigationInfo nav) { }
public NavigationFailedEventMessage(NavigationInfo navigationInfo) : base(navigationInfo) { }
private void EnterNavigationCollection(NavigationInfo info) { _navSources.Push(info); }
private void Build(NavigationInfo navigation) { switch (navigation.Action) { case "MainView": { string[] parts = navigation.Argument.Split(':'); if (parts.Length == 2) { string name = BasePluginInfo.FormatFullName(parts[0], parts[1]); MainViewInfo mainView; if (_context.MainViews.TryGetValue(name, out mainView)) { navigation.NavUrl = mainView.MainTable + ".aspx"; } else { LogWarning("Unable to find the '{0}' main view", name); } } else { LogWarning("Unable to parse argument: '{0}'", navigation.Argument); } } break; default: LogWarning("Legacy action '{0}' not supported", navigation.Action); break; } }
/// <summary> /// Method used to deserialize the NavData information from NavigationInfo path /// in the form object. This is will help us to restore te modified information /// while performing the submission of NavigationForm through javascript. /// </summary> /// <param name="request"></param> /// <param name="navigationInfo"></param> private void UpdateNavigationData(HttpRequestBase request, NavigationInfo navigationInfo) { var navigationData = request.Form["navigateInfo"]; if (string.IsNullOrEmpty(navigationData)) return; var jTokenNavigationData = JToken.Parse(navigationData); //NewtonSoft will consider every object as JProperty. //This will be interated to match with the property in NavigationInfo type. //If NavigationInfo class has any matched properties, then we will set the //value from JProperty to corresponding type in NavigationInfo using reflection. foreach (JProperty jTokenData in jTokenNavigationData) { var property = navigationInfo.GetType().GetProperty(jTokenData.Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (property == null) continue; if (jTokenData.Value is JValue) { var value = ((JValue)jTokenData.Value).Value; //In case of Nullable properties, we need to consider taking the Underlying property type //to set the data. Otherwise, reflection will throw error during setValue. var propertyType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; property.SetValue(navigationInfo, Convert.ChangeType(value, propertyType), null); } else { property.SetValue(navigationInfo, (dynamic)jTokenData.Value, null); } } }
protected override async void InitFromNavigation(NavigationInfo nav) { IsAppSupporterContentVisible = await App.Current.ViewModel.LicensingManager.ValidateCustomSupportLicense(); }
public NavigatingEventMessage(NavigationInfo navigationInfo) : base(navigationInfo) { }
void proc() { JContext jc = JContext.Current; HttpContext context = jc.Context; // set a ajax request token jc.IsAjaxRequest = true; // get querystring string qs = context.Request.Params["querystring"]; if (StringUtil.HasText(qs)) { qs = qs.TrimStart('?'); jc.QueryString.Add(StringUtil.DelimitedEquation2NVCollection("&", qs)); } if (context.Request.UrlReferrer != null) { UrlMappingModule module = UrlMappingModule.Instance; if (module != null) { UrlMappingItem mapping = null; jc.QueryString.Add(module.GetMappedQueryString(context.Request.UrlReferrer.AbsolutePath, out mapping)); if (mapping != null) { NavigationInfo navi = new NavigationInfo(); navi.Set(mapping, UrlMappingModule.GetUrlRequested(context.Request.UrlReferrer.AbsolutePath)); jc.Navigation = navi; // fire url matched event module.OnUrlMatched(); } } } // set view data UrlMappingModule.SetViewData(); string classId = context.Request.Params[CLASS_ID_PARAM]; string methodName = context.Request.Params[METHOD_NAME_PARAM]; string methodJsonArgs = context.Request.Params[METHOD_ARGS_PARAM]; string jsonp = context.Request.Params[JSONP]; object result; int cacheMinutes = -1; if (string.IsNullOrEmpty(classId) || string.IsNullOrEmpty(methodName)) { result = "null"; } else { AjaxConfiguration config = AjaxConfiguration.GetConfig(); AjaxMethod m = null; try { string id = jc.Navigation.Id; if (id.Contains(":")) id = id.Substring(id.IndexOf(":") + 1); AjaxClass c = config.FindClass(classId, id); m = config.FindMethod(c, methodName); if (string.Equals("Post", m.AjaxType, StringComparison.InvariantCultureIgnoreCase)) cacheMinutes = -1; else if (StringUtil.HasText(m.CacheTest)) cacheMinutes = methodJsonArgs.Equals(m.CacheTest) ? cacheMinutes : -1; // before execute BeforeExecuteEventArgs e = new BeforeExecuteEventArgs() { JContext = jc, TypeName = c.Key, MethodName = m.MethodName }; OnBeforeExecute(e); if (e.PreventDefault) { result = e.ReturnValue; goto response; } if (c.Type != null) result = m.Invoke(c.Type, methodJsonArgs); else result = m.Invoke(c.TypeString, methodJsonArgs); } catch (Exception ex) { LogManager.GetLogger<AjaxController>().Error("ajax handler error." + ExceptionUtil.WriteException(ex)); AjaxServerException ajaxEx = null; if (m != null) ajaxEx = m.Exception; if (ajaxEx != null) result = ajaxEx.ToJson(); else result = null; } } goto response; response: OnAfterExecute(result); ResponseUtil.OutputJson(context.Response, result, cacheMinutes, jsonp); ContentType = context.Response.ContentType; }
protected override void InitFromNavigation(NavigationInfo nav) { // Inits the application bar. InitAppBar(); // Refresh everything. RefreshLocationStatuses(); RefreshCompassStatuses(); }
public NavigationRequestedEventMessage(NavigationInfo navigationInfo) : base(navigationInfo) { }
internal static DbExpression FindNavigationExpression(DbExpression expression, AliasGenerator aliasGenerator, out NavigationInfo navInfo) { Debug.Assert(TypeSemantics.IsCollectionType(expression.ResultType), "Non-collection input to projection?"); navInfo = null; TypeUsage elementType = ((CollectionType)expression.ResultType.EdmType).TypeUsage; if (!TypeSemantics.IsEntityType(elementType) && !TypeSemantics.IsReferenceType(elementType)) { return expression; } RelationshipNavigationVisitor visitor = new RelationshipNavigationVisitor(aliasGenerator); DbExpression rewrittenExpression = visitor.Find(expression); if (!object.ReferenceEquals(expression, rewrittenExpression)) { Debug.Assert(visitor._original != null && visitor._rewritten != null, "Expression was rewritten but no navigation was found?"); navInfo = new NavigationInfo(visitor._original, visitor._rewritten); return rewrittenExpression; } else { return expression; } }
/// <summary> /// Called by pages when they are navigated to. /// </summary> /// <param name="e"></param> /// <param name="navCtx"></param> public void OnPageNavigatedTo(NavigationEventArgs e, NavigationContext navCtx) { // Marks the page as visible. IsPageVisible = true; // Always perform the common initializations. NavigationInfo nav = new NavigationInfo(navCtx, e.NavigationMode); InitFromNavigationInternal(nav); // This view model needs to be init'ed only if the navigation // gets to the associated page for the first time, or if // the app is recovering from being tombstoned. if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh) { InitFromNavigation(nav); } else if (e.NavigationMode == NavigationMode.Back) { if (App.Current.ViewModel.HasRecoveredFromTombstone) { InitFromNavigation(nav); } else { OnPageNavigatedBackToOverride(); } } }
public NavigationEventMessage(NavigationInfo navigationInfo) { NavigationInfo = navigationInfo; }
protected override void InitFromNavigation(NavigationInfo nav) { // Synchronizes the cartridge store. Model.CartridgeStore.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(OnCartridgeStoreCollectionChanged); Model.CartridgeStore.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnCartridgeStorePropertyChanged); Model.CartridgeStore.SyncFromIsoStore(); // Monitors the history. Model.History.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(OnHistoryCollectionChanged); // Initial refresh. RefreshRecentCartridges(); RefreshAllCartridges(); RefreshVisibilities(); // Inits the app bar. RefreshAppBar(); }
private void Persist(NavigationInfo navigation) { }
protected override void InitFromNavigation(NavigationInfo nav) { base.InitFromNavigation(nav); // Checks if this Input appears to be looping. // If so, a special panel is shown. IsDiscardable = App.Current.ViewModel.InputManager.IsLooping(Input); }
protected override void InitFromNavigation(NavigationInfo nav) { base.InitFromNavigation(nav); // We probably have a lot of things to do. // Let's block the UI and show some progress bar. RefreshProgressBar(Model.Core.GameState); System.Windows.Navigation.NavigationContext navCtx = nav.NavigationContext; // Tries to get a particular section to display. string section; if (navCtx.QueryString.TryGetValue(SectionKey, out section)) { ShowSection(section); } // Refreshes the application bar. RefreshAppBar(); // Nothing more to do if a cartridge exists already. if (Cartridge != null) { return; } // Makes sure the screen lock is disabled. App.Current.ViewModel.IsScreenLockEnabled = false; // Resets the custom status text. App.Current.ViewModel.SystemTrayManager.StatusText = null; // Tries to get the filename to query for. string filename; if (navCtx.QueryString.TryGetValue(CartridgeFilenameKey, out filename)) { string gwsFilename; // Restores the cartridge or starts a new game? if (navCtx.QueryString.TryGetValue(SavegameFilenameKey, out gwsFilename)) { // Starts restoring the game. RunOrDeferIfNotReady( new Action(() => { // Restores the game. Model.Core.InitAndRestoreCartridgeAsync(filename, gwsFilename) .ContinueWith(t => { // Keeps the cartridge. Cartridge = t.Result; // Registers a history entry. CartridgeTag cart = Model.CartridgeStore.GetCartridgeTagOrDefault(Cartridge); Model.History.AddRestoredGame( cart, cart.Savegames.SingleOrDefault(cs => cs.SavegameFile == gwsFilename)); }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); })); } else { // Starts a new game. RunOrDeferIfNotReady( new Action(() => { // Starts the game. Model.Core.InitAndStartCartridgeAsync(filename) .ContinueWith(t => { // Stores the result of the cartridge. Cartridge = t.Result; // Registers a history entry. Model.History.AddStartedGame(Model.CartridgeStore.GetCartridgeTagOrDefault(Cartridge)); }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); })); } } // TODO: Cancel nav if no cartridge in parameter? }
public NavigatedEventMessage(NavigationInfo navigationInfo, IViewModelBase viewModel) : base(navigationInfo) { ViewModel = viewModel; }