Esempio n. 1
0
        public int HandleClick(Point mousePosition)
        {
            if (null == visibleMenuItems || (visibleMenuItems.Count <= 0))
            {
                return(-1);
            }
            mousePosition.X -= radialMenuVisual.Transform.Value.OffsetX;
            mousePosition.Y -= radialMenuVisual.Transform.Value.OffsetY;

            if (upScroller != null && downScroller != null)
            {
                Scroller tempScroller = new Scroller(ScrollerType.None);
                bool     result       = ScrollerHitTest(mousePosition, out tempScroller);

                if (tempScroller.Type == ScrollerType.Up)
                {
                    this.HandleScrollUp();
                    return(0);
                }
                else if (tempScroller.Type == ScrollerType.Down)
                {
                    this.HandleScrollDown();
                    return(0);
                }
            }
            if (IsWithinHitTestRegion(mousePosition) == false)
            {
                return(-1);
            }

            int    itemIndex;
            double min;

            GetClosestItemToAnchor(out itemIndex, out min);
            MenuItemInfo item = visibleMenuItems.ElementAt(itemIndex);
            Point        temp;
            int          tempId;

            HandleMouseMove(mousePosition, out temp, out tempId);
            return(item.MenuId);
        }
Esempio n. 2
0
        private void InitializeMenuItems()
        {
            visibleMenuItems = new LinkedList<MenuItemInfo>();
            int i = index;

            int itemsCount = reducedList.Count;
            if (itemsCount > Configurations.RadialMenuMaxItems)
                itemsCount = Configurations.RadialMenuMaxItems;
            for (; i < index + itemsCount; i++)
            {
                MenuItemInfo menuItem = new MenuItemInfo(reducedList.ElementAt(i).Value, this.keyword, anchor);
                menuItem.MenuId = reducedList.ElementAt(i).Key;
                menuItem.ItemPosition = centerPosition;
                visibleMenuItems.AddLast(menuItem);
            }
            this.UpdateScrollerState();
            arcStartPoint.X = centerPosition.X + radius * Math.Cos(startAngle);
            arcStartPoint.Y = centerPosition.Y - radius * Math.Sin(startAngle);

            arcEndPoint.X = centerPosition.X + radius * Math.Cos(endAngle);
            arcEndPoint.Y = centerPosition.Y - radius * Math.Sin(endAngle);
        }