コード例 #1
0
        public CourseListViewModel(IEventAggregator eventAggregator, INavigate navigator )
        {
            this.eventAggregator = eventAggregator;
            this.navigator = navigator;

            eventAggregator.GetEvent<CourseDetailsReadyEvent>().Subscribe(NavigateToCoursePage, ThreadOption.UIThread);
        }
コード例 #2
0
        public void NavigateToPage(INavigateMoveDirection moveDirection)
        {
            // if we're navigating to this flipview page,
            // we need to know which direction we're coming from
            // so that we know which page in the flipview to show
            switch (moveDirection)
            {
            case INavigateMoveDirection.Backward:
                // moving backwards to get here, so set to the last page in the flipview
                this.DeviceModeFlipView.SelectedIndex = 2;
                break;

            case INavigateMoveDirection.Forward:
                // moving forwards, so set to first
                this.DeviceModeFlipView.SelectedIndex = 0;
                break;

            case INavigateMoveDirection.Unknown:
            default:
                // don't do anything for Unknown
                break;
            }

            // animations in
            // propagate navigation to child flipview pages on first navigate from outer FV page
            INavigate navigatePage = (INavigate)((FlipViewItemEx)this.DeviceModeFlipView.SelectedItem).GetChildViewAsObject();

            navigatePage.NavigateToPage(moveDirection);
        }
コード例 #3
0
 public PhoneWithAllFunctions(IPhone phone)
 {
     _phone    = phone;
     _camera   = new Camera(phone);
     _internet = new Internet(phone);
     _navigate = new NavigatePhone(phone);
 }
コード例 #4
0
        public void NavigateFromPage()
        {
            // animations out
            INavigate navigatePage = (INavigate)((FlipViewItemEx)this.DeviceModeFlipView.SelectedItem).GetChildViewAsObject();

            navigatePage.NavigateFromPage();
        }
コード例 #5
0
 public AskQuestionViewModel(ISearch search, IQuestion question, INavigate navigate)
     : this()
 {
     _search   = search;
     _question = question;
     _navigate = navigate;
 }
コード例 #6
0
 public GettingStartedViewModel(IEventAggregator eventAggregator, INavigate navigator )
 {
     this.eventAggregator = eventAggregator;
     this.navigator = navigator;
     
     ReturnToLoginScreenCommand = new DelegateCommand<object>(ReturnToLoginScreen, CanReturnToLoginScreen);
 }
コード例 #7
0
        public SearchViewModel(ISearch search, IQuestion question, INavigate navigate) : this()
        {
            _search   = search;
            _question = question;
            _navigate = navigate;

            InviteAnswerTapped = new RelayCommand <Author>(InviteAnswerTappedMethod);
        }
コード例 #8
0
        public LessonContentViewModel(IEventAggregator eventAggregator, INavigate navigator)
        {
            this.eventAggregator = eventAggregator;
            this.navigator = navigator;

            eventAggregator.GetEvent<ExitLessonEvent>().Subscribe(
                GoToLessonListing, ThreadOption.UIThread);
        }
コード例 #9
0
        public CollectionViewModel(ICollection collection, INavigate naviagation) : this()
        {
            this._collection = collection;
            this._navigation = naviagation;

            GetDetailCommand    = new RelayCommand(GetCollectionDetailMethod);
            GetFollowingCommand = new RelayCommand(GetFollowingMethod);
            FollowUnFollow      = new RelayCommand(FollowUnFollowMethod);
        }
コード例 #10
0
        public void NavigateDown()
        {
            INavigate atb = fm.CurrentControl as INavigate;

            if (atb != null && ((Control)atb).Focused)
            {
                atb.NavigateDown();
            }
        }
