コード例 #1
0
        public async Task GoBackToPageAsync(PageKey pageKey)
        {
            IReadOnlyList <Page> navigationStack = _navigation.Navigation.NavigationStack;

            var numberOfPagesToSkip = 0;

            if (navigationStack.Count > 2)
            {
                var startIndex = navigationStack.Count - 2;

                for (var i = startIndex; i >= 0; i--)
                {
                    var page = navigationStack[i];

                    var pageType = _pages.First(x => x.Value == pageKey).Key;

                    if (page.GetType() == pageType)
                    {
                        numberOfPagesToSkip = startIndex - i;
                        break;
                    }
                }
            }

            await GoBackAsync(numberOfPagesToSkip);
        }
コード例 #2
0
            /// <summary>
            /// Creates a new menu item view model object
            /// </summary>
            /// <param name="title">title of menu item</param>
            /// <param name="svgImageName">SVG image name of image to display</param>
            /// <param name="pageKey">page key of page to navigate to</param>
            public MenuItemViewModel(string title, string svgImageName, PageKey pageKey)
            {
                this.Title   = title;
                this.PageKey = pageKey;

                this.ImageSource = SvgImageCache.GetImageSource(svgImageName);
            }
コード例 #3
0
        public NavigationService(
            NavigationDictionary <Type> typeNavigationDictionary,
            PageKey rootPageKey)
        {
            this.TypeNavigationDictionary = typeNavigationDictionary;
            this.PageNavigationDictionary = new NavigationDictionary <Page>();

            this.RootPageKey = rootPageKey;
        }
コード例 #4
0
        public void NavigateTo(PageKey page, object parameters)
        {
            if (!this._pages.ContainsKey(page))
            {
                return;
            }

            var pageType = this._pages[page];

            this.NavigateToPage(pageType, parameters);
        }
コード例 #5
0
ファイル: EContentTypeMap.cs プロジェクト: rehee/trylambda
 public static ViewTempAndContent GetViewTempAndContent(this PageKey input)
 {
     try
     {
         return(new ViewTempAndContent(DefailtPageContentTypeMap[input].ContentTypeViewPath(), DefaltPageIdMap[input]));
     }
     catch
     {
         return(null);
     }
 }
コード例 #6
0
        public void NavigateTo(PageKey page, object parameters)
        {
            if (!_pages.ContainsKey(page))
            {
                return;
            }

            var pageType = _pages[page];
            NavigateToPage(pageType, parameters);
            UpdateBackButtonVisibility();
        }
コード例 #7
0
        private Page GetPage(PageKey pageKey, Dictionary <string, object> parameters = null)
        {
            Page page;

            ResolverOverride[] resolverOverrides = null;
            if (parameters != null && parameters.Count() > 0)
            {
                resolverOverrides = new ResolverOverride[parameters.Count()];
                for (int i = 0; i < parameters.Count(); i++)
                {
                    var dictionaryItem = parameters.ElementAt(i);
                    resolverOverrides[i] = new ParameterOverride(dictionaryItem.Key, dictionaryItem.Value);
                }
            }

            switch (pageKey)
            {
            case PageKey.Home:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(Home), typeof(Home).ToString());
                break;

            case PageKey.Login:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(Login), typeof(Login).ToString());
                break;

            case PageKey.Signup:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(Signup), typeof(Signup).ToString());
                break;

            case PageKey.Search:
                page = resolverOverrides != null ? (ContentPage)ContainerManager.Container.Resolve(typeof(Search), typeof(Search).ToString(), resolverOverrides) : (ContentPage)ContainerManager.Container.Resolve(typeof(Search), typeof(Search).ToString());
                break;

            case PageKey.RestaurantDetail:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(RestaurantDetail), typeof(RestaurantDetail).ToString());
                break;

            case PageKey.Filter:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(Filter), typeof(Filter).ToString());
                break;

            default:
                throw new ArgumentException(
                          $"No such page: {pageKey}. Did you forget to Register it?", nameof(pageKey));
            }

            if (!_pages.ContainsKey(page.GetType()))
            {
                _pages.Add(page.GetType(), pageKey);
            }

            return(page);
        }
コード例 #8
0
        public void NavigateTo(PageKey pageKey, IDictionary <string, object> parameters = null)
        {
            if (_mainFrame == null)
            {
                throw new TypeInitializationException("Main Frame not initialized, please call NavigationService.Initialize() First", null);
            }

            Page page = GetPage(pageKey, parameters);

            _mainFrame.Navigate(page);
            Console.WriteLine($"Name : {_mainFrame.Name}, CurrentSource : {_mainFrame.CurrentSource}, {_mainFrame.BackStack}");
        }
