///
        void IExpandCollapseProvider.Collapse()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            UIElement owner = GetWrapper();

            if (owner == null)
            {
                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
            }

            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;

            if (menuItemOwner != null)
            {
                MenuItemRole role = menuItemOwner.Role;

                if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) ||
                    !menuItemOwner.HasItems)
                {
                    throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
                }

                menuItemOwner.IsSubmenuOpen = false;
            }
            else
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }
        }
コード例 #2
0
        // Token: 0x06005E79 RID: 24185 RVA: 0x001A799C File Offset: 0x001A5B9C
        private static void OnIsSelectedChanged(object sender, RoutedPropertyChangedEventArgs <bool> e)
        {
            MenuItem menuItem = e.OriginalSource as MenuItem;

            if (menuItem != null)
            {
                MenuBase menuBase = (MenuBase)sender;
                if (e.NewValue)
                {
                    if (menuBase.CurrentSelection != menuItem && menuItem.LogicalParent == menuBase)
                    {
                        bool flag = false;
                        if (menuBase.CurrentSelection != null)
                        {
                            flag = menuBase.CurrentSelection.IsSubmenuOpen;
                            menuBase.CurrentSelection.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, BooleanBoxes.FalseBox);
                        }
                        menuBase.CurrentSelection = menuItem;
                        if (menuBase.CurrentSelection != null && flag)
                        {
                            MenuItemRole role = menuBase.CurrentSelection.Role;
                            if ((role == MenuItemRole.SubmenuHeader || role == MenuItemRole.TopLevelHeader) && menuBase.CurrentSelection.IsSubmenuOpen != flag)
                            {
                                menuBase.CurrentSelection.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, BooleanBoxes.Box(flag));
                            }
                        }
                    }
                }
                else if (menuBase.CurrentSelection == menuItem)
                {
                    menuBase.CurrentSelection = null;
                }
                e.Handled = true;
            }
        }
コード例 #3
0
ファイル: BasePopupItem.cs プロジェクト: pentest30/MenuRibbon
 protected virtual void UpdateRole()
 {
     if (IsTopLevel)
     {
         if (HasItems)
         {
             Role = MenuItemRole.TopLevelHeader;
         }
         else
         {
             Role = MenuItemRole.TopLevelItem;
         }
     }
     else
     {
         if (HasItems)
         {
             Role = MenuItemRole.SubmenuHeader;
         }
         else
         {
             Role = MenuItemRole.SubmenuItem;
         }
     }
 }
コード例 #4
0
        /// <summary>Gets the control pattern for the <see cref="T:System.Windows.Controls.MenuItem" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.MenuItemAutomationPeer" />.</summary>
        /// <param name="patternInterface">One of the enumeration values.</param>
        /// <returns>An object that supports the control pattern if <paramref name="patternInterface" /> is a supported value; otherwise, <see langword="null" />. </returns>
        // Token: 0x06002785 RID: 10117 RVA: 0x000BA168 File Offset: 0x000B8368
        public override object GetPattern(PatternInterface patternInterface)
        {
            object   result   = null;
            MenuItem menuItem = (MenuItem)base.Owner;

            if (patternInterface == PatternInterface.ExpandCollapse)
            {
                MenuItemRole role = menuItem.Role;
                if ((role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader) && menuItem.HasItems)
                {
                    result = this;
                }
            }
            else if (patternInterface == PatternInterface.Toggle)
            {
                if (menuItem.IsCheckable)
                {
                    result = this;
                }
            }
            else if (patternInterface == PatternInterface.Invoke)
            {
                MenuItemRole role2 = menuItem.Role;
                if ((role2 == MenuItemRole.TopLevelItem || role2 == MenuItemRole.SubmenuItem) && !menuItem.HasItems)
                {
                    result = this;
                }
            }
            else if (patternInterface == PatternInterface.SynchronizedInput)
            {
                result = base.GetPattern(patternInterface);
            }
            return(result);
        }
