This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomDropDown.cs
74 lines (63 loc) · 2.4 KB
/
CustomDropDown.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Ribbon;
namespace TokenEditCustomDropDown {
public partial class CustomDropDown : CustomTokenEditDropDownControlBase {
List<TokenEditToken> tokenList = new List<TokenEditToken>();
GalleryItem clickedItem;
public CustomDropDown() {
InitializeComponent();
customGallery1.Gallery.ShowItemText = true;
customGallery1.Gallery.ItemClick += Gallery_ItemClick;
}
void Gallery_ItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e) {
clickedItem = e.Item;
if ((OwnerEdit as TokenEdit).EditValue != null && (OwnerEdit as TokenEdit).EditValue.ToString().Contains(e.Item.Description))
return;
this.OwnerEdit.ClosePopup(PopupCloseMode.Normal);
}
public override int GetItemCount() {
return tokenList.Count;
}
public override void SetDataSource(object dataSource) {
if (customGallery1.Gallery.Groups[0].Items.Count != 10) createData();
}
public override int CalcFormHeight(int itemCount) {
return 130;
}
public override int CalcFormWidth() {
return base.CalcFormWidth();
}
public override object GetResultValue() {
int index = customGallery1.Gallery.Groups[0].Items.IndexOf(clickedItem);
return tokenList[index];
}
public IEnumerable<TokenEditToken> createData() {
for (int i = 0; i < 10; i++) {
tokenList.Add(new TokenEditToken("Token " + i.ToString(), "Token " + i.ToString()));
customGallery1.Gallery.Groups[0].Items.Add(new GalleryItem(imageCollection1.Images[i], tokenList[i].Description, tokenList[i].Description));
}
return tokenList;
}
}
[ToolboxItem(true)]
public class customGallery : GalleryControl {
public customGallery() {
//SetStyle(ControlStyles.UserMouse, false);
}
protected override bool AllowFocus {
get {
return false;
}
}
}
}