Example #1
0
        private void Table_DragStarted(object source, TableDragStartedEventArgs e)
        {
            e.Handled          = true;
            IsDragging         = true;
            IsNotDragging      = false;
            IsDraggingTable    = true;
            IsNotDraggingTable = false;
            var eventArgs = new TableDragStartedEventArgs(TableDragStartedEvent, this, SelectedTables);

            RaiseEvent(eventArgs);
            e.Cancel = eventArgs.Cancel;
        }
Example #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (isDragging)
            {
                Point  curMousePoint = e.GetPosition(ParentTemplateView);
                object item          = this;
                if (DataContext != null)
                {
                    item = DataContext;
                }
                Vector offset = curMousePoint - lastMousePoint;
                if (offset.X != 0.0 ||
                    offset.Y != 0.0)
                {
                    lastMousePoint = curMousePoint;
                    RaiseEvent(new TableDraggingEventArgs(TableDraggingEvent, this, new object[] { item }, offset.X, offset.Y));
                }
            }
            else if (isLeftMouseDown && ParentTemplateView.EnableTableDragging)
            {
                Point  curMousePoint = e.GetPosition(ParentTemplateView);
                var    dragDelta     = curMousePoint - lastMousePoint;
                double dragDistance  = Math.Abs(dragDelta.Length);
                if (dragDistance > DragThreshold)
                {
                    TableDragStartedEventArgs eventArgs = new TableDragStartedEventArgs(TableDragStartedEvent, this, new ItemTable[] { this });
                    RaiseEvent(eventArgs);

                    if (eventArgs.Cancel)
                    {
                        isLeftMouseDown           = false;
                        isLeftMouseAndControlDown = false;
                        return;
                    }
                    isDragging = true;
                    CaptureMouse();
                    e.Handled = true;
                }
            }
        }