コード例 #5
0
        public override object GetPattern(PatternInterface patternInterface)
        {
            object           result = null;
            FrameworkElement owner  = GetWrapper();

            if (owner != null)
            {
                RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
                if (menuItemOwner == null)
                {
                    AutomationPeer wrapperPeer = GetWrapperPeer();
                    if (wrapperPeer != null)
                    {
                        result = wrapperPeer.GetPattern(patternInterface);
                    }
                }
                else
                {
                    MenuItemRole role = menuItemOwner.Role;
                    if (patternInterface == PatternInterface.ExpandCollapse)
                    {
                        if ((role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader) &&
                            menuItemOwner.HasItems)
                        {
                            result = this;
                        }
                    }
                    else if (patternInterface == PatternInterface.Toggle)
                    {
                        result = this;
                    }
                    else if (patternInterface == PatternInterface.Invoke)
                    {
                        if ((role == MenuItemRole.TopLevelItem || role == MenuItemRole.SubmenuItem) &&
                            !menuItemOwner.HasItems)
                        {
                            result = this;
                        }
                    }
                    else if (patternInterface == PatternInterface.Transform)
                    {
                        if (menuItemOwner.IsSubmenuOpen && (menuItemOwner.CanUserResizeHorizontally || menuItemOwner.CanUserResizeVertically))
                        {
                            result = this;
                        }
                    }
                    else
                    {
                        AutomationPeer wrapperPeer = GetWrapperPeer();
                        if (wrapperPeer != null)
                        {
                            result = wrapperPeer.GetPattern(patternInterface);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #6
0
        private static void OnIsSelectedChanged(object sender, RoutedPropertyChangedEventArgs <bool> e)
        {
            // We assume that within a menu the only top-level menu items are direct children of
            // the one and only top-level menu.
            MenuItem newSelectedMenuItem = e.OriginalSource as MenuItem;

            if (newSelectedMenuItem != null)
            {
                MenuBase menu = (MenuBase)sender;

                // If the selected item is a child of ours, make it the current selection.
                // If the selection changes from a top-level menu item with its submenu
                // open to another, the new selection's submenu should be open.
                if (e.NewValue)
                {
                    if ((menu.CurrentSelection != newSelectedMenuItem) && (newSelectedMenuItem.LogicalParent == menu))
                    {
                        bool wasSubmenuOpen = false;

                        if (menu.CurrentSelection != null)
                        {
                            wasSubmenuOpen = menu.CurrentSelection.IsSubmenuOpen;
                            menu.CurrentSelection.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, BooleanBoxes.FalseBox);
                        }

                        menu.CurrentSelection = newSelectedMenuItem;
                        if (menu.CurrentSelection != null && wasSubmenuOpen)
                        {
                            // Only open the submenu if it's a header (i.e. has items)
                            MenuItemRole role = menu.CurrentSelection.Role;

                            if (role == MenuItemRole.SubmenuHeader || role == MenuItemRole.TopLevelHeader)
                            {
                                if (menu.CurrentSelection.IsSubmenuOpen != wasSubmenuOpen)
                                {
                                    menu.CurrentSelection.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, BooleanBoxes.Box(wasSubmenuOpen));
                                }
                            }
                        }
                    }
                }
                else
                {
                    // As in MenuItem.OnIsSelectedChanged, if the item is deselected
                    // and it's our current selection, set CurrentSelection to null.
                    if (menu.CurrentSelection == newSelectedMenuItem)
                    {
                        menu.CurrentSelection = null;
                    }
                }

                e.Handled = true;
            }
        }
コード例 #7
0
        ///
        override protected string GetAccessKeyCore()
        {
            string accessKey = base.GetAccessKeyCore();

            if (!string.IsNullOrEmpty(accessKey))
            {
                MenuItem     menuItem = (MenuItem)Owner;
                MenuItemRole role     = menuItem.Role;
                if (role == MenuItemRole.TopLevelHeader || role == MenuItemRole.TopLevelItem)
                {
                    accessKey = "Alt+" + accessKey;
                }
            }
            return(accessKey);
        }
コード例 #8
0
        // Token: 0x06005E80 RID: 24192 RVA: 0x001A7CD4 File Offset: 0x001A5ED4
        private static void OnMenuItemPreviewClick(object sender, RoutedEventArgs e)
        {
            MenuBase menuBase = (MenuBase)sender;
            MenuItem menuItem = e.OriginalSource as MenuItem;

            if (menuItem != null && !menuItem.StaysOpenOnClick)
            {
                MenuItemRole role = menuItem.Role;
                if (role == MenuItemRole.TopLevelItem || role == MenuItemRole.SubmenuItem)
                {
                    menuBase.IsMenuMode = false;
                    e.Handled           = true;
                }
            }
        }
コード例 #9
0
        /// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary>
        // Token: 0x0600278B RID: 10123 RVA: 0x000BA374 File Offset: 0x000B8574
        void IExpandCollapseProvider.Collapse()
        {
            if (!base.IsEnabled())
            {
                throw new ElementNotEnabledException();
            }
            MenuItem     menuItem = (MenuItem)base.Owner;
            MenuItemRole role     = menuItem.Role;

            if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) || !menuItem.HasItems)
            {
                throw new InvalidOperationException(SR.Get("UIA_OperationCannotBePerformed"));
            }
            menuItem.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, BooleanBoxes.FalseBox);
        }
