-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomAlertControl.cs
76 lines (62 loc) · 2.89 KB
/
CustomAlertControl.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
75
76
using DevExpress.XtraBars.Alerter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication2 {
public class CustomAlertControl : AlertControl {
public CustomAlertControl() { }
public CustomAlertControl(System.ComponentModel.IContainer container)
: base(container) { }
protected override AlertForm CreateAlertForm(System.Drawing.Point location, AlertControl control, AlertInfo info) {
return new MyAlertForm(location, control, info);
}
public void Show(Form owner, string caption, string text, string hotTrackedText, Image image, object tag, Color color) {
base.Show(owner, new MyAlertInfo(caption, text, hotTrackedText, image, tag, color));
}
}
public class MyAlertForm : AlertForm {
public MyAlertForm(System.Drawing.Point location, IAlertControl control, AlertInfo info)
: base(location, control, info) { }
protected override AlertPainter CreatePainter() {
return new MyAlertPainter(this);
}
}
public class MyAlertPainter : AlertPainter {
public MyAlertPainter(AlertFormCore form)
: base(form) {
}
protected override void DrawContent(DevExpress.Utils.Drawing.GraphicsCache graphicsCache, DevExpress.Skins.Skin skin) {
base.DrawContent(graphicsCache, skin);
MyAlertInfo alertInfo = Owner.Info as MyAlertInfo;
if (alertInfo != null) {
Color backColor = alertInfo.BackColor;
Rectangle rect = new Rectangle(Owner.ClientRectangle.Location, Owner.ClientRectangle.Size);
rect.Inflate(-2, -2);
using (SolidBrush brush = new SolidBrush(backColor))
graphicsCache.Graphics.FillRectangle(brush, rect);
}
}
}
public class MyAlertInfo : AlertInfo {
public MyAlertInfo(string caption, string text)
: base(caption, text) { }
public MyAlertInfo(string caption, string text, string hotTrackedText)
: base(caption, text, hotTrackedText) {
}
public MyAlertInfo(string caption, string text, Image image)
: base(caption, text, image) { }
public MyAlertInfo(string caption, string text, string hotTrackedText, Image image)
: base(caption, text, hotTrackedText, image) { }
public MyAlertInfo(string caption, string text, string hotTrackedText, Image image, object tag)
: base(caption, text, hotTrackedText, image, tag) { }
public MyAlertInfo(string caption, string text, string hotTrackedText, Image image, object tag, Color color)
: base(caption, text, hotTrackedText, image, tag) {
BackColor = color;
}
public Color BackColor {
get; set;
}
}
}