public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow(UIScreen.MainScreen.Bounds); viewController = new KSStapleMenuViewController(); window.RootViewController = viewController; window.MakeKeyAndVisible(); var txt = new UITextField(new RectangleF(0, 0, 400, 30)); txt.TextAlignment = UITextAlignment.Center; viewController.View.AddSubview(txt); txt.Center = new PointF(viewController.View.Center.X, viewController.View.Center.Y + 60); // Create a new annotation/sync/review selection toolbar. var stapleMenu = new KSStapleMenu(KSStapleMenu.STAPLEMENU_MODE.Right, 80f, new SizeF(80f, 80f)); KSStapleMenuItem inkItem = null; KSStapleMenuItem noteItem = null; KSStapleMenuItem freetextItem = null; KSStapleMenuItem hilightItem = null; inkItem = new KSStapleMenuItem("INK", UIImage.FromBundle("Assets/Images/PDF/annot-ink-0"), "Ink 0", 12f, UIColor.Black); for (int i = 1; i <= 3; i++) { inkItem.AddElement(UIImage.FromBundle("Assets/Images/PDF/annot-ink-" + i), "Ink " + i, 12f, UIColor.Black); } hilightItem = new KSStapleMenuItem("HIGHLIGHT", UIImage.FromBundle("Assets/Images/PDF/annot-highlight-0"), "Highlight 0", 12f, UIColor.Black); for (int i = 1; i <= 3; i++) { hilightItem.AddElement(UIImage.FromBundle("Assets/Images/PDF/annot-highlight-" + i), "Highlight " + i, 12f, UIColor.Black); } noteItem = new KSStapleMenuItem("NOTE", UIImage.FromBundle("Assets/Images/PDF/annot-note"), "Note", 12f, UIColor.Black); freetextItem = new KSStapleMenuItem("FREETEXT", UIImage.FromBundle("Assets/Images/PDF/annot-freetext"), "Freetext", 12f, UIColor.Black); KSStapleMenuItem syncItem = null; KSStapleMenuItem switchReviewsItem = null; // Only show sync and review selection button if server side reviews are enabled and the user has permissions to annotate. syncItem = new KSStapleMenuItem("SYNC", UIImage.FromBundle("Assets/Images/PDF/annot-sync"), "Sync", 12f, UIColor.Black); switchReviewsItem = new KSStapleMenuItem("REVIEWS", UIImage.FromBundle("Assets/Images/PDF/reviewselect"), "Switch", 12f, UIColor.Black); stapleMenu.AddItems(inkItem, hilightItem, noteItem, freetextItem, syncItem, switchReviewsItem); // Add a callback to get informed if an element was tapped. stapleMenu.ItemSelected += (string id, int index) => { Console.WriteLine("Selected item {0} with index {1}", id, index); txt.Text = string.Format("Selected item {0} with index {1}", id, index); }; viewController.View.AddSubview(stapleMenu); return(true); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); viewController = new KSStapleMenuViewController (); window.RootViewController = viewController; window.MakeKeyAndVisible (); var txt = new UITextField(new RectangleF(0, 0, 400, 30)); txt.TextAlignment = UITextAlignment.Center; viewController.View.AddSubview(txt); txt.Center = new PointF (viewController.View.Center.X, viewController.View.Center.Y + 60); // Create a new annotation/sync/review selection toolbar. var stapleMenu = new KSStapleMenu ( KSStapleMenu.STAPLEMENU_MODE.Right, 80f, new SizeF ( 80f, 80f ) ); KSStapleMenuItem inkItem = null; KSStapleMenuItem noteItem = null; KSStapleMenuItem freetextItem = null; KSStapleMenuItem hilightItem = null; inkItem = new KSStapleMenuItem ( "INK", UIImage.FromBundle ( "Assets/Images/PDF/annot-ink-0" ), "Ink 0", 12f, UIColor.Black ); for ( int i = 1; i <= 3; i++ ) { inkItem.AddElement ( UIImage.FromBundle ( "Assets/Images/PDF/annot-ink-" + i ), "Ink " + i, 12f, UIColor.Black ); } hilightItem = new KSStapleMenuItem ( "HIGHLIGHT", UIImage.FromBundle ( "Assets/Images/PDF/annot-highlight-0" ), "Highlight 0", 12f, UIColor.Black ); for ( int i = 1; i <= 3; i++ ) { hilightItem.AddElement ( UIImage.FromBundle ( "Assets/Images/PDF/annot-highlight-" + i ), "Highlight " + i, 12f, UIColor.Black ); } noteItem = new KSStapleMenuItem ( "NOTE", UIImage.FromBundle ( "Assets/Images/PDF/annot-note" ), "Note", 12f, UIColor.Black ); freetextItem = new KSStapleMenuItem ( "FREETEXT", UIImage.FromBundle ( "Assets/Images/PDF/annot-freetext" ), "Freetext", 12f, UIColor.Black ); KSStapleMenuItem syncItem = null; KSStapleMenuItem switchReviewsItem = null; // Only show sync and review selection button if server side reviews are enabled and the user has permissions to annotate. syncItem = new KSStapleMenuItem ( "SYNC", UIImage.FromBundle ( "Assets/Images/PDF/annot-sync" ), "Sync", 12f, UIColor.Black ); switchReviewsItem = new KSStapleMenuItem ( "REVIEWS", UIImage.FromBundle ( "Assets/Images/PDF/reviewselect" ), "Switch", 12f, UIColor.Black ); stapleMenu.AddItems ( inkItem, hilightItem, noteItem, freetextItem, syncItem, switchReviewsItem ); // Add a callback to get informed if an element was tapped. stapleMenu.ItemSelected += (string id, int index) => { Console.WriteLine ("Selected item {0} with index {1}", id, index); txt.Text = string.Format ("Selected item {0} with index {1}", id, index); }; viewController.View.AddSubview (stapleMenu); return true; }
/// <summary> /// Initializes a new instance of the <see cref="KSStapleMenu.KSMenuItemHostView"/> class. /// </summary> /// <param name="menu">the menu that is using this view</param> /// <param name="menuItem">the item encapsulated by the host view</param> internal KSMenuItemHostView(KSStapleMenu menu, KSStapleMenuItem menuItem) : base() { this.menu = menu; this.ItemId = menuItem.Id; // this.BackgroundColor = UIColor.Blue; // this.Layer.BorderColor = UIColor.Yellow.CGColor; // this.Layer.BorderWidth = 2f; if (menuItem.NumberOfElements > 1) { this.expandIndicatorView = new ExpandIndicatorView(new RectangleF(0, 0, 8, 16)) { BackgroundColor = UIColor.Clear, }; this.AddSubview(this.expandIndicatorView); } }
/// <summary> /// Initializes a new instance of the <see cref="KSStapleMenu.KSMenuItemHostView"/> class. /// </summary> /// <param name="menu">the menu that is using this view</param> /// <param name="menuItem">the item encapsulated by the host view</param> internal KSMenuItemHostView(KSStapleMenu menu, KSStapleMenuItem menuItem) : base() { this.menu = menu; this.ItemId = menuItem.Id; // this.BackgroundColor = UIColor.Blue; // this.Layer.BorderColor = UIColor.Yellow.CGColor; // this.Layer.BorderWidth = 2f; if(menuItem.NumberOfElements > 1) { this.expandIndicatorView = new ExpandIndicatorView(new RectangleF(0, 0, 8, 16)) { BackgroundColor = UIColor.Clear, }; this.AddSubview(this.expandIndicatorView); } }
public KSStapleMenuBlurView(KSStapleMenu menu) : base() { this.menu = menu; this.BackgroundColor = UIColor.LightGray; this.Layer.CornerRadius = 15f; this.gradientLayer = new CAGradientLayer(); if (menu.Mode == KSStapleMenu.STAPLEMENU_MODE.Left) { this.gradientLayer.Colors = new CGColor[] { UIColor.FromRGB(0.4f, 0.4f, 0.4f).CGColor, UIColor.FromRGB(0.9f, 0.9f, 0.9f).CGColor }; } else { this.gradientLayer.Colors = new CGColor[] { UIColor.FromRGB(0.9f, 0.9f, 0.9f).CGColor, UIColor.FromRGB(0.4f, 0.4f, 0.4f).CGColor }; } this.gradientLayer.Opacity = 0.8f; this.gradientLayer.StartPoint = new PointF(0f, 0.5f); this.gradientLayer.EndPoint = new PointF(1f, 0.5f); this.Layer.AddSublayer(this.gradientLayer); }
public KSStapleMenuBlurView(KSStapleMenu menu) : base() { this.menu = menu; this.BackgroundColor = UIColor.LightGray; this.Layer.CornerRadius = 15f; this.gradientLayer = new CAGradientLayer(); if(menu.Mode == KSStapleMenu.STAPLEMENU_MODE.Left) { this.gradientLayer.Colors = new CGColor[] { UIColor.FromRGB(0.4f, 0.4f, 0.4f).CGColor, UIColor.FromRGB(0.9f, 0.9f, 0.9f).CGColor }; } else { this.gradientLayer.Colors = new CGColor[] { UIColor.FromRGB(0.9f, 0.9f, 0.9f).CGColor, UIColor.FromRGB(0.4f, 0.4f, 0.4f).CGColor }; } this.gradientLayer.Opacity = 0.8f; this.gradientLayer.StartPoint = new PointF(0f, 0.5f); this.gradientLayer.EndPoint = new PointF(1f, 0.5f); this.Layer.AddSublayer(this.gradientLayer); }