コード例 #10
0
        /// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary>
        // Token: 0x0600278A RID: 10122 RVA: 0x000BA31C File Offset: 0x000B851C
        void IExpandCollapseProvider.Expand()
        {
            if (!base.IsEnabled())
            {
                throw new ElementNotEnabledException();
            }
            MenuItem     menuItem = (MenuItem)base.Owner;
            MenuItemRole role     = menuItem.Role;

            if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) || !menuItem.HasItems)
            {
                throw new InvalidOperationException(SR.Get("UIA_OperationCannotBePerformed"));
            }
            menuItem.OpenMenu();
        }
コード例 #11
0
        /// <summary>Gets the access key for the <see cref="T:System.Windows.Controls.MenuItem" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.MenuItemAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetAccessKey" />.</summary>
        /// <returns>The access key for the <see cref="T:System.Windows.Controls.MenuItem" />.</returns>
        // Token: 0x06002788 RID: 10120 RVA: 0x000BA248 File Offset: 0x000B8448
        protected override string GetAccessKeyCore()
        {
            string text = base.GetAccessKeyCore();

            if (!string.IsNullOrEmpty(text))
            {
                MenuItem     menuItem = (MenuItem)base.Owner;
                MenuItemRole role     = menuItem.Role;
                if (role == MenuItemRole.TopLevelHeader || role == MenuItemRole.TopLevelItem)
                {
                    text = "Alt+" + text;
                }
            }
            return(text);
        }
コード例 #12
0
        /// <summary>
        /// Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated.
        /// </summary>
        /// <param name="e">The event data that describes the property that changed, as well as old and new values.</param>
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            // Always call the base implementation, as the first operation in your implementation.  Failure to do this will significantly disable the entire WPF
            // property system, which causes incorrect values to be reported. The specific FrameworkElement implementation is also responsible for maintaining
            // proper state for a variety of properties that affect the visible user interface. These include invalidating the visual tree based on changes to
            // style at appropriate times.
            base.OnPropertyChanged(e);

            // This will catch a transition of a gadget from a submenu item to a top-level item.  In order to act like a simple menu item when the BreadcrumbItem is
            // in an overflow item or the child of another BreadcrumbItem, it must not have any children.  It's not enough to try to change the appearance of the
            // element based on the role, the children must be removed in order for it to behave properly.  That is, when a BreadcrumbItem is presented in a
            // submenu, then clicking on the item should take you to that part of the path, not present the child items of that path (as it would if it was a
            // header).  To accomplish this, the children are moved into a holding area while a BreadcrumbItem is part of a submenu.
            if (e.Property == MenuItem.RoleProperty)
            {
                // Extract the new and old roles from the generic arguments.
                MenuItemRole newRole = (MenuItemRole)e.NewValue;
                MenuItemRole oldRole = (MenuItemRole)e.OldValue;

                // The state transition indicates when items should be moved out of their invisible holding area.  When a BreadcrumbItem is placed on the menu it
                // becomes a top-level header for the submenu items.  This allows the user to navigate through the BreadcrumbBar by selecting the submenu items for
                // the next level of the path.  Note that due to a slight eccentricity with the updating of the roles by the base classes, both the TopLevelItem and
                // TopLevelHeader need to be checked.  Theoretically, only a transition from a SubmenuItem to a TopLevelItem is possible, but there is some residual
                // memory of the items that leads the base class to allow the illegal transition.
                if (oldRole == MenuItemRole.SubmenuItem && (newRole == MenuItemRole.TopLevelItem || newRole == MenuItemRole.TopLevelHeader))
                {
                    foreach (Object item in this.hiddenList)
                    {
                        this.Items.Add(item);
                    }
                    this.hiddenList.Clear();
                }

                // When a BreadcrumbItem is place on the submenu it looses all the child items so it can act like a regular menu item.  Clicking on the item when it
                // resides in the overflow panel should create a path to show that item.  It should not bring up a submenu which it would do without moving the items
                // to an invisible holding area.  Note that a transition from SubmenuItem to SubmenuHeader will also moving things into the holding area.  This is
                // done to catch the condition where items are added to a BreadcrumbItem that is not yet associated with a menu.  The role of an orphaned (new)
                // BreadcrumbItem is a SubmenuItem.
                if ((oldRole == MenuItemRole.TopLevelHeader || oldRole == MenuItemRole.SubmenuItem) && newRole == MenuItemRole.SubmenuHeader)
                {
                    foreach (Object item in this.Items)
                    {
                        this.hiddenList.Add(item);
                    }
                    this.Items.Clear();
                }
            }
        }
