첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ BitmapHelper.cs

using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace TestProject
{
    /// <summary>
    /// 비트맵 헬퍼
    /// </summary>
    public unsafe class BitmapHelper
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Struct
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 픽셀 데이터 - PixelData

        /// <summary>
        /// 픽셀 데이터
        /// </summary>
        private struct PixelData
        {
            //////////////////////////////////////////////////////////////////////////////////////////////////// Field
            ////////////////////////////////////////////////////////////////////////////////////////// Public

            #region Field

            /// <summary>
            /// 파란색
            /// </summary>
            public byte Blue;

            /// <summary>
            /// 녹색
            /// </summary>
            public byte Green;

            /// <summary>
            /// 빨간색
            /// </summary>
            public byte Red;

            /// <summary>
            /// 알파
            /// </summary>
            public byte Alpha;

            #endregion

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

            #region 문자열 구하기 - ToString()

            /// <summary>
            /// 문자열 구하기
            /// </summary>
            /// <returns>문자열</returns>
            public override string ToString()
            {
                return "(" + Alpha.ToString() + ", " + Red.ToString() + ", " + Green.ToString() + ", " + Blue.ToString() + ")";
            }

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 비트맵
        /// </summary>
        private Bitmap bitmap = null;

        /// <summary>
        /// 비트맵 너비
        /// </summary>
        private int bitmapWidth = 0;

        /// <summary>
        /// 비트맵 데이터
        /// </summary>
        private BitmapData bitmapData = null;

        /// <summary>
        /// 베이스 포인터
        /// </summary>
        private Byte* basePointer = null;

        /// <summary>
        /// 픽셀 데이터
        /// </summary>
        private PixelData* pixelData = null;

        #endregion

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

        #region 생성자 - BitmapHelper(bitmap)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="bitmap">비트맵</param>
        public BitmapHelper(Bitmap bitmap)
        {
            this.bitmap = bitmap;
        }

        #endregion

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

        #region 비트맵 잠그기 - LockBitmap()

        /// <summary>
        /// 비트맵 잠그기
        /// </summary>
        public void LockBitmap()
        {
            Rectangle rectangle = new Rectangle(Point.Empty, this.bitmap.Size);

            this.bitmapWidth = (int)(rectangle.Width * sizeof(PixelData));

            if(this.bitmapWidth % 4 != 0)
            {
                this.bitmapWidth = 4 * (this.bitmapWidth / 4 + 1);
            }

            this.bitmapData = this.bitmap.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

            this.basePointer = (Byte*)this.bitmapData.Scan0.ToPointer();
        }

        #endregion

        #region 픽셀 구하기 - GetPixel(int x, int y)

        /// <summary>
        /// 픽셀 구하기
        /// </summary>
        /// <param name="x">X 좌표</param>
        /// <param name="y">Y 좌표</param>
        /// <returns>색상</returns>
        public Color GetPixel(int x, int y)
        {
            this.pixelData = (PixelData*)(this.basePointer + y * this.bitmapWidth + x * sizeof(PixelData));

            return Color.FromArgb(this.pixelData->Alpha, this.pixelData->Red, this.pixelData->Green, this.pixelData->Blue);
        }

        #endregion
        #region 다음 픽셀 구하기 - GetPixelNext()

        /// <summary>
        /// 다음 픽셀 구하기
        /// </summary>
        /// <returns>색상</returns>
        public Color GetPixelNext()
        {
            this.pixelData++;

            return Color.FromArgb(this.pixelData->Alpha, this.pixelData->Red, this.pixelData->Green, this.pixelData->Blue);
        }

        #endregion
        #region 픽셀 설정하기 - SetPixel(x, y, color)

        /// <summary>
        /// 픽셀 설정하기
        /// </summary>
        /// <param name="x">X 좌표</param>
        /// <param name="y">Y 좌표</param>
        /// <param name="color">색상</param>
        public void SetPixel(int x, int y, Color color)
        {
            PixelData* pixelData = (PixelData*)(this.basePointer + y * this.bitmapWidth + x * sizeof(PixelData));

            pixelData->Alpha = color.A;
            pixelData->Red   = color.R;
            pixelData->Green = color.G;
            pixelData->Blue  = color.B;
        }

        #endregion

        #region 비트맵 잠금 해제하기 - UnlockBitmap()

        /// <summary>
        /// 비트맵 잠금 해제하기
        /// </summary>
        public void UnlockBitmap()
        {
            this.bitmap.UnlockBits(this.bitmapData);

            this.bitmapData  = null;
            this.basePointer = null;
        }

        #endregion
    }
}

 

