// 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;
                }
            }
        }
 // Token: 0x06005E84 RID: 24196 RVA: 0x001A7D7C File Offset: 0x001A5F7C
 internal static void SetSuspendingPopupAnimation(ItemsControl menu, MenuItem ignore, bool suspend)
 {
     if (menu != null)
     {
         int count = menu.Items.Count;
         for (int i = 0; i < count; i++)
         {
             MenuItem menuItem = menu.ItemContainerGenerator.ContainerFromIndex(i) as MenuItem;
             if (menuItem != null && menuItem != ignore && menuItem.IsSuspendingPopupAnimation != suspend)
             {
                 menuItem.IsSuspendingPopupAnimation = suspend;
                 if (!suspend)
                 {
                     MenuBase.SetSuspendingPopupAnimation(menuItem, null, suspend);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        ///     Called when this element loses capture.
        /// </summary>
        private static void OnLostMouseCapture(object sender, MouseEventArgs e)
        {
            MenuBase menu = sender as MenuBase;

            // need a better solution for subcapture!

            // Use the same technique employed in ComoboBox.OnLostMouseCapture to allow another control in the
            // application to temporarily take capture and then take it back afterwards.

            if (Mouse.Captured != menu)
            {
                if (e.OriginalSource == menu)
                {
                    // If capture is null or it's not below the menu, close.
                    // More workaround for task 22022 -- check if it's a descendant (following Logical links too)
                    if (Mouse.Captured == null || !MenuBase.IsDescendant(menu, Mouse.Captured as DependencyObject))
                    {
                        menu.IsMenuMode = false;
                    }
                }
                else
                {
                    if (MenuBase.IsDescendant(menu, e.OriginalSource as DependencyObject))
                    {
                        // Take capture if one of our children gave up capture
                        if (menu.IsMenuMode && Mouse.Captured == null && MS.Win32.SafeNativeMethods.GetCapture() == IntPtr.Zero)
                        {
                            Mouse.Capture(menu, CaptureMode.SubTree);
                            e.Handled = true;
                        }
                    }
                    else
                    {
                        menu.IsMenuMode = false;
                    }
                }
            }
        }
 // Token: 0x06005E7A RID: 24186 RVA: 0x001A7A75 File Offset: 0x001A5C75
 private bool IsDescendant(DependencyObject node)
 {
     return(MenuBase.IsDescendant(this, node));
 }