Example #1
0
        protected virtual bool CheckCanProcessMnemonic(IItemsControl itemsControl, char keyData)
        {
            bool result = false;

            foreach (RadItem item in itemsControl.Items)
            {
                RadMenuItemBase menuItem = item as RadMenuItemBase;

                if (menuItem != null && menuItem.IsPopupShown)
                {
                    return(this.CheckCanProcessMnemonic(menuItem.DropDown, keyData));
                }

                if (IsMnemonic(keyData, item.Text))
                {
                    if (menuItem != null && menuItem.HasChildren)
                    {
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Example #2
0
        protected virtual bool ProcessUpDownNavigationKey(bool isUp)
        {
            RadMenuItemBase selectedItem1 = this.GetSelectedItem() as RadMenuItemBase;

            if (selectedItem1 != null)
            {
                this.EnsureItemEnabled((RadItem)selectedItem1, isUp);
            }
            else if (!isUp)
            {
                this.SelectFirstVisibleItem();
                RadMenuItemBase selectedItem2 = this.GetSelectedItem() as RadMenuItemBase;
                if (!selectedItem2.Enabled)
                {
                    this.EnsureItemEnabled((RadItem)selectedItem2, isUp);
                }
            }
            else
            {
                this.SelectLastVisibleItem();
                RadMenuItemBase selectedItem2 = this.GetSelectedItem() as RadMenuItemBase;
                if (!selectedItem2.Enabled)
                {
                    this.EnsureItemEnabled((RadItem)selectedItem2, isUp);
                }
            }
            return(true);
        }
Example #3
0
        public override AccessibleObject GetChild(int index)
        {
            RadApplicationMenuButtonElement owner    = this.Owner as RadApplicationMenuButtonElement;
            RadApplicationMenuDropDown      dropDown = owner.DropDownMenu as RadApplicationMenuDropDown;
            int count = base.GetChildCount();

            if (index < count)
            {
                return(base.GetChild(index));
            }

            index -= count;
            count  = dropDown.RightColumnItems.Count;

            if (index < count)
            {
                RadMenuItemBase menuItemBase = dropDown.RightColumnItems[index] as RadMenuItemBase;
                return(menuItemBase.AccessibleObject);
            }

            index -= count;
            RadMenuItemBase button = dropDown.ButtonItems[index] as RadMenuItemBase;

            return(button.AccessibleObject);
        }
Example #4
0
        protected void PerformItemClick(RadMenuItemBase menuItem)
        {
            if (menuItem == null || !menuItem.Enabled)
            {
                return;
            }

            this.clickedItem = menuItem;

            if (menuItem.HasChildren)
            {
                menuItem.ShowChildItems();
                menuItem.DropDown.SelectFirstVisibleItem();
            }
            else
            {
                PopupManager.Default.CloseAllToRoot(RadPopupCloseReason.Keyboard, this);
                if (menuItem.Owner is RadMenuElement)
                {
                    if (((menuItem.Owner as RadMenuElement).ElementTree.Control is RadMenu))
                    {
                        ((menuItem.Owner as RadMenuElement).ElementTree.Control as RadMenu).SetMenuState(RadMenu.RadMenuState.NotActive);
                    }
                }
            }


            menuItem.PerformClick();
            this.clickedItem = null;
        }
Example #5
0
        protected override void OnDropDownClosed(RadPopupClosedEventArgs args)
        {
            base.OnDropDownClosed(args);

            RadMenuItemBase currentItem = this.GetSelectedItem() as RadMenuItemBase;

            if (currentItem != null)
            {
                currentItem.Deselect();
            }

            if (!(this.OwnerElement is RadMenuItemBase))
            {
                return;
            }

            RadMenuItemBase ownerMenuItem = this.OwnerElement as RadMenuItemBase;

            if (!(this.lastPressedKey == Keys.Escape) &&
                !ownerMenuItem.IsOnDropDown &&
                ownerMenuItem.ElementTree.Control is IItemsControl)
            {
                IItemsControl   ownerItemsControl = ownerMenuItem.ElementTree.Control as IItemsControl;
                RadMenuItemBase menuItemBase      = ownerItemsControl.GetSelectedItem() as RadMenuItemBase;

                if (!object.ReferenceEquals(menuItemBase, ownerMenuItem))
                {
                    return;
                }

                ownerMenuItem.Selected = false;
            }
        }
Example #6
0
 public RadMenuItemAccessibleObject(RadMenuItemBase owner)
 {
     this.owner                 = owner;
     this.owner.MouseHover     += new EventHandler(Owner_MouseHover);
     this.owner.DropDownOpened += new EventHandler(Owner_DropDownOpened);
     this.owner.DropDownClosed += new RadPopupClosedEventHandler(Owner_DropDownClosed);
 }
Example #7
0
        private void ItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
        {
            if (operation == ItemsChangeOperation.Inserted ||
                operation == ItemsChangeOperation.Set)
            {
                target.AngleTransform = GetRotationDegree(this.Orientation);
            }

            RadMenuItemBase menuItem = target as RadMenuItemBase;

            if (menuItem != null)
            {
                if (operation == ItemsChangeOperation.Inserted || operation == ItemsChangeOperation.Set)
                {
                    menuItem.Owner = this;
                    if (!this.IsDesignMode)
                    {
                        menuItem.ClickMode = ClickMode.Press;
                    }
                    menuItem.IsMainMenuItem = true;
                }
                else if (operation == ItemsChangeOperation.Removed)
                {
                    menuItem.Deselect();
                    menuItem.Owner = null;
                    if (menuItem.IsPopupShown)
                    {
                        menuItem.HideChildItems();
                    }
                }
            }
        }
Example #8
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            RadMenuItemBase menuItemAtPoint = this.GetMenuItemAtPoint(e.Location);

            base.OnMouseClick(e);
            RadElement rootOwnerElement = this.GetRootOwnerElement();

            if (rootOwnerElement != null && e.Button == MouseButtons.Left && rootOwnerElement.IsDesignMode)
            {
                this.DoDesignTimeDoubleClick(e);
            }
            else
            {
                if (menuItemAtPoint == null || !menuItemAtPoint.Enabled)
                {
                    return;
                }
                this.clickedItem = (RadItem)menuItemAtPoint;
                if (menuItemAtPoint is RadMenuButtonItem || menuItemAtPoint is RadMenuComboItem)
                {
                    return;
                }
                this.DoOnItemClicked(menuItemAtPoint, e);
                this.PerformMenuItemClick(menuItemAtPoint);
                this.clickedItem = (RadItem)null;
            }
        }
Example #9
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            RadMenuItemBase menuItem = this.ElementTree.GetElementAtPoint(e.Location) as RadMenuItemBase;

            base.OnMouseClick(e);

            RadElement ownerElement = this.GetRootOwnerElement();

            if (ownerElement != null && e.Button == MouseButtons.Left &&
                ownerElement.IsDesignMode)
            {
                this.DoDesignTimeDoubleClick(e);
            }
            else
            {
                if (menuItem == null || !menuItem.Enabled)
                {
                    return;
                }

                this.clickedItem = menuItem;
                this.DoOnItemClicked(menuItem, e);

                if (menuItem.GetSite() == null)
                {
                    if (!menuItem.IsMouseOver)
                    {
                        menuItem.PerformClick();
                    }
                }

                this.clickedItem = null;
            }
        }
Example #10
0
        protected override void SetVisibleCore(bool value)
        {
            base.SetVisibleCore(value);

            if (value == true)
            {
                if (this.ownerElement != null && this.ownerElement.ElementTree != null)
                {
                    Control ownerControl = this.ownerElement.ElementTree.Control;

                    if (ownerControl != null)
                    {
                        ownerControl.Capture = false;
                    }
                }

                if (this.popupElement is RadDropDownMenuElement)
                {
                    this.popupElement.SetValue(RadDropDownMenuElement.DropDownPositionProperty, DropDownPosition.Popup);
                }
            }
            else
            {
                RadMenuItemBase currentItem = this.GetSelectedItem() as RadMenuItemBase;
                if (currentItem != null)
                {
                    currentItem.Deselect();
                }
            }
        }
Example #11
0
        private void DoOnItemClicked(RadMenuItemBase menuItem, MouseEventArgs e)
        {
            if (!menuItem.HasChildren && menuItem.GetSite() == null)
            {
                menuItem.Select();
                PopupManager.Default.CloseAllToRoot(RadPopupCloseReason.Mouse, this);

                if (menuItem.RootItem == null ||
                    !(menuItem.RootItem.Owner is RadMenuElement))
                {
                    return;
                }

                if (menuItem.Owner is RadMenuElement)
                {
                    if ((menuItem.Owner as RadMenuElement).ElementTree.Control is RadMenu)
                    {
                        ((menuItem.Owner as RadMenuElement).ElementTree.Control as RadMenu).SetMenuState(RadMenu.RadMenuState.NotActive);
                    }
                }
            }
            else
            {
                if (!(menuItem.GetSite() != null && e.Button == MouseButtons.Right))
                {
                    menuItem.ShowChildItems();
                }
            }
        }
        protected virtual bool ProcessLeftRightNavigationKey(bool isLeft)
        {
            RadMenuItemBase selectedItem = this.GetSelectedItem() as RadMenuItemBase;

            if (selectedItem == null)
            {
                return(false);
            }
            if (!isLeft)
            {
                if (!selectedItem.HasChildren)
                {
                    return(false);
                }
                selectedItem.ShowChildItems();
                selectedItem.DropDown.SelectFirstVisibleItem();
                return(true);
            }
            if (selectedItem.HierarchyParent == null || selectedItem.HierarchyParent.IsRootItem && this.OwnerPopup == null)
            {
                return(false);
            }
            this.ClosePopup(RadPopupCloseReason.Keyboard);
            return(true);
        }
Example #13
0
        protected virtual void OnItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
        {
            RadMenuItemBase menuItem = target as RadMenuItemBase;

            if (menuItem != null)
            {
                if (operation == ItemsChangeOperation.Inserted || operation == ItemsChangeOperation.Set)
                {
                    menuItem.HierarchyParent = this.ownerElement as IHierarchicalItem;

                    menuItem.Owner = this.ownerElement;
                }

                else if (operation == ItemsChangeOperation.Removed)
                {
                    menuItem.HierarchyParent = null;
                }
            }

            if (operation == ItemsChangeOperation.Inserted)
            {
                if (menuItem is RadMenuItem && menuItem.Site == null)
                {
                    (menuItem as RadMenuItem).ShowKeyboardCue = false;
                }
            }
        }
Example #14
0
        protected virtual bool CheckCanNavigate(Keys keyData)
        {
            RadMenuItemBase selectedItem = this.GetSelectedItem() as RadMenuItemBase;

            if (selectedItem != null)
            {
                if (keyData == Keys.Right)
                {
                    if (selectedItem.Enabled && selectedItem.HasChildren)
                    {
                        return(true);
                    }

                    return(false);
                }
                else if (keyData == Keys.Left)
                {
                    if (selectedItem.HierarchyParent != null && !selectedItem.HierarchyParent.IsRootItem)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
        private void OnMenuItem_DropDownOpening(object sender, CancelEventArgs e)
        {
            if (this.IsDesignMode)
            {
                return;
            }
            RadMenuItemBase radMenuItemBase = sender as RadMenuItemBase;

            if (radMenuItemBase == null)
            {
                return;
            }
            RadPopupOpeningEventArgs openingEventArgs = e as RadPopupOpeningEventArgs;

            if (!(radMenuItemBase.Parent is RadDropDownMenuLayout))
            {
                return;
            }
            RadDropDownMenuLayout parent = radMenuItemBase.Parent as RadDropDownMenuLayout;

            openingEventArgs.CustomLocation = new Point(openingEventArgs.CustomLocation.X, parent.ControlBoundingRectangle.Y + this.DropDownMenu.Location.Y);
            RadDropDownMenu dropDown = radMenuItemBase.DropDown;
            Size            size     = new Size(dropDown.Width, parent.ControlBoundingRectangle.Height);

            dropDown.MinimumSize = size;
        }
Example #16
0
        protected virtual void OnItemsChanged(
            RadItemCollection changed,
            RadItem target,
            ItemsChangeOperation operation)
        {
            RadMenuItemBase radMenuItemBase = target as RadMenuItemBase;

            if (radMenuItemBase != null)
            {
                if (operation == ItemsChangeOperation.Inserted || operation == ItemsChangeOperation.Set)
                {
                    radMenuItemBase.HierarchyParent = this.ownerElement as IHierarchicalItem;
                    radMenuItemBase.Owner           = (object)this.ownerElement;
                }
                else if (operation == ItemsChangeOperation.Removed)
                {
                    radMenuItemBase.HierarchyParent = (IHierarchicalItem)null;
                }
            }
            if (operation != ItemsChangeOperation.Inserted || !(radMenuItemBase is RadMenuItem) || radMenuItemBase.Site != null)
            {
                return;
            }
            (radMenuItemBase as RadMenuItem).ShowKeyboardCue = false;
        }
Example #17
0
        public override bool CanClosePopup(RadPopupCloseReason reason)
        {
            if (reason == RadPopupCloseReason.Mouse)
            {
                if (this.OwnerPopup == null && this.OwnerElement != null && this.RootTreeHandler != null)
                {
                    RadMenuItemBase menuItem    = this.OwnerElement as RadMenuItemBase;
                    Control         rootControl = this.RootTreeHandler as Control;

                    Point currentMousePoint = rootControl.PointToClient(MousePosition);

                    RadElement itemUnderMouse = this.RootTreeHandler.ElementTree.GetElementAtPoint(currentMousePoint);

                    if ((menuItem != null && itemUnderMouse != null &&
                         object.ReferenceEquals(itemUnderMouse, menuItem) &&
                         rootControl.Focused) || (menuItem != null && menuItem.IsMouseDown))
                    {
                        return(false);
                    }
                }

                if (this.OwnerElement != null)
                {
                    this.OwnerElement.UpdateContainsMouse();
                    if (this.OwnerElement.ContainsMouse || this.OwnerElement.IsMouseDown)
                    {
                        return(false);
                    }
                }
            }

            return(base.CanClosePopup(reason));
        }
        private void OnItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
        {
            if (operation == ItemsChangeOperation.Inserted)
            {
                RadMenuItemBase menuItem = target as RadMenuItemBase;

                if (menuItem != null)
                {
                    menuItem.DropDownOpening += new CancelEventHandler(OnMenuItem_DropDownOpening);
                }
            }
            else if (operation == ItemsChangeOperation.Removed)
            {
                RadMenuItemBase menuItem = target as RadMenuItemBase;

                if (menuItem != null)
                {
                    menuItem.DropDownOpening -= new CancelEventHandler(OnMenuItem_DropDownOpening);
                }
            }
            else if (operation == ItemsChangeOperation.Clearing)
            {
                foreach (RadMenuItemBase item in changed)
                {
                    item.DropDownOpening -= new CancelEventHandler(OnMenuItem_DropDownOpening);
                }
            }
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            RadMenuItemBase elementAtPoint = this.ElementTree.GetElementAtPoint(e.Location) as RadMenuItemBase;
            RadMenuItemBase selectedItem   = this.GetSelectedItem() as RadMenuItemBase;

            if (elementAtPoint == null || !elementAtPoint.Enabled)
            {
                base.OnMouseMove(e);
            }
            else
            {
                if (selectedItem != null && !object.ReferenceEquals((object)selectedItem, (object)elementAtPoint))
                {
                    selectedItem.Deselect();
                    lock (this.syncObj)
                        this.itemsToClose.Push(selectedItem);
                }
                if (object.ReferenceEquals((object)elementAtPoint, this.childDropDownTimeout.Tag))
                {
                    this.childDropDownTimeout.Stop();
                    this.childDropDownTimeout.Tag = (object)null;
                }
                else if (!object.ReferenceEquals((object)selectedItem, (object)elementAtPoint))
                {
                    if (this.childDropDownTimeout.Tag == null)
                    {
                        this.childDropDownTimeout.Tag = (object)selectedItem;
                    }
                    this.childDropDownTimeout.Start();
                }
                base.OnMouseMove(e);
            }
        }
Example #20
0
 public override bool CanClosePopup(RadPopupCloseReason reason)
 {
     if (reason == RadPopupCloseReason.Mouse)
     {
         if (this.OwnerPopup == null && this.OwnerElement != null && this.RootTreeHandler != null)
         {
             RadMenuItemBase ownerElement    = this.OwnerElement as RadMenuItemBase;
             Control         rootTreeHandler = this.RootTreeHandler as Control;
             RadElement      elementAtPoint  = this.RootTreeHandler.ElementTree.GetElementAtPoint(rootTreeHandler.PointToClient(Control.MousePosition));
             if (ownerElement != null && elementAtPoint != null && (object.ReferenceEquals((object)elementAtPoint, (object)ownerElement) && rootTreeHandler.Focused) || ownerElement != null && ownerElement.IsMouseDown)
             {
                 return(false);
             }
         }
         if (this.OwnerElement != null)
         {
             this.OwnerElement.UpdateContainsMouse();
             if (this.OwnerElement.ContainsMouse || this.OwnerElement.IsMouseDown)
             {
                 return(false);
             }
         }
     }
     return(base.CanClosePopup(reason));
 }
Example #21
0
        public override bool OnKeyDown(Keys keyData)
        {
            this.lastPressedKey = keyData;
            switch (keyData)
            {
            case Keys.Back:
                return(false);

            case Keys.Return:
                RadMenuItemBase selectedItem = this.GetSelectedItem() as RadMenuItemBase;
                if (selectedItem == null)
                {
                    return(false);
                }
                this.BeginInvoke((Delegate) new RadDropDownMenu.PerformClickInvoker(this.PerformItemClick), (object)selectedItem);
                return(true);

            case Keys.Left:
            case Keys.Right:
                return(this.ProcessLeftRightNavigationKey(keyData == Keys.Left ^ this.RightToLeft == RightToLeft.Yes));

            case Keys.Up:
            case Keys.Down:
                return(this.ProcessUpDownNavigationKey(keyData == Keys.Up));

            default:
                if (this.ProcessMnemonic(keyData))
                {
                    return(true);
                }
                return(base.OnKeyDown(keyData));
            }
        }
Example #22
0
 protected virtual void PerformMenuItemClick(RadMenuItemBase menuItem)
 {
     if (menuItem.GetSite() != null || menuItem.IsMouseOver)
     {
         return;
     }
     menuItem.PerformClick();
 }
Example #23
0
 protected virtual bool CanProcessItem(RadMenuItemBase menuItem)
 {
     if (menuItem != null)
     {
         return(menuItem.Enabled);
     }
     return(false);
 }
Example #24
0
        private void DoDesignTimeDoubleClick(MouseEventArgs e)
        {
            RadMenuItemBase oldElementUnderMouse = null;

            oldElementUnderMouse = elementUnderMouse;
            elementUnderMouse    = this.ElementTree.GetElementAtPoint(e.Location) as RadMenuItemBase;

            if (dblClickStopWatch == null)
            {
                dblClickStopWatch = Stopwatch.StartNew();
                return;
            }

            if (elementUnderMouse != oldElementUnderMouse)
            {
                if (dblClickStopWatch != null)
                {
                    dblClickStopWatch.Reset();
                    dblClickStopWatch.Start();
                }
                return;
            }

            if (dblClickStopWatch.ElapsedMilliseconds < SystemInformation.DoubleClickTime)
            {
                if (elementUnderMouse == null)
                {
                    return;
                }
                ISite site = elementUnderMouse.GetSite();

                if (site == null)
                {
                    return;
                }

                IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                if (host == null)
                {
                    return;
                }

                this.ClosePopup(RadPopupCloseReason.Mouse);

                if (this.OwnerPopup != null)
                {
                    PopupManager.Default.CloseAllToRoot(RadPopupCloseReason.Mouse, this.OwnerPopup);
                }

                dblClickStopWatch.Reset();
                elementUnderMouse = null;
            }
            else
            {
                dblClickStopWatch.Reset();
                elementUnderMouse = null;
            }
        }
Example #25
0
        protected override void OnItemSelected(ItemSelectedEventArgs args)
        {
            base.OnItemSelected(args);

            if (args.Item is RadMenuItemBase)
            {
                RadMenuItemBase item = args.Item as RadMenuItemBase;
                item.Selected = true;
            }
        }
        public override AccessibleObject GetChild(int index)
        {
            RadMenuItemBase radMenuItemBase = this.owner.Items[index] as RadMenuItemBase;

            if (radMenuItemBase != null)
            {
                return((AccessibleObject)radMenuItemBase.AccessibleObject);
            }
            return(base.GetChild(index));
        }
Example #27
0
 private void Items_ItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
 {
     if (operation == ItemsChangeOperation.Inserted)
     {
         RadMenuItemBase menuItem = target as RadMenuItemBase;
         if (menuItem != null)
         {
             menuItem.OwnerControl = this.menu;
         }
     }
 }
Example #28
0
 private void OnItemListMenu_DropDownClosed(object sender, EventArgs e)
 {
     for (int i = this.itemListMenu.Items.Count - 1; i >= 0; i--)
     {
         RadMenuItemBase menuItem = this.itemListMenu.Items[i] as RadMenuItemBase;
         if (this.itemListMenu.DropDown.ClickedItem != menuItem)
         {
             this.ClearMenuItem(menuItem);
         }
     }
 }
Example #29
0
        protected override void OnItemDeselected(ItemSelectedEventArgs args)
        {
            base.OnItemDeselected(args);

            if (args.Item is RadMenuItemBase)
            {
                RadMenuItemBase item = args.Item as RadMenuItemBase;
                item.Selected = false;
                item.HideChildItems();
            }
        }
Example #30
0
        private void OnChildrenDropDown_TimeOut(object sender, EventArgs e)
        {
            RadMenuItemBase selectedItem = this.GetSelectedItem() as RadMenuItemBase;

            if (selectedItem != null)
            {
                selectedItem.ShowChildItems();
            }

            this.childDropDownTimeout.Stop();
        }