728x90

 

▶ TransparentSplashControl.cs

using System;
using System.Drawing;
using System.Drawing.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 투명 스플래시 컨트롤
    /// </summary>
    public sealed class TransparentSplashControl : Control
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Import
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 데스크톱 윈도우 구하기 - GetDesktopWindow()

        /// <summary>
        /// 데스크톱 윈도우 구하기
        /// </summary>
        /// <returns>데스크톱 윈도우 핸들</returns>
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr GetDesktopWindow();

        #endregion
        #region 부모 설정하기 - SetParent(childHandle, parentHandle)

        /// <summary>
        /// 부모 설정하기
        /// </summary>
        /// <param name="childHandle">자식 핸들</param>
        /// <param name="parentHandle">부모 핸들</param>
        /// <returns>처리 결과</returns>
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr SetParent(IntPtr childHandle, IntPtr parentHandle);

        #endregion
        #region 윈도우 위치 설정하기 - SetWindowPos(windowHandle, windowHandleInsertAfter, x, y, width, height, flag)

        /// <summary>
        /// 윈도우 위치 설정하기
        /// </summary>
        /// <param name="windowHandle">윈도우 핸들</param>
        /// <param name="windowHandleInsertAfter">추가할 윈도우의 앞에 오는 윈도우 핸들</param>
        /// <param name="x">X 좌표</param>
        /// <param name="y">Y 좌표</param>
        /// <param name="width">너비</param>
        /// <param name="height">높이</param>
        /// <param name="flag">플래그</param>
        /// <returns>처리 결과</returns>
        [DllImport("user32.dll", EntryPoint = "SetWindowPos", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        private static extern int SetWindowPos(IntPtr windowHandle, IntPtr windowHandleInsertAfter, int x, int y, int width, int height, uint flag);

        #endregion
        #region 비트맵 복사하기 - BitBlt(targetDCHandle, targetX, targetY, width, height, sourceDCHandle, sourceX, sourceY, ropFlag)

        /// <summary>
        /// 비트맵 복사하기
        /// </summary>
        /// <param name="targetDCHandle">타겟 디바이스 컨텍스트 핸들</param>
        /// <param name="targetX">타겟 X 좌표</param>
        /// <param name="targetY">타겟 Y 좌표</param>
        /// <param name="width">너비</param>
        /// <param name="height">높이</param>
        /// <param name="sourceDCHandle">소스 디바이스 컨텍스트 핸들</param>
        /// <param name="sourceX">소스 X 좌표</param>
        /// <param name="sourceY">소스 Y 좌표</param>
        /// <param name="ropFlag">래스터 연산 플래그</param>
        /// <returns>처리 결과</returns>
        [DllImport("gdi32.dll")]
        private static extern bool BitBlt(IntPtr targetDCHandle, int targetX, int targetY, int width, int height, IntPtr sourceDCHandle, int sourceX, int sourceY, uint ropFlag);

        #endregion
        #region 픽셀 설정하기 - SetPixel(dcHandle, x, y, color)

        /// <summary>
        /// 픽셀 설정하기
        /// </summary>
        /// <param name="dcHandle">디바이스 컨텍스트 핸들</param>
        /// <param name="x">X 좌표</param>
        /// <param name="y">Y 좌표</param>
        /// <param name="color">색상</param>
        /// <returns>실제 설정 색상</returns>
        [DllImport("gdi32.dll")]
        private static extern uint SetPixel(IntPtr dcHandle, int x, int y, uint color);

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 인스턴스
        /// </summary>
        private static TransparentSplashControl _instance;

        /// <summary>
        /// 잠금 객체
        /// </summary>
        private static object _lockObject = new object();

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// WS_EX_TOPMOST
        /// </summary>
        private const int WS_EX_TOPMOST = unchecked((int)0x00000008L);

        /// <summary>
        /// WS_EX_TOOLWINDOW
        /// </summary>
        private const int WS_EX_TOOLWINDOW = unchecked((int)0x00000080);

        /// <summary>
        /// SWP_NOSIZE
        /// </summary>
        private const uint SWP_NOSIZE = 0x0001;

        /// <summary>
        /// SWP_NOMOVE
        /// </summary>
        private const uint SWP_NOMOVE = 0x0002;

        /// <summary>
        /// HWND_TOPMOST
        /// </summary>
        private const int HWND_TOPMOST = -1;


        /// <summary>
        /// 제목
        /// </summary>
        private string title;

        /// <summary>
        /// 주석
        /// </summary>
        private string comment;

        /// <summary>
        /// 문자열 포맷
        /// </summary>
        private StringFormat stringFormat;

        /// <summary>
        /// 텍스트 오프셋 X
        /// </summary>
        private int textOffsetX;

        /// <summary>
        /// 텍스트 오프셋 Y
        /// </summary>
        private int textOffsetY;

        /// <summary>
        /// 리딩
        /// </summary>
        private int leading;

        #endregion

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

        #region 인스턴스 - Instance

        /// <summary>
        /// 인스턴스
        /// </summary>
        public static TransparentSplashControl Instance
        {
            get
            {
                lock(_lockObject)
                {
                    if(_instance == null || _instance.IsDisposed)
                    {
                        _instance = new TransparentSplashControl();
                    }

                    return _instance;
                }
            }
        }

        #endregion

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

        #region 제목 - Title

        /// <summary>
        /// 제목
        /// </summary>
        public string Title
        {
            get
            {
                return this.title;
            }
            set
            {
                if(this.title != value)
                {
                    this.title = value;

                    Invalidate
                    (
                        new Rectangle
                        (
                            Convert.ToInt32(TitleRectangle.X),
                            Convert.ToInt32(TitleRectangle.Y),
                            TextAreaWidth,
                            Convert.ToInt32(TitleRectangle.Height)
                        )
                    );

                    Update();
                }
            }
        }

        #endregion
        #region 주석 - Comment

        /// <summary>
        /// 주석
        /// </summary>
        public string Comment
        {
            get
            {
                return this.comment;
            }
            set
            {
                if(this.comment != value)
                {
                    this.comment = value;

                    Invalidate
                    (
                        new Rectangle
                        (
                            Convert.ToInt32(CommentRectangle.X),
                            Convert.ToInt32(CommentRectangle.Y),
                            TextAreaWidth,
                            Convert.ToInt32(CommentRectangle.Height)
                        )
                    );

                    Update();
                }
            }
        }

        #endregion
        #region 텍스트 영역 X - TextAreaX

        /// <summary>
        /// 텍스트 영역 X
        /// </summary>
        public int TextAreaX { get; set; }

        #endregion
        #region 텍스트 영역 Y - TextAreaY

        /// <summary>
        /// 텍스트 영역 Y
        /// </summary>
        public int TextAreaY { get; set; }

        #endregion
        #region 텍스트 영역 너비 - TextAreaWidth

        /// <summary>
        /// 텍스트 영역 너비
        /// </summary>
        public int TextAreaWidth { get; set; }

        #endregion
        #region 텍스트 영역 높이 - TextAreaHeight

        /// <summary>
        /// 텍스트 영역 높이
        /// </summary>
        public int TextAreaHeight { get; set; }

        #endregion
        #region 투명 색상 - TransparencyColor

        /// <summary>
        /// 투명 색상
        /// </summary>
        public Color TransparencyColor { get; set; }

        #endregion
        #region 제목 사각형 - TitleRectangle

        /// <summary>
        /// 제목 사각형
        /// </summary>
        private RectangleF TitleRectangle { get; set; }

        #endregion
        #region 주석 사각형 - CommentRectangle

        /// <summary>
        /// 주석 사각형
        /// </summary>
        private RectangleF CommentRectangle { get; set; }

        #endregion
        #region 주석 폰트 - CommentFont

        /// <summary>
        /// 주석 폰트
        /// </summary>
        public Font CommentFont { get; set; }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 생성 매개 변수 - CreateParams

        /// <summary>
        /// 생성 매개 변수
        /// </summary>
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams createParams = base.CreateParams;

                createParams.ExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;

                createParams.Parent = IntPtr.Zero;

                return createParams;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 생성자 - TransparentSplashControl()

        /// <summary>
        /// 생성자
        /// </summary>
        private TransparentSplashControl()
        {
            Title   = string.Empty;
            Comment = string.Empty;

            Font        = new Font("Verdana", 28.00f, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            CommentFont = new Font("Verdana", 8.25f , FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));

            SetStyle(ControlStyles.DoubleBuffer        , false);
            SetStyle(ControlStyles.UserPaint           , true );
            SetStyle(ControlStyles.AllPaintingInWmPaint, true );

            this.stringFormat = new StringFormat();

            this.stringFormat.FormatFlags |= StringFormatFlags.NoWrap;
            this.stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

            this.textOffsetY = 0;
            this.textOffsetX = 10;

            this.leading = 6;

            Visible = false;

            TextAreaX      = 0;
            TextAreaY      = 0;
            TextAreaWidth  = 0;
            TextAreaHeight = 0;

            TransparencyColor = Color.Black;

            CommentRectangle = RectangleF.Empty;
            TitleRectangle   = RectangleF.Empty;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Protected

        #region 디스플레이 시작하기 - BeginDisplay()

        /// <summary>
        /// 디스플레이 시작하기
        /// </summary>
        public static void BeginDisplay()
        {
            if(!Instance.Visible)
            {
                Instance.SetLocation();

                if(!Instance.Created)
                {
                    Instance.CreateControl();
                }

                SetWindowPos(Instance.Handle, (IntPtr)HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

                Instance.Visible = true;

                Instance.Refresh();
            }
        }

        #endregion
        #region 디스플레이 종료하기 - EndDisplay()

        /// <summary>
        /// 디스플레이 종료하기
        /// </summary>
        public static void EndDisplay()
        {
            Instance.Visible = false;
        }

        #endregion

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

        #region 핸들 생성시 처리하기 - OnHandleCreated(e)

        /// <summary>
        /// 핸들 생성시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnHandleCreated(EventArgs e)
        {
            IntPtr desktopWindowHandle = IntPtr.Zero;

            if(Handle != IntPtr.Zero)
            {
                desktopWindowHandle = GetDesktopWindow();

                SetParent(Handle, desktopWindowHandle);
            }

            if(TextAreaWidth == 0)
            {
                TextAreaWidth = ClientRectangle.Width;
            }

            if(TextAreaHeight == 0)
            {
                TextAreaHeight = ClientRectangle.Height;
            }

            CommentRectangle = new RectangleF(0, 0, (float)TextAreaWidth, (float)TextAreaHeight);
            TitleRectangle   = new RectangleF(0, 0, (float)TextAreaWidth, (float)TextAreaHeight);

            base.OnHandleCreated(e);
        }

        #endregion
        #region 배경 이미지 변경시 처리하기 - OnBackgroundImageChanged(e)

        /// <summary>
        /// 배경 이미지 변경시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnBackgroundImageChanged(EventArgs e)
        {
            base.OnBackgroundImageChanged(e);

            if(BackgroundImage != null)
            {
                Width  = BackgroundImage.Width;
                Height = BackgroundImage.Height;

                SetLocation();
            }

            Refresh();
        }

        #endregion
        #region 배경 페인트시 처리하기 - OnPaintBackground(e)

        /// <summary>
        /// 배경 페인트시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {
        }

        #endregion
        #region 페인트시 처리하기 - OnPaint(e)

        /// <summary>
        /// 페인트시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if(Bounds.Width > 0 && Bounds.Height > 0 && Visible)
            {
                Graphics graphics = e.Graphics;

                graphics.SetClip(e.ClipRectangle);

                graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                #region 이미지 배경을 투명 처리한다.

                Color transparentColor = Color.FromArgb(TransparencyColor.R, TransparencyColor.G, TransparencyColor.B);

                IntPtr dcHandle = graphics.GetHdc();

                Point point = new Point();

                Color pixelColor;

                Bitmap bitmap = (Bitmap)BackgroundImage;

                BitmapHelper bitmapHelper = new BitmapHelper(bitmap);

                bitmapHelper.LockBitmap();

                for(point.Y = 0; point.Y < BackgroundImage.Height; point.Y++)
                {
                    for(point.X = 0; point.X < BackgroundImage.Width; point.X++)
                    {
                        if((pixelColor = bitmapHelper.GetPixel(point.X, point.Y)) != transparentColor)
                        {
                            SetPixel(dcHandle, point.X, point.Y, GetColorValue(pixelColor));
                        }
                    }
                }

                bitmapHelper.UnlockBitmap();

                graphics.ReleaseHdc();

                #endregion
                #region 텍스트를 그린다.

                this.textOffsetY = TextAreaY;

                if(Title != string.Empty)
                {
                    Font fontTitle = new Font(Font, FontStyle.Bold);

                    SizeF titleSize = graphics.MeasureString(Title, fontTitle, TextAreaWidth, this.stringFormat);

                    RectangleF titleRectangle = new RectangleF(TextAreaX + this.textOffsetX, this.textOffsetY, titleSize.Width, titleSize.Height);

                    SolidBrush titleBrush = new SolidBrush(ForeColor);

                    graphics.DrawString(Title, fontTitle, titleBrush, titleRectangle, this.stringFormat);

                    titleBrush.Dispose();

                    fontTitle.Dispose();

                    TitleRectangle = titleRectangle;

                    this.textOffsetY += this.leading + Convert.ToInt32(titleRectangle.Height);
                }

                if(Comment != string.Empty)
                {
                    SizeF commentSize = graphics.MeasureString(Comment, CommentFont, TextAreaWidth, this.stringFormat);

                    this.textOffsetY += Convert.ToInt32(Math.Ceiling(commentSize.Height));

                    RectangleF commentRectangle = new RectangleF(TextAreaX + this.textOffsetX, this.textOffsetY, commentSize.Width, commentSize.Height);

                    SolidBrush commentBrush = new SolidBrush(ForeColor);

                    graphics.DrawString(Comment, CommentFont, commentBrush, commentRectangle, this.stringFormat);

                    commentBrush.Dispose();

                    CommentRectangle = commentRectangle;
                }

                #endregion
            }
        }

        #endregion
        #region 리소스 해제하기 - Dispose(disposing)

        /// <summary>
        /// 리소스 해제하기
        /// </summary>
        /// <param name="disposing">해제 여부</param>
        protected override void Dispose(bool disposing)
        {
            if(disposing)
            {
                CommentFont.Dispose();

                CommentFont = null;

                if(this.stringFormat != null)
                {
                    this.stringFormat.Dispose();

                    this.stringFormat = null;
                }
            }

            base.Dispose(disposing);
        }

        #endregion

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

        #region 배경 이미지 설정하기 - SetBackgroundImage(image)

        /// <summary>
        /// 배경 이미지 설정하기
        /// </summary>
        /// <param name="image">이미지</param>
        public static void SetBackgroundImage(Image image)
        {
            Instance.BackgroundImage = image;
        }

        #endregion
        #region 제목 설정하기 - SetTitle(title)

        /// <summary>
        /// 제목 설정하기
        /// </summary>
        /// <param name="title">제목</param>
        public static void SetTitle(string title)
        {
            Instance.Title = title;
        }

        #endregion
        #region 주석 설정하기 - SetComment(comment)

        /// <summary>
        /// 주석 설정하기
        /// </summary>
        /// <param name="comment">주석</param>
        public static void SetComment(string comment)
        {
            Instance.Comment = comment;
        }

        #endregion

        #region 위치 설정하기 - SetLocation()

        /// <summary>
        /// 위치 설정하기
        /// </summary>
        private void SetLocation()
        {
            Rectangle workingArea = SystemInformation.WorkingArea;

            int x = (workingArea.Width  - Width ) / 2;
            int y = (workingArea.Height - Height) / 2;

            Location = new Point(x, y);
        }

        #endregion
        #region 색상 값 구하기 - GetColorValue(color)

        /// <summary>
        /// 색상 값 구하기
        /// </summary>
        /// <param name="color">색상</param>
        /// <returns>색상 값</returns>
        private uint GetColorValue(Color color)
        {
            return Convert.ToUInt32((color.B << 16 | color.G << 8 | color.R));
        }

        #endregion
    }
}

 

