예제 #1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            LoadingBar.IsIndeterminate = true;
            LoadingBar.Visibility      = Visibility.Visible;
            rec            = new StoreListing();
            rec            = e.Parameter as StoreListing;
            Title.Text     = rec.Title;
            Cover.Source   = rec.Image;
            FullCost.Text  = rec.Price;
            Author.Text    = rec.Author;
            DescBlock.Text = rec.desc;
            FullCost.Text  = "Full Book Price: " + rec.Price;

            try
            {
                StorageFolder folder     = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile   sampleFile = await folder.GetFileAsync("sample.txt");

                testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

                list = new List <ChapterView>();
                ChapterView temp;
                try
                {
                    items = await Table.Where(Chapter
                                              => Chapter.bookid == rec.Id).ToCollectionAsync();

                    foreach (Chapter lol in items)
                    {
                        temp       = new ChapterView();
                        temp.Id    = lol.Id;
                        temp.Title = "Chapter: " + (lol.sno + 1).ToString();
                        temp.Price = "Price: " + lol.price.ToString();
                        list.Add(temp);
                    }
                    LoadingBar.Visibility     = Visibility.Collapsed;
                    StoreListView.ItemsSource = list;
                }
                catch (Exception)
                {
                    LoadingBar.Visibility = Visibility.Collapsed;
                    MessageDialog mess = new Windows.UI.Popups.MessageDialog("Sorry Can't load the chapters now :(:(");
                    await mess.ShowAsync();
                }
            }
            catch (Exception)
            {
                MessageDialog msgbox = new MessageDialog("Something is not right try later");
                await msgbox.ShowAsync();

                LoadingBar.Visibility = Visibility.Collapsed;
            }
        }
예제 #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            StorageFolder folder     = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFile   sampleFile = await folder.GetFileAsync("sample.txt");

            testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

            LoadingBar.Visibility      = Visibility.Visible;
            LoadingBar.IsIndeterminate = true;

            try
            {
                rec          = e.Parameter as PurchasedView;
                Cover.Source = rec.sel.Image;
                Title.Text   = rec.sel.Title;
                Author.Text  = rec.sel.Author;
                List <string> chaps = new List <string>();
                string[]      lol   = rec.purchases.Split(',');
                for (int i = 0; i < lol.Length; i++)
                {
                    string   test3 = lol[i];
                    string[] test4 = test3.Split('.');
                    if (test4[0] == rec.sel.Id)
                    {
                        if (test4[1] != "full")
                        {
                            chaps.Add(test4[1]);
                        }
                        else
                        {
                            items = await Table.Where(Chapter
                                                      => Chapter.bookid == rec.sel.Id).ToCollectionAsync();

                            foreach (Chapter lol2 in items)
                            {
                                chaps.Add(lol2.Id);
                            }
                        }
                    }
                }

                list = new List <ChapterView>();
                ChapterView temp;
                try
                {
                    items = await Table.Where(Chapter
                                              => chaps.Contains(Chapter.Id)).ToCollectionAsync();


                    foreach (Chapter lol2 in items)
                    {
                        temp       = new ChapterView();
                        temp.Id    = lol2.Id;
                        temp.Title = "Chapter No: " + (lol2.sno + 1).ToString();
                        temp.Price = "Price: " + lol2.price.ToString();
                        list.Add(temp);
                    }
                    LoadingBar.Visibility     = Visibility.Collapsed;
                    StoreListView.ItemsSource = list;
                }
                catch (Exception)
                {
                    LoadingBar.Visibility = Visibility.Collapsed;
                    await(new MessageDialog("Can't get data now please try again later")).ShowAsync();
                }
            }

            catch (Exception)
            {
                LoadingBar.Visibility = Visibility.Collapsed;
                await(new MessageDialog("Can't get data now please try again later")).ShowAsync();
            }
        }