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(); }; }
//Handles the click event of the bookmark button on the top toolbar private void BookmarkButton_TouchUpInside(object sender, EventArgs e) { if (bookmarkToolbar == null) { bookmarkToolbar = new BookmarkToolbar(this); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { if (bookmarkToolbar.Superview == null) { AddSubview(bookmarkToolbar); } else { bookmarkToolbar.RemoveFromSuperview(); } isBookmarkPaneVisible = !isBookmarkPaneVisible; annotHelper.RemoveAllToolbars(false); pdfViewerControl.AnnotationMode = AnnotationMode.None; isAnnotationToolbarVisible = false; } else { if (bookmarkToolbar.Superview == null) { AddSubview(bookmarkToolbar); } isBookmarkPaneVisible = true; } }
protected virtual UIView CreateSearchTopToolbar() { annotHelper.RemoveAllToolbars(false); toolBarFrame = Frame; toolBarFrame.Height = DefaultToolbarHeight; toolBarFrame.Y = 0; searchToolBar.Frame = toolBarFrame; searchToolBar.BackgroundColor = UIColor.FromRGB(249, 249, 249); searchToolBar.AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleWidth; if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { backButton.Frame = new CGRect(20, 2, 50, 50); } else { backButton.Frame = new CGRect(2, 5, 40, 40); } backButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; backButton.TouchUpInside += BackButtonClicked; backButton.Font = highFont; backButton.SetTitle("\ue71b", UIControlState.Normal); backButton.SetTitleColor(UIColor.FromRGB(0, 118, 255), UIControlState.Normal); searchToolBar.Add(backButton); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { searchBar.Frame = new CGRect(95, 5, 550, 40); } else { searchBar.Frame = new CGRect(40, 5, 210, 40); } searchBar.Placeholder = "Enter text to search"; searchBar.TextChanged += SearchBar_TextChanged; searchBar.SearchButtonClicked += SearchBar_SearchButtonClicked; searchToolBar.Add(searchBar); return(searchToolBar); }
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(); }; }