Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            myLibraryItemNames = new List<Xassida>();

            BookPage titlePage, tardioumanePage, bp;

            LoadXassida();

            this.DataContext = currentXassida;

            PagesCollection = new PaginatedCollection<Beyit>(currentXassida.Beyits);

            /// the title of the xassida will be the first page
            ///
            titlePage = new BookPage();

            StackPanel p = new StackPanel() { VerticalAlignment = VerticalAlignment.Center };
            TextBlock tPageTb = new TextBlock()
            {
                Text = currentXassida.Titre,
                FontSize = 35,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                TextAlignment = TextAlignment.Center,
                TextWrapping = TextWrapping.Wrap
            };
            p.Children.Add(tPageTb);
            titlePage.Content = p;

            readerBook.Items.Add(titlePage);

            tardioumanePage = new BookPage();
            tardioumanePage.Content = new TextBlock()
            {
                Text = currentXassida.Tardioumane,
                TextWrapping = TextWrapping.WrapWithOverflow,
                VerticalAlignment = VerticalAlignment.Center,

            };

            readerBook.Items.Add(tardioumanePage);

            for (int i = 0; i < PagesCollection.PagesCount; i++)
            {

                bp = new BookPage();
                StackPanel container = new StackPanel() { Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center };

                foreach (Beyit beyit in PagesCollection.GetData(i))
                {

                    DockPanel c = new DockPanel();
                    foreach (Bahru bahru in beyit.Bahrus)
                    {
                        TextBlock tb = new TextBlock() { Text = bahru.Contenu, Margin = new Thickness(4, 6, 4, 6), Width = 50 };
                        c.Children.Add(tb);
                    }

                    container.Children.Add(c);
                }

                container.Children.Add(new TextBlock() { Text = String.Format("page {0}", (i + 1).ToString()), Foreground = SystemColors.GrayTextBrush, FontSize = 7, Margin = new Thickness(0, 10, 0, 10) });

                bp.Content = container;
                readerBook.Items.Add(bp);

            }

            AppStore = IsolatedStorageFile.GetUserStoreForDomain();
            // Check for files saved in isolated storage
            foreach (string file in AppStore.GetFileNames())
            {
                myLibraryItemNames.Add(new Xassida() { Titre = file});
            }

            // Set the items source of the myLibrary List view

            myLibraryListView.ItemsSource = myLibraryItemNames;
        }