Example #1
0
 static void EnableGalleryItemDraggingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is GalleryControl)
     {
         if ((bool)e.NewValue == true)
         {
             gallery = (d as GalleryControl);
             gallery.PreviewMouseLeftButtonDown += Gallery_PreviewMouseLeftButtonDown;
             gallery.PreviewMouseLeftButtonUp   += GalleryItemDragDropHelper_PreviewMouseLeftButtonUp;
             gallery.MouseMove += gallery_MouseMove;
             gallery.Drop      += gallery_Drop;
             gallery.DragOver  += gallery_DragOver;
         }
         else
         {
             if (gallery != null)
             {
                 gallery.PreviewMouseLeftButtonDown -= Gallery_PreviewMouseLeftButtonDown;
                 gallery.PreviewMouseLeftButtonUp   -= GalleryItemDragDropHelper_PreviewMouseLeftButtonUp;
                 gallery.MouseMove -= gallery_MouseMove;
                 gallery.Drop      -= gallery_Drop;
                 gallery.DragOver  -= gallery_DragOver;
             }
         }
     }
 }
        private void OnSourceGalleryMouseDown(object sender, MouseEventArgs e)
        {
            GalleryControl galControl = (GalleryControl)sender;
            RibbonHitInfo  hitInfo    = galControl.CalcHitInfo(e.Location);

            if (hitInfo.InGalleryItem)
            {
                dragItemHitInfo = hitInfo;
                return;
            }

            dragItemHitInfo = null;
        }
Example #3
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 #4
0
        private void galleryControl1_MouseDown(object sender, MouseEventArgs e)
        {
            GalleryControl gc    = sender as GalleryControl;
            RibbonHitInfo  hInfo = gc.CalcHitInfo(e.Location);

            if (hInfo.InGalleryItem)
            {
                dragItemHitInfo = hInfo;
                ((DXMouseEventArgs)e).Handled = true;
                return;
            }

            dragItemHitInfo = null;
        }
Example #5
0
        private void OnGalleryControlMouseDown(object sender, MouseEventArgs e)
        {
            GalleryControl gallery = (GalleryControl)sender;
            RibbonHitInfo  hitInfo = gallery.CalcHitInfo(e.Location);

            if (hitInfo.InGalleryItem)
            {
                DragItemHitInfo = hitInfo;
                DragSource      = gallery;
            }
            else
            {
                DragItemHitInfo = null;
            }
        }
Example #6
0
        private void galleryControl_MouseDown(object sender, MouseEventArgs e)
        {
            var galControl = sender as GalleryControl;
            var hitInfo    = galControl.CalcHitInfo(e.Location);

            if (hitInfo.InGalleryItem && galControl.Gallery.GetCheckedItems().Count > 0)
            {
                galControl.Gallery.AllowMarqueeSelection = false;
                hitPoint      = e.Location;
                sourceControl = galControl;
                return;
            }
            galControl.Gallery.AllowMarqueeSelection = true;
            hitPoint      = pointInvalid;
            sourceControl = null;
        }
Example #7
0
        private void galleryControl1_MouseMove(object sender, MouseEventArgs e)
        {
            GalleryControl gc = sender as GalleryControl;

            if (e.Button != MouseButtons.Left || Control.ModifierKeys != Keys.None || dragItemHitInfo == null)
            {
                return;
            }

            Size      dragSize = SystemInformation.DragSize;
            Rectangle dragRect = new Rectangle(dragItemHitInfo.HitPoint.X - dragSize.Width / 2, dragItemHitInfo.HitPoint.Y - dragSize.Height / 2, dragSize.Width, dragSize.Height);

            if (!(dragRect.Contains(e.Location)))
            {
                gc.DoDragDrop(dragItemHitInfo.GalleryItem, DragDropEffects.Move);
            }
        }
Example #8
0
        private void OnGalleryControlMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || Control.ModifierKeys != Keys.None || DragItemHitInfo == null)
            {
                return;
            }
            GalleryControl     gallery      = (GalleryControl)sender;
            List <GalleryItem> checkedItems = gallery.Gallery.GetCheckedItems();

            if (checkedItems.Count == 0)
            {
                checkedItems.Add(DragItemHitInfo.GalleryItem);
            }
            if (!new Rectangle(DragItemHitInfo.HitPoint.X - SystemInformation.DragSize.Width / 2,
                               DragItemHitInfo.HitPoint.Y - SystemInformation.DragSize.Height / 2,
                               SystemInformation.DragSize.Width, SystemInformation.DragSize.Height)
                .Contains(e.Location))
            {
                gallery.DoDragDrop(checkedItems, DragDropEffects.All);
            }
        }
Example #9
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 #11
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;
        }
Example #12
0
 public DragDropHelper(GalleryControl sourceGallery, GalleryControl targetGallery)
 {
     this.sourceGallery = sourceGallery;
     this.targetGallery = targetGallery;
 }
 public DragDropHelper(GalleryControl sourceGallery, GalleryControl targetGallery)
 {
     this.sourceGallery = sourceGallery;
     this.targetGallery = targetGallery;
 }
