/// <summary> /// Selects or deselects the <paramref name="item"/> (depends on whether the item was already /// selected and whether Shift or Control keys are pressed). /// </summary> /// <param name="item">clicked item</param> /// <param name="e">event arguments</param> public override void SelectableItemPreviewMouseDown(ISelectable item, MouseButtonEventArgs e) { base.SelectableItemPreviewMouseDown(item, e); //Selection handling if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { if (item.IsSelected) { item = SelectedItemsCollection.GetOwner(item); item.IsSelected = false; Canvas.SelectedItems.Remove(item); } else { item.IsSelected = true; Canvas.SelectedItems.Add(item); } } else if (!item.IsSelected) { Canvas.SelectedItems.SetSelection(item); //foreach (ISelectable i in Canvas.SelectedItems) // i.IsSelected = false; //Canvas.SelectedItems.Clear(); //item.IsSelected = true; //Canvas.SelectedItems.Add(item); } }
/// <summary> /// Creates new instance of XCaseCanvas /// </summary> public XCaseCanvas() { selectedItems = new SelectedItemsCollection(); normalState = new NormalState(this); draggingElementState = new DraggingElementState(this); draggingConnectionState = new DraggingConnectionState(this); State = ECanvasState.Normal; #if DEBUG MouseLabel = new Label(); this.Children.Add(MouseLabel); #endif InitializeContextMenu(); }