コード例 #13
0
        ///
        void IExpandCollapseProvider.Expand()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            MenuItem     owner = (MenuItem)Owner;
            MenuItemRole role  = owner.Role;

            if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) ||
                !owner.HasItems)
            {
                throw new InvalidOperationException(SR.Get(SRID.UIA_OperationCannotBePerformed));
            }

            owner.OpenMenu();
        }
コード例 #14
0
        ///
        void IExpandCollapseProvider.Collapse()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            MenuItem     owner = (MenuItem)Owner;
            MenuItemRole role  = owner.Role;

            if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) ||
                !owner.HasItems)
            {
                throw new InvalidOperationException(SR.Get(SRID.UIA_OperationCannotBePerformed));
            }

            owner.SetCurrentValueInternal(MenuItem.IsSubmenuOpenProperty, MS.Internal.KnownBoxes.BooleanBoxes.FalseBox);
        }
コード例 #15
0
        /// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary>
        // Token: 0x0600278D RID: 10125 RVA: 0x000BA414 File Offset: 0x000B8614
        void IInvokeProvider.Invoke()
        {
            if (!base.IsEnabled())
            {
                throw new ElementNotEnabledException();
            }
            MenuItem     menuItem = (MenuItem)base.Owner;
            MenuItemRole role     = menuItem.Role;

            if (role == MenuItemRole.TopLevelItem || role == MenuItemRole.SubmenuItem)
            {
                menuItem.ClickItem();
                return;
            }
            if (role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader)
            {
                menuItem.ClickHeader();
            }
        }
コード例 #16
0
        private static void OnIsSelectedChanged(object sender, RadRoutedPropertyChangedEventArgs <bool> e)
        {
            RadMenuItem originalSource = e.OriginalSource as RadMenuItem;

            if (originalSource != null)
            {
                MenuBase menu = (MenuBase)sender;
                if (e.NewValue)
                {
                    if ((menu.CurrentSelection != originalSource) && (originalSource.ParentItem == null))
                    {
                        bool submenuOpen = false;
                        if (menu.CurrentSelection != null)
                        {
                            submenuOpen = menu.CurrentSelection.IsSubmenuOpen;
                            menu.CurrentSelection.CloseMenu();
                        }

                        menu.CurrentSelection = originalSource;
                        if ((menu.CurrentSelection != null) && submenuOpen)
                        {
                            MenuItemRole role = menu.CurrentSelection.Role;
                            if (((role == MenuItemRole.SubmenuHeader) || (role == MenuItemRole.TopLevelHeader)) && (menu.CurrentSelection.IsSubmenuOpen != submenuOpen))
                            {
                                if (submenuOpen)
                                {
                                    menu.CurrentSelection.OpenMenu();
                                }
                                else
                                {
                                    menu.CurrentSelection.CloseMenu();
                                }
                            }
                        }
                    }
                }
                else if (menu.CurrentSelection == originalSource)
                {
                    menu.CurrentSelection = null;
                }
                e.Handled = true;
            }
        }
コード例 #17
0
        ///
        void IInvokeProvider.Invoke()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            MenuItem owner = (MenuItem)Owner;

            MenuItemRole role = owner.Role;

            if (role == MenuItemRole.TopLevelItem || role == MenuItemRole.SubmenuItem)
            {
                owner.ClickItem();
            }
            else if (role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader)
            {
                owner.ClickHeader();
            }
        }
コード例 #18
0
ファイル: NoesisGUI_.cs プロジェクト: Hengle/Managed
        public static MenuItemRole Unbox_MenuItemRole(IntPtr val)
        {
            MenuItemRole ret = (MenuItemRole)NoesisGUI_PINVOKE.Unbox_MenuItemRole(val);

            return(ret);
        }
コード例 #19
0
		protected virtual void UpdateRole()
		{
			if (IsTopLevel)
			{
				if (HasItems)
				{
					Role = MenuItemRole.TopLevelHeader;
				}
				else
				{
					Role = MenuItemRole.TopLevelItem;
				}
			}
			else
			{
				if (HasItems)
				{
					Role = MenuItemRole.SubmenuHeader;
				}
				else
				{
					Role = MenuItemRole.SubmenuItem;
				}
			}
		}
