첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ ViewInfo.cs

using System.Drawing;

using DevExpress.Utils.Drawing;
using DevExpress.Utils.Text;

namespace TestProject
{
    /// <summary>
    /// 뷰 정보
    /// </summary>
    public class ViewInfo
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 진행 폰트
        /// </summary>
        private Font progressFont = null;

        /// <summary>
        /// 브러시
        /// </summary>
        private Brush brush = null;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public
        
        #region 단계 - Stage

        /// <summary>
        /// 단계
        /// </summary>
        public string Stage { get; set; }

        #endregion
        #region 카운터 - Counter

        /// <summary>
        /// 카운터
        /// </summary>
        public int Counter { get; set; }

        #endregion
        #region 텍스트 - Text

        /// <summary>
        /// 텍스트
        /// </summary>
        public string Text
        {
            get
            {
                return string.Format("{0} - ({1}%)", Stage, Counter.ToString("D2"));
            }
        }

        #endregion
        #region 진행 레이블 폰트 - ProgressLabelFont

        /// <summary>
        /// 진행 레이블 폰트
        /// </summary>
        public Font ProgressLabelFont
        {
            get
            {
                if(this.progressFont == null)
                {
                    this.progressFont = new Font("나눔고딕코딩", 10);
                }

                return this.progressFont;
            }
        }

        #endregion
        #region 브러시 - Brush

        /// <summary>
        /// 브러시
        /// </summary>
        public Brush Brush
        {
            get
            {
                if(this.brush == null)
                {
                    this.brush = new SolidBrush(Color.Black);
                }

                return this.brush;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - ViewInfo()

        /// <summary>
        /// 생성자
        /// </summary>
        public ViewInfo()
        {
            Stage   = string.Empty;
            Counter = 1;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 진행 레이블 위치 계산하기 - CalculateProgressLabelPoint(graphicsCache, boundRectangle)

        /// <summary>
        /// 진행 레이블 위치 계산하기
        /// </summary>
        /// <param name="graphicsCache">그래픽스 캐시</param>
        /// <param name="boundRectangle">경계 사각형</param>
        /// <returns>진행 레이블 위치</returns>
        public PointF CalculateProgressLabelPoint(GraphicsCache graphicsCache, Rectangle boundRectangle)
        {
            const int yOffset = 40;

            Size size = TextUtils.GetStringSize(graphicsCache.Graphics, Text, ProgressLabelFont);

            return new Point(boundRectangle.Width / 2 - size.Width / 2, yOffset);
        }

        #endregion
    }
}

 

▶ CustomImagePainter.cs

using System.Drawing;

using DevExpress.Utils.Drawing;
using DevExpress.Utils.Text;
using DevExpress.XtraSplashScreen;

namespace TestProject
{
    /// <summary>
    /// 커스텀 이미지 페인터
    /// </summary>
    class CustomImagePainter : ICustomImagePainter
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 뷰 정보
        /// </summary>
        private ViewInfo viewInfo = null;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 페인터 - Painter

        /// <summary>
        /// 페인터
        /// </summary>
        public static CustomImagePainter Painter { get; private set; }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 뷰 정보 - ViewInfo

        /// <summary>
        /// 뷰 정보
        /// </summary>
        public ViewInfo ViewInfo
        {
            get
            {
                if(this.viewInfo == null)
                {
                    this.viewInfo = new ViewInfo();
                }

                return this.viewInfo;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Static

        #region 생성자 - CustomImagePainter()

        /// <summary>
        /// 생성자
        /// </summary>
        static CustomImagePainter()
        {
            Painter = new CustomImagePainter();
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Protected

        #region 생성자 - CustomImagePainter()

        /// <summary>
        /// 생성자
        /// </summary>
        protected CustomImagePainter()
        {
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 그리기 - Draw(graphicsCache, boundRectangle)

        /// <summary>
        /// 그리기
        /// </summary>
        /// <param name="graphicsCache">그래픽스 캐시</param>
        /// <param name="boundRectangle">경계 사각형</param>
        public void Draw(GraphicsCache graphicsCache, Rectangle boundRectangle)
        {
            PointF point = ViewInfo.CalculateProgressLabelPoint(graphicsCache, boundRectangle);

            graphicsCache.Graphics.DrawString(ViewInfo.Text, ViewInfo.ProgressLabelFont, ViewInfo.Brush, point);
        }

        #endregion
    }
}

 

▶ Program.cs

using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

using DevExpress.XtraSplashScreen;

namespace TestProject
{
    /// <summary>
    /// 프로그램
    /// </summary>
    static class Program
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 이미지 구하기 - GetImage()

        /// <summary>
        /// 이미지 구하기
        /// </summary>
        /// <returns>이미지</returns>
        private static Image GetImage()
        {
            Assembly assembly = typeof(Program).Assembly;
 
            return new Bitmap(assembly.GetManifestResourceStream("TestProject.Images.sample.png"));
        }

        #endregion
        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Image image = GetImage();

            SplashScreenManager.ShowImage(image, true, true, CustomImagePainter.Painter);

            Application.Run(new MainForm());
        }

        #endregion
    }
}

 

▶ MainForm.cs

using System;
using System.Windows.Forms;

using DevExpress.XtraSplashScreen;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            Initialize();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 로드시 처리하기 - OnLoad(e)

        /// <summary>
        /// 로드시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SplashScreenManager.HideImage();
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 기본 데이터 로드하기 - LoadBasicData()

        /// <summary>
        /// 기본 데이터 로드하기
        /// </summary>
        private void LoadBasicData()
        {
            CustomImagePainter.Painter.ViewInfo.Stage = "기본 데이터 로딩";

            for(int i = 1; i <= 100; i++)
            {
                System.Threading.Thread.Sleep(20);
                
                CustomImagePainter.Painter.ViewInfo.Counter = i;

                SplashScreenManager.Default.Invalidate();
            }
        }

        #endregion
        #region 폰트 데이터 로드하기 - LoadFontData()

        /// <summary>
        /// 폰트 데이터 로드하기
        /// </summary>
        private void LoadFontData()
        {
            CustomImagePainter.Painter.ViewInfo.Stage = "폰트 데이터 로딩";

            for(int i = 1; i <= 100; i++)
            {
                System.Threading.Thread.Sleep(20);

                CustomImagePainter.Painter.ViewInfo.Counter = i;

                SplashScreenManager.Default.Invalidate();
            }
        }

        #endregion
        #region 텍스처 데이터 로드하기 - LoadTextureData()

        /// <summary>
        /// 텍스처 데이터 로드하기
        /// </summary>
        private void LoadTextureData()
        {
            CustomImagePainter.Painter.ViewInfo.Stage = "텍스처 데이터 로딩";

            for(int i = 1; i <= 100; i++)
            {
                System.Threading.Thread.Sleep(20);

                CustomImagePainter.Painter.ViewInfo.Counter = i;

                SplashScreenManager.Default.Invalidate();
            }
        }

        #endregion
        #region 초기화 하기 - Initialize()

        /// <summary>
        /// 초기화 하기 
        /// </summary>
        protected void Initialize()
        {
            LoadBasicData();

            LoadFontData();

            LoadTextureData();
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요