Esempio n. 1
0
        void ccvRequests_Drop(object sender, DragEventArgs e)
        {
            ToolRoomRequest trr;

            if (e.Data.GetDataPresent(DATA_FORMAT))
            {
                trr         = e.Data.GetData(DATA_FORMAT) as ToolRoomRequest;
                lastDropped = trr;
                //     dgRequests.ItemsSource .Remove(trr);
                //        dgRequests.Items.Refresh();
                Logger.log(MethodBase.GetCurrentMethod(), "dropped");
            }
        }
Esempio n. 2
0
        void dgRequests_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (!mouseMoving)
            {
                return;
            }
            // Get the current mouse position
            Point  mousePos = e.GetPosition(null);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
            {
#if true
                DataGrid        dg       = sender as DataGrid;
                ToolRoomRequest contact  = dg.SelectedItem as ToolRoomRequest;
                DataObject      dragData = new DataObject(DATA_FORMAT, contact);
                Logger.log(MethodBase.GetCurrentMethod(), "begin drag");
                DragDrop.DoDragDrop(sender as DependencyObject, dragData, DragDropEffects.Move);
                Logger.log(MethodBase.GetCurrentMethod(), "end drag");
#else
                // Get the dragged ListViewItem
                ListView     listView     = sender as ListView;
                ListViewItem listViewItem =
                    FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);

                // Find the data behind the ListViewItem
                Contact contact = (Contact)listView.ItemContainerGenerator.
                                  ItemFromContainer(listViewItem);

                // Initialize the drag & drop operation
                DataObject dragData = new DataObject(DATA_FORMAT, contact);
                DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move);
#endif
            }
        }