·您的位置: 首页 » 资源教程 » 编程开发 » ASP.NET » 一个自定义LABEL组件的C#源代码

一个自定义LABEL组件的C#源代码

类别: ASP.NET教程  评论数:0 总得分:0
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;

namespace wzsbmain
{
 /// <summary>
 /// Summary description for LabelGradient.
 /// </summary>
  
 public class wzsbmainLabel : System.Windows.Forms.Label
 {
  
  #region Implementtation Member Fields
  protected Color gradientColorOne = Color.White;
  protected Color gradientColorTwo = Color.Blue;
  protected LinearGradientMode lgm = LinearGradientMode.ForwardDiagonal;
  protected Border3DStyle b3dstyle = Border3DStyle.Bump;
  #endregion

  #region GradientColorOne Properties
  [
  DefaultValue(typeof(Color),\"White\"),
  Description(\"The first gradient color.\"),
  Category(\"Appearance\"),
  ]

   //GradientColorOne Properties
  public Color GradientColorOne
  {
   get
   {
    return gradientColorOne;
   }
   set
   {
    gradientColorOne = value;
    Invalidate();
   }
  }
  #endregion
  
  #region GradientColorTwo Properties
  [
  DefaultValue(typeof(Color),\"Blue\"),
  Description(\"The second gradient color.\"),
  Category(\"Appearance\"),
  ]

   //GradientColorTwo Properties
  public Color GradientColorTwo
  {
   get
   {
    return gradientColorTwo;
   }
   set
   {
    gradientColorTwo = value;
    Invalidate();
   }
  }

  #endregion

  #region LinearGradientMode Properties
  //LinearGradientMode Properties
  [
  DefaultValue(typeof(LinearGradientMode),\"ForwardDiagonal\"),
  Description(\"Gradient Mode\"),
  Category(\"Appearance\"),
  ]
  
  public LinearGradientMode GradientMode
  {
   get
   {
    return lgm;
   }
   
   set
   {
    lgm = value;
    Invalidate();
   }
  }
  #endregion
       
  #region Border3DStyle Properties
  //Border3DStyle Properties
  [
  DefaultValue(typeof(Border3DStyle),\"Bump\"),
  Description(\"BorderStyle\"),
  Category(\"Appearance\"),
  ]

   // hide BorderStyle inherited from the base class
  new public Border3DStyle BorderStyle
  {
   get
   {
    return b3dstyle;
   }
   set
   {
    b3dstyle = value;
    Invalidate();
   }
  }
  #endregion

  #region Removed Properties
  
  // Remove BackColor Property
  [
  Browsable(false),
  EditorBrowsable(EditorBrowsableState.Never)
  ]
  public override System.Drawing.Color BackColor
  {
   get 
   {
    return new System.Drawing.Color();
   }
   set {;}
  }
  
  #endregion


  //  protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  //  {
  //   Graphics gfx = e.Graphics;
  //   //Border3DStyle b3dstyle = Border3DStyle.Bump;
  //   //Border3DSide b3dside = Border3DSide.All;
  //   
  //   Rectangle rect = new Rectangle (0,0,this.Width,this.Height);
  //
  //   // Dispose of brush resources after use
  //   using (LinearGradientBrush lgb = new LinearGradientBrush(rect, gradientColorOne,gradientColorTwo,lgm))
  //   gfx.FillRectangle(lgb,rect);
  //   
  //   //3d border
  //   //ControlPaint.DrawBorder3D(gfx,rect,b3dstyle,b3dside);
  //   
  //      
  //   // Call the OnPaint method of the base class
  //            base.OnPaint(e);
  //   
  //  }

  protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
  {
   Graphics gfx = pevent.Graphics;
   
   Rectangle rect = new Rectangle (0,0,this.Width,this.Height);
   
   // Dispose of brush resources after use
   using (LinearGradientBrush lgb = new LinearGradientBrush(rect, gradientColorOne,gradientColorTwo,lgm))
    gfx.FillRectangle(lgb,rect);
   
   ControlPaint.DrawBorder3D(gfx,rect,b3dstyle);
  }


 }
}

-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1