//public BitmapImage Convert(Bitmap src) //{ // MemoryStream ms = new MemoryStream(); // (src).Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); // BitmapImage image = new BitmapImage(); // image.BeginInit(); // ms.Seek(0, SeekOrigin.Begin); // image.StreamSource = ms; // image.EndInit(); // return image; //} public OverviewWindow(ObservableCollection <Book> books) { InitializeComponent(); this.books = books; firstPage = new BookPage1(books.First()); lastPage = new BookPage1(books.Last()); filmsFrame.Content = firstPage; if (books.Count == 1) { nextPage = firstPage; previousPage = firstPage; } else if (books.Count == 2) { nextPage = lastPage; previousPage = lastPage; } else { nextPage = new BookPage1(books.ElementAt(books.IndexOf(firstPage.book) + 1)); if (books.IndexOf(firstPage.book) - 1 < 0) { previousPage = lastPage; } else { previousPage = new BookPage1(books.ElementAt(books.IndexOf(firstPage.book) - 1)); } } }
private void LastPageDo() { int previousIndex = books.IndexOf(lastPage.book) - 1; if (previousIndex < 0) { previousIndex = books.Count - 1; } nextPage = firstPage; Dispatcher.Invoke(() => previousPage = new BookPage1(books.ElementAt(previousIndex))); }
private void PreviousPageDo() { int nextIndex = books.IndexOf(previousPage.book) + 1; int previousIndex = books.IndexOf(previousPage.book) - 1; if (nextIndex > books.Count - 1) { nextIndex = 0; } if (previousIndex < 0) { previousIndex = books.Count - 1; } Dispatcher.Invoke(() => nextPage = new BookPage1(books.ElementAt(nextIndex))); Dispatcher.Invoke(() => previousPage = new BookPage1(books.ElementAt(previousIndex))); }