Example #1
0
        private void OnGalleryControlDragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(List <GalleryItem>)))
            {
                e.Effect = DragDropEffects.Move;
            }
            GalleryControl gallery = (GalleryControl)sender;

            RibbonHitInfo hitInfo = gallery.CalcHitInfo(gallery.PointToClient(new Point(e.X, e.Y)));

            targetHighlightItem = hitInfo.GalleryItem;
            gallery.Invalidate();
        }
Example #2
0
        private void galleryControl1_DragDrop(object sender, DragEventArgs e)
        {
            if (!(e.Data.GetDataPresent(typeof(GalleryItem))))
            {
                return;
            }

            GalleryItem draggedItem = e.Data.GetData(typeof(GalleryItem)) as GalleryItem;

            GalleryControl galControl = (GalleryControl)sender;
            RibbonHitInfo  hitInfo    = galControl.CalcHitInfo(galControl.PointToClient(new Point(e.X, e.Y)));

            if (hitInfo.InGalleryGroup)
            {
                draggedItem.GalleryGroup.Items.Remove(draggedItem);
                hitInfo.GalleryItemGroup.Items.Add((GalleryItem)draggedItem);
            }

            dragItemHitInfo = null;
            galleryControlClient1.Invalidate();
        }
        private void OnTargetGalleryDragDrop(object sender, DragEventArgs e)
        {
            if (!(e.Data.GetDataPresent(typeof(GalleryItem))))
            {
                return;
            }

            GalleryItem draggedItem = e.Data.GetData(typeof(GalleryItem)) as GalleryItem;

            GalleryControl galControl = (GalleryControl)sender;
            RibbonHitInfo  hitInfo    = galControl.CalcHitInfo(galControl.PointToClient(new Point(e.X, e.Y)));

            if (hitInfo.InGalleryGroup)
            {
                hitInfo.GalleryItemGroup.Items.Add((GalleryItem)draggedItem.Clone());
            }
            else
            {
                int groupIndex = galControl.Gallery.Groups.Add(new GalleryItemGroup());
                galControl.Gallery.Groups[groupIndex].Caption = draggedItem.GalleryGroup.Caption;
                galControl.Gallery.Groups[groupIndex].Items.Add((GalleryItem)draggedItem.Clone());
            }
        }
Example #4
0
        private void OnGalleryControlDragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(List <GalleryItem>)) || DragSource == null)
            {
                return;
            }
            GalleryControl dragTarget = (GalleryControl)sender;
            RibbonHitInfo  hitInfo    = dragTarget.CalcHitInfo(dragTarget.PointToClient(new Point(e.X, e.Y)));
            GalleryItem    targetItem = hitInfo.GalleryItem;

            if (targetItem != null)
            {
                GalleryItemCollection target = targetItem.GalleryGroup.Items;
                int index = target.IndexOf(targetItem);
                List <GalleryItem> draggedItems = (List <GalleryItem>)e.Data.GetData(typeof(List <GalleryItem>));
                foreach (GalleryItem item in draggedItems)
                {
                    GalleryItemCollection source = item.GalleryGroup.Items;
                    source.Remove(item);
                    target.Insert(index++, item);
                }
            }
            targetHighlightItem = null;
        }