-
Notifications
You must be signed in to change notification settings - Fork 0
/
RepositoryItemCustomRadioGroup.cs
72 lines (61 loc) · 2.28 KB
/
RepositoryItemCustomRadioGroup.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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.XtraEditors.Registrator;
using DevExpress.XtraEditors.Repository;
using System.Reflection;
using System.Drawing;
using DevExpress.XtraEditors.ViewInfo;
using DXSample;
namespace WindowsApplication3 {
[UserRepositoryItem("RegisterCustomEdit")]
public class RepositoryItemCustomRadioGroup : RepositoryItemRadioGroup
{
static RepositoryItemCustomRadioGroup() { RegisterCustomEdit(); }
public RepositoryItemCustomRadioGroup() { }
public const string CustomEditName = "CustomRadioGroup";
public override string EditorTypeName { get { return CustomEditName; } }
public static void RegisterCustomEdit()
{
Image img = null;
try
{
img = (Bitmap)Bitmap.FromStream(Assembly.GetExecutingAssembly().
GetManifestResourceStream("DevExpress.CustomEditors.CustomEdit.bmp"));
}
catch
{
}
EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(CustomEditName,
typeof(CustomRadioGroup), typeof(RepositoryItemCustomRadioGroup),
typeof(RadioGroupViewInfo), new CustomRadioGroupPainter(), true, img));
}
static readonly object customDraw = new object();
public event CustomDrawEventHandler CustomDrawItem
{
add { this.Events.AddHandler(customDraw, value); }
remove { this.Events.RemoveHandler(customDraw, value); }
}
internal void RaiseCustomDrawItem(CustomDrawEventArgs e)
{
CustomDrawEventHandler handler = (CustomDrawEventHandler)Events[customDraw];
if (handler != null) handler(GetEventSender(), e);
}
public override void Assign(RepositoryItem item)
{
BeginUpdate();
try
{
base.Assign(item);
RepositoryItemCustomRadioGroup source = item as RepositoryItemCustomRadioGroup;
if (source == null) return;
Events.AddHandler(customDraw, source.Events[customDraw]);
}
finally
{
EndUpdate();
}
}
}
}