Ejemplo n.º 1
0
        private async Task NavigateToPageAsync(PageTokens pageToken)
        {
            if (CanNavigateToPage(pageToken))
            {
                if (pageToken == PageTokens.Login)
                {
                    var result = await _dialogService.ShowConfirmation("Are you sure you want to log out?");

                    if (result != ContentDialogResult.Primary)
                    {
                        return;
                    }
                    //Perform logout
                    await _userManagerService.LogOutAsync();

                    await _hubService.DisconnectFromHub();
                }

                if (_navigationService.Navigate(pageToken.ToString(), null))
                {
                    UpdateCanNavigateLookup(pageToken);
                    RaiseCanExecuteChanged();
                }
            }
        }
Ejemplo n.º 2
0
 private void NavigateToPage(PageTokens pageToken)
 {
     if (CanNavigateToPage(pageToken))
     {
         _navigationService.Navigate(pageToken.ToString(), null);
     }
 }
Ejemplo n.º 3
0
 private void NavigateToPage(PageTokens pageToken)
 {
     if (CanNavigateToPage(pageToken))
     {
         _navigationService.Navigate(pageToken.ToString(), null);
     }
 }
Ejemplo n.º 4
0
        public async Task <GetStreamsResponse> Execute(GetStreamsQuery query)
        {
            var streamFilters = new StreamFilterOptions {
                GameName = query.Filters.GameName
            };

            var unpackedTokens = PageTokens.UnpackTokens(query.PageToken);

            var supportedPlatforms = streamPlatformService.GetSupportingPlatforms(streamFilters);

            var platformStreams = await streamPlatformService.GetStreams(supportedPlatforms, streamFilters, query.PageSize, unpackedTokens);

            var packedTokens = PageTokens
                               .FromList(platformStreams.Select(p => new PageToken(p.StreamPlatformName, p.NextPageToken)))
                               .PackTokens();

            var aggregatedStreams = platformStreams.SelectMany(p => p.Streams.Select(s => new Stream
            {
                StreamTitle        = s.StreamTitle,
                StreamerName       = s.StreamerName,
                StreamUrl          = s.StreamUrl,
                IsLive             = s.IsLive,
                Views              = s.Views,
                PlatformName       = p.StreamPlatformName,
                StreamThumbnailUrl = s.StreamThumbnailUrl,
                StreamerAvatarUrl  = s.StreamerAvatarUrl,
            }));

            return(new GetStreamsResponse
            {
                Streams = aggregatedStreams.OrderByDescending(s => s.Views),
                NextPageToken = packedTokens
            });
        }
Ejemplo n.º 5
0
        public MenuViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
        {
            _navigationService = navigationService;

            Commands = new ObservableCollection<MenuItemViewModel>
            {
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DTSBehaviorSampleMenuItemDisplayName"), FontIcon = "\ue15f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSBehaviorSample), () => CanNavigateToSamplePage(PageTokens.DTSBehaviorSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DTSSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSSample), () => CanNavigateToSamplePage(PageTokens.DTSSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("IncrementalLoadingMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.IncrementalLoadingSample), () => CanNavigateToSamplePage(PageTokens.IncrementalLoadingSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DeferLoadStrategyMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeferLoadStrategySample), () => CanNavigateToSamplePage(PageTokens.DeferLoadStrategySample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("CustomLVIPMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CustomLVIPSample), () => CanNavigateToSamplePage(PageTokens.CustomLVIPSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("StateTriggerMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.StateTriggerSample), () => CanNavigateToSamplePage(PageTokens.StateTriggerSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("CVSMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CollectionViewSourceSample), () => CanNavigateToSamplePage(PageTokens.CollectionViewSourceSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DeviceSpecificMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeviceSpecificSample), () => CanNavigateToSamplePage(PageTokens.DeviceSpecificSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("ExpanderSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.ExpanderSample), () => CanNavigateToSamplePage(PageTokens.ExpanderSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("OldMainPageMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.OldMain), () => CanNavigateToSamplePage(PageTokens.OldMain)) },
            };

            _currentPageToken = PageTokens.DTSBehaviorSample;
            _canNavigateLookup = new Dictionary<PageTokens, bool>();

            foreach (PageTokens pageToken in Enum.GetValues(typeof(PageTokens)))
            {
                _canNavigateLookup.Add(pageToken, true);
            }

            _canNavigateLookup[_currentPageToken] = false;
        }