コード例 #20
0
        /// <summary>
        ///     Select this item and expand the hierarchy below it.
        /// </summary>
        /// <param name="role"></param>
        private void OpenHierarchy(MenuItemRole role)
        {
            FocusOrSelect();

            if (role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader)
            {
                OpenMenu();
            }
        }
コード例 #21
0
        private void MouseLeaveInMenuMode(MenuItemRole role)
        {
            // When mouse moves out of a submenu item, we should deselect
            // the item.  This is what Win32 does, and our menus don't
            // feel right without it.
            if (role == MenuItemRole.SubmenuHeader || role == MenuItemRole.SubmenuItem)
            {
                if (MenuItem.GetBoolField(this, BoolField.IgnoreNextMouseLeave))
                {
                    // The mouse was within a submenu that closed. A submenu header is receiving this
                    // message, but we want to ignore this one.
                    MenuItem.SetBoolField(this, BoolField.IgnoreNextMouseLeave, false);
                }
                else
                {
                    if (!IsSubmenuOpen)
                    {
                        // When the submenu isn't open we can deselect the item right away.
                        if (IsSelected)
                        {
                            SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.FalseBox);
                        }
                        else
                        {
                            // If it's not selected it might just be highlighted,
                            // so remove the highlight.
                            IsHighlighted = false;
                        }

                        if (IsKeyboardFocusWithin)
                        {
                            ItemsControl parent = ItemsControl.ItemsControlFromItemContainer(this);
                            if (parent != null)
                            {
                                parent.Focus();
                            }
                        }
                    }
                    else
                    {
                        // If the submenu is open and the mouse moved to some sibling
                        // hierarchy, we need to delay and deselect the item after
                        // MenuShowDelay ms, as long as the item doesn't get re-selected.
                        if (IsMouseOverSibling)
                        {
                            SetTimerToCloseHierarchy();
                        }
                    }
                }
            }

            // No matter what, we've left the menu item and we should
            // stop any timer which would cause the item to open.
            StopTimer(ref _openHierarchyTimer);
        }
コード例 #22
0
        private void MouseEnterInMenuMode(MenuItemRole role)
        {
            switch (role)
            {
                case MenuItemRole.TopLevelHeader:
                case MenuItemRole.TopLevelItem:
                    {
                        // When mousing over a top-level hierarchy, it should open immediately.
                        if (!IsSubmenuOpen)
                        {
                            OpenHierarchy(role);
                        }
                    }
                    break;

                case MenuItemRole.SubmenuHeader:
                case MenuItemRole.SubmenuItem:
                    {
                        // If the current sibling has an open hierarchy, we cannot
                        // move focus/selection immediately.  Instead we must set
                        // a timer to open after MenuShowDelay ms.  If the sibling has
                        // no hierarchy open, it is safe to select the item immediately.
                        MenuItem sibling = CurrentSibling;

                        if (sibling == null || !sibling.IsSubmenuOpen)
                        {
                            if (!IsSubmenuOpen)
                            {
                                // Try to focus/select this item.
                                FocusOrSelect();
                            }
                            else
                            {
                                // If the submenu is open, then it should already be selected.
                                Debug.Assert(IsSelected, "When IsSubmenuOpen = true, IsSelected should be true as well");

                                // Need to make sure that when we leave the hierarchy and come back
                                // that the item is highlighted.
                                IsHighlighted = true;
                            }
                        }
                        else
                        {
                            // Highlight this item and remove the highlight
                            // from its sibling selected MenuItem
                            sibling.IsHighlighted = false;
                            IsHighlighted = true;
                        }

                        // If the submenu isn't open already, OpenHierarchy after MenuShowDelay ms
                        if (!IsSelected || !IsSubmenuOpen)
                        {
                            // When the timout happens, OpenHierarchy will select this item
                            SetTimerToOpenHierarchy();
                        }
                    }
                    break;
            }


            // Now that we're over this menu hierarchy with the mouse, we
            // should stop any timers which might cause this hierarchy to close.
            StopTimer(ref _closeHierarchyTimer);
        }
コード例 #23
0
ファイル: NoesisGUI_.cs プロジェクト: Hengle/Managed
        public static IntPtr Box_MenuItemRole(MenuItemRole val)
        {
            IntPtr ret = NoesisGUI_PINVOKE.Box_MenuItemRole((int)val);

            return(ret);
        }