private void AddBookInfoView(String bookID, Chapter chapter) { String numNotes = "0"; String numBookmarks = "0"; String numAnnotations = "0"; numNotes = BooksOnDeviceAccessor.GetNumNotesInChapter(bookID, chapter.ID); numBookmarks = BooksOnDeviceAccessor.GetNumBookmarksInChapter(bookID, chapter.ID); numAnnotations = BooksOnDeviceAccessor.GetNumAnnotationsInChapter(bookID, chapter.ID); // bookInfoView BookInfoView bookInfoView = new BookInfoView(numNotes, numBookmarks, numAnnotations, chapter.Pagecount.ToString(), false, false, this.Frame.Width - 30); bookInfoView.Frame = new CGRect(10, this.Frame.Bottom - 40, bookInfoView.Frame.Width, bookInfoView.Frame.Height); this.AddSubview(bookInfoView); }
private void UpdateBookInfo() { String numNotes = "0"; String numBookmarks = "0"; String numAnnotations = "0"; bookInfoView = new BookInfoView(numNotes, numBookmarks, numAnnotations, BookshelfBook.PageCount.ToString(), false, false, this.Frame.Width - 30); bookInfoView.Frame = new CGRect(10, this.Frame.Bottom - 44, bookInfoView.Frame.Width, bookInfoView.Frame.Height); bookInfoView.Alpha = 0f; this.AddSubview(bookInfoView); numNotes = BooksOnDeviceAccessor.GetNumNotesInBook(BookshelfBook.ID); numBookmarks = BooksOnDeviceAccessor.GetNumBookmarksInBook(BookshelfBook.ID); numAnnotations = BooksOnDeviceAccessor.GetNumAnnotationsInBook(BookshelfBook.ID); bookInfoView.NumNoteLabel.Text = numNotes; bookInfoView.NumBookmarkLabel.Text = numBookmarks; bookInfoView.NumAnnLabel.Text = numAnnotations; }
public LibraryBookView(Book book, LibraryViewController parentVC) : base(new CGRect(0, 0, 280, 280)) { this.LibraryBook = book; this.BackgroundColor = UIColor.White; this.Layer.ShadowColor = UIColor.Black.CGColor; this.Layer.ShadowOpacity = 0.3f; this.Layer.ShadowRadius = 2f; this.Layer.ShadowOffset = new CGSize(5f, 5f); // imageView imageView = new UIImageView(); imageView.Frame = new CGRect(0, 0, this.Frame.Width, 150); this.AddSubview(imageView); if (!String.IsNullOrEmpty(LibraryBook.LargeImageURL)) { // imageSpinner imageSpinner = eBriefingAppearance.GenerateBounceSpinner(); imageSpinner.Center = imageView.Center; this.AddSubview(imageSpinner); // Download image bool exist = FileDownloader.Download(LibraryBook.LargeImageURL, parentVC); if (exist) { bool outDated = false; var item = BooksOnServerAccessor.GetBook(LibraryBook.ID); if (item != null) { if (item.ImageVersion < LibraryBook.ImageVersion) { DownloadedFilesCache.RemoveFile(item.LargeImageURL); DownloadedFilesCache.RemoveFile(item.SmallImageURL); outDated = true; } } if (outDated) { FileDownloader.Download(LibraryBook.LargeImageURL, parentVC, true); } else { UpdateImage(LibraryBook.LargeImageURL); } } } // titleLabel UILabel titleLabel = eBriefingAppearance.GenerateLabel(16); titleLabel.Frame = new CGRect(10, imageView.Frame.Bottom + 8, 260, 21); titleLabel.Lines = 2; titleLabel.LineBreakMode = UILineBreakMode.WordWrap; titleLabel.Text = book.Title; titleLabel.SizeToFit(); titleLabel.Frame = new CGRect(10, titleLabel.Frame.Y, 260, titleLabel.Frame.Height); this.AddSubview(titleLabel); // bookInfoView BookInfoView bookInfoView = new BookInfoView("0", "0", "0", book.PageCount.ToString(), false, false, this.Frame.Width - 30); bookInfoView.Frame = new CGRect(10, this.Frame.Bottom - 44, bookInfoView.Frame.Width, bookInfoView.Frame.Height); this.AddSubview(bookInfoView); // downloadButton UIButton downloadButton = UIButton.FromType(UIButtonType.Custom); downloadButton.Font = eBriefingAppearance.ThemeBoldFont(14); downloadButton.SetTitleColor(eBriefingAppearance.Color("37b878"), UIControlState.Normal); downloadButton.SetTitleColor(UIColor.White, UIControlState.Highlighted); downloadButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Normal); downloadButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Highlighted); downloadButton.Frame = new CGRect(this.Center.X - 65, bookInfoView.Frame.Top - 28, 130, downloadButton.CurrentBackgroundImage.Size.Height); downloadButton.SetTitle("DOWNLOAD", UIControlState.Normal); downloadButton.TouchUpInside += HandleDownloadButtonTouchUpInside; this.AddSubview(downloadButton); }
public DashboardView(Book book, CGRect frame) : base(frame) { this.book = book; this.BackgroundColor = UIColor.White; // overview UILabel overview = eBriefingAppearance.GenerateLabel(21); overview.Frame = new CGRect(20, 20, frame.Width - 40, 21); overview.Text = "Overview"; this.AddSubview(overview); // imageView UIImageView imageView = new UIImageView(); imageView.Frame = new CGRect(overview.Frame.X, overview.Frame.Bottom + 16, overview.Frame.Width, 150); String localImagePath = DownloadedFilesCache.BuildCachedFilePath(book.LargeImageURL); if (File.Exists(localImagePath)) { imageView.Image = UIImage.FromFile(localImagePath); } this.AddSubview(imageView); // bookInfoView bookInfoView = new BookInfoView("0", "0", "0", book.PageCount.ToString(), false, false, frame.Width - 60); bookInfoView.Frame = new CGRect(30, imageView.Frame.Bottom + 8, bookInfoView.Frame.Width, bookInfoView.Frame.Height); this.AddSubview(bookInfoView); // line0 UIView line0 = new UIView(); line0.BackgroundColor = eBriefingAppearance.Gray4; line0.Frame = new CGRect(overview.Frame.X, bookInfoView.Frame.Bottom + 10, overview.Frame.Width, 1); this.AddSubview(line0); // descLabel UILabel descLabel = GenerateLabel("Description", true); descLabel.Frame = new CGRect(overview.Frame.X, line0.Frame.Bottom + 10, overview.Frame.Width, 21); this.AddSubview(descLabel); // desc UILabel desc = GenerateLabel(book.Description, false); desc.Frame = new CGRect(overview.Frame.X, descLabel.Frame.Bottom + 8, overview.Frame.Width, 1); desc.Lines = 0; desc.SizeToFit(); this.AddSubview(desc); // line1 UIView line1 = new UIView(); line1.BackgroundColor = eBriefingAppearance.Gray4; line1.Frame = new CGRect(overview.Frame.X, desc.Frame.Bottom + 10, overview.Frame.Width, 1); this.AddSubview(line1); // versionLabel UILabel versionLabel = GenerateLabel("Version", true); versionLabel.Frame = new CGRect(overview.Frame.X, line1.Frame.Bottom + 10, overview.Frame.Width, 21); this.AddSubview(versionLabel); // version UILabel version = GenerateLabel(book.Version.ToString(), false); version.Frame = new CGRect(overview.Frame.X, versionLabel.Frame.Bottom + 8, overview.Frame.Width, 21); this.AddSubview(version); // line2 UIView line2 = new UIView(); line2.BackgroundColor = eBriefingAppearance.Gray4; line2.Frame = new CGRect(overview.Frame.X, version.Frame.Bottom + 10, overview.Frame.Width, 1); this.AddSubview(line2); // createdLabel UILabel createdLabel = GenerateLabel("Date Created", true); createdLabel.Frame = new CGRect(overview.Frame.X, line2.Frame.Bottom + 10, overview.Frame.Width, 21); this.AddSubview(createdLabel); // created UILabel created = GenerateLabel(book.UserAddedDate.ToString("MMMM dd, yyyy"), false); created.Frame = new CGRect(overview.Frame.X, createdLabel.Frame.Bottom + 8, overview.Frame.Width, 21); this.AddSubview(created); // line3 UIView line3 = new UIView(); line3.BackgroundColor = eBriefingAppearance.Gray4; line3.Frame = new CGRect(overview.Frame.X, created.Frame.Bottom + 10, overview.Frame.Width, 1); this.AddSubview(line3); // modifiedLabel UILabel modifiedLabel = GenerateLabel("Date Modified", true); modifiedLabel.Frame = new CGRect(overview.Frame.X, line3.Frame.Bottom + 10, overview.Frame.Width, 21); this.AddSubview(modifiedLabel); // modified UILabel modified = GenerateLabel(book.UserModifiedDate.ToString("MMMM dd, yyyy"), false); modified.Frame = new CGRect(overview.Frame.X, modifiedLabel.Frame.Bottom + 8, overview.Frame.Width, 21); this.AddSubview(modified); // shadow UIImageView shadow = new UIImageView(); shadow.AutoresizingMask = UIViewAutoresizing.FlexibleHeight; shadow.Frame = new CGRect(frame.Right - 3, 0, 3, frame.Height); shadow.Image = UIImage.FromBundle("Assets/Backgrounds/shadow.png").CreateResizableImage(new UIEdgeInsets(2, 0, 2, 0)); this.AddSubview(shadow); this.ContentSize = new CGSize(frame.Width, modified.Frame.Bottom + 20); }
public ChapterView(String bookID, Chapter chapter, Int32 index) : base(new RectangleF(0, 0, 220, 388.33f)) { this.BackgroundColor = UIColor.Clear; this.Layer.ShadowColor = UIColor.Black.CGColor; this.Layer.ShadowOpacity = 0.3f; this.Layer.ShadowRadius = 2f; this.Layer.ShadowOffset = new SizeF(0f, 2f); this.Layer.ShadowPath = UIBezierPath.FromRoundedRect(this.Frame, 7f).CGPath; this.Layer.ShouldRasterize = true; this.Layer.RasterizationScale = UIScreen.MainScreen.Scale; this.BookChapter = chapter; // For rounded corner and shadow UIView subView = new UIView(new RectangleF(0, 0, 220, 388.33f)); subView.BackgroundColor = UIColor.White; subView.Layer.CornerRadius = 7f; subView.Layer.MasksToBounds = true; this.AddSubview(subView); // imageView UIImageView imageView = new UIImageView(); imageView.Frame = new RectangleF(0, 0, this.Frame.Width, 293.33f); String localImagePath = DownloadedFilesCache.BuildCachedFilePath(BookChapter.LargeImageURL); imageView.Image = UIImage.FromFile(localImagePath); imageView.ContentMode = UIViewContentMode.ScaleToFill; subView.AddSubview(imageView); // chapterLabel UILabel chapterLabel = new UILabel(); chapterLabel.Frame = new RectangleF(10, imageView.Frame.Bottom + 8, 200, 21); chapterLabel.Font = UIFont.SystemFontOfSize(14f); chapterLabel.TextAlignment = UITextAlignment.Left; chapterLabel.BackgroundColor = UIColor.Clear; chapterLabel.TextColor = UIColor.DarkGray; chapterLabel.Text = "Chapter " + (index + 1).ToString(); this.AddSubview(chapterLabel); // titleLabel UILabel titleLabel = new UILabel(); titleLabel.Frame = new RectangleF(10, chapterLabel.Frame.Bottom + 4, 200, 21); titleLabel.Font = UIFont.SystemFontOfSize(14f); titleLabel.BackgroundColor = UIColor.Clear; titleLabel.TextColor = UIColor.DarkGray; titleLabel.LineBreakMode = UILineBreakMode.TailTruncation; titleLabel.Text = chapter.Title; this.AddSubview(titleLabel); // bookInfoView String numNotes = "0"; String numBookmarks = "0"; String numAnnotations = "0"; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { numNotes = BooksOnDeviceAccessor.GetNumNotesInChapter(bookID, chapter.ID); numBookmarks = BooksOnDeviceAccessor.GetNumBookmarksInChapter(bookID, chapter.ID); numAnnotations = BooksOnDeviceAccessor.GetNumAnnotationsInChapter(bookID, chapter.ID); }; worker.RunWorkerCompleted += delegate { this.InvokeOnMainThread(delegate { BookInfoView bookInfoView = new BookInfoView(numNotes, numBookmarks, numAnnotations, chapter.Pagecount.ToString(), false, false, this.Frame.Width - 30); bookInfoView.Frame = new RectangleF(10, this.Frame.Bottom - 40, bookInfoView.Frame.Width, bookInfoView.Frame.Height); this.AddSubview(bookInfoView); }); }; worker.RunWorkerAsync(); }