コード例 #11
0
        private void FlipViewEx_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // stop the page timer
            if (null != _pageMoveTimer)
            {
                _pageMoveTimer.Stop();
            }

            // if we have a bottom nav bar
            if (null != this.BottomNavBar)
            {
                // get the sender
                if (sender is FlipViewEx flipView)
                {
                    // navigate from the previous page
                    if (null != _previousPage)
                    {
                        _previousPage.NavigateFromPage();
                    }

                    // navigate to the new page
                    if (null != flipView.SelectedItem)
                    {
                        INavigateMoveDirection moveDirection = INavigateMoveDirection.Unknown;

                        // get the pageIndex of the new page
                        int nextPageIndex = flipView.SelectedIndex;

                        // find the index of the previous page
                        int previousPageIndex = flipView.GetIndexOfChildView(_previousPage);

                        // if we got it
                        if (-1 != previousPageIndex)
                        {
                            // are we moving forward or backward to get to the new page?
                            if (previousPageIndex < nextPageIndex)
                            {
                                moveDirection = INavigateMoveDirection.Forward;
                            }
                            else if (nextPageIndex < previousPageIndex)
                            {
                                moveDirection = INavigateMoveDirection.Backward;
                            }
                        }

                        // save the current page so we can navigate away from it later
                        _previousPage = (INavigate)((FlipViewItemEx)flipView.SelectedItem).GetChildViewAsObject();

                        // navigate to it
                        _previousPage.NavigateToPage(moveDirection);

                        // tell the navbar to move to it
                        this.BottomNavBar.MoveToPageIndex(nextPageIndex, (INavigateMoveDirection.Forward == moveDirection));
                    }
                }
            }
        }
コード例 #12
0
        protected NavigatingMenuCommand(INavigate navigator)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException("navigator", "navigator is null.");
            }

            _navigator = navigator;
        }
コード例 #13
0
        public MessageViewModel(IPerson person, IMessage message, INavigate navigate) : this()
        {
            this._person   = person;
            this._message  = message;
            this._navigate = navigate;

            GetReceiver = new RelayCommand(GetReceiverMethod);
            SendMessage = new RelayCommand(SendMessageMethod);
        }
コード例 #14
0
        public ModuleContentViewModel(IEventAggregator eventAggregator, INavigate navigator)
        {
            this.eventAggregator = eventAggregator;
            this.navigator = navigator;

            eventAggregator.GetEvent<LessonSelectedEvent>().Subscribe(
                NavigateToLesson, ThreadOption.UIThread);
            GoBackCommand = new DelegateCommand<object>(GoBack, CanGoBack);
        }
コード例 #15
0
        public AmazingGuyViewModel(IPerson service, INavigate navigation) : this()
        {
            this._service  = service;
            this._navigate = navigation;

            NextCommand = new RelayCommand(NextMethod);

            GetAmazingGuys = new RelayCommand(GetAmazingGuysMethod);
            FollowUnfollow = new RelayCommand <AmazingGuy>(FollowUnfollowMethod);
        }
コード例 #16
0
ファイル: ViewModelBase.cs プロジェクト: Hengyin-Group/IntoPC
        /// <summary>
        /// 当前页的主窗体Frame跳页
        /// </summary>
        /// <param name="obj"></param>
        public void Navigate(Object[] obj)
        {
            Window win   = Window.GetWindow((obj[0] as Page));
            Frame  frame = win.FindName("Frame") as Frame;
            string str   = (obj[1] as Button).Tag.ToString();

            //MessageBox.Show(str);
            _navigationService = ServiceLocator.Current.GetInstance <INavigate>();
            _navigationService.FrameNavigateTo(str, frame);
        }
コード例 #17
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="sender">The <see cref="System.Object"/> that is passed to the action by the behavior. Generally this is <seealso cref="Microsoft.Xaml.Interactivity.IBehavior.AssociatedObject"/> or a target object.</param>
        /// <param name="parameter">The value of this parameter is determined by the caller.</param>
        /// <returns>True if the navigation to the specified page is successful; else false.</returns>
        public object Execute(object sender, object parameter)
        {
            if (string.IsNullOrEmpty(this.TargetPage))
            {
                return(false);
            }

            IXamlMetadataProvider metadataProvider = Application.Current as IXamlMetadataProvider;

            if (metadataProvider == null)
            {
                // This will happen if there are no XAML files in the project other than App.xaml.
                // The markup compiler doesn't bother implementing IXamlMetadataProvider on the app
                // in that case.
                return(false);
            }

            IXamlType xamlType = metadataProvider.GetXamlType(this.TargetPage);

            if (xamlType == null)
            {
                return(false);
            }

            INavigate        navigateElement = Window.Current.Content as INavigate;
            DependencyObject senderObject    = sender as DependencyObject;

            // If the sender wasn't an INavigate, then keep looking up the tree from the
            // root we were given for another INavigate.
            while (senderObject != null && navigateElement == null)
            {
                navigateElement = senderObject as INavigate;
                if (navigateElement == null)
                {
                    senderObject = this._visualTreeHelper.GetParent(senderObject);
                }
            }

            if (navigateElement == null)
            {
                return(false);
            }

            Frame frame = navigateElement as Frame;

            if (frame != null)
            {
                return(frame.Navigate(xamlType.UnderlyingType, this.Parameter ?? parameter));
            }
            else
            {
                return(navigateElement.Navigate(xamlType.UnderlyingType));
            }
        }
