public void WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView()
        {
            // Arrange

            var serviceLocatorMock = new Mock<IServiceLocator>();

            var region = new Region();

            var view = new TestView();

            region.Add(view);

            var navigationContext = new NavigationContext(null, new Uri(view.GetType().Name, UriKind.Relative));

            var navigationTargetHandler = new TestRegionNavigationContentLoader(serviceLocatorMock.Object);


            // Act

            var returnedView = navigationTargetHandler.LoadContent(region, navigationContext);


            // Assert

            Assert.AreSame(view, returnedView);
        }
        public void WhenRegionHasMultipleViews_ThenViewsWithMatchingFullTypeNameAreConsidered()
        {
            // Arrange

            var serviceLocatorMock = new Mock<IServiceLocator>();

            var region = new Region();

            var view1 = new TestView();
            var view2 = "view";

            region.Add(view1);
            region.Add(view2);

            var navigationContext = new NavigationContext(null, new Uri(view2.GetType().FullName, UriKind.Relative));

            var navigationTargetHandler = new TestRegionNavigationContentLoader(serviceLocatorMock.Object);

            // Act

            var returnedView = navigationTargetHandler.LoadContent(region, navigationContext);

            // Assert

            Assert.AreSame(view2, returnedView);
        }
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     _player = (from player in _state.Context.Players
         where
             player.Id == (int) navigationContext.Parameters["player"]
         select player).FirstOrDefault();
 }
        public void WhenAskedCanNavigateForDifferentQuery_ThenReturnsFalse()
        {
            var email = new EmailDocument();

            var emailServiceMock = new Mock<IEmailService>();
            emailServiceMock
                .Setup(svc => svc.GetEmailDocument(email.Id))
               .Returns(email)
               .Verifiable();

            var viewModel = new EmailViewModel(emailServiceMock.Object);

            NavigationContext context = new NavigationContext(new Mock<IRegionNavigationService>().Object, new Uri("location", UriKind.Relative));
            context.Parameters.Add("EmailId", email.Id);
            
            ((INavigationAware)viewModel).OnNavigatedTo(context);

            context = new NavigationContext(new Mock<IRegionNavigationService>().Object, new Uri("location", UriKind.Relative));
            context.Parameters.Add("EmailId", new Guid());

            bool canNavigate =
                ((INavigationAware)viewModel).IsNavigationTarget(context);

            Assert.IsFalse(canNavigate);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegionNavigationEventArgs"/> class.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public RegionNavigationFailedEventArgs(NavigationContext navigationContext)
        {
            if (navigationContext == null)
                throw new ArgumentNullException(nameof(navigationContext));

            this.NavigationContext = navigationContext;
        }
 private void RaiseNavigated(NavigationContext navigationContext)
 {
     if (this.Navigated != null)
     {
         this.Navigated(this, new RegionNavigationEventArgs(navigationContext));
     }
 }
        public void WhenNoCurrentMatchingViewExists_ThenReturnsNewlyCreatedInstanceWithServiceLocatorAddedToTheRegion()
        {
            // Arrange

            var serviceLocatorMock = new Mock<IServiceLocator>();

            var region = new Region();

            var view = new TestView();

            serviceLocatorMock
                .Setup(sl => sl.GetInstance<object>(view.GetType().Name))
                .Returns(view);

            var navigationContext = new NavigationContext(null, new Uri(view.GetType().Name, UriKind.Relative));

            var navigationTargetHandler = new TestRegionNavigationContentLoader(serviceLocatorMock.Object);

            // Act

            var returnedView = navigationTargetHandler.LoadContent(region, navigationContext);

            // Assert

            Assert.AreSame(view, returnedView);
            Assert.IsTrue(region.Views.Contains(view));
        }
        /// <summary>
        ///     Called when the implementer has been navigated to.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);

            Invoices.Clear();
            Invoices.AddRange(ConManager.GetAllInvoices());
        }
 public void OnNavigatedFrom(NavigationContext navigationContext)
 {
     IRFIDService rfidService = container.Resolve<IRFIDService>();
     rfidService.stop();
     eventAggregator.GetEvent<RFIDNewItemEvent>().Unsubscribe(handleNewItemFromRFID);
     eventAggregator.GetEvent<RFIDHardwareEvent>().Unsubscribe(handleErrorFromRFID);
     eventAggregator.GetEvent<DatabaseEvent>().Unsubscribe(handleErrorFromDatabase);
 }
        /// <summary>
        ///     Called when the implementer has been navigated to.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);

            {
                Clients.AddRange(ConManager.GetAllClients());
            }
        }
 void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
 {
     if (navigationContext == null)
     {
         throw new ArgumentNullException("navigationContext");
     }
     Name = navigationContext.Parameters["Name"] as string;
 }
