最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
[原创]IssueVision 学习笔记(二)-----为控件添加自定义属性和事件-Web_Serv
时间:2022-07-02 11:17:27 编辑:袖梨 来源:一聚教程网
我们先来看看IssueVision中一个用户控件PaneCaption在可视化设计器中的属性窗口.
再看一下在另一个用户控件StaffPane中使用它时的属性窗口:
大家会发现它多出来很多个属性,这些属性是原来继承控件中没有的属性,如:InactiveTextColor,InactiveTextColor等等.它们是如何实现的呢?我们就来看一下这个用户控件的代码PaneCaption.cs吧.
namespace IssueVision
{
// Custom control that draws the caption for each pane. Contains an active
// state and draws the caption different for each state. Caption is drawn
// with a gradient fill and antialias font.
public class PaneCaption : UserControl
{
private class Consts
{
......
可以看到它是由 System.Windows.Forms.UserControl 继承而来,图一显示了它的默认属性.下面我们接着PaneCaption.cs代码,看看是如何将属性或事件显示在可视化设计器中.
[DefaultValueAttribute(typeof(Color), "3, 55, 145")]
[DescriptionAttribute("Low color of the inactive gradient.")]
[CategoryAttribute("Appearance")]
public Color InactiveGradientLowColor
{
get
{
return m_colorInactiveLow;
}
set
{
if (value == Color.Empty)
{
value = Color.FromArgb(3, 55, 145);
}
m_colorInactiveLow = value;
CreateGradientBrushes(); //自定义方法,用于创建线形渐变笔刷
Invalidate(); //Control.Invalidate 方法,使控件的特定区域无效并向控件发送绘制消息
}
}
[CategoryAttribute("Appearance")]
[DescriptionAttribute("High color of the inactive gradient.")]
再看一下在另一个用户控件StaffPane中使用它时的属性窗口:
大家会发现它多出来很多个属性,这些属性是原来继承控件中没有的属性,如:InactiveTextColor,InactiveTextColor等等.它们是如何实现的呢?我们就来看一下这个用户控件的代码PaneCaption.cs吧.
namespace IssueVision
{
// Custom control that draws the caption for each pane. Contains an active
// state and draws the caption different for each state. Caption is drawn
// with a gradient fill and antialias font.
public class PaneCaption : UserControl
{
private class Consts
{
......
可以看到它是由 System.Windows.Forms.UserControl 继承而来,图一显示了它的默认属性.下面我们接着PaneCaption.cs代码,看看是如何将属性或事件显示在可视化设计器中.
[DefaultValueAttribute(typeof(Color), "3, 55, 145")]
[DescriptionAttribute("Low color of the inactive gradient.")]
[CategoryAttribute("Appearance")]
public Color InactiveGradientLowColor
{
get
{
return m_colorInactiveLow;
}
set
{
if (value == Color.Empty)
{
value = Color.FromArgb(3, 55, 145);
}
m_colorInactiveLow = value;
CreateGradientBrushes(); //自定义方法,用于创建线形渐变笔刷
Invalidate(); //Control.Invalidate 方法,使控件的特定区域无效并向控件发送绘制消息
}
}
[CategoryAttribute("Appearance")]
[DescriptionAttribute("High color of the inactive gradient.")]
相关文章
- 网页版邮箱登录入口全攻略及实用技巧大全 12-16
- 学习通网页版访问线路升级-一键直达课程界面更快捷 12-16
- 光与影33号远征队持久强力符文:符文持久强力的作用及获取方式详解 12-16
- 失控进化测试资格查询入口 失控进化测试资格申请攻略 12-16
- 豆包网页版多语言翻译实时入口-豆包网页版语音交互免下载直达 12-16
- 全国大学生英语四六级考试官网入口 成绩查询登录通道 12-16