Esempio n. 1
0
        public void SetSelectedPages()
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            Canvas.SetZIndex((bp0 as BookPage), 1);
            Canvas.SetZIndex((bp1 as BookPage), 0);
        }
Esempio n. 2
0
        private void OnRightMouseDown(object sender, MouseButtonEventArgs args)
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            Canvas.SetZIndex((bp0 as BookPage), 0);
            Canvas.SetZIndex((bp1 as BookPage), 1);
        }
Esempio n. 3
0
File: Book.cs Progetto: mvkolos/BM
        private void OnRightPageTurned(object sender, RoutedEventArgs args)
        {
            CurrentSheetIndex++;

            int currentSheetIndex = CurrentSheetIndex;
            int itemsCount        = GetItemsCount();

            if (CurrentSheetIndex == GetItemsCount() / 2)
            {
                BookPage bp1 = GetTemplateChild("sheet1") as BookPage;
                bp1.IsEnabled = false;
            }
        }
Esempio n. 4
0
        public override void TouchDown(PointF p)
        {
            Book b = Source as Book;
            if (b == null) return;
            
            b.SetSelectedPages();
            selectedPage = findSelectedPage(b, new System.Windows.Point(p.X, p.Y));

            b.CheckSheets(selectedPage);

            if (selectedPage != null)
            {
                selectedPage.GrabPage(b, new System.Windows.Point(p.X, p.Y));
            }

            base.TouchDown(p);
        }
Esempio n. 5
0
        public void AnimateToPreviousPage(bool fromTop, int duration)
        {
            if (CurrentSheetIndex > 0)
            {
                BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
                BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

                if ((bp0 == null) || (bp1 == null))
                {
                    return;
                }

                Canvas.SetZIndex((bp1 as BookPage), 0);
                Canvas.SetZIndex((bp0 as BookPage), 1);
                bp0.AutoTurnPage(fromTop ? CornerOrigin.TopLeft : CornerOrigin.BottomLeft, duration);
            }
        }
Esempio n. 6
0
        public void AnimateToNextPage(bool fromTop, int duration)
        {
            if (CurrentSheetIndex + 1 <= GetItemsCount() / 2)
            {
                BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
                BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

                if ((bp0 == null) || (bp1 == null))
                {
                    return;
                }

                Canvas.SetZIndex((bp0 as BookPage), 0);
                Canvas.SetZIndex((bp1 as BookPage), 1);
                bp1.AutoTurnPage(fromTop ? CornerOrigin.TopRight : CornerOrigin.BottomRight, duration);
            }
        }
Esempio n. 7
0
        private void OnLoaded(object sender, RoutedEventArgs args)
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            if ((bp0 == null) || (bp1 == null))
            {
                return;
            }

            defaultDataTemplate = (DataTemplate)Resources["defaultDataTemplate"];
            Read <PageStatus>   GetStatus = delegate() { return(_status); };
            Action <PageStatus> SetStatus = delegate(PageStatus ps) { _status = ps; };

            bp0.GetStatus += GetStatus;
            bp0.SetStatus += SetStatus;
            bp1.GetStatus += GetStatus;
            bp1.SetStatus += SetStatus;

            RefreshSheetsContent();
        }
Esempio n. 8
0
        public void CheckSheets(BookPage curPage)
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            if ((bp0 == null) || (bp1 == null))
            {
                return;
            }

            if (bp1 == curPage)
            {
                Canvas.SetZIndex((bp0 as BookPage), 0);
                Canvas.SetZIndex((bp1 as BookPage), 1);
            }
            else
            {
                Canvas.SetZIndex((bp0 as BookPage), 1);
                Canvas.SetZIndex((bp1 as BookPage), 0);
            }
        }
Esempio n. 9
0
        public void CheckSheets(BookPage curPage)
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;
            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            if ((bp0 == null) || (bp1 == null))
                return;

            if (bp1 == curPage)
            {
                Canvas.SetZIndex((bp0 as BookPage), 0);
                Canvas.SetZIndex((bp1 as BookPage), 1);
            }
            else
            {
                Canvas.SetZIndex((bp0 as BookPage), 1);
                Canvas.SetZIndex((bp1 as BookPage), 0);
            }
        }
Esempio n. 10
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;
        }
Esempio n. 11
0
        //public override void TouchDown(PointF p)
        public override void TouchDown(PointF global, PointF relative)
        {
            Book b = Source as Book;
            if (b == null) return;

            b.SetSelectedPages();
            //selectedPage = findSelectedPage(b, new System.Windows.Point(p.X, p.Y));
            selectedPage = findSelectedPage(b, new System.Windows.Point(relative.X, relative.Y));

            b.CheckSheets(selectedPage);

            if (selectedPage != null)
            {
                //CornerOrigin? ISCorner = selectedPage.GetCorner(b, new System.Windows.Point(p.X, p.Y));
                CornerOrigin? ISCorner = selectedPage.GetCorner(b, new System.Windows.Point(relative.X, relative.Y));
                if (ISCorner != null)
                {
                    //TouchFramework.MTSmoothContainer()

                    //selectedPage.GrabPage(b, new System.Windows.Point(p.X, p.Y));

                    if (ISCorner == CornerOrigin.TopRight)
                    {
                        b.AnimateToNextPage(true, 1000);
                    }
                    else if (ISCorner == CornerOrigin.BottomRight)
                    {
                        b.AnimateToNextPage(false, 1000);
                    }
                    else if (ISCorner == CornerOrigin.TopLeft)
                    {
                        b.AnimateToPreviousPage(true, 1000);
                    }
                    else if (ISCorner == CornerOrigin.BottomLeft)
                    {
                        b.AnimateToPreviousPage(false, 1000);
                    }

                    //b.ContainerObj.noScale = true;

                    //MTSmoothContainer containerobj = b.ContainerObj as MTSmoothContainer;
                    //b.ContainerObj.noScale = true;
                    //b.ContainerObj.noRotate = true;
                    // b.ContainerObj.noMove = true;

                }
            }

            //base.TouchDown(p);
            base.TouchDown(global, relative);
        }