Beispiel #12
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            //Start running a script
            string filename = (string)navigationContext.Parameters["filename"];

            _script = new TaiScript(filename,TAIClient.taiClient);
            _script.Start();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegionNavigationEventArgs"/> class.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public RegionNavigationEventArgs(NavigationContext navigationContext)
        {
            if (navigationContext == null)
            {
                throw new ArgumentNullException("navigationContext");
            }

            this.NavigationContext = navigationContext;
        }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            if (PlugInNames.Count != 0)
                return;

            foreach(ModuleInfo mi in _moduleCatalog.Modules)
            {
                if(mi.ModuleName != "PlugInHomeModule" && mi.ModuleName != "StartScreenModule")
                    PlugInNames.Add(mi.ModuleName);
            }
        }
 public bool IsNavigationTarget(NavigationContext navigationContext)
 {
     var toCategoryTitle = ((CategoryVO) navigationContext.Parameters["To"]).Title;
     if (Title == toCategoryTitle)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Beispiel #16
0
        protected override void BeforeNavigation(NavigationContext context)
        {
            int chosenId = (int)context.Parameters["id"];

            test = testsService.Get(chosenId);
            Identity = string.Format("{0}.{1}.{2}.{3}", Importance, Id, ParentId, TopmostParentId);
            Importance = 3;
            Id = test.Id;
            ParentId = test.ScenarioId;
            TopmostParentId = test.Scenario.ProjectId;
            Name = test.Name;
        }
Beispiel #17
0
        protected override void BeforeNavigation(NavigationContext context)
        {
            int chosenId = (int)context.Parameters["id"];

            project = projectsService.Get(chosenId);
            Id = project.Id;
            ParentId = Id;
            TopmostParentId = Id;
            Name = project.Name;
            importance = 1;
            Identity = string.Format("{0}.{1}.{2}.{3}", Importance, Id, ParentId, TopmostParentId);
        }
        /// <summary>
        ///     Called when the implementer has been navigated to.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);

            Users.Clear();
            Users.AddRange(ConManager.GetAllUsers());

            JobTypes.Clear();
            JobTypes.AddRange(ConManager.GetAllJobTypes());

            JobStatuses.Clear();
            JobStatuses.AddRange(ConManager.GetAllJobStatuses());
        }
 bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
 {
     if (navigationContext == null)
     {
         throw new ArgumentNullException("navigationContext");
     }
     var name = navigationContext.Parameters["Name"] as string;
     if (!string.IsNullOrEmpty(name))
     {
         return string.Compare(name, Name, StringComparison.OrdinalIgnoreCase) == 0;
     }
     return false;
 }
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     var selectedInsuree = navigationContext.Parameters["SelectedInsuree"] as ListInsuree;
     if (selectedInsuree != null)
     {
         _logger.Debug($"Getting insuree with id: {selectedInsuree.Id}.");
         Insuree.Value = _insureeManagementAppService.GetExistingInsureeToEdit(selectedInsuree.Id);
     }
     else
     {
         _logger.Debug("Creating a new insuree.");
         Insuree.Value = _insureeManagementAppService.GetNewInsuree();
     }
 }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            //ISerialService serialService = container.Resolve<ISerialService>();
            //IBookInformationService bookInformationService = container.Resolve<IBookInformationService>();
            //IBookLocationService bookLocationService = container.Resolve<IBookLocationService>();
            IRFIDService rfidService = container.Resolve<IRFIDService>();

            //开始读取RFID的信息,并查询数据库
            eventAggregator.GetEvent<RFIDNewItemEvent>().Subscribe(handleNewItemFromRFID);
            //开始订阅RFID服务发出的事件,这个事件是扫描到的条码的信息,在该view非激活时务必取消此事件的订阅
            eventAggregator.GetEvent<RFIDHardwareEvent>().Subscribe(handleErrorFromRFID);
            eventAggregator.GetEvent<DatabaseEvent>().Subscribe(handleErrorFromDatabase);

            rfidService.start();//开启rfid的后台扫描线程
        }
        public void WhenCreatingANewContextForAUriWithNoQuery_ThenNewContextInitializesPropertiesGetsEmptyQuery()
        {
            var uri = new Uri("test", UriKind.Relative);

            var navigationJournalMock = new Mock<IRegionNavigationJournal>();

            var navigationServiceMock = new Mock<IRegionNavigationService>();
            navigationServiceMock.SetupGet(x => x.Journal).Returns(navigationJournalMock.Object);

            var context = new NavigationContext(navigationServiceMock.Object, uri);

            Assert.AreSame(navigationServiceMock.Object, context.NavigationService);
            Assert.AreEqual(uri, context.Uri);
            Assert.AreEqual(0, context.Parameters.Count());
        }
		public override void OnNavigatedTo(NavigationContext navigationContext)
		{
			if (navigationContext.Parameters.Count() > 0)
			{
				if (navigationContext.Parameters.Any(x => x.Key == "guid"))
				{
					try
					{
						var reactionGuid = (Guid)navigationContext.Parameters["guid"];

						var reaction = Monitor.RootFolder.FindReaction(reactionGuid);
						ReactionVM.Value = new ReactionViewModel(reaction, PageManager, _AppPolicyManager);

						PageManager.IsOpenSubContent = true;
					}
					catch
					{
						Console.WriteLine("FolderReactionManagePage: パラメータが不正です。存在するReactionのGuidを指定してください。");
					}
				}

				else if (navigationContext.Parameters.Any(x => x.Key == "filepath"))
				{
					try
					{
						var reactionFilePath = (string)navigationContext.Parameters["filepath"];

						var reaction = Monitor.RootFolder.Reactions
							.SingleOrDefault(x => Monitor.RootFolder.MakeReactionSaveFilePath(x) == reactionFilePath);


						if (reaction == null)
						{
							throw new Exception("use import reaction.");
						}

						ReactionVM.Value = new ReactionViewModel(reaction, PageManager, _AppPolicyManager);
						PageManager.IsOpenSubContent = true;
					}
					catch
					{
						Console.WriteLine("FolderReactionManagePage: パラメータが不正です。存在するReactionのGuidを指定してください。");
					}
				}
			}

		}
