ZForge.Controls.ExplorerBar.TaskItem.DrawGdiText C# (CSharp) 메소드

DrawGdiText() 보호된 메소드

protected DrawGdiText ( Graphics g ) : void
g System.Drawing.Graphics
리턴 void
        protected void DrawGdiText(Graphics g)
        {
            IntPtr hdc = g.GetHdc();

            if (hdc != IntPtr.Zero)
            {
                IntPtr hFont = this.Font.ToHfont();
                IntPtr oldFont = NativeMethods.SelectObject(hdc, hFont);

                int oldBkMode = NativeMethods.SetBkMode(hdc, 1);

                if (this.Enabled)
                {
                    int oldColor = NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(this.FocusLinkColor));

                    RECT rect = RECT.FromRectangle(this.TextRect);

                    NativeMethods.DrawText(hdc, this.Text, this.Text.Length, ref rect, this.DrawTextFlags);

                    NativeMethods.SetTextColor(hdc, oldColor);
                }
                else
                {
                    Rectangle layoutRectangle = this.TextRect;
                    layoutRectangle.Offset(1, 1);

                    Color color = ControlPaint.LightLight(this.DisabledColor);

                    int oldColor = NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(color));
                    RECT rect = RECT.FromRectangle(layoutRectangle);
                    NativeMethods.DrawText(hdc, this.Text, this.Text.Length, ref rect, this.DrawTextFlags);

                    layoutRectangle.Offset(-1, -1);
                    color = ControlPaint.Dark(this.DisabledColor);

                    NativeMethods.SetTextColor(hdc, ColorTranslator.ToWin32(color));
                    rect = RECT.FromRectangle(layoutRectangle);
                    NativeMethods.DrawText(hdc, this.Text, this.Text.Length, ref rect, this.DrawTextFlags);

                    NativeMethods.SetTextColor(hdc, oldColor);
                }

                NativeMethods.SetBkMode(hdc, oldBkMode);
                NativeMethods.SelectObject(hdc, oldFont);
                NativeMethods.DeleteObject(hFont);
            }
            else
            {
                this.DrawText(g);
            }

            g.ReleaseHdc(hdc);
        }