Beispiel #1
0
        private void HandListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ignoredDeviceList.Remove(e.Device);
            InputDeviceHelper.ClearDeviceState(e.Device);

            InputDeviceHelper.InitializeDeviceState(e.Device);
        }
Beispiel #2
0
 private void HandListBox_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     // If this is a mouse whose state has been initialized when its down event happens
     if (InputDeviceHelper.GetDragSource(e.Device) != null)
     {
         StartDragDrop(HandListBox, e);
     }
 }
Beispiel #3
0
        private void StartDragDrop(ListBox sourceListBox, InputEventArgs e)
        {
            DependencyObject downSource = InputDeviceHelper.GetDragSource(e.Device);

            Debug.Assert(downSource != null);

            SurfaceListBoxItem draggedListBoxItem = GetVisualAncestor <SurfaceListBoxItem>(downSource);

            if (draggedListBoxItem == null)
            {
                return;
            }

            SimpleCard data = draggedListBoxItem.Content as SimpleCard;

            // Create a new ScatterViewItem as cursor visual.
            ScatterViewItem cursorVisual = new ScatterViewItem();

            cursorVisual.Style   = (Style)FindResource("ScatterItemStyle");
            cursorVisual.Content = data;

            IEnumerable <InputDevice> devices = null;

            TouchEventArgs touchEventArgs = e as TouchEventArgs;

            if (touchEventArgs != null)
            {
                devices = MergeInputDevices(draggedListBoxItem.TouchesCapturedWithin, e.Device);
            }
            else
            {
                devices = new List <InputDevice>(new InputDevice[] { e.Device });
            }

            SurfaceDragCursor cursor = SurfaceDragDrop.BeginDragDrop(HandListBox, draggedListBoxItem, cursorVisual, data, devices, DragDropEffects.All);

            // Reset the input device's state.

            InputDeviceHelper.ClearDeviceState(e.Device);

            ((ObservableCollection <SimpleCard>) this.HandListBox.ItemsSource).Remove(data);
        }