Example #1
0
 static void gallery_Drop(object sender, DragEventArgs e)
 {
     e.Handled = true;
     if (dragableItem != null)
     {
         HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender));
         if (res.VisualHit == null)
         {
             return;
         }
         GalleryItemControl target = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit);
         if (target != null && target.Item != dragableItem)
         {
             GalleryItemCollection targetCollection = target.Item.Group.Items;
             GalleryItemCollection sourceCollection = dragableItem.Group.Items;
             int targetIndex = targetCollection.IndexOf(target.Item);
             if (targetCollection == sourceCollection)
             {
                 targetCollection.Move(originalIndex, targetIndex);
             }
             else
             {
                 sourceCollection.Remove(dragableItem);
                 targetCollection.Insert(targetIndex, dragableItem);
             }
             dragableItem = null;
         }
     }
 }
Example #2
0
 private void chartGalleryBarItem_GalleryItemClick(object sender, GalleryItemClickEventArgs e)
 {
     if (e.Item.Checked)
     {
         e.Item.Checked = false;
         this.coverageSplitContainerControl.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel1;
     }
     else
     {
         showChartType(e.Item.Caption);
         GalleryItemCollection items = this.chartGalleryBarItem.Gallery.Groups[0].Items;
         // this.checkedChartItemindex = items.IndexOf(e.Item);
         foreach (GalleryItem item in items)
         {
             if (item.Equals(e.Item))
             {
                 item.Checked = true;
                 coverageGridviewShow();
                 this.coverageSplitContainerControl.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Both;
             }
             else
             {
                 item.Checked = false;
             }
         }
     }
 }
Example #3
0
 static void InsertSample(GalleryItemCollection items, int count)
 {
     for (int i = 0; i < count; i++)
     {
         items.Add(new GalleryItem(null, null, string.Concat("DX Sample ", ++Index),
                                   string.Concat("The Drag&Drop gallery items example."), -1, -1, null,
                                   string.Empty, true, false));
     }
 }
Example #4
0
        /// <summary>
        /// 根据条件获取集合
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, GalleryItemCollection> Search(List <string> collection, List <string> categories, List <string> size, string fileName = "")
        {
            Dictionary <string, GalleryItemCollection> dict = new Dictionary <string, GalleryItemCollection>();

            GalleryItemCollection list = new GalleryItemCollection();

            foreach (var key in ImageCollection.Keys)
            {
                //使用正则表达式获取图标文件名中的集合、类别、大小等信息
                string reg            = @"(?<collection>\S*?)/(?<category>\S*?)/(?<name>\S*)";
                var    collectionItem = CRegex.GetText(key, reg, "collection");
                var    categoryItem   = CRegex.GetText(key, reg, "category");
                string sizeReg        = @"_(?<size>\S*)\.";
                var    sizeItem       = CRegex.GetText(key, sizeReg, "size");

                //如果是查询处理,把记录放到查询结果里面
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (key.Contains(fileName))
                    {
                        list.Add(ImageCollection[key]);
                    }
                    dict["查询结果"] = list;
                }
                else
                {
                    //如果是集合和列表中包含的,把它们按类别添加到字典里面
                    if (collection.Contains(collectionItem) &&
                        categories.Contains(categoryItem) &&
                        size.Contains(sizeItem))
                    {
                        if (!dict.ContainsKey(categoryItem))
                        {
                            GalleryItemCollection cateList = new GalleryItemCollection();
                            cateList.Add(ImageCollection[key]);
                            dict[categoryItem] = cateList;
                        }
                        else
                        {
                            GalleryItemCollection cateList = dict[categoryItem];
                            cateList.Add(ImageCollection[key]);
                        }
                    }
                }
            }
            return(dict);
        }
Example #5
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;
        }