Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DropInfo"/> class.
        /// </summary>
        /// <param name="sender">
        /// The sender of the drag event.
        /// </param>
        /// <param name="e">
        /// The drag event
        /// </param>
        public DropInfo(object sender, DragEventArgs e)
        {
            var dataFormat = FrameworkElementDragBehavior.DataFormat.Name;

            this.Payload      = e.Data.GetDataPresent(dataFormat) ? e.Data.GetData(dataFormat) : e.Data;
            this.KeyStates    = e.KeyStates;
            this.Effects      = e.Effects;
            this.VisualTarget = sender as UIElement;
            this.DropPosition = e.GetPosition(this.VisualTarget);

            var control = sender as Control;

            this.TargetGroup = VisualTreeExtensions.FindGroup(control, this.DropPosition);

            var gridcontrol = sender as GridControl;

            if (gridcontrol != null)
            {
                this.SetTargetItem(gridcontrol, e);
            }

            var treeListControl = sender as TreeListControl;

            if (treeListControl != null)
            {
                this.SetTargetItem(treeListControl, e);
            }

            var itemsControl = sender as ItemsControl;

            if (itemsControl != null)
            {
                this.SetTargetItem(itemsControl);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Event handler for the <see cref="MouseLeftButtonDown"/> event
        /// </summary>
        /// <remarks>
        /// Occurs when the left mouse button is pressed while the mouse pointer is over this element.
        /// </remarks>
        /// <param name="sender">the sender of the event</param>
        /// <param name="e">the <see cref="MouseButtonEventArgs"/> associated to the event</param>
        private void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount != 1 || VisualTreeExtensions.HitTestScrollBar(sender, e) ||
                VisualTreeExtensions.HitTestGridColumnHeader(sender, e))
            {
                this.dragInfo = null;
                return;
            }

            this.dragInfo = new DragInfo(sender, e);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the <see cref="TargetItem"/> to the item that the mouse is over.
        /// </summary>
        /// <param name="itemsControl">
        /// The <see cref="ItemsControl"/> that the mouse is moving over
        /// </param>
        private void SetTargetItem(ItemsControl itemsControl)
        {
            var item = VisualTreeExtensions.GetItemContainerAt(itemsControl, this.DropPosition);

            if (item != null)
            {
                this.VisualTargetOrientation = VisualTreeExtensions.GetItemsPanelOrientation(itemsControl);

                var itemParent = ItemsControl.ItemsControlFromItemContainer(item);
                this.TargetItem = itemParent.ItemContainerGenerator.ItemFromContainer(item);
            }
        }