private void LoadTemplates() { Items.Clear(); PageItems.Clear(); int count = 0; string[] files = Directory.GetFiles(Constants.TemplateThumbnailRoot); if (files == null) { Debug.Write("Error: Reading files from the souvenirs image folder returns null."); return; } foreach (var file in files) { string name = Path.GetFileNameWithoutExtension(file); TemplateModel template = new TemplateModel(name, Path.GetFullPath(file), name); if (count < Constants.NumberOfItemsPerPage) { PageItems.Add(template); ++count; } Items.Add(template); } PageCursor = 1; NumberOfPages = (Items.Count + Constants.NumberOfItemsPerPage - 1) / Constants.NumberOfItemsPerPage; PageBackCommand.RaiseCanExecuteChanged(); PageForwardCommand.RaiseCanExecuteChanged(); }
private void BuildMenu() { var settingsItem = new SDK.Model.MenuItem("Settings", "appbar_settings", new SDK.Tools.Thickness(5, 5, 5, 5), true); settingsItem.Click += (s, e) => { MainWindow.SettingsFlyout.Width = MainWindow.ProfileSwitcher.ActualWidth + MainWindow.FLYOUT_WIDTH_MIN; if (!MainWindow.SettingsFlyout.IsOpen) { MainWindow.SettingsFlyout.Visibility = Visibility.Hidden; } MainWindow.SettingsFlyout.IsOpen = true; }; var consoleItem = new SDK.Model.MenuItem("Console", "appbar_app", new SDK.Tools.Thickness(5, 7, 5, 7), true); consoleItem.Click += (s, e) => { ShowWindow(App.Kernel.Get <Logger>().Container); MainWindow.MenuFlyout.IsOpen = false; }; var aboutItem = new SDK.Model.MenuItem("About", "appbar_information", new SDK.Tools.Thickness(9, 4, 9, 4), true); aboutItem.Click += (s, e) => { ShowWindow(App.Kernel.Get <About>().Container); MainWindow.MenuFlyout.IsOpen = false; }; List <MenuItem> extraMenuItems = new List <MenuItem>(MenuItems); MenuItems.Clear(); MenuItems.Add(settingsItem); MenuItems.Add(consoleItem); MenuItems.Add(aboutItem); InternalMenuCount = MenuItems.Count; OwnedItems.AddRange(MenuItems); foreach (MenuItem item in extraMenuItems) { MenuItems.Add(item); } MainPage = new PageItem("MainWindow_NewsTab", new MainPage().Container, true); Gallery = new PageItem("MainWindow_GalleryTab", new Gallery().Container, true); Community = new PageItem("MainWindow_CommunityTab", new Community().Container, true); Personalization = new PageItem("MainWindow_PersonalizationTab", new Personalization().Container, true); List <PageItem> extraPages = new List <PageItem>(PageItems); PageItems.Clear(); PageItems.Add(MainPage); PageItems.Add(Gallery); PageItems.Add(Community); PageItems.Add(Personalization); OwnedItems.AddRange(PageItems); foreach (PageItem item in extraPages) { PageItems.Add(item); } }
protected void Reset() { PageCursor = 1; NumberOfPages = 1; Items.Clear(); PageItems.Clear(); PageBackCommand.RaiseCanExecuteChanged(); PageForwardCommand.RaiseCanExecuteChanged(); }
private void PageForwardCommandExecute(object parameter) { PageItems.Clear(); ++PageCursor; int startIndex = (PageCursor - 1) * Constants.NumberOfItemsPerPage; for (var i = startIndex; i < startIndex + Constants.NumberOfItemsPerPage; ++i) { if (i >= Items.Count) { break; } PageItems.Add(Items[i]); } PageBackCommand.RaiseCanExecuteChanged(); PageForwardCommand.RaiseCanExecuteChanged(); }
public void Update() { PageItems.Clear(); foreach (var item in AppManager.GetInstance().PageList) { AppPageItem pageItem = new AppPageItem(); pageItem.Page = item.Key; pageItem.IsSelect = false; PageItems.Add(pageItem); } bool isExist = false; foreach (AppPageItem item in PageItems) { if (item.Page == SelectPage) { item.IsSelect = true; isExist = true; break; } } if (!isExist) { SelectPage = 0; foreach (AppPageItem item in PageItems) { if (item.Page == SelectPage) { item.IsSelect = true; break; } } } AppItems.Clear(); foreach (AppItem item in AppManager.GetInstance().AppItemList) { if (item.Page == SelectPage) { AppItems.Add(item); } } }
private async void LoadAlbumsAsync() { lock (loadAlbumsMutex) { if (isLoadingAlbums) { return; } isLoadingAlbums = true; } Items.Clear(); PageItems.Clear(); int count = 0; var albums = await oneDriveController.GetAlbumsAsync(); if (albums == null) { if (!HasInternetConnection) { Debug.WriteLine("No internet connection."); } ItemsExist = false; IsLoading = false; Debug.WriteLine("Error: Fetching albums from OneDrive returns null."); lock (loadAlbumsMutex) { isLoadingAlbums = false; } } else { foreach (var album in albums) { var bundle = new BundleModel(album.Id, album.Name, album.ThumbnailUrl); if (count < Constants.NumberOfItemsPerPage) { PageItems.Add(bundle); ++count; } Items.Add(bundle); } } PageCursor = 1; NumberOfPages = (Items.Count + Constants.NumberOfItemsPerPage - 1) / Constants.NumberOfItemsPerPage; NumberOfPages = NumberOfPages < 1 ? 1 : NumberOfPages; ItemsExist = Items.Count != 0; PageBackCommand.RaiseCanExecuteChanged(); PageForwardCommand.RaiseCanExecuteChanged(); IsLoading = false; lock (loadAlbumsMutex) { isLoadingAlbums = false; } }