コード例 #18
0
        private void FlipViewEx_Loaded(object sender, RoutedEventArgs e)
        {
            // set the current page
            this.ContentFlipView.SelectedIndex = 0;

            // save the current page so we can navigate from it
            _previousPage = (INavigate)((FlipViewItemEx)this.ContentFlipView.SelectedItem).GetChildViewAsObject();

            // navigate to it
            _previousPage.NavigateToPage(INavigateMoveDirection.Forward);
        }
コード例 #19
0
        public HomeViewModel(IEventAggregator eventAggregator, INavigate navigator)
        {
            this.eventAggregator = eventAggregator;
            this.navigator = navigator;

            eventAggregator.GetEvent<LoginStatusChangedEvent>().Subscribe(
                NavigateToCourseListing,
                ThreadOption.UIThread,
                false,
                IsLoginSuccessful); // Needs real method, Lambda has access issues (aka exception)
        }
コード例 #20
0
        public TopicViewModel(ITopic topic, INavigate naviagation)
            : this()
        {
            this._topic      = topic;
            this._navigation = naviagation;

            GetDetail      = new RelayCommand(GetDetailMethod);
            GetFollowing   = new RelayCommand(GetFollowingMethod);
            FollowUnFollow = new RelayCommand(FollowUnFollowMethod);

            NavToAnswerCommand = new RelayCommand <Answer>(NavToAnswerMethod);
        }
コード例 #21
0
        public SampleViewModel(INavigate <Regions.TabRegion> router, ISampleController controller)
        {
            if (router == null)
            {
                throw new ArgumentNullException("router", "router is null.");
            }
            if (controller == null)
            {
                throw new ArgumentNullException("controller", "controller is null.");
            }

            _router     = router;
            _controller = controller;
        }
コード例 #22
0
        public TabViewModel(INavigate router, ReactiveViewModel childViewModel)
        {
            if (router == null)
            {
                throw new ArgumentNullException("router", "router is null.");
            }
            if (childViewModel == null)
            {
                throw new ArgumentNullException("childViewModel", "childViewModel is null.");
            }

            _router         = router;
            _childViewModel = childViewModel;

            Close = ReactiveCommand.CreateFromTask(_ => Router.RequestClose(ChildViewModel, NavigationParameters.UserNavigation));
        }
コード例 #23
0
        public void RemoveChild(IHierarchicalViewModel child)
        {
            //check interfaces for events to remove handlers for.
            if (child is INavigate)
            {
                INavigate ele = child as INavigate;
                ele.NavigationEvent -= Navigate;
            }
            //if (child is ICanClose)
            //{
            //    ICanClose ele = child as ICanClose;
            //    ele.Close -= RequestClose;
            //}
            _Children.Remove(child);//what if child doesnt exist?

            NotifyPropertyChanged(nameof(Children));
        }
コード例 #24
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="sender">The <see cref="System.Object"/> that is passed to the action by the behavior. Generally this is <seealso cref="Microsoft.Xaml.Interactivity.IBehavior.AssociatedObject"/> or a target object.</param>
        /// <param name="parameter">The value of this parameter is determined by the caller.</param>
        /// <returns>True if the navigation to the specified page is successful; else false.</returns>
        public object Execute(object sender, object parameter)
        {
            if (string.IsNullOrEmpty(this.TargetPage))
            {
                return(false);
            }

            IXamlMetadataProvider metadataProvider = (IXamlMetadataProvider)Application.Current;
            IXamlType             xamlType         = metadataProvider.GetXamlType(this.TargetPage);

            if (xamlType == null)
            {
                return(false);
            }

            INavigate        navigateElement = Window.Current.Content as INavigate;
            DependencyObject senderObject    = sender as DependencyObject;

            // If the sender wasn't an INavigate, then keep looking up the tree from the
            // root we were given for another INavigate.
            while (senderObject != null && navigateElement == null)
            {
                navigateElement = sender as INavigate;
                if (navigateElement == null)
                {
                    senderObject = VisualTreeHelper.GetParent(senderObject);
                }
            }

            if (navigateElement == null)
            {
                return(false);
            }

            Frame frame = navigateElement as Frame;

            if (frame != null)
            {
                return(frame.Navigate(xamlType.UnderlyingType, this.Parameter ?? parameter));
            }
            else
            {
                return(navigateElement.Navigate(xamlType.UnderlyingType));
            }
        }
