Ejemplo n.º 1
0
        private void Part_Dropped(TabControlParts_DragItem e)
        {
            RemoveFromTab(e.Part3D);

            this.PreviousRemoved.Add(Tuple.Create(e.Part3D.Token, DateTime.UtcNow));
        }
Ejemplo n.º 2
0
        private void TabControl_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            bool shouldClearDragStart = true;

            try
            {
                if (_dragStart == null || e.LeftButton != MouseButtonState.Pressed)
                {
                    return;
                }

                TabControlPartsVM context = this.DataContext as TabControlPartsVM;
                if (context == null)
                {
                    return;
                }

                // Get the current mouse position
                Point  mousePos = e.GetPosition(null);
                Vector diff     = _dragStart.Value - mousePos;

                if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    // Get the item they are dragging
                    TabControlParts_DragItem dragItem = context.GetDragItem((DependencyObject)e.OriginalSource);
                    if (dragItem == null)
                    {
                        return;
                    }

                    // This isn't null on the reentry.  It's like DragDrop.DoDragDrop is double calling
                    //if(_dragStart == null)
                    //{
                    //    return;
                    //}

                    shouldClearDragStart = false;

                    // Initialize the drag & drop operation
                    DataObject dragData = new DataObject(DRAGDROP_FORMAT, dragItem);
                    if (DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move) == DragDropEffects.None)
                    {
                        // If they drag around, but not in a place where Drop gets fired, then execution reenters here.
                        if (this.DragDropCancelled != null)
                        {
                            this.DragDropCancelled(this, dragItem);
                        }
                    }
                    else
                    {
                        shouldClearDragStart = true;
                    }
                }
                else
                {
                    shouldClearDragStart = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), TITLE, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                if (shouldClearDragStart)
                {
                    _dragStart = null;
                }
            }
        }
Ejemplo n.º 3
0
        private void tabCtrl_DragDropCancelled(object sender, TabControlParts_DragItem e)
        {
            try
            {
                // Since the tabcontrol started the dragdrop, it knows when the drop failed
                // Get rid of the dragging part
                if (_draggingDropObject != null && _draggingDropObject.HasAddedToViewport)      // this will be null if they started dragging, but not over the 3D viewport
                {
                    _viewport.Children.Remove(_draggingDropObject.Model);
                }

                _draggingDropObject = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), _msgboxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 4
0
        private void Part_Dropped(TabControlParts_DragItem e)
        {
            RemoveFromTab(e.Part3D);

            this.PreviousRemoved.Add(Tuple.Create(e.Part3D.Token, DateTime.UtcNow));
        }