Ejemplo n.º 1
0
        public virtual void Drop(DropInfo dropInfo)
        {
            int insertIndex = dropInfo.InsertIndex;
            IList destinationList = GetList(dropInfo.TargetCollection);
            IEnumerable data = ExtractData(dropInfo.Data);

            if (dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget)
            {
                IList sourceList = GetList(dropInfo.DragInfo.SourceCollection);

                foreach (object o in data)
                {
                    int index = sourceList.IndexOf(o);

                    if (index != -1)
                    {
                        sourceList.RemoveAt(index);

                        if (sourceList == destinationList && index < insertIndex)
                        {
                            --insertIndex;
                        }
                    }
                }
            }

            foreach (object o in data)
            {
                destinationList.Insert(insertIndex++, o);
            }
        }
Ejemplo n.º 2
0
 public virtual void DragOver(DropInfo dropInfo)
 {
     if (CanAcceptData(dropInfo))
     {
         dropInfo.Effects = DragDropEffects.Copy;
     }
 }
Ejemplo n.º 3
0
 protected static bool CanAcceptData(DropInfo dropInfo)
 {
     if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection)
     {
         return GetList(dropInfo.TargetCollection) != null;
     }
     else if (dropInfo.DragInfo.SourceCollection is ItemCollection)
     {
         return false;
     }
     else
     {
         if (TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data))
         {
             return !IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
         }
         else
         {
             return false;
         }
     }
 }
Ejemplo n.º 4
0
        static void DropTarget_PreviewDrop(object sender, DragEventArgs e)
        {
            DropInfo dropInfo = new DropInfo(sender, e, m_DragInfo, m_Format.Name);
            IDropTarget dropHandler = GetDropHandler((UIElement)sender);

            if (dropHandler != null)
            {
                dropHandler.Drop(dropInfo);
            }
            else
            {
                DefaultDropHandler.Drop(dropInfo);
            }

            e.Handled = true;
        }
Ejemplo n.º 5
0
        static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
        {
            DropInfo dropInfo = new DropInfo(sender, e, m_DragInfo, m_Format.Name);
            IDropTarget dropHandler = GetDropHandler((UIElement)sender);

            if (dropHandler != null)
            {
                dropHandler.DragOver(dropInfo);
            }
            else
            {
                DefaultDropHandler.DragOver(dropInfo);
            }

            e.Effects = dropInfo.Effects;
            e.Handled = true;

            Scroll((DependencyObject)sender, e);
        }
Ejemplo n.º 6
0
 void IDropTarget.Drop(DropInfo dropInfo)
 {
     Picture picture = (Picture)dropInfo.Data;
     ListOfDraggedPictures.Add(picture);
     GameScore += 10;
     PicturesToDrag.Remove(picture);
 }
Ejemplo n.º 7
0
 void IDropTarget.DragOver(DropInfo dropInfo)
 {
     if (dropInfo.Data is Picture)
     {
         dropInfo.Effects = DragDropEffects.Move;
     }
 }