コード例 #9
0
        private Page GetPage(PageKey pageKey, IDictionary <string, object> parameters = null)
        {
            Page page;

            ResolverOverride[] resolverOverrides = null;
            if (parameters != null && parameters.Count() > 0)
            {
                resolverOverrides = new ResolverOverride[parameters.Count()];
                for (int i = 0; i < parameters.Count(); i++)
                {
                    var dictionaryItem = parameters.ElementAt(i);
                    resolverOverrides[i] = new ParameterOverride(dictionaryItem.Key, dictionaryItem.Value);
                }
            }

            switch (pageKey)
            {
            case PageKey.Login:
                page = (Page)ContainerManager.Container.Resolve(typeof(Login), typeof(Login).ToString());
                break;

            case PageKey.Dashboard:
                page = (Page)ContainerManager.Container.Resolve(typeof(Dashboard), typeof(Dashboard).ToString());
                break;

            case PageKey.TrainingReport:
                page = (Page)ContainerManager.Container.Resolve(typeof(TrainingReport), typeof(TrainingReport).ToString());
                break;

            case PageKey.Admin:
                page = (Page)ContainerManager.Container.Resolve(typeof(Admin), typeof(Admin).ToString());
                break;

            case PageKey.ManageDriver:
                page = (Page)ContainerManager.Container.Resolve(typeof(ManageDriver), typeof(ManageDriver).ToString());
                break;

            case PageKey.System:
                page = (Page)ContainerManager.Container.Resolve(typeof(SystemView), typeof(SystemView).ToString());
                break;

            default:
                throw new ArgumentException(
                          $"No such page: {pageKey}. Did you forgot to register your view in Bootstrapper?", nameof(pageKey));
            }

            if (!_pages.ContainsKey(page.GetType()))
            {
                _pages.Add(page.GetType(), pageKey);
            }

            return(page);
        }
コード例 #10
0
        public async Task NavigateToAsync(PageKey pageKey, Dictionary <string, object> parameters = null, bool isAnimated = true)
        {
            Page page = GetPage(pageKey, parameters);

            if (pageKey == PageKey.Login || pageKey == PageKey.Signup || pageKey == PageKey.Home)
            {
                _navigation = new NavigationPage(page);
                Application.Current.MainPage = _navigation;
            }
            else
            {
                await _navigation.PushAsync(page, isAnimated);
            }
        }
コード例 #11
0
ファイル: KeysService.cs プロジェクト: bamb0q/WebApplication3
        public async Task AddUserPageKeyAsync(PageKeyAddModel pageKeyAdd)
        {
            var user = await this.context.Users.FirstOrDefaultAsync(x => x.Id == pageKeyAdd.UserId);

            byte[] IV;
            var    encryptedPassword = this.passwordEndcodingHelper.EncryptString_Aes(pageKeyAdd.Password, user.PasswordHash, out IV);
            var    pageKeyToAdd      = new PageKey
            {
                Name              = pageKeyAdd.Name,
                UserId            = user.Id,
                EncryptedPassword = encryptedPassword,
                IV = Convert.ToBase64String(IV),
            };

            this.context.PageKeys.Add(pageKeyToAdd);
            await context.SaveChangesAsync();
        }
コード例 #12
0
        public object GetPage(PageKey pageKey, object parameter)
        {
            if (!this.TypeNavigationDictionary.ContainsKey(pageKey))
            {
                throw new ArgumentException(
                          string.Format(
                              "NoPage",
                              pageKey.PageName),
                          "pageKey");
            }

            if (!this.PageNavigationDictionary.ContainsKey(pageKey))
            {
                ConstructorInfo pageConstructor;
                object[]        pageParameters;

                var pageType = this.TypeNavigationDictionary[pageKey];
                if (parameter != null)
                {
                    pageConstructor = pageType.GetTypeInfo()
                                      .DeclaredConstructors
                                      .FirstOrDefault(constructor => constructor.GetParameters().Count() == 1 && constructor.GetParameters()[0].ParameterType == parameter.GetType());
                    pageParameters = new[] { parameter };
                }
                else
                {
                    pageConstructor = pageType.GetTypeInfo().DeclaredConstructors.FirstOrDefault(c => !c.GetParameters().Any());
                    pageParameters  = new object[] { };
                }

                if (pageConstructor == null)
                {
                    throw new InvalidOperationException(string.Format("NoConstructor", pageKey));
                }

                var page = pageConstructor.Invoke(pageParameters) as Page;
                if (pageKey == this.RootPageKey)
                {
                    this.NavigationPage = new NavigationPage(page);
                }

                this.PageNavigationDictionary.Add(pageKey, page);
            }

            return(this.PageNavigationDictionary[pageKey]);
        }
