public CustomToolbar() { parentView = new UIView(this.Frame); var tap = new UITapGestureRecognizer(OnSingleTap); tap.CancelsTouchesInView = false; //for iOS5 highFont = UIFont.FromName("Final_PDFViewer_IOS_FontUpdate", 30); this.AddGestureRecognizer(tap); helper = new TextMarkupAnnotationHelper(this); inkHelper = new InkAnnotationHelper(this); annotHelper = new AnnotationHelper(this); opacitybutton.TouchUpInside += inkHelper.Opacitybutton_TouchUpInside; pdfViewerControl = new SfPdfViewer(); pdfViewerControl.Toolbar.Enabled = false; pdfViewerControl.PageChanged += ViewerControl_PageChanged; pdfViewerControl.SearchCompleted += PdfViewerControl_SearchCompleted; pdfViewerControl.TextMarkupSelected += helper.PdfViewerControl_TextMarkupSelected; pdfViewerControl.TextMarkupDeselected += helper.PdfViewerControl_TextMarkupDeselected; pdfViewerControl.CanUndoModified += PdfViewerControl_CanUndoModified; pdfViewerControl.CanRedoModified += PdfViewerControl_CanRedoModified; pdfViewerControl.CanUndoInkModified += inkHelper.PdfViewerControl_CanUndoInkModified; pdfViewerControl.CanRedoInkModified += inkHelper.PdfViewerControl_CanRedoInkModified; pdfViewerControl.InkSelected += inkHelper.PdfViewerControl_InkSelected; pdfViewerControl.InkDeselected += inkHelper.PdfViewerControl_InkDeselected; BoldBtn1.TouchUpInside += inkHelper.BoldColorBtn1_TouchUpInside; BoldColorBtn1.TouchUpInside += inkHelper.BoldColorBtn1_TouchUpInside; BoldBtn2.TouchUpInside += inkHelper.BoldColorBtn2_TouchUpInside; BoldColorBtn2.TouchUpInside += inkHelper.BoldColorBtn2_TouchUpInside; BoldBtn3.TouchUpInside += inkHelper.BoldColorBtn3_TouchUpInside; BoldColorBtn3.TouchUpInside += inkHelper.BoldColorBtn3_TouchUpInside; BoldColorBtn4.TouchUpInside += inkHelper.BoldColorBtn4_TouchUpInside; BoldBtn4.TouchUpInside += inkHelper.BoldColorBtn4_TouchUpInside; BoldColorBtn5.TouchUpInside += inkHelper.BoldColorBtn5_TouchUpInside; BoldBtn5.TouchUpInside += inkHelper.BoldColorBtn5_TouchUpInside; inkColorButton.TouchUpInside += helper.ColorButton_TouchUpInside; colorButton.TouchUpInside += helper.ColorButton_TouchUpInside; inkAnnotationButton.TouchUpInside += inkHelper.InkAnnotationButton_TouchUpInside; inkThicknessButton.TouchUpInside += inkHelper.InkThicknessButton_TouchUpInside; pageNumberField.Text = "1"; CreateTopToolbar(); bottomToolBar = CreateBottomToolbar(); toolbar = toolBar; parentView.AddSubview(pdfViewerControl); AddSubview(parentView); AddSubview(toolbar); AddSubview(bottomToolBar); activityDialog = new ActivityIndicator(); activityDialog.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 125, UIScreen.MainScreen.Bounds.Height / 2 - 50, 250, 100); popUpAlertView = new UIAlertView(); dropDownMenu = CreateDropDownMenu(); dropDownMenu.DropDownMenuItemChanged += (e, a) => { fileStream = typeof(CustomToolbar).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDFViewer.Assets." + a.DisplayText + ".pdf"); pdfViewerControl.LoadDocument(fileStream); ResetToolBar(); annotHelper.RemoveAllToolbars(false); dropDownMenu.Close(); }; }
protected virtual UIView CreateTopToolbar() { toolBarFrame = this.Frame; toolBarFrame.Height = DefaultToolbarHeight; toolBarFrame.Y = 0; toolBar.Frame = toolBarFrame; toolBar.BackgroundColor = UIColor.FromRGB(249, 249, 249); toolBar.AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleWidth; if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { fileButton.Frame = new CGRect(10, 7, 35, 35); } else { fileButton.Frame = new CGRect(5, 7, 35, 35); } fileButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; fileButton.TouchUpInside += (e, a) => { if (dropDownMenu.IsOpened) { dropDownMenu.Close(); } else { dropDownMenu.Open(); } }; fileButton.Font = highFont; fileButton.SetTitle("\ue71d", UIControlState.Normal); fileButton.SetTitleColor(UIColor.FromRGB(0, 118, 255), UIControlState.Normal); toolBar.Add(fileButton); saveButton.Frame = new CGRect(55, 7, 35, 35); saveButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; saveButton.TouchUpInside += annotHelper.SaveButton_TouchUpInside; saveButton.Font = highFont; saveButton.SetTitle("\ue718", UIControlState.Normal); saveButton.SetTitleColor(UIColor.FromRGB(0, 118, 255), UIControlState.Normal); toolBar.Add(saveButton); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { undoButton.Frame = new CGRect(parentView.Frame.Width / 2 - 25, 7, 35, 35); } else { undoButton.Frame = new CGRect(130, 7, 35, 35); } undoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; undoButton.TouchUpInside += UndoButton_TouchUpInside;; undoButton.Font = highFont; undoButton.SetTitle("\ue70a", UIControlState.Normal); undoButton.SetTitleColor(UIColor.LightGray, UIControlState.Normal); toolBar.Add(undoButton); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { redoButton.Frame = new CGRect(parentView.Frame.Width / 2 + 10, 7, 35, 35); } else { redoButton.Frame = new CGRect(175, 7, 35, 35); } redoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; redoButton.TouchUpInside += RedoButton_TouchUpInside;; redoButton.Font = highFont; redoButton.SetTitle("\ue716", UIControlState.Normal); redoButton.SetTitleColor(UIColor.LightGray, UIControlState.Normal); toolBar.Add(redoButton); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { bookmarkButton.Frame = new CGRect(parentView.Frame.Width - 50, 7, 35, 35); } else { bookmarkButton.Frame = new CGRect(parentView.Frame.Width - 55, 7, 35, 35); } bookmarkButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; bookmarkButton.TouchUpInside += BookmarkButton_TouchUpInside; bookmarkButton.Font = bookmarkFont; bookmarkButton.SetTitle("\ue701", UIControlState.Normal); bookmarkButton.SetTitleColor(UIColor.FromRGB(0, 118, 255), UIControlState.Normal); toolBar.Add(bookmarkButton); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { searchButton.Frame = new CGRect(parentView.Frame.Width - 50, 7, 35, 35); } else { searchButton.Frame = new CGRect(parentView.Frame.Width - 10, 7, 35, 35); } searchButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; searchButton.TouchUpInside += SearchButtonClicked; searchButton.Font = highFont; searchButton.SetTitle("\ue719", UIControlState.Normal); searchButton.SetTitleColor(UIColor.FromRGB(0, 118, 255), UIControlState.Normal); toolBar.Add(searchButton); return(toolBar); }
public CustomToolbar() { parentView = new UIView(this.Frame); initialStream = typeof(CustomToolbar).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDFViewer.Assets.F# Succinctly.pdf"); loadedDocument = new PdfLoadedDocument(initialStream); PopulateInitialBookmarkList(); var tap = new UITapGestureRecognizer(OnSingleTap); tap.CancelsTouchesInView = false; //for iOS5 highFont = UIFont.FromName("Final_PDFViewer_IOS_FontUpdate", 30); fontSizeFont = UIFont.FromName("Font size Font", 30); signatureFont = UIFont.FromName("Signature_PDFViewer_FONT", 30); //Font that defines the icons for the bookmark toolbar buttons bookmarkFont = UIFont.FromName("PdfViewer_FONT", 30); this.AddGestureRecognizer(tap); helper = new TextMarkupAnnotationHelper(this); inkHelper = new InkAnnotationHelper(this); annotHelper = new AnnotationHelper(this); rangeSlider = new SfRangeSlider(); edittextHelper = new EditTextAnnotationHelper(this); shapeHelper = new ShapeAnnotationHelper(this); opacitybutton.TouchUpInside += inkHelper.Opacitybutton_TouchUpInside; pdfViewerControl = new SfPdfViewer(); pdfViewerControl.Toolbar.Enabled = false; pdfViewerControl.PageChanged += ViewerControl_PageChanged; pdfViewerControl.TextMarkupSelected += helper.PdfViewerControl_TextMarkupSelected; pdfViewerControl.TextMarkupDeselected += helper.PdfViewerControl_TextMarkupDeselected; pdfViewerControl.CanUndoModified += PdfViewerControl_CanUndoModified; pdfViewerControl.CanRedoModified += PdfViewerControl_CanRedoModified; pdfViewerControl.CanUndoInkModified += inkHelper.PdfViewerControl_CanUndoInkModified; pdfViewerControl.CanRedoInkModified += inkHelper.PdfViewerControl_CanRedoInkModified; pdfViewerControl.InkSelected += inkHelper.PdfViewerControl_InkSelected; pdfViewerControl.InkDeselected += inkHelper.PdfViewerControl_InkDeselected; pdfViewerControl.FreeTextAnnotationAdded += edittextHelper.PdfViewerControl_FreeTextAnnotationAdded; pdfViewerControl.FreeTextAnnotationDeselected += edittextHelper.PdfViewerControl_FreeTextAnnotationDeselected; pdfViewerControl.FreeTextAnnotationSelected += edittextHelper.PdfViewerControl_FreeTextAnnotationSelected; pdfViewerControl.FreeTextPopupDisappeared += edittextHelper.PdfViewerControl_FreeTextPopupDisappearing; pdfViewerControl.ShapeAnnotationSelected += shapeHelper.PdfViewerControl_ShapeAnnotationSelected; pdfViewerControl.ShapeAnnotationDeselected += shapeHelper.PdfViewerControl_ShapeAnnotationDeselected; BoldBtn1.TouchUpInside += inkHelper.BoldColorBtn1_TouchUpInside; BoldColorBtn1.TouchUpInside += inkHelper.BoldColorBtn1_TouchUpInside; BoldBtn2.TouchUpInside += inkHelper.BoldColorBtn2_TouchUpInside; BoldColorBtn2.TouchUpInside += inkHelper.BoldColorBtn2_TouchUpInside; BoldBtn3.TouchUpInside += inkHelper.BoldColorBtn3_TouchUpInside; BoldColorBtn3.TouchUpInside += inkHelper.BoldColorBtn3_TouchUpInside; BoldColorBtn4.TouchUpInside += inkHelper.BoldColorBtn4_TouchUpInside; BoldBtn4.TouchUpInside += inkHelper.BoldColorBtn4_TouchUpInside; BoldColorBtn5.TouchUpInside += inkHelper.BoldColorBtn5_TouchUpInside; BoldBtn5.TouchUpInside += inkHelper.BoldColorBtn5_TouchUpInside; inkColorButton.TouchUpInside += helper.ColorButton_TouchUpInside; colorButton.TouchUpInside += helper.ColorButton_TouchUpInside; inkAnnotationButton.TouchUpInside += inkHelper.InkAnnotationButton_TouchUpInside; inkThicknessButton.TouchUpInside += inkHelper.InkThicknessButton_TouchUpInside; shapeThicknessButton.TouchUpInside += inkHelper.InkThicknessButton_TouchUpInside; edittextThicknessButton.TouchUpInside += edittextHelper.EditTextThicknessButton_TouchUpInside; edittextColorButton.TouchUpInside += helper.ColorButton_TouchUpInside; shapeColorButton.TouchUpInside += helper.ColorButton_TouchUpInside; pageNumberField.Text = "1"; CreateTopToolbar(); bottomToolBar = CreateBottomToolbar(); toolbar = toolBar; parentView.AddSubview(pdfViewerControl); AddSubview(parentView); AddSubview(toolbar); AddSubview(bottomToolBar); topBorder.BackgroundColor = UIColor.FromRGBA(red: 0.86f, green: 0.86f, blue: 0.86f, alpha: 1.0f); AddSubview(topBorder); activityDialog = new ActivityIndicator(); activityDialog.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 125, UIScreen.MainScreen.Bounds.Height / 2 - 50, 250, 100); popUpAlertView = new UIAlertView(); dropDownMenu = CreateDropDownMenu(); dropDownMenu.DropDownMenuItemChanged += (e, a) => { fileStream = typeof(CustomToolbar).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDFViewer.Assets." + a.DisplayText + ".pdf"); loadedDocument = new PdfLoadedDocument(fileStream); PopulateInitialBookmarkList(); pdfViewerControl.LoadDocument(fileStream); isBookmarkPaneVisible = false; if (bookmarkToolbar != null && bookmarkToolbar.Superview != null) { bookmarkToolbar.RemoveFromSuperview(); } ResetToolBar(); annotHelper.RemoveAllToolbars(false); dropDownMenu.Close(); }; }