Ejemplo n.º 6
0
        public void Should_Return_An_Empty_Page_Token_When_One_Was_Not_Found_For_The_Platform()
        {
            var pageTokens = new PageTokens()
                             .AddToken("twitch", "twitch token");

            var pageToken = pageTokens.GetTokenOrEmpty("youtube");

            Assert.True(pageToken.IsEmpty());
        }
Ejemplo n.º 7
0
        public void Should_Return_An_Empty_String_When_All_Page_Tokens_Are_Empty()
        {
            var pageTokens = new PageTokens()
                             .AddToken("youtube", "")
                             .AddToken("twitch", "");

            var packedTokens = pageTokens.PackTokens();

            Assert.IsEmpty(packedTokens);
        }
Ejemplo n.º 8
0
        public void Should_Return_The_Page_Token_For_The_Platform()
        {
            var pageTokens = new PageTokens()
                             .AddToken("youtube", "youtube token")
                             .AddToken("twitch", "twitch token");

            var pageToken = pageTokens.GetTokenOrEmpty("twitch");

            Assert.AreEqual(pageToken.Token, "twitch token");
        }
Ejemplo n.º 9
0
 private void NavigateToPage(PageTokens pageToken)
 {
     if (CanNavigateToPage(pageToken))
     {
         if (_navigationService.Navigate(pageToken.ToString(), null))
         {
             UpdateCanNavigateLookup(pageToken);
             RaiseCanExecuteChanged();
         }
     }
 }
Ejemplo n.º 10
0
 private void NavigateToPage(PageTokens pageToken)
 {
     if (CanNavigateToPage(pageToken))
     {
         if (_navigationService.Navigate(pageToken.ToString(), null))
         {
             UpdateCanNavigateLookup(pageToken);
             RaiseCanExecuteChanged();
         }
     }
 }
Ejemplo n.º 11
0
        public void Should_Only_Pack_Non_Empty_Tokens()
        {
            var pageTokens = new PageTokens()
                             .AddToken("youtube", "youtube token")
                             .AddToken("twitch", "");

            var packedTokens = pageTokens.PackTokens();

            var unpackedTokens = PageTokens.UnpackTokens(packedTokens);

            Assert.AreEqual(unpackedTokens.GetTokenOrEmpty("youtube").Token, "youtube token");
            Assert.AreEqual(unpackedTokens.GetTokenOrEmpty("twitch").Token, "");
        }
        private void CleanRestrictedPagesFromNavigationHistory()
        {
            var app = App.Current as App;

            foreach (var pageToken in PageTokens.GetAll())
            {
                var page         = app.GetPage(pageToken);
                var isRestricted = Attribute.IsDefined(page, typeof(Restricted));
                if (isRestricted)
                {
                    _navigationService.RemoveAllPages(pageToken);
                }
            }
        }
Ejemplo n.º 13
0
 private void UpdateCanNavigateLookup(PageTokens navigatedTo)
 {
     if (navigatedTo == _currentPageToken)
     {
         return;
     }
     _canNavigateLookup[_currentPageToken] = true;
     _canNavigateLookup[navigatedTo]       = false;
     _currentPageToken = navigatedTo;
     ShowMenuButton    =
         _currentPageToken != PageTokens.Login &&
         _currentPageToken != PageTokens.SingleFileDownload &&
         _currentPageToken != PageTokens.FileUpload;
     IsMenuOpen = false;
 }
