Пример #1
0
        private void SetupEditor(string msgboxCaption, TabControlPartsVM vm, UIElement managementControl)
        {
            //TODO: Take in some other settings, like max size

            ClearAll();

            _msgboxCaption = msgboxCaption;

            tabCtrl.DataContext = vm;

            pnlManagement.Child = managementControl;
        }
Пример #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;
                }
            }
        }