■ AdornerUIManager 클래스를 사용해 배지를 표시하는 방법을 보여준다.
▶ MainForm.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 |
using System.Drawing; using DevExpress.Utils.VisualEffects; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Badge badge1 = GetBadge(this.button1, ContentAlignment.MiddleLeft, BadgePaintStyle.Critical , "1"); Badge badge2 = GetBadge(this.button2, ContentAlignment.MiddleLeft, BadgePaintStyle.Information, "2"); Badge badge3 = GetBadge(this.button3, ContentAlignment.MiddleLeft, BadgePaintStyle.Question , "3"); Badge badge4 = GetBadge(this.button4, ContentAlignment.MiddleLeft, BadgePaintStyle.System , "4"); Badge badge5 = GetBadge(this.button5, ContentAlignment.MiddleLeft, BadgePaintStyle.Warning , "5"); this.adornerUIManager.Elements.Add(badge1); this.adornerUIManager.Elements.Add(badge2); this.adornerUIManager.Elements.Add(badge3); this.adornerUIManager.Elements.Add(badge4); this.adornerUIManager.Elements.Add(badge5); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 배지 구하기 - GetBadge(targetElement, location, paintStyle, text) /// <summary> /// 배지 구하기 /// </summary> /// <param name="targetElement">타겟 엘리먼트</param> /// <param name="location">위치</param> /// <param name="paintStyle">페인트 스타일</param> /// <param name="text">텍스트</param> /// <returns>배지</returns> private Badge GetBadge(object targetElement, ContentAlignment? location, BadgePaintStyle? paintStyle, string text) { Badge badge = new Badge(); badge.TargetElement = targetElement; badge.Properties.Location = location; badge.Properties.PaintStyle = paintStyle; badge.Properties.TextMargin = new System.Windows.Forms.Padding(1); badge.Properties.Text = text; return badge; } #endregion } } |