Example #14
0
 private void PrepareGallery(GalleryControl gc)
 {
     gc.Gallery.ItemImageLayout = ImageLayoutMode.ZoomInside;
     gc.Gallery.ImageSize = new Size(120, 90);
 }
Example #15
0
        private void test1()
        {
            if (!String.IsNullOrEmpty(cachPictureFilePath) &&
                File.Exists(cachPictureFilePath))
            {
                FileInfo fi = new FileInfo(cachPictureFilePath);
                if (fi.Length > 0)
                {
                    try
                    {
                        using (FileStream fs = new FileStream(cachPictureFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            try
                            {
                                Image imageFromStream = Image.FromStream(fs);
                                if (imageFromStream != null)
                                {
                                    new Thread(new ParameterizedThreadStart(delegate(object threadObject)
                                    {
                                        Thread.CurrentThread.IsBackground = true;
                                        if (!this.Disposing && !this.IsDisposed)
                                        {
                                            this.BeginInvoke(new MethodInvoker(delegate
                                            {
                                                GalleryControl threadObjectGalleryControl = null;
                                                PictureEdit threadObjectPictureEdit       = null;
                                                Image threadObjectStreamImage             = null;
                                                if (threadObject is Object[])
                                                {
                                                    foreach (object eachObject in threadObject as Object[])
                                                    {
                                                        if (eachObject is GalleryControl)
                                                        {
                                                            threadObjectGalleryControl = eachObject as GalleryControl;
                                                        }
                                                        if (eachObject is PictureEdit)
                                                        {
                                                            threadObjectPictureEdit = eachObject as PictureEdit;
                                                        }
                                                        if (eachObject is Image)
                                                        {
                                                            threadObjectStreamImage = eachObject as Image;
                                                        }
                                                    }
                                                }
                                                ////if (threadObjectGalleryControl == null)
                                                ////    threadObjectGalleryControl = galleryControl1;
                                                if (threadObjectPictureEdit == null)
                                                {
                                                    threadObjectPictureEdit = pictureEdit1;
                                                }

                                                try
                                                {
                                                    if (threadObjectGalleryControl != null)
                                                    {
                                                        foreach (GalleryItem eachGalleryItem in threadObjectGalleryControl.Gallery.Groups[0].Items)
                                                        {
                                                            eachGalleryItem.Image = (Image)threadObjectStreamImage.Clone();

                                                            {
                                                                count1++;
                                                            }
                                                        }
                                                    }
                                                    if (threadObjectPictureEdit != null)
                                                    {
                                                        threadObjectPictureEdit.Image = (Image)threadObjectStreamImage.Clone();

                                                        {
                                                            count2++;
                                                        }
                                                    }
                                                }
                                                catch (OutOfMemoryException catchOutOfMemoryException)
                                                {
                                                    timer1.Stop();
                                                    Debug.WriteLine("catchOutOfMemoryException");
                                                    //MessageBox.Show("catchOutOfMemoryException");
                                                }
                                                catch (Exception catchImageException)
                                                {
                                                    ////MessageBox.Show("catchImageException");
                                                }
                                                finally
                                                {
                                                    if (fs != null)
                                                    {
                                                        ////fs.Close();
                                                        ////fs.Dispose();
                                                    }

                                                    ////GC.Collect();
                                                    ////GC.WaitForPendingFinalizers();
                                                }
                                            }
                                                                               ));
                                        }
                                    }
                                                                            )).Start(new Object[] { imageFromStream });
                                }
                            }
                            catch (OutOfMemoryException catchOutOfMemoryException)
                            {
                                timer1.Stop();
                                Debug.WriteLine("catchOutOfMemoryException");
                                //MessageBox.Show("catchOutOfMemoryException");
                            }
                            catch (Exception catchImageException)
                            {
                                ////MessageBox.Show("catchImageException");
                            }
                            finally
                            {
                                if (fs != null)
                                {
                                    fs.Close();
                                    fs.Dispose();
                                }

                                ////GC.Collect();
                                ////GC.WaitForPendingFinalizers();
                            }
                        }
                    }
                    catch (OutOfMemoryException catchOutOfMemoryException)
                    {
                        Debug.WriteLine("catchOutOfMemoryException");
                        //MessageBox.Show("catchOutOfMemoryException");
                    }
                    catch (Exception catchException)
                    {
                        ////MessageBox.Show("catchException");
                    }
                    finally
                    {
                    }
                }
            }
        }
Example #16
0
 public DragDropHelper(GalleryControl galleryControl1, GalleryControl galleryControl2)
 {
     this.galleryControl1 = galleryControl1;
     this.galleryControl2 = galleryControl2;
 }
Example #17
0
 public myGallery(GalleryControl galleryControl)
     : base(galleryControl)
 {
 }
 public DragDropHelper(GalleryControl sourceGallery, GalleryControl targetGallery,LabelControl Recycle)
 {
     this.sourceGallery = sourceGallery;
     this.targetGallery = targetGallery;
     this.Recycle = Recycle;
 }