■ AdornerUIManager 클래스 : 배지 사용하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

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

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요