Esempio n. 1
0
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            if (dataType != null)
            {
                Collection <int> _ChildNodeIDs = ViewModels.AssetTreeExViewModel.ChildNodeIDs;

                int _assetid = 0;
                if (this.AssociatedObject.DataContext.GetType().Equals(typeof(ViewModels.TVAssetViewModel)))
                {
                    _assetid = ((ViewModels.TVAssetViewModel) this.AssociatedObject.DataContext).Asset.ID;
                }
                if (!_ChildNodeIDs.Contains(_assetid))
                {
                    //if the data type can be dropped
                    if (e.Data.GetDataPresent(dataType))
                    {
                        //drop the data
                        IDropable target = this.AssociatedObject.DataContext as IDropable;
                        target.Drop(e.Data.GetData(dataType));

                        //remove the data from the source
                        //IDragable source = e.Data.GetData(dataType) as IDragable;
                        //source.Remove(e.Data.GetData(dataType));
                    }
                }
            }
            if (this.adorner != null)
            {
                this.adorner.Remove();
            }

            e.Handled = true;
            return;
        }
Esempio n. 2
0
        /// <summary>
        /// Drop event to call the respective classes to handle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            if (dataType != null)
            {
                //if the data type can be dropped
                if (e.Data.GetDataPresent(dataType))
                {
                    //drop the data
                    IDropable target = AssociatedObject.DataContext as IDropable;
                    if (target.CanDrop)
                    {
                        target.Drop(e.Data.GetData(dataType));

                        //remove the data from the source
                        IDragable source = e.Data.GetData(dataType) as IDragable;
                        source.Remove(e.Data.GetData(dataType));
                    }
                }
            }
            if (adorner != null)
            {
                adorner.Remove();
            }

            e.Handled = true;
            return;
        }
Esempio n. 3
0
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            if (_dataType != null)
            {
                //if the data type can be dropped
                if (e.Data.GetDataPresent(_dataType))
                {
                    //drop the data
                    IDropable target = AssociatedObject.DataContext as IDropable;
                    //var point = e.GetPosition(this.AssociatedObject.DataContext as IInputElement);
                    if (target != null)
                    {
                        target.Drop(e.Data.GetData(_dataType), e);
                    }

                    //remove the data from the source
                    IDragable source = e.Data.GetData(_dataType) as IDragable;
                    if (source != null)
                    {
                        source.Remove(e.Data.GetData(_dataType));
                    }
                }
            }

            //if (this.adorner != null)
            //    this.adorner.Remove();

            e.Handled = true;
        }
Esempio n. 4
0
 protected virtual void AssociatedObject_Drop(object sender, DragEventArgs e)
 {
     if (DataType != null)
     {
         //if the data type can be dropped
         if (e.Data.GetDataPresent(DataType))
         {
             //drop the data
             IDropable target = AssociatedObject.DataContext as IDropable;
             target?.Drop(e.Data.GetData(DataType));
         }
     }
     e.Handled = true;
 }
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            if (dataType != null)
            {
                if (e.Data.GetDataPresent(dataType))
                {
                    IDropable target = this.AssociatedObject.DataContext as IDropable;
                    target.Drop(e);

                    IDragable source = e.Data.GetData(dataType) as IDragable;
                    source.Remove();
                }
            }
        }
Esempio n. 6
0
 private void AssociatedObjectOnDrop(object sender, DragEventArgs dragEventArgs)
 {
     if (_transferedType != null && dragEventArgs.Data.GetDataPresent(_transferedType))
     {
         var data = dragEventArgs.Data.GetData(_transferedType);
         dragEventArgs.Effects = DragDropEffects.Move;
         IDropable dropable = AssociatedObject.DataContext as IDropable;
         if (dropable != null)
         {
             var position = dragEventArgs.GetPosition(AssociatedObject);
             dropable.Drop(data, position.X, position.Y);
         }
     }
 }
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            IDropable target = this.AssociatedObject.DataContext as IDropable;
            int       index  = -1;

            if (target != null)
            {
                if (((DataGrid)sender) != null)
                {
                    index = ((DataGrid)sender).SelectedIndex;
                }
                target.Drop(e.Data.GetData(DataFormats.FileDrop), index);
            }
            e.Handled = true;
        }
        void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            //if the data type can be dropped
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                //drop the data
                IDropable target = this.AssociatedObject.DataContext as IDropable;
                target.Drop(e.Data.GetData(DataFormats.FileDrop));

                //remove the data from the source
                //IDragable source = e.Data.GetData(DataFormats.FileDrop) as IDragable;
                //source.Remove(e.Data.GetData(DataFormats.FileDrop));
            }

            e.Handled = true;
            return;
        }
        /// <summary>
        /// The associated object_ drop.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void AssociatedObject_Drop(object sender, DragEventArgs e)
        {
            // if the data type can be dropped
            if (this.dataType != null)
            {
                if (e.Data.GetDataPresent(this.dataType))
                {
                    // first find the UIElement that it was dropped over, then we determine if it's
                    // dropped above or under the UIElement, then insert at the correct index.
                    ItemsControl dropContainer = sender as ItemsControl;

                    // get the UIElement that was dropped over
                    UIElement droppedOverItem = UIHelper.GetUIElement(dropContainer, e.GetPosition(dropContainer));
                    int       dropIndex       = -1; // the location where the item will be dropped
                    dropIndex = dropContainer.ItemContainerGenerator.IndexFromContainer(droppedOverItem) + 1;

                    // find if it was dropped above or below the index item so that we can insert
                    // the item in the correct place
                    if (UIHelper.IsPositionAboveElement(droppedOverItem, e.GetPosition(droppedOverItem)))
                    {
                        // if above
                        dropIndex = dropIndex - 1; // we insert at the index above it
                    }

                    // remove the data from the source
                    IDragable source = e.Data.GetData(this.dataType) as IDragable;
                    source.Remove(e.Data.GetData(this.dataType));

                    // drop the data
                    IDropable target = this.AssociatedObject.DataContext as IDropable;
                    target.Drop(e.Data.GetData(this.dataType), dropIndex);
                }
            }

            if (this.insertAdornerManager != null)
            {
                this.insertAdornerManager.Clear();
            }

            e.Handled = true;
            return;
        }