Beispiel #24
0
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            // todo: 18 - Navigating an inner region based on context
            // The ContactsView will navigate an inner region based on the
            // value of the 'Show' query parameter.  If the value is 'Avatars'
            // we will navigate to the avatar view otherwise we'll use the details view.

            NavigationParameters parameters = navigationContext.Parameters;
            if (parameters != null && parameters.ContainsKey(ShowParameterName) && string.Equals(parameters[ShowParameterName].ToString(), AvatarsValue))
            {
                regionManager.RequestNavigate(ContactsRegionNames.ContactDetailsRegion, new Uri(ContactAvatarViewName, UriKind.Relative));
            }
            else
            {
                regionManager.RequestNavigate(ContactsRegionNames.ContactDetailsRegion, new Uri(ContactDetailViewName, UriKind.Relative));
            }
        }
        /// <summary>
        /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="navigationContext">The context representing the navigation request.</param>
        /// <returns>
        /// The view to be the target of the navigation request.
        /// </returns>
        /// <remarks>
        /// If none of the views in the region can be the target of the navigation request, a new view
        /// is created and added to the region.
        /// </remarks>
        /// <exception cref="ArgumentException">when a new view cannot be created for the navigation request.</exception>
        public object LoadContent(IRegion region, NavigationContext navigationContext)
        {
            if (region == null)
                throw new ArgumentNullException(nameof(region));

            if (navigationContext == null)
                throw new ArgumentNullException(nameof(navigationContext));

            string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext);

            var candidates = this.GetCandidatesFromRegion(region, candidateTargetContract);

            var acceptingCandidates =
                candidates.Where(
                    v =>
                    {
                        var navigationAware = v as INavigationAware;
                        if (navigationAware != null && !navigationAware.IsNavigationTarget(navigationContext))
                        {
                            return false;
                        }

                        var frameworkElement = v as FrameworkElement;
                        if (frameworkElement == null)
                        {
                            return true;
                        }

                        navigationAware = frameworkElement.DataContext as INavigationAware;
                        return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext);
                    });


            var view = acceptingCandidates.FirstOrDefault();

            if (view != null)
            {
                return view;
            }

            view = this.CreateNewRegionItem(candidateTargetContract);

            region.Add(view);

            return view;
        }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            _journal = navigationContext.NavigationService.Journal;
               
            CategoryVO category = navigationContext.Parameters["To"] as CategoryVO;

            if (category != null)
            {
                Title = category.Title;
                Description = category.Description;
            }
            else
            {
                Title = "No Category info provided";
            }

        }
        public void WhenCreatingANewContextForAUriWithAQuery_ThenNewContextInitializesPropertiesAndExtractsTheQuery()
        {
            var uri = new Uri("test?name=value", UriKind.Relative);

            var navigationJournalMock = new Mock<IRegionNavigationJournal>();
            var navigationServiceMock = new Mock<IRegionNavigationService>();

            IRegion region = new Region();
            navigationServiceMock.SetupGet(n => n.Region).Returns(region);
            navigationServiceMock.SetupGet(x => x.Journal).Returns(navigationJournalMock.Object);

            var context = new NavigationContext(navigationServiceMock.Object, uri);

            Assert.AreSame(navigationServiceMock.Object, context.NavigationService);
            Assert.AreEqual(uri, context.Uri);
            Assert.AreEqual(1, context.Parameters.Count());
            Assert.AreEqual("value", context.Parameters["name"]);
        }
		public override void OnNavigatedTo(NavigationContext navigationContext)
		{
			if (Model == null)
			{
				Model = new InstantActionModel(AppPolicyManger);
				Model.OutputFolderPath = InstantActionManager.TempSaveFolder;
			}


			if (navigationContext.Parameters.Any(x => x.Key == "targetfiles"))
			{
				try
				{
					var paths = (string[])navigationContext.Parameters["targetfiles"];
					foreach (var path in paths)
					{
						Model.AddTargetFile(path);
					}
				}
				catch
				{
					
				}

			}

			else if (navigationContext.Parameters.Any(x => x.Key == "filepath"))
			{
				try
				{
					var filepath = (string)navigationContext.Parameters["filepath"];

					Model = InstantActionManager.Load(filepath);
				}
				catch
				{

				}
			}


			// ファイル選択画面からスタート
			ShowFileSelectStep();
		}
		public override void OnNavigatedTo(NavigationContext navigationContext)
		{


			if (navigationContext.Parameters.Count() > 0)
			{
				if (navigationContext.Parameters.Any(x => x.Key == "guid"))
				{
					try
					{
//						var reactionGuid = (Guid)navigationContext.Parameters["guid"];

//						SelectReaction(Monitor.RootFolder.FindReaction(reactionGuid));
					}
					catch
					{
						Console.WriteLine("FolderReactionManagePage: パラメータが不正です。存在するReactionのGuidを指定してください。");
					}
				}

				else if (navigationContext.Parameters.Any(x => x.Key == "filepath"))
				{
					try
					{
						var reactionFilePath = (string)navigationContext.Parameters["filepath"];

						var reaction = Monitor.RootFolder.Reactions
							.SingleOrDefault(x => Monitor.RootFolder.MakeReactionSaveFilePath(x) == reactionFilePath);


						if (reaction == null)
						{
							throw new Exception("use import reaction.");
						}

//						SelectReaction(reaction);
					}
					catch
					{
						Console.WriteLine("FolderReactionManagePage: パラメータが不正です。存在するReactionのGuidを指定してください。");
					}
				}}
			
		}
		public override void OnNavigatedTo(NavigationContext navigationContext)
		{
			if (navigationContext.Parameters.Count() > 0)
			{
				if (navigationContext.Parameters.Any(x => x.Key == "guid"))
				{
					try
					{
						var appPolicyGuid = (Guid)navigationContext.Parameters["guid"];

						SelectAppPolicy(AppPolicyManager.FromAppGuid(appPolicyGuid));
					}
					catch
					{
						Console.WriteLine("FolderReactionManagePage: パラメータが不正です。存在するReactionのGuidを指定してください。");
					}
				}
			}
		}
Beispiel #31
0
 private void RaiseNavigated(NavigationContext navigationContext)
 {
     Navigated?.Invoke(this, new RegionNavigationEventArgs(navigationContext));
 }
Beispiel #32
0
 private static void NotifyActiveViewsNavigatingFrom(NavigationContext navigationContext, object[] activeViews)
 {
     InvokeOnNavigationAwareElements(activeViews, (n) => n.OnNavigatedFrom(navigationContext));
 }
Beispiel #33
0
 private void RaiseNavigationFailed(NavigationContext navigationContext, Exception error)
 {
     NavigationFailed?.Invoke(this, new RegionNavigationFailedEventArgs(navigationContext, error));
 }