qlabeltitle.cs

来自「基于C/S的医疗卫生管理系统」· CS 代码 · 共 82 行

CS
82
字号
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Qeb.Control
{
    public partial class QLabelTitle : System.Windows.Forms.Label
    {
        //private Color m_StartColor = Color.White;
        //private Color m_EndColor = Color.LightSteelBlue;
        private Color m_StartColor = Color.FromArgb(200, 223, 251);
        private Color m_EndColor = Color.FromArgb(125, 165, 224);
        private LinearGradientMode m_LinearGradientMode = LinearGradientMode.Vertical;

        private ViewStyle m_ViewStyle = ViewStyle.Standard;

        [Description("控件样式"), Category("控件样式")]
        public ViewStyle ControlStyle
        {
            get { return m_ViewStyle; }
            set { m_ViewStyle = value; }
        }

        public QLabelTitle()
        {
            InitializeComponent();
        }

        public QLabelTitle(IContainer container)
        {
            this.AutoSize = false;
            container.Add(this);

            InitializeComponent();
        }

        [Description("渐变色开始颜色"), Category("控件背景")]
        public Color StartColor
        {
            get { return m_StartColor; }
            set { m_StartColor = value; }
        }

        [Description("渐变色终止颜色"), Category("控件背景")]
        public Color EndColor
        {
            get { return m_EndColor; }
            set { m_EndColor = value; }
        }

        [Description("渐变色绘制方向"), Category("控件背景")]
        public LinearGradientMode LinearGradientMode
        {
            get { return m_LinearGradientMode; }
            set { m_LinearGradientMode = value; }
        }

        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
            if (m_ViewStyle == ViewStyle.Custom)
            {
                base.OnPaintBackground(pevent);
            }
            else
            {
                if (this.Disposing) return;
                if (ClientRectangle.IsEmpty) return;

                LinearGradientBrush linearGradientBrush = new LinearGradientBrush(ClientRectangle, m_StartColor, m_EndColor, m_LinearGradientMode);

                pevent.Graphics.FillRectangle(linearGradientBrush, ClientRectangle);
                pevent.Graphics.Flush();
                linearGradientBrush.Dispose();
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?