private void TreeViewExplorer_MouseMove(object sender, MouseEventArgs e) { TreeViewItem item = TreeViewExtensions.GetNearestContainer(e.OriginalSource as UIElement); if ((e.LeftButton == MouseButtonState.Pressed) && (item != null)) { var mousePos = e.GetPosition(null); var diff = startPoint - mousePos; if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) { if (selectedItems.Count != 0) { List <ProjectElementBase> elements = new List <ProjectElementBase>(); foreach (TreeViewItem i in selectedItems) { if (i != null) { ProjectElementBase elem = i.Tag as ProjectElementBase; elements.Add(elem); } } if (ClipboardBufferData.CheckGroupValid(elements) != GroupType.IllegalGroup) { var dragData = new DataObject(new ClipboardBufferData(ClipboardOperationType.Cut, elements)); DragDrop.DoDragDrop(TreeViewExplorer, dragData, DragDropEffects.Move | DragDropEffects.None); } } } } }
private void Copy_CanExecute(object sender, CanExecuteRoutedEventArgs e) { if (selectedItems.Count != 0) { List <ProjectElementBase> elements = new List <ProjectElementBase>(); foreach (TreeViewItem i in selectedItems) { if (i != null) { ProjectElementBase elem = i.Tag as ProjectElementBase; elements.Add(elem); } } e.CanExecute = (ClipboardBufferData.CheckGroupValid(elements) != GroupType.IllegalGroup); foreach (TreeViewItem i in selectedItems) { if (i != null) { ProjectElementBase elem = i.Tag as ProjectElementBase; elem.Copy_CanExecute(sender, e); } } } }