public AuthenticationSubView(CGRect frame) { this.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; try { // spinner RTSpinKitView spinner = eBriefingAppearance.GenerateBounceSpinner(); spinner.Frame = new CGRect(0, 0, spinner.Frame.Width, spinner.Frame.Height); this.AddSubview(spinner); // StatusLabel UILabel label = eBriefingAppearance.GenerateLabel(25, eBriefingAppearance.BlueColor); label.Frame = new CGRect(spinner.Frame.Right + 10, spinner.Center.Y - (40f / 2f), 300, 40); label.TextAlignment = UITextAlignment.Center; label.Text = StringRef.checkingConnection; label.SizeToFit(); label.Frame = new CGRect(label.Frame.X, label.Frame.Y, label.Frame.Width, 40); this.AddSubview(label); this.Frame = new CGRect(0, 0, label.Frame.Right, 40); } catch (Exception ex) { Logger.WriteLineDebugging("AuthenticationSubView - AuthenticationSubView: {0}", ex.ToString()); } }
public static RTSpinKitView GenerateBounceSpinner() { RTSpinKitView spinner = new RTSpinKitView(RTSpinKitViewStyle.ArcAlt); spinner.HidesWhenStopped = true; spinner.Color = eBriefingAppearance.BlueColor; spinner.StartAnimating(); return(spinner); }
private void InsertSpinnerOfStyle( RTSpinKitViewStyle style, UIColor backgroundColor, string labelString) { var screenBounds = UIScreen.MainScreen.Bounds; var screenWidth = screenBounds.Width; var spinner = new RTSpinKitView(style, UIColor.White); spinner.Center = new CGPoint(screenBounds.GetMidX(), screenBounds.GetMidY()); spinner.StartAnimating(); screenBounds.Offset(screenWidth * _numberOfSpinners, 0f); var panel = new UIView(screenBounds); panel.BackgroundColor = backgroundColor; panel.AddSubview(spinner); var label = new UILabel(new CGRect(0, 50, screenWidth, 30)); label.Text = labelString; label.Font = UIFont.SystemFontOfSize(25); label.TextColor = UIColor.White; if (label.RespondsToSelector(new ObjCRuntime.Selector("timeColor"))) { label.TextAlignment = UITextAlignment.Center; } else { label.TextAlignment = UITextAlignment.Center; label.BackgroundColor = UIColor.Clear; } panel.AddSubview(label); var scrollView = (UIScrollView)View; scrollView.AddSubview(panel); _numberOfSpinners += 1; }
public static void Show(String title, String message, bool showCancel = true) { if (alert == null || (alert != null && showCancel == true)) { if (showCancel) { alert = new UIAlertView(title, message, null, StringRef.cancel, null); } else { alert = new UIAlertView(title, message, null, null, null); } alert.Dismissed += HandleDismissed; UIView customView = new UIView(); customView.BackgroundColor = UIColor.Clear; customView.Frame = new CGRect(0, 0, 270, 48); try { RTSpinKitView spinner = eBriefingAppearance.GenerateBounceSpinner(); spinner.Frame = new CGRect(customView.Center.X - (spinner.Frame.Width / 2), 0, spinner.Frame.Width, spinner.Frame.Height); customView.AddSubview(spinner); } catch (Exception ex) { Logger.WriteLineDebugging("LoadingView - Show: {0}", ex.ToString()); } alert.SetValueForKey(customView, new NSString("accessoryView")); alert.Show(); } else { alert.Title = title; alert.Message = message; } }
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 BookshelfBookView(Book book, bool updateMenu, BookshelfViewController parentVC) : base(new CGRect(0, 0, 280, 280)) { this.BookshelfBook = book; this.updateMenu = updateMenu; 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); // recognizer this.AddGestureRecognizer(new UILongPressGestureRecognizer(this, new Selector("HandleLongPress:"))); if (!String.IsNullOrEmpty(BookshelfBook.LargeImageURL)) { // imageSpinner imageSpinner = eBriefingAppearance.GenerateBounceSpinner(); imageSpinner.Center = imageView.Center; this.AddSubview(imageSpinner); // Download image bool exist = FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC); if (exist) { bool outDated = false; var item = BooksOnDeviceAccessor.GetBook(BookshelfBook.ID); if (item != null) { if (item.ImageVersion < BookshelfBook.ImageVersion) { DownloadedFilesCache.RemoveFile(item.LargeImageURL); DownloadedFilesCache.RemoveFile(item.SmallImageURL); outDated = true; } } if (outDated) { FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC, true); } else { UpdateImage(BookshelfBook.LargeImageURL); } } } // favoriteView if (BooksDataAccessor.IsFavorite(book.ID)) { AddFavorite(); } if (book.New) { AddRibbon(); } // titleLabel 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); UpdateUI(); }
private void UpdateUI() { if (BookshelfBook.Status == Book.BookStatus.DOWNLOADED || BookshelfBook.Status == Book.BookStatus.ISUPDATE) { if (downloadSpinner != null) { downloadSpinner.StopAnimating(); downloadSpinner.RemoveFromSuperview(); downloadSpinner.Dispose(); downloadSpinner = null; } if (downloadLabel != null) { downloadLabel.RemoveFromSuperview(); downloadLabel.Dispose(); downloadLabel = null; } if (progressView != null) { progressView.RemoveFromSuperview(); progressView.Dispose(); progressView = null; } // bookInfoView if (bookInfoView == null) { UpdateBookInfo(); } if (BookshelfBook.Status == Book.BookStatus.DOWNLOADED) { // descriptionLabel if (descriptionLabel == null) { descriptionLabel = eBriefingAppearance.GenerateLabel(14, eBriefingAppearance.Gray2); descriptionLabel.Frame = new CGRect(10, titleLabel.Frame.Bottom + 4, 260, 42); descriptionLabel.Lines = 2; descriptionLabel.Text = BookshelfBook.Description; descriptionLabel.Alpha = 0f; this.AddSubview(descriptionLabel); } } else { // updateButton if (updateButton == null) { updateButton = UIButton.FromType(UIButtonType.Custom); updateButton.Font = eBriefingAppearance.ThemeBoldFont(14); updateButton.SetTitleColor(eBriefingAppearance.Color("37b878"), UIControlState.Normal); updateButton.SetTitleColor(UIColor.White, UIControlState.Highlighted); updateButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(0, 14f, 0, 14f)), UIControlState.Normal); updateButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(0, 14f, 0, 14f)), UIControlState.Highlighted); updateButton.Frame = new CGRect(this.Center.X - 65, bookInfoView.Frame.Top - 28, 130, updateButton.CurrentBackgroundImage.Size.Height); updateButton.SetTitle("UPDATE", UIControlState.Normal); updateButton.TouchUpInside += HandleUpdateButtonTouchUpInside; this.AddSubview(updateButton); } } ShowHideInfo(1f); } else { // downloadSpinner if (downloadSpinner == null) { downloadSpinner = eBriefingAppearance.GenerateBounceSpinner(); downloadSpinner.Frame = new CGRect(10, (this.Frame.Bottom - 50), downloadSpinner.Frame.Width, downloadSpinner.Frame.Height); this.AddSubview(downloadSpinner); } // downloadLabel if (downloadLabel == null) { downloadLabel = eBriefingAppearance.GenerateLabel(17); downloadLabel.Frame = new CGRect(downloadSpinner.Frame.Right + 8, downloadSpinner.Frame.Y + 2, this.Frame.Width - (downloadSpinner.Frame.Right + 8) - 10, 21); this.AddSubview(downloadLabel); UpdateDownloadLabel(); } // progressView if (progressView == null) { progressView = new UIProgressView(UIProgressViewStyle.Default); progressView.Frame = new CGRect(downloadLabel.Frame.X, downloadLabel.Frame.Bottom + 8, downloadLabel.Frame.Width, progressView.Frame.Height); progressView.ProgressTintColor = eBriefingAppearance.BlueColor; progressView.Progress = BookshelfBook.DownloadProgress; this.AddSubview(progressView); } } }
async private void GenerateThumbnail(String bookID, String pageID, String text, bool bookmark = false) { try { // spinner RTSpinKitView spinner = eBriefingAppearance.GenerateBounceSpinner(); spinner.Center = this.Center; this.AddSubview(spinner); // Generate pdf thumbnail Page page = await eBriefingService.Run(() => BooksOnDeviceAccessor.GetPage(bookID, pageID)); Annotation annotation = null; if (String.IsNullOrEmpty(text)) { annotation = await eBriefingService.Run(() => BooksOnDeviceAccessor.GetAnnotation(bookID, pageID)); } spinner.StopAnimating(); if (page != null) { String localPath = DownloadedFilesCache.BuildCachedFilePath(page.URL); if (!String.IsNullOrEmpty(localPath)) { CGPDFDocument pdfDoc = CGPDFDocument.FromFile(localPath); if (pdfDoc != null) { CGPDFPage pdfPage = pdfDoc.GetPage(1); if (pdfPage != null) { UIImage pdfImg = ImageHelper.PDF2Image(pdfPage, this.Frame.Width, UIScreen.MainScreen.Scale); // pageView UIImageView pageView = new UIImageView(); pageView.Frame = new CGRect(0, (this.Frame.Height / 2) - (pdfImg.Size.Height / 2), pdfImg.Size.Width, pdfImg.Size.Height); // If this is annotation thumbnail, draw annotation overlay on top of pdf if (annotation != null) { Dictionary <String, PSPDFInkAnnotation> dictionary = AnnotationsDataAccessor.GenerateAnnDictionary((nuint)page.PageNumber - 1, annotation); if (dictionary != null) { foreach (KeyValuePair <String, PSPDFInkAnnotation> item in dictionary) { // Create full size annotation UIImage annImg = ImageHelper.DrawPSPDFAnnotation(item.Key, item.Value); if (annImg != null) { // Scale down the annotation image annImg = annImg.Scale(new CGSize(pdfImg.Size.Width, pdfImg.Size.Height)); // Overlap pdfImg and annImg pdfImg = ImageHelper.Overlap(pdfImg, annImg, CGPoint.Empty, CGPoint.Empty, UIScreen.MainScreen.Scale); } } } } pageView.Image = pdfImg; this.AddSubview(pageView); if (pdfImg.Size.Height < this.Frame.Height) { this.BackgroundColor = UIColor.Clear; } // THIS IS REQUIRED TO SKIP iCLOUD BACKUP SkipBackup2iCloud.SetAttribute(localPath); // Add ribbon if this is bookmark thumbnail if (bookmark) { UIImageView ribbon = new UIImageView(); ribbon.Image = UIImage.FromBundle("Assets/Buttons/bookmark_solid.png"); ribbon.Frame = new CGRect(pageView.Frame.Right - 35, pageView.Frame.Y, 25, 33.78f); this.AddSubview(ribbon); } // Do not add text if this is annotation thumbnail if (!String.IsNullOrEmpty(text)) { // titleLabel UILabel titleLabel = eBriefingAppearance.GenerateLabel(16); titleLabel.Frame = new CGRect(0, pageView.Frame.Bottom + 4, this.Frame.Width, 42); titleLabel.Lines = 2; titleLabel.LineBreakMode = UILineBreakMode.TailTruncation; titleLabel.TextAlignment = UITextAlignment.Center; titleLabel.Text = text; this.AddSubview(titleLabel); } } } } } } catch (Exception ex) { Logger.WriteLineDebugging("ThumbnailView - GenerateThumbnail: {0}", ex.ToString()); } }
private void InitializeControls() { this.View.BackgroundColor = UIColor.Clear; this.View.Layer.ShadowPath = UIBezierPath.FromRoundedRect(this.View.Frame, 7f).CGPath; this.View.Layer.ShouldRasterize = true; this.View.Layer.RasterizationScale = UIScreen.MainScreen.Scale; // For rounded corner and shadow UIView subView = new UIView(new CGRect(0, 0, FRAME_WIDTH, FRAME_HEIGHT)); subView.BackgroundColor = UIColor.White; subView.Layer.CornerRadius = 7f; subView.Layer.MasksToBounds = true; this.View.AddSubview(subView); // imageView imageView = new UIImageView(); imageView.BackgroundColor = eBriefingAppearance.Gray3; imageView.Frame = new CGRect(20, 20, 280, 150); subView.AddSubview(imageView); // spinner1 spinner1 = eBriefingAppearance.GenerateBounceSpinner(); spinner1.Center = imageView.Center; subView.AddSubview(spinner1); // titleLabel titleLabel = eBriefingAppearance.GenerateLabel(21); titleLabel.Text = book.Title; titleLabel.Frame = new CGRect(319, 20, 307, 52); titleLabel.Lines = 0; titleLabel.SizeToFit(); if (titleLabel.Frame.Height > 78f) { titleLabel.Frame = new CGRect(titleLabel.Frame.X, titleLabel.Frame.Y, titleLabel.Frame.Width, 78); } subView.AddSubview(titleLabel); // pageLabel pageLabel = eBriefingAppearance.GenerateLabel(14); pageLabel.Text = "Number of Pages : " + book.PageCount.ToString(); pageLabel.Frame = new CGRect(titleLabel.Frame.X, titleLabel.Frame.Bottom + 8, 307, 21); subView.AddSubview(pageLabel); // dateLabel dateLabel = eBriefingAppearance.GenerateLabel(14); dateLabel.Text = "Last Modified : " + book.ServerModifiedDate.ToString(); dateLabel.Frame = new CGRect(titleLabel.Frame.X, pageLabel.Frame.Bottom + 8, 307, 21); subView.AddSubview(dateLabel); // downloadButton 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_unfilled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Highlighted); downloadButton.Frame = new CGRect(titleLabel.Frame.X, 142, 130, downloadButton.CurrentBackgroundImage.Size.Height); if (isUpdate) { downloadButton.SetTitle("UPDATE", UIControlState.Normal); } else { downloadButton.SetTitle("DOWNLOAD", UIControlState.Normal); } downloadButton.TouchUpInside += HandleDownloadButtonTouchUpInside; subView.AddSubview(downloadButton); // segmentedControl segmentedControl = new UISegmentedControl(new object[] { "Description", "Chapters" }); segmentedControl.Frame = new CGRect((FRAME_WIDTH / 2) - (226 / 2), imageView.Frame.Bottom + 20, 226, 29); segmentedControl.SelectedSegment = 0; segmentedControl.ValueChanged += HandleValueChanged; segmentedControl.TintColor = eBriefingAppearance.Color("848484"); segmentedControl.Enabled = false; subView.AddSubview(segmentedControl); // line UIView line = new UIView(); line.Frame = new CGRect(0, segmentedControl.Frame.Bottom + 19, FRAME_WIDTH, 1); line.BackgroundColor = eBriefingAppearance.Color("b4b4b4"); subView.AddSubview(line); UIView subView2 = new UIView(new CGRect(0, line.Frame.Bottom, FRAME_WIDTH, FRAME_HEIGHT - line.Frame.Bottom)); subView2.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("Assets/Backgrounds/background_portrait.png")); subView.AddSubview(subView2); // textView textView = new UITextView(); textView.Frame = new CGRect(0, 0, subView2.Frame.Width, subView2.Frame.Height); textView.Font = eBriefingAppearance.ThemeRegularFont(17); textView.Text = book.Description; textView.Editable = false; textView.BackgroundColor = UIColor.Clear; textView.TextContainerInset = new UIEdgeInsets(15, 10, 20, 10); textView.TextColor = eBriefingAppearance.Gray1; subView2.AddSubview(textView); // tableView tableView = new UITableView(); tableView.Frame = textView.Frame; tableView.BackgroundColor = UIColor.Clear; tableView.ContentInset = new UIEdgeInsets(5, 0, 10, 0); tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; subView2.AddSubview(tableView); // spinner2 spinner2 = eBriefingAppearance.GenerateBounceSpinner(); spinner2.Center = tableView.Center; subView2.AddSubview(spinner2); }