Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // create the custom toolbar and add it on top of the HUDView.
            this.verticalToolbar = new KSStapleMenu(KSStapleMenu.STAPLEMENU_MODE.Right, 80f, new SizeF(80f, 80f));
            this.verticalToolbar.BackgroundColor = UIColor.White;

            var inkItem = new KSStapleMenuItem("INK", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-0"), "Red", 12f, UIColor.Black);

            inkItem.AddElement(UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-1"), "Green", 12f, UIColor.Black);
            inkItem.AddElement(UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-2"), "Blue", 12f, UIColor.Black);

            var noteItem = new KSStapleMenuItem("NOTE", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-note"), "Note", 12f, UIColor.Black);

            var freetextItem = new KSStapleMenuItem("FREETEXT", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-freetext"), "Freetext", 12f, UIColor.Black);

            var hilightItem = new KSStapleMenuItem("HIGHLIGHT", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-0"), "Red", 12f, UIColor.Black);

            hilightItem.AddElement(UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-1"), "Green", 12f, UIColor.Black);
            hilightItem.AddElement(UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-2"), "Blue", 12f, UIColor.Black);

            this.verticalToolbar.AddItems(inkItem, noteItem, freetextItem, hilightItem);
            this.verticalToolbar.ItemSelected += HandleAnnotationToolbarItemSelected;
            this.HUDView.AddSubview(this.verticalToolbar);

            // Setup our own annotation toolbar delegate that hides the annotation toolbar.
            this.AnnotationButtonItem.AnnotationToolbar.Delegate = new KSVerticalAnnotationToolbarDelegate();

            this.AnnotationButtonItem.AnnotationToolbar.HideAfterDrawingDidFinish = true;
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// create the custom toolbar and add it on top of the HUDView.
			this.verticalToolbar = new KSStapleMenu(KSStapleMenu.STAPLEMENU_MODE.Right, 80f, new SizeF(80f, 80f));
			this.verticalToolbar.BackgroundColor = UIColor.White;
			
			var inkItem = new KSStapleMenuItem("INK", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-0"), "Red", 12f, UIColor.Black);
			inkItem.AddElement( UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-1"), "Green", 12f, UIColor.Black);
			inkItem.AddElement( UIImage.FromBundle("ResourceData/VerticalToolbar/annot-ink-2"), "Blue", 12f, UIColor.Black);

			var noteItem = new KSStapleMenuItem("NOTE", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-note"), "Note", 12f, UIColor.Black);

			var freetextItem = new KSStapleMenuItem("FREETEXT", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-freetext"), "Freetext", 12f, UIColor.Black);
			
			var hilightItem = new KSStapleMenuItem("HIGHLIGHT", UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-0"), "Red", 12f, UIColor.Black);
			hilightItem.AddElement( UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-1"), "Green", 12f, UIColor.Black);
			hilightItem.AddElement( UIImage.FromBundle("ResourceData/VerticalToolbar/annot-highlight-2"), "Blue", 12f, UIColor.Black);

			this.verticalToolbar.AddItems(inkItem, noteItem, freetextItem, hilightItem);
			this.verticalToolbar.ItemSelected += HandleAnnotationToolbarItemSelected;
			this.HUDView.AddSubview(this.verticalToolbar);
			
			// Setup our own annotation toolbar delegate that hides the annotation toolbar.
			this.AnnotationButtonItem.AnnotationToolbar.Delegate = new KSVerticalAnnotationToolbarDelegate();

			this.AnnotationButtonItem.AnnotationToolbar.HideAfterDrawingDidFinish = true;
		}
Example #3
0
 private void HandleItemSelect(KSStapleMenuItem item, int index)
 {
     this.SelectItem(item.Id, index);
     this.Collapse(true);
     if (this.ItemSelected != null)
     {
         this.ItemSelected(item.Id, index);
     }
 }
Example #4
0
        /// <summary>
        /// Adds items to the menu.
        /// </summary>
        /// <param name="itemsToAdd">Items to add.</param>
        public void AddItems(params KSStapleMenuItem[] itemsToAdd)
        {
            Debug.Assert(itemsToAdd != null, "Provide valid items for initialization!");

            if (this.items == null)
            {
                this.items = new ObservableCollection <KSStapleMenuItem> ();
            }

            this.items.CollectionChanged -= this.HandleItemsCollectionChanged;
            for (int i = 0; i < itemsToAdd.Length; ++i)
            {
                KSStapleMenuItem currentItem = itemsToAdd[i];
                this.items.Add(currentItem);

                currentItem.SizeElements(this.ItemSize);
                currentItem.OnLongPress += this.HandleItemLongPress;
                currentItem.OnSelect    += this.HandleItemSelect;

                var containerView = new KSMenuItemHostView(this, currentItem.Id);

                // Make container wide enough to hold all items.
                containerView.Frame = new RectangleF(0, 0, this.ItemSize.Width * currentItem.NumberOfElements, this.ItemSize.Height);

                // Add element views to container view.
                for (int elementIndex = 0; elementIndex < currentItem.NumberOfElements; elementIndex++)
                {
                    var itemView = currentItem.GetViewForIndex(elementIndex);
                    containerView.AddSubview(itemView);

                    if (this.Mode == STAPLEMENU_MODE.Right)
                    {
                        itemView.Center = new PointF(containerView.Bounds.Width - itemView.Bounds.Width / 2f, containerView.Bounds.Height / 2f);
                    }
                    else
                    {
                        itemView.Center = new PointF(itemView.Bounds.Width / 2f, containerView.Bounds.Height / 2f);
                    }
                }

                this.AddSubview(containerView);
            }
            this.items.CollectionChanged += this.HandleItemsCollectionChanged;
        }
Example #5
0
        private void HandleItemLongPress(object sender, EventArgs args)
        {
            KSStapleMenuItem item = (KSStapleMenuItem)sender;

            this.ExpandItem(item.Id, true);
        }
 private void HandleItemSelect(KSStapleMenuItem item, int index)
 {
     this.SelectItem (item.Id, index);
     this.Collapse (true);
     if(this.ItemSelected != null)
     {
         this.ItemSelected(item.Id, index);
     }
 }