コード例 #25
0
        public FeedsViewModel(IFeed feed, IPerson people, INavigate navigate) : this()
        {
            _feed     = feed;
            _people   = people;
            _navigate = navigate;

            Refresh  = new RelayCommand(RefreshMethod);
            TurnDark = new RelayCommand(TurnDarkMethod);

            Load = new RelayCommand(LoadMethod);

            NavToNotificationCommand = new RelayCommand(NavToNotificationMethod);
            NavToExploreCommand      = new RelayCommand(NavigateToExploreMethod);
            NavToSearchCommand       = new RelayCommand(NavToSearchMethod);
            NavToPopularCommand      = new RelayCommand(NavToPopularPopularMethod);
            NavToMakeQuesCommand     = new RelayCommand(NavToMakeQuesMethod);
            NavToOfflineCommand      = new RelayCommand(NavToOfflineMethod);
        }
コード例 #26
0
        private async void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            if ((passwordBox.Password == "") || (usernameBox.Text == ""))
            {
                MessageDialog message = new MessageDialog("Please Enter an username and a password!", "Attention!");
                await message.ShowAsync();
            }

            logicsData.LoginUser(usernameBox.Text, passwordBox.Password);
            if (logicsData.IsLoggedIn())
            {
                INavigate rootFrame = Window.Current.Content as INavigate;
                rootFrame.Navigate(typeof(MenuAdmin));
            }
            else
            {
                await new MessageDialog("This user does not exist").ShowAsync();
            }
        }
コード例 #27
0
        private void FlipViewEx_Loaded(object sender, RoutedEventArgs e)
        {
            // set the current page
            //this.ContentFlipView.SelectedIndex = 0;   // not necessary and will interfere with page timer

            // save the current page so we can navigate from it
            _previousPage = (INavigate)((FlipViewItemEx)this.ContentFlipView.SelectedItem).GetChildViewAsObject();

            // navigate to it
            _previousPage.NavigateToPage(INavigateMoveDirection.Forward);

            // configure our page move timer
            _pageMoveTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(PAGE_TIMER_DURATION)
            };
            _pageMoveTimer.Tick += PageMoveTimer_Tick;
            _pageMoveTimer.Start();
        }
コード例 #28
0
        private INavigate GetCurrentlySelectedChildPage()
        {
            INavigate currentPage = null;

            // if we have a flipview
            if (null != this.ContentFlipView)
            {
                // get the selected it
                FlipViewItem flipViewItem = (FlipViewItem)this.ContentFlipView.SelectedItem;

                // is its content a frame?
                if (flipViewItem.Content is Frame frame)
                {
                    // get the content as our interface
                    currentPage = (INavigate)frame.Content;
                }
            }

            return(currentPage);
        }
コード例 #29
0
        public void AddChild(IHierarchicalViewModel child, bool allowDuplicateNames = false)
        {
            if (_Children == null)
            {
                _Children = new ObservableCollection <IHierarchicalViewModel>();
            }
            if (!allowDuplicateNames)
            {
                if (CheckForNameConflict(child))
                {
                    //silently fix the name?
                    int    i        = 1;
                    string prevname = child.Name;
                    do
                    {
                        child.Name = prevname + "_" + i;
                        i++;
                    } while (CheckForNameConflict(child));
                }
            }
            //check interfaces for events to add handlers for.
            if (child is INavigate)
            {
                INavigate ele = child as INavigate;
                ele.NavigationEvent += Navigate;
            }
            if (child is Base.Interfaces.IReportMessage)
            {
                Base.Interfaces.IReportMessage ele = child as Base.Interfaces.IReportMessage;
                Base.Implementations.MessageHub.Register(ele);
            }
            //if (child.GetType().GetInterfaces().Contains(typeof(ICanClose)))
            //{
            //    ICanClose ele = child as ICanClose;
            //    ele.Close += RequestClose;
            //}

            _Children.Add(child);
            child.Parent = this;
            NotifyPropertyChanged(nameof(Children));
        }
