Beispiel #1
0
 private void HandleMouseButtonDown(MouseButton mouseButton)
 {
     if (NavigateMenuItem.UiGetIsSelectable(this) && base.Focus())
     {
         NavigateMenu parentListBox = this.ParentListBox;
         if (parentListBox != null)
         {
             parentListBox.NotifyListItemClicked(this, mouseButton);
         }
     }
 }
Beispiel #2
0
 private static bool UiGetIsSelectable(DependencyObject o)
 {
     if (o != null)
     {
         if (!NavigateMenuItem.ItemGetIsSelectable(o))
         {
             return(false);
         }
         ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(o);
         if (itemsControl != null)
         {
             object obj = itemsControl.ItemContainerGenerator.ItemFromContainer(o);
             return(obj == o || NavigateMenuItem.ItemGetIsSelectable(obj));
         }
     }
     return(false);
 }
        public void NotifyListItemClicked(NavigateMenuItem item, MouseButton mouseButton)
        {
            if (mouseButton == MouseButton.Left && Mouse.Captured != this)
            {
                Mouse.Capture(this, CaptureMode.SubTree);
                //base.SetInitialMousePosition();
            }

            if (!item.IsSelected)
            {
                item.SetCurrentValue(Selector.IsSelectedProperty, true);
            }
            else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                item.SetCurrentValue(Selector.IsSelectedProperty, false);
            }
            //this.UpdateAnchorAndActionItem(base.ItemInfoFromContainer(item));
            return;

            //switch (this.SelectionMode)
            //{
            //    case SelectionMode.Single:
            //        if (!item.IsSelected)
            //        {
            //            item.SetCurrentValue(Selector.IsSelectedProperty, true);
            //        }
            //        else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            //        {
            //            item.SetCurrentValue(Selector.IsSelectedProperty, false);
            //        }
            //        //this.UpdateAnchorAndActionItem(base.ItemInfoFromContainer(item));
            //        return;
            //case SelectionMode.Multiple:
            //    this.MakeToggleSelection(item);
            //    return;
            //case SelectionMode.Extended:
            //    if (mouseButton != MouseButton.Left)
            //    {
            //        if (mouseButton == MouseButton.Right && (Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.None)
            //        {
            //            if (item.IsSelected)
            //            {
            //                this.UpdateAnchorAndActionItem(base.ItemInfoFromContainer(item));
            //                return;
            //            }
            //            this.MakeSingleSelection(item);
            //        }
            //        return;
            //    }
            //    if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift))
            //    {
            //        this.MakeAnchorSelection(item, false);
            //        return;
            //    }
            //    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            //    {
            //        this.MakeToggleSelection(item);
            //        return;
            //    }
            //    if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
            //    {
            //        this.MakeAnchorSelection(item, true);
            //        return;
            //    }
            //    this.MakeSingleSelection(item);
            //    return;
            //default:
            //    return;
            //}
        }