Ejemplo n.º 14
0
 private void UpdateCanNavigateLookup(PageTokens navigatedTo)
 {
     if (navigatedTo == PageTokens.Login)
     {
         foreach (var key in _canNavigateLookup.Keys.ToList())
         {
             _canNavigateLookup[key] = false;
         }
         _currentPageToken = navigatedTo;
         return;
     }
     _canNavigateLookup[_currentPageToken] = true;
     _canNavigateLookup[navigatedTo]       = false;
     _currentPageToken = navigatedTo;
 }
Ejemplo n.º 15
0
        public MenuViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
        {
            _navigationService = navigationService;

            Commands = new ObservableCollection <MenuItemViewModel>
            {
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("DTSBehaviorSampleMenuItemDisplayName"), FontIcon = "\ue15f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSBehaviorSample), () => CanNavigateToSamplePage(PageTokens.DTSBehaviorSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("DTSSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSSample), () => CanNavigateToSamplePage(PageTokens.DTSSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("IncrementalLoadingMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.IncrementalLoadingSample), () => CanNavigateToSamplePage(PageTokens.IncrementalLoadingSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("DeferLoadStrategyMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeferLoadStrategySample), () => CanNavigateToSamplePage(PageTokens.DeferLoadStrategySample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("CustomLVIPMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CustomLVIPSample), () => CanNavigateToSamplePage(PageTokens.CustomLVIPSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("StateTriggerMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.StateTriggerSample), () => CanNavigateToSamplePage(PageTokens.StateTriggerSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("CVSMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CollectionViewSourceSample), () => CanNavigateToSamplePage(PageTokens.CollectionViewSourceSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("DeviceSpecificMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeviceSpecificSample), () => CanNavigateToSamplePage(PageTokens.DeviceSpecificSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("ExpanderSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.ExpanderSample), () => CanNavigateToSamplePage(PageTokens.ExpanderSample))
                },
                new MenuItemViewModel {
                    DisplayName = resourceLoader.GetString("OldMainPageMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.OldMain), () => CanNavigateToSamplePage(PageTokens.OldMain))
                },
            };

            _currentPageToken  = PageTokens.DTSBehaviorSample;
            _canNavigateLookup = new Dictionary <PageTokens, bool>();

            foreach (PageTokens pageToken in Enum.GetValues(typeof(PageTokens)))
            {
                _canNavigateLookup.Add(pageToken, true);
            }

            _canNavigateLookup[_currentPageToken] = false;
        }
Ejemplo n.º 16
0
 private bool CanNavigateToPage(PageTokens pageToken)
 {
     return _canNavigateLookup[pageToken];
 }
Ejemplo n.º 17
0
 private void UpdateCanNavigateLookup(PageTokens navigatedTo)
 {
     _canNavigateLookup[_currentPageToken] = true;
     _canNavigateLookup[navigatedTo] = false;
     _currentPageToken = navigatedTo;
 }
Ejemplo n.º 18
0
 private void UpdateCanNavigateLookup(PageTokens navigatedTo)
 {
     _canNavigateLookup[_currentPageToken] = true;
     _canNavigateLookup[navigatedTo]       = false;
     _currentPageToken = navigatedTo;
 }
Ejemplo n.º 19
0
 private bool CanNavigateToPage(PageTokens pageToken)
 {
     return(_canNavigateLookup[pageToken]);
 }
Ejemplo n.º 20
0
 public static void Navigate(this INavigationService navigationService, PageTokens token)
 {
     navigationService.Navigate(token, null);
 }
Ejemplo n.º 21
0
 public static void Navigate(this INavigationService navigationService, PageTokens token, object param)
 {
     navigationService.Navigate(token.ToString(), param);
 }
Ejemplo n.º 22
0
 public NavigationEntry(string name, string glyph, PageTokens token)
 {
     Name  = name;
     Glyph = glyph;
     Token = token;
 }
Ejemplo n.º 23
0
 public MenuViewItem(string title, string icon, PageTokens token)
 {
     Title    = title;
     FontIcon = icon;
     Token    = token;
 }