コード例 #30
0
ファイル: HyperlinkButton.cs プロジェクト: ynkbt/moon
        bool FindNavigatorInSubtree(UIElement e, UIElement skip, out INavigate navigator)
        {
            // The docs say that HyperLinkButton searches the visual tree so that's what I implemented
            // Maybe it actually uses FindName.
            navigator = e as INavigate;
            if (navigator != null)
            {
                if (!string.IsNullOrEmpty(TargetName))
                {
                    // if we have a target name make sure it matches
                    if (navigator is FrameworkElement && ((FrameworkElement)navigator).Name == TargetName)
                    {
                        return(true);
                    }
                }
                else
                {
                    // if we don't have a target name, take what we can get
                    return(true);
                }
            }

            // Popups are treated specially as they don't have a regular visual child.
            // Needed to pass DRT HyperlinkButtonP2.
            int count = e is Popup ? 1 : VisualTreeHelper.GetChildrenCount(e);

            for (int i = 0; i < count; i++)
            {
                UIElement ui = e is Popup ? ((Popup)e).Child : (UIElement)VisualTreeHelper.GetChild(e, i);
                if (ui == skip)
                {
                    continue;
                }
                if (FindNavigatorInSubtree(ui, null, out navigator))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #31
0
ファイル: HyperlinkButton.cs プロジェクト: kangaroo/moon
        bool FindNavigatorInSubtree (UIElement e, UIElement skip, out INavigate navigator)
        {
            // The docs say that HyperLinkButton searches the visual tree so that's what I implemented
            // Maybe it actually uses FindName.
            navigator = e as INavigate;
            if (navigator != null) {
		    if (TargetName != null) {
			    // if we have a target name make sure it matches
			    if (navigator is FrameworkElement && ((FrameworkElement)navigator).Name == TargetName)
				    return true;
		    }
		    else {
			    // if we don't have a target name, take what we can get
			    return true;
		    }
	    }

            int count = VisualTreeHelper.GetChildrenCount (e);
            for (int i = 0; i < count; i++) {
		    UIElement ui = (UIElement) VisualTreeHelper.GetChild (e, i);
		    if (ui == skip)
			    continue;
		    if (FindNavigatorInSubtree ((UIElement) VisualTreeHelper.GetChild (e, i), null, out navigator))
			    return true;
	    }
            return false;
        }
コード例 #32
0
        private void ContentFlipView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (null != this.ContentFlipView)
            {
                // navigate from the previous page
                if (null != _previousPage)
                {
                    _previousPage.NavigateFromPage();
                }

                // save the current page so we can navigate away from it later
                _previousPage = GetCurrentlySelectedChildPage();

                // navigate to it
                if (null != _previousPage)
                {
                    _previousPage.NavigateToPage();
                }

                // based on the current page, set the scheme to light or dark
                switch (this.ContentFlipView.SelectedIndex)
                {
                case 0:         // audio page
                    this.ColorScheme = ColorSchemes.Light;

                    if ((null != this.LeftChevronLight) && (null != LeftChevronDark) && (null != RightChevronLight) && (null != RightChevronDark))
                    {
                        // hide the left arrow
                        this.LeftChevronLight.Visibility = Visibility.Collapsed;
                        this.LeftChevronDark.Visibility  = Visibility.Collapsed;

                        // show the right arrow dark
                        this.RightChevronLight.Visibility = Visibility.Collapsed;
                        this.RightChevronDark.Visibility  = Visibility.Visible;
                    }
                    break;

                case 1:         // features page
                    this.ColorScheme = ColorSchemes.Dark;

                    // show the left arrow light
                    if ((null != this.LeftChevronLight) && (null != LeftChevronDark) && (null != RightChevronLight) && (null != RightChevronDark))
                    {
                        this.LeftChevronLight.Visibility = Visibility.Visible;
                        this.LeftChevronDark.Visibility  = Visibility.Collapsed;

                        // show the right arrow dark
                        this.RightChevronLight.Visibility = Visibility.Collapsed;
                        this.RightChevronDark.Visibility  = Visibility.Visible;
                    }
                    break;

                case 2:         // speeds and feeds page
                    this.ColorScheme = ColorSchemes.Light;

                    if ((null != this.LeftChevronLight) && (null != LeftChevronDark) && (null != RightChevronLight) && (null != RightChevronDark))
                    {
                        // show the left arrow dark
                        this.LeftChevronLight.Visibility = Visibility.Collapsed;
                        this.LeftChevronDark.Visibility  = Visibility.Visible;

                        // hide the right arrow
                        this.RightChevronLight.Visibility = Visibility.Collapsed;
                        this.RightChevronDark.Visibility  = Visibility.Collapsed;
                    }
                    break;
                }

                // update play button
                // - play button has no color changes any longer

                // update navigation buttons
                if (null != this.NavigationBarExploreWindows)
                {
                    this.NavigationBarExploreWindows.ColorScheme = this.ColorScheme;
                }
                if (null != this.NavigationBarGoToDesktop)
                {
                    this.NavigationBarGoToDesktop.ColorScheme = this.ColorScheme;
                }
            }
        }
コード例 #33
0
 public NotifyViewModel(INotify notify, IMessage message, INavigate navigate) : this()
 {
     this._notify   = notify;
     this._message  = message;
     this._navigate = navigate;
 }
コード例 #34
0
        private void FlipViewEx_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // if the count of e.AddedItems == 1, then the SelectedIndex has actually
            // changed. if it's equal to 3 (the number of panels loaded in a VirtualizingStackPanel),
            // then this isn't a real change in the SelectedIndex, and we'll ignore it.
            if (3 != e.AddedItems.Count)
            {
                // stop the page timer
                if (null != _pageMoveTimer)
                {
                    _pageMoveTimer.Stop();
                }
            }

            // if we have a bottom nav bar
            if (null != this.BottomNavBar)
            {
                // get the sender
                if (sender is FlipViewEx flipView)
                {
                    // navigate from the previous page
                    if (null != _previousPage)
                    {
                        _previousPage.NavigateFromPage();
                    }

                    // navigate to the new page
                    if (null != flipView.SelectedItem)
                    {
                        INavigateMoveDirection moveDirection = INavigateMoveDirection.Unknown;

                        // get the pageIndex of the new page
                        int nextPageIndex = flipView.SelectedIndex;

                        // find the index of the previous page
                        int previousPageIndex = flipView.GetIndexOfChildView(_previousPage);

                        // if we got it
                        if (-1 != previousPageIndex)
                        {
                            // are we moving forward or backward to get to the new page?
                            if (previousPageIndex < nextPageIndex)
                            {
                                moveDirection = INavigateMoveDirection.Forward;
                            }
                            else if (nextPageIndex < previousPageIndex)
                            {
                                moveDirection = INavigateMoveDirection.Backward;
                            }
                        }

                        // save the current page so we can navigate away from it later
                        _previousPage = (INavigate)((FlipViewItemEx)flipView.SelectedItem).GetChildViewAsObject();

                        // navigate to it
                        _previousPage.NavigateToPage(moveDirection);

                        // tell the navbar to move to it
                        this.BottomNavBar.MoveToPageIndex(nextPageIndex, (INavigateMoveDirection.Forward == moveDirection));

                        // telemetry - log section views
                        if (nextPageIndex < PAGE_ACCESSORIES)
                        {
                            TelemetryService.Current?.LogTelemetryEvent(TelemetryEvents.ViewExperience);
                        }
                        else if (nextPageIndex < PAGE_BESTOF)
                        {
                            TelemetryService.Current?.LogTelemetryEvent(TelemetryEvents.ViewAccessories);
                        }
                        else if (nextPageIndex < PAGE_COMPARE)
                        {
                            TelemetryService.Current?.LogTelemetryEvent(TelemetryEvents.ViewBestOf);
                        }
                        else
                        {
                            TelemetryService.Current?.LogTelemetryEvent(TelemetryEvents.ViewComparison);
                        }
                    }
                }
            }
        }