コード例 #13
0
        public async Task NavigateToAsync(PageKey pageKey, bool isAnimated = false)
        {
            ContentPage page = GetPage(pageKey);

            if (pageKey == PageKey.FirstPage)
            {
                if (_masterDetailPage == null)
                {
                    _masterDetailPage = new MasterDetailPage();

                    _menuPage = (MenuPage)ContainerManager.Container.Resolve(typeof(MenuPage), typeof(MenuPage).GetType().ToString());
                }

                _masterDetailPage.Master = new NavigationPage(_menuPage)
                {
                    Title        = "Menu",
                    Icon         = "menu.png",
                    BarTextColor = Color.White
                };

                _masterDetailPage.Detail = _navigation = new NavigationPage(page)
                {
                    BackgroundColor    = ColorConstants.DarkAppColor,
                    BarBackgroundColor = ColorConstants.DarkAppColor,
                    BarTextColor       = Color.White
                };

                App.Current.MainPage          = _masterDetailPage;
                _masterDetailPage.IsPresented = false;
            }
            else
            {
                if (_masterDetailPage != null)
                {
                    _masterDetailPage.IsPresented = false;
                }

                await _navigation.PushAsync(page, isAnimated);
            }
        }
コード例 #14
0
        private ContentPage GetPage(PageKey pageKey)
        {
            ContentPage page;

            switch (pageKey)
            {
            case PageKey.FirstPage:
                page = (ContentPage)ContainerManager.Container.Resolve(typeof(FirstPage), typeof(FirstPage).GetType().ToString());
                break;

            default:
                throw new ArgumentException(
                          $"No such page: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey));
            }

            if (!_pages.ContainsKey(page.GetType()))
            {
                _pages.Add(page.GetType(), pageKey);
            }

            return(page);
        }
コード例 #15
0
        private static IReadOnlyDictionary <PageKey, uint> GetResidentSetPageCounts(string tracePath,
                                                                                    Timestamp startTime, Timestamp stopTime)
        {
            using (ITraceProcessor trace = TraceProcessor.Create(tracePath))
            {
                IPendingResult <IResidentSetDataSource> pendingResidentSet = trace.UseResidentSetData();

                trace.Process();

                IResidentSetDataSource residentSetData = pendingResidentSet.Result;

                Dictionary <PageKey, uint> pageCounts = new Dictionary <PageKey, uint>();

                foreach (IResidentSetSnapshot snapshot in residentSetData.Snapshots)
                {
                    if (snapshot.Timestamp < startTime || snapshot.Timestamp > stopTime)
                    {
                        continue;
                    }

                    foreach (IResidentSetPage page in snapshot.Pages)
                    {
                        PageKey key = new PageKey(snapshot.Timestamp, page.MemoryManagerListType, page.Priority);

                        if (!pageCounts.ContainsKey(key))
                        {
                            pageCounts.Add(key, 0);
                        }

                        ++pageCounts[key];
                    }
                }

                return(pageCounts);
            }
        }
コード例 #16
0
 public object GetPage(PageKey pageKey)
 {
     return(this.GetPage(pageKey, null));
 }
コード例 #17
0
 public void NavigateTo(PageKey pageKey)
 {
     this.NavigateTo(pageKey, null, false);
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: rrkreitler/TBR_CL
        private static void ShowPaginatedList(IEnumerable <Tweet> queryResult, ArgValidator argValidator)
        {
            List <Tweet> results = queryResult.ToList();
            // Set start index for page.
            int startIndex = -1;
            int endIndex   = 0;

            // Show page
            PageKey key = PageKey.Home;

            do
            {
                string keyNext      = " next - >";
                string keyPrvious   = "< - previous ";
                bool   updateScreen = false;
                switch (key)
                {
                // Jump to end.
                case PageKey.End:
                    if (endIndex != results.Count)
                    {
                        endIndex   = results.Count;
                        startIndex = endIndex - argValidator.PageSize;
                        if (startIndex < 0)
                        {
                            startIndex = 0;
                        }
                        keyNext      = "";
                        updateScreen = true;
                    }
                    break;

                // Next page.
                case PageKey.Next:
                    if (endIndex != results.Count)
                    {
                        if (startIndex + argValidator.PageSize < results.Count)
                        {
                            startIndex += argValidator.PageSize;
                            endIndex   += argValidator.PageSize;
                            if (endIndex > results.Count)
                            {
                                keyNext = "";
                            }
                            updateScreen = true;
                        }
                    }
                    break;

                // Jump to beginning.
                case PageKey.Home:
                    if (startIndex != 0)
                    {
                        Console.Clear();
                        startIndex = 0;
                        endIndex   = startIndex +
                                     ((argValidator.PageSize == 0) ? results.Count : argValidator.PageSize);
                        updateScreen = true;
                        keyPrvious   = "";
                    }

                    break;

                // Previou page.
                case PageKey.Previous:
                    if (startIndex != 0)
                    {
                        startIndex -= argValidator.PageSize;
                        if (startIndex <= 0)
                        {
                            startIndex = 0;
                            keyPrvious = "";
                        }
                        endIndex     = startIndex + argValidator.PageSize;
                        updateScreen = true;
                    }
                    break;

                // Show key help on invalid keystrokes.
                default:
                    Console.WriteLine("*** Valid keys:");
                    Console.WriteLine("N-next P-previous HOME-begin END-end Q-quit\n");
                    updateScreen = false;
                    break;
                }

                for (int i = startIndex; i < endIndex && i < results.Count() && updateScreen; i++)
                {
                    Console.WriteLine($"{results[i].Id}   {results[i].Stamp}\n{results[i].Text}");
                    Console.WriteLine("------------------------------------------------------------");
                }

                // Display page number information
                if (argValidator.PageSize != 0)
                {
                    if (updateScreen)
                    {
                        Console.WriteLine($"\nQuery from: {argValidator.StartDate} to {argValidator.EndDate}");
                        int endNum = (endIndex > results.Count) ? results.Count : endIndex;
                        Console.WriteLine(
                            $"Records {startIndex + 1} - {endNum} of {results.Count}   {keyPrvious}{keyNext}\n");
                    }
                    key = CheckKey(Console.ReadKey());
                }
                else
                {
                    key = PageKey.Quit;
                }
            } while (key != PageKey.Quit);
        }
コード例 #19
0
 public async Task <object> GetPageAsync(PageKey pageKey)
 {
     return(await Task.Run(() => this.GetPage(pageKey)));
 }
コード例 #20
0
        public void NavigateTo(PageKey page, object parameters)
        {
            if (!this._pages.ContainsKey(page))
            {
                throw new ArgumentOutOfRangeException(
                    $"The target page '{page}' does not exist. Did you have initialized the page dictionary correcty?");
            }

            var pageType = this._pages[page];
            this.NavigateToPage(pageType, parameters);

            this.UpdateBackButtonVisibility();
        }
コード例 #21
0
 public void GoBackToPage(PageKey pageKey)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
 public void NavigateTo(PageKey pageKey, object parameter)
 {
     this.NavigateTo(pageKey, parameter, false);
 }
コード例 #23
0
 public void NavigateTo(PageKey page)
 {
     this.NavigateTo(page, null);
 }
コード例 #24
0
 public void NavigateTo(PageKey page)
 {
     NavigateTo(page, null);
 }
コード例 #25
0
        public async Task NavigateTo(PageKey pageKey, object parameter, bool isModal)
        {
            var currentPageKey = this.CurrentPageKey;

            if (currentPageKey == null || currentPageKey == pageKey)
            {
                return;
            }

            var page = this.GetPage(pageKey, parameter) as Page;

            if (page == null)
            {
                return;
            }

            this.OnNavigationStarted();

            if (pageKey.IsDetailPage)
            {
                // Pop modals if they exist
                dynamic lastPage = this.NavigationPage.Navigation.ModalStack.LastOrDefault() ?? this.NavigationPage;

                while (lastPage != null &&
                       ((lastPage is NavigationPage && lastPage.CurrentPage.GetType() != this.NavigationPage.CurrentPage.GetType()) ||
                        (!(lastPage is NavigationPage) && lastPage.GetType() != this.NavigationPage.CurrentPage.GetType())))
                {
                    await this.NavigationPage.Navigation.PopModalAsync();

                    lastPage = this.NavigationPage.Navigation.ModalStack.LastOrDefault();
                }

                // Pop navigation pages if they exist
                if (!currentPageKey.IsDetailPage)
                {
                    await this.NavigationPage.Navigation.PopToRootAsync();
                }

                // TODO Use if needed for MasterDetailPage
                // Change detail page
                //var masterDetail = this.NavigationPage.CurrentPage as MainPage;
                //if (masterDetail != null)
                //{
                //    masterDetail.SetDetailPage(page);
                //}
            }
            else
            {
                if (page.Parent != null)
                {
                    page.Parent = null;
                }

                if (isModal)
                {
                    await this.NavigationPage.Navigation.PushModalAsync(page);
                }
                else
                {
                    await this.NavigationPage.Navigation.PushAsync(page);
                }
            }

            this.OnNavigationCompleted();
        }