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

源代码

 
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);
  }

 }
}

时间: 2024-08-02 13:41:48

一个自定义LABEL组件的C#源代码的相关文章

Vue.js实现一个自定义分页组件vue-paginaiton_javascript技巧

vue实现一个分页组件vue-paginaiton vue使用了一段时间的感触就是,我再也不想直接操作DOM了.数据绑定式的编程体验真是好.实现的一个分页组件. 这里的css就不放出来了,可以看直接去github上下载:vue-pagination 先上一张实例图吧 模版 <div class="page-bar"> <ul> <li v-if="showFirstText"><a v-on:click="cur-

项目中布局文件怎么引用另一个项目自定义的组件

问题描述 项目中布局文件怎么引用另一个项目自定义的组件 如果我在一个项目里自定义了一个组件,我想在另一个项目的布局文件中加入这个组件,怎么配置呢?怎么让布局文件能够找到这个组件呢? 解决方案 参考这个例子:http://www.yiibai.com/android/simple_android_custom_component_using_xm.html 解决方案二: xml中include

gdi+-C#如何如何开发一个自定义的富文本编辑器组件?使用GDI+来完成么?

问题描述 C#如何如何开发一个自定义的富文本编辑器组件?使用GDI+来完成么? 如题, 1 自定义C#组件 2 富文本编辑器 完成这项东西,需要使用哪些技术来完成?能给个思路就更好了 解决方案 富到什么程度? 可以用RichTextBox或者WebBrowser做编辑界面

使用自定义验证组件库扩展 Windows 窗体

window 摘要:数据验证是确保正常的数据捕获以及后续处理和报告的关键步骤.本文介绍了 Windows 窗体固有的程序验证基础结构,并以此为基础开发了用于提供更高效验证功能的自定义验证组件库,该验证功能与使用 ASP.NET 的验证控件相似. 下载 winforms03162004_sample.msi 示例文件. 本页内容 引言 Windows 窗体验证的主要功能 程序验证与声明性验证 建立设计时支持 模仿是最真诚的恭维 必需字段验证程序简介 BaseValidator:分治法 一个放便士,

component-如何读取自定义的组件中的 android:src ?

问题描述 如何读取自定义的组件中的 android:src ? 我想创建一个自定义组件,继承 RelativeLayout. 在我的 xml 布局文件中是这样设置的: <Mycomponent android:src="@drawable/my_test_image"> <TestView> </Mycomponent> 如何在 Mycomponent 的 constructor 里创建一个 Drawable 类? 我想查看 ImageView 的源

WebFields 免费自定义字段组件

web EasyFields适用于asp开发环境的自定义字段组件,该组件您可以到网站http://haitiansoft.126.com下载组件,并有组件的详细使用说明. WebFields自定义字段组件组件能够让客户或者开发人员进行数据库表字段的动态添加.删除 等操作,由客户自己将系统客户化,让开发出的应用系统更能够满足客户的需要. 组件提供相应的记录编辑.新建.查询.显示等一系列的方法,对于应用系统的产品 化有重要作用. WebFields自定义字段组件组件含有多种数据类型,字符型.数据型.

WebFields适用于asp开发环境的自定义字段组件

web WebFields适用于asp开发环境的自定义字段组件,该组件您可以到网站http://www.haitiansoft.com下载组件,并有组件的详细使用说明. WebFields自定义字段组件组件能够让客户或者开发人员进行数据库表字段的动态添加.删除 等操作,由客户自己将系统客户化,让开发出的应用系统更能够满足客户的需要. 组件提供相应的记录编辑.新建.查询.显示等一系列的方法,对于应用系统的产品 化有重要作用. WebFields自定义字段组件组件含有多种数据类型,字符型.数据型.下

使用BPM V8设计并实现一个自定义收件箱和My Team Performance任务列表

使用 IBM Business Process Manager V8 设计并实现一个自定义收件箱和 My Team Performance 任务列表 简介 IBM Business Process Manager (IBM BPM) 提供了一些有用的功能来管理业务流程,包括流程参与者的收件箱.尽管建议您尽可能地使用开箱即用的功能,但在某些情形下,默认的实现可能无法满足您的要求.在这种情况下,您可能需要设计并实现一个自定义收件箱.本文为这种自定义收件箱提供了一种设计方法和示例实现.类似地,默认的

编写JSF自定义复合组件的技巧和窍门

本文介绍开发 JavaServer Faces(JSF)自定义复合组件的新思路,提供如何快速开发可重用 JSF 组 件的技巧,而不用像传统方式那样自己实现渲染器 (renderer).状态管理和事件监听器.本文提供的 原则和技术也对一般的 JSF 开发很有帮助. 介绍 JavaServer Faces(JSF)提供可扩展的组件模型,开发人员可以创建可重用的组件,使用这些自定义 组件提高开发效率和降低开发成本.虽然对于定制和重用而言 JSF 的组件模型非常强大,但是开发人员 普遍认为开发 JSF