300x250

 

▶ MainForm.cs

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

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

        #region 생성자 - MainForm()

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

            TransparentSplashControl.Instance.TransparencyColor = Color.Black ;
            TransparentSplashControl.Instance.Width             = 256;
            TransparentSplashControl.Instance.Height            = 256;
            TransparentSplashControl.Instance.TextAreaX         = 32;
            TransparentSplashControl.Instance.TextAreaY         = 96;
            TransparentSplashControl.Instance.TextAreaWidth     = 192;
            TransparentSplashControl.Instance.TextAreaHeight    = 64;
            TransparentSplashControl.Instance.ForeColor         = Color.White ;

            TransparentSplashControl.SetBackgroundImage(Image.FromFile("splash.png"));

            TransparentSplashControl.SetTitle("스플래시!");

            this.startButton.Click += startButton_Click;
            this.stopButton.Click  += stopButton_Click;
        }

        #endregion

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

        #region 폼을 닫는 경우 처리하기 - OnFormClosed(e)

        /// <summary>
        /// 폼을 닫는 경우 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            TransparentSplashControl.EndDisplay();

            TransparentSplashControl.Instance.Dispose();

            base.OnFormClosed(e);
        }

        #endregion

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

        #region 시작하기 버튼 클릭시 처리하기 - startButton_Click(sender, e)

        /// <summary>
        /// 시작하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void startButton_Click(object sender, EventArgs e)
        {
            TransparentSplashControl.BeginDisplay();
        }

        #endregion
        #region 중단하기 버튼 클릭시 처리하기 - stopButton_Click(sender, e)

        /// <summary>
        /// 중단하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void stopButton_Click(object sender, EventArgs e)
        {
            TransparentSplashControl.EndDisplay();
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요