Esempio n. 12
0
        private void RefreshSheetsContent()
        {
            BookPage bp0 = GetTemplateChild("sheet0") as BookPage;

            if (bp0 == null)
            {
                return;
            }

            BookPage bp1 = GetTemplateChild("sheet1") as BookPage;

            if (bp1 == null)
            {
                return;
            }

            ContentPresenter sheet0Page0Content = bp0.FindName("page0") as ContentPresenter;
            ContentPresenter sheet0Page1Content = bp0.FindName("page1") as ContentPresenter;
            ContentPresenter sheet0Page2Content = bp0.FindName("page2") as ContentPresenter;

            ContentPresenter sheet1Page0Content = bp1.FindName("page0") as ContentPresenter;
            ContentPresenter sheet1Page1Content = bp1.FindName("page1") as ContentPresenter;
            ContentPresenter sheet1Page2Content = bp1.FindName("page2") as ContentPresenter;

            Visibility bp0Visibility = Visibility.Visible;
            Visibility bp1Visibility = Visibility.Visible;

            bp1.IsTopRightCornerEnabled    = true;
            bp1.IsBottomRightCornerEnabled = true;

            Visibility sheet0Page0ContentVisibility = Visibility.Visible;
            Visibility sheet0Page1ContentVisibility = Visibility.Visible;
            Visibility sheet0Page2ContentVisibility = Visibility.Visible;
            Visibility sheet1Page0ContentVisibility = Visibility.Visible;
            Visibility sheet1Page1ContentVisibility = Visibility.Visible;
            Visibility sheet1Page2ContentVisibility = Visibility.Visible;

            DataTemplate dt = ItemTemplate;

            if (dt == null)
            {
                dt = defaultDataTemplate;
            }

            sheet0Page0Content.ContentTemplate = dt;
            sheet0Page1Content.ContentTemplate = dt;
            sheet0Page2Content.ContentTemplate = dt;
            sheet1Page0Content.ContentTemplate = dt;
            sheet1Page1Content.ContentTemplate = dt;
            sheet1Page2Content.ContentTemplate = dt;

            sheet0Page2ContentVisibility = _currentSheetIndex == 1 ? Visibility.Hidden : Visibility.Visible;
            int  count      = GetItemsCount();
            int  sheetCount = count / 2;
            bool isOdd      = (count % 2) == 1;

            if (_currentSheetIndex == sheetCount)
            {
                if (isOdd)
                {
                    bp1.IsTopRightCornerEnabled    = false;
                    bp1.IsBottomRightCornerEnabled = false;
                }
                else
                {
                    bp1Visibility = Visibility.Hidden;
                }
            }

            if (_currentSheetIndex == sheetCount - 1)
            {
                if (!isOdd)
                {
                    sheet1Page2ContentVisibility = Visibility.Hidden;
                }
            }

            if (_currentSheetIndex == 0)
            {
                sheet0Page0Content.Content = null;
                sheet0Page1Content.Content = null;
                sheet0Page2Content.Content = null;
                bp0.IsEnabled = false;
                bp0Visibility = Visibility.Hidden;
            }
            else
            {
                sheet0Page0Content.Content = GetPage(2 * (CurrentSheetIndex - 1) + 1);
                sheet0Page1Content.Content = GetPage(2 * (CurrentSheetIndex - 1));
                sheet0Page2Content.Content = GetPage(2 * (CurrentSheetIndex - 1) - 1);
                bp0.IsEnabled = true;
            }

            sheet1Page0Content.Content = GetPage(2 * CurrentSheetIndex);
            sheet1Page1Content.Content = GetPage(2 * CurrentSheetIndex + 1);
            sheet1Page2Content.Content = GetPage(2 * CurrentSheetIndex + 2);

            bp0.Visibility = bp0Visibility;
            bp1.Visibility = bp1Visibility;

            sheet0Page0Content.Visibility = sheet0Page0ContentVisibility;
            sheet0Page1Content.Visibility = sheet0Page1ContentVisibility;
            sheet0Page2Content.Visibility = sheet0Page2ContentVisibility;
            sheet1Page0Content.Visibility = sheet1Page0ContentVisibility;
            sheet1Page1Content.Visibility = sheet1Page1ContentVisibility;
            sheet1Page2Content.Visibility = sheet1Page2ContentVisibility;
        }