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
/
Form1.cs
54 lines (53 loc) · 2.04 KB
/
Form1.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
using DevExpress.Utils;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Ribbon.Gallery;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DXApplication1
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
DataItemCollection dataStore;
public Form1() {
InitializeComponent();
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
this.dataStore = LoadData();
InitializeGallery(this.dataStore);
}
private DataItemCollection LoadData() {
return new DataItemCollection() { new DataItem(true), new DataItem(false), new DataItem(true), new DataItem(false)};
}
void InitializeGallery(DataItemCollection dataStore) {
foreach(var item in dataStore)
galleryControl1.Gallery.Groups[0].Items.Add(new GalleryItem() { Tag = item, Image = DXApplication1.Properties.Resources.Image1 });
}
private void galleryControl1_Gallery_ContextButtonClick(object sender, ContextItemClickEventArgs e) {
CheckContextButton check = e.Item as CheckContextButton;
if(check == null) return;
GalleryItem galleryItem = e.DataItem as GalleryItem;
DataItem data = (DataItem)galleryItem.Tag;
data.IsChecked = check.Checked;
}
private void galleryControl1_Gallery_ContextButtonCustomize(object sender, GalleryContextButtonCustomizeEventArgs e) {
CheckContextButton check = e.Item as CheckContextButton;
if(check == null) return;
DataItem data = (DataItem)e.GalleryItem.Tag;
check.Checked = data.IsChecked;
}
}
public class DataItem {
public DataItem(bool isChecked) {
IsChecked = isChecked;
}
public bool IsChecked { get; set; }
}
public class DataItemCollection : List<DataItem> {
}
}