コード例 #35
0
 public AccountViewModel(IAccountService service, INavigate navigator)
 {
     this.service = service;
     this.LogOnCommand = new DelegateCommand(LogOn);
     this.navigator = navigator;
 }
コード例 #36
0
        private void DeviceModeFlipView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((null != this.DeviceModeFlipView) && (null != this.DeviceModeSlider))
            {
                // navigate from the previous page
                if (null != _previousPage)
                {
                    _previousPage.NavigateFromPage();
                }

                // navigate to the current page
                if (null != this.DeviceModeFlipView.SelectedItem)
                {
                    INavigateMoveDirection moveDirection = INavigateMoveDirection.Unknown;

                    // get the pageIndex of the new page
                    int nextPageIndex = this.DeviceModeFlipView.SelectedIndex;


                    // find the index of the previous page
                    int previousPageIndex = this.DeviceModeFlipView.Items.IndexOf(_previousPage);

                    // if we got it
                    if (-1 != previousPageIndex)
                    {
                        // are we moving forward or backward?
                        if (previousPageIndex < nextPageIndex)
                        {
                            moveDirection = INavigateMoveDirection.Forward;
                        }
                        else if (nextPageIndex < previousPageIndex)
                        {
                            moveDirection = INavigateMoveDirection.Backward;
                        }
                    }

                    // save the current page so we can navigate from it
                    _previousPage = (INavigate)((FlipViewItemEx)this.DeviceModeFlipView.SelectedItem).GetChildViewAsObject();

                    // navigate to it
                    _previousPage.NavigateToPage(moveDirection);

                    // telemetry
                    TelemetryService.Current?.LogTelemetryEvent(TelemetryEvents.ViewExperience);
                }

                // update slider
                switch (this.DeviceModeFlipView.SelectedIndex)
                {
                case 0:
                    // to avoid infinite event loops, only update if it's not already set to the new value
                    if (DeviceModeSliderSnapPositions.Studio != this.DeviceModeSlider.Position)
                    {
                        this.DeviceModeSlider.SnapTo(DeviceModeSliderSnapPositions.Studio);
                    }
                    break;

                case 1:
                    // to avoid infinite event loops, only update if it's not already set to the new value
                    if (DeviceModeSliderSnapPositions.Laptop != this.DeviceModeSlider.Position)
                    {
                        this.DeviceModeSlider.SnapTo(DeviceModeSliderSnapPositions.Laptop);
                    }
                    break;

                case 2:
                    // to avoid infinite event loops, only update if it's not already set to the new value
                    if (DeviceModeSliderSnapPositions.Tablet != this.DeviceModeSlider.Position)
                    {
                        this.DeviceModeSlider.SnapTo(DeviceModeSliderSnapPositions.Tablet);
                    }
                    break;
                }

                this.RaiseSelectionChangedEvent(this);
            }
        }
コード例 #37
0
 public Navigate(INavigate navigate)
 {
     _navigate = navigate;
 }
コード例 #38
0
 public MenuGameViewModel(IGameService gameService, INavigate navigator)
 {
     this.gameService = gameService;
     this.navigator = navigator;
 }
コード例 #39
0
ファイル: HyperlinkButton.cs プロジェクト: dfr0/moon
        bool FindNavigatorInSubtree (UIElement e, UIElement skip, out INavigate navigator)
        {
            // The docs say that HyperLinkButton searches the visual tree so that's what I implemented
            // Maybe it actually uses FindName.
            navigator = e as INavigate;
            if (navigator != null) {
		    if (!string.IsNullOrEmpty (TargetName)) {
			    // if we have a target name make sure it matches
			    if (navigator is FrameworkElement && ((FrameworkElement)navigator).Name == TargetName)
				    return true;
		    }
		    else {
			    // if we don't have a target name, take what we can get
			    return true;
		    }
	    }

			// Popups are treated specially as they don't have a regular visual child.
			// Needed to pass DRT HyperlinkButtonP2.
            int count = e is Popup ? 1 : VisualTreeHelper.GetChildrenCount (e);
            for (int i = 0; i < count; i++) {
		    UIElement ui = e is Popup ? ((Popup)e).Child : (UIElement) VisualTreeHelper.GetChild (e, i);
		    if (ui == skip)
			    continue;
		    if (FindNavigatorInSubtree (ui, null, out navigator))
			    return true;
	    }
            return false;
        }