之前在网上看到很多关于组件开发的资料,但真正可以用到框架内的却很少。今天贴出自己做的组件,并适合大部分框架的代码。

组件开发需要先做出组件的基类,然后由其他的各类组件去继承这个基类,下面是组件基类的代码。

组件基类:

public abstract class Component
{
public abstract string Name { get; }
public abstract string Icon { get; }
public abstract string Description { get; } public abstract ComponentEvent ComponentEvent
{
get;
} public abstract ComponentProperty ComponentProperty
{
get;
} public abstract UIElement CreateUIElement();
}

组件基类的属性:

public abstract class ComponentProperty : INotifyPropertyChanged
{
private double width;
private double height;
private double left;
private double top;private string name; [Category("基本")]
[Description("名称")]
public string Name
{
get { return name; }
set
{
if (name == value) return;
name = value;
OnPropertyChanged("Name");
}
} [Category("大小")]
[Description("宽度")]
public double Width
{
get { return width; }
set
{
if (width == value) return;
width = value;
OnPropertyChanged("Width");
}
} [Category("大小")]
[Description("高度")]
public double Height
{
get { return height; }
set
{
if (height == value) return;
height = value;
OnPropertyChanged("Height");
}
} [Category("位置")]
[Description("距左")]
public double Left
{
get { return left; }
set
{
if (left == value) return;
left = value;
OnPropertyChanged("Left");
}
} [Category("位置")]
[Description("距上")]
public double Top
{
get { return top; }
set
{
if (top == value) return;
top = value;
OnPropertyChanged("Top");
}
} #region INotifyPropertyChanged Members
      //属性的监听事件
public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName)
{
if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
} #endregion
}

组件基类的事件:

public abstract class ComponentEvent : INotifyPropertyChanged
{
#region 这个可以去掉
private string _Click; public string Click {   get{return _Click;}   set{     if(_Click==value)return;
    _Click=value;
    OnPropertyChanged("Click");
  } } public void OnClick(object sender,RoutedEventArgs e) {   if(Click!=null){     //事件的处理
  } }
#endregion
#region INotifyPropertyChanged Members
//监听事件
public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName)
{
if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
} #endregion
}

以上是组件的基类,组件基类打包为模板以及组件开发请关注后续章节,加群可优先哦。

WPF、AE技术交流群:94234450  
点击加入QQ群:

WPF组件开发之组件的基类的更多相关文章

  1. Filter组件开发中的SDK基类分析

    DirectShow SDK提供了一套开发Filter的基类源代码.基于这些基类开发Filter将大大简化开发过程. 1.CBaseObject 大部分SDK类都从CBaseObject类(参见com ...

  2. moviepy音视频开发:音频剪辑基类AudioClip

    ☞ ░ 前往老猿Python博文目录 ░ 一.背景知识介绍 1.1.声音三要素: 音调:人耳对声音高低的感觉称为音调(也叫音频).音调主要与声波的频率有关.声波的频率高,则音调也高. 音量:也就是响度 ...

  3. [js开源组件开发]query组件,获取url参数和form表单json格式

    query组件,获取url参数和form表单json格式 距离上次的组件[js开源组件开发]ajax分页组件一转眼过去了近二十天,或许我一周一组件的承诺有了质疑声,但其实我一直在做,只是没人看到……, ...

  4. WPF 之 创建继承自Window 基类的自定义窗口基类

    开发项目时,按照美工的设计其外边框(包括最大化,最小化,关闭等按钮)自然不同于 Window 自身的,但窗口的外边框及窗口移动.最小化等标题栏操作基本都是一样的.所以通过查看资料,可按如下方法创建继承 ...

  5. 小白学习vue第五天(理解使用组件开发,组件第一弹)

    组件怎么从创建到使用? 第一步创建组件构造器对象 感觉个人理解就是创建一个模板,和创建MongoDB数据模板相似 const cpnC = Vue.extend({ template: ` <d ...

  6. moviepy音视频开发:音频剪辑基类AudioClip详解

    ☞ ░ 前往老猿Python博文目录 ░ 一.背景知识介绍 1.1.声音三要素: 音调:人耳对声音高低的感觉称为音调(也叫音频).音调主要与声波的频率有关.声波的频率高,则音调也高. 音量:也就是响度 ...

  7. javascript组件开发

    最近忙于重构项目,今天周末把在重构中的一些思想记记: 一.javascript的组件开发:基类的封装 由于这次重构项目需要对各种组件进行封装,并且这些组件的实现方式都差不多,所以想到对组件封装一个ba ...

  8. 汉王云名片识别(SM)组件开发详解

    大家好,最近在DeviceOne平台上做了一个汉王云名片识别的功能组件.下面把我开发过程给大家做一个分享,希望可以帮助到大家. 下面我把我的思路给大家讲解一下.   1.找到我要集成的sdk,也就是汉 ...

  9. [转]详解C#组件开发的来龙去脉

    C#组件开发首先要了解组件的功能,以及组件为什么会存在.在Visual Studio .NET环境下,将会有新形式的C#组件开发. 组件的功能 微软即将发布的 Visual Studio .NET 将 ...

随机推荐

  1. Python+django部署(一)

    之所以 写这篇文章的原因在于django环境的确轻松搭建,之前Ubuntu上安装了,的确很轻松,但是后期我才知道随便做个环境出来很容易到了后面很麻烦,污 染了系统里的python版本,导致系统pyth ...

  2. ubuntu系统下创建软件桌面快捷方式

    转自ubuntu系统下创建软件桌面快捷方式 默认情况下,ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键-复制- ...

  3. [topcoder]IncreasingSubsequences

    http://community.topcoder.com/stat?c=problem_statement&pm=7753&rd=10672 http://community.top ...

  4. VS2008编译器编译出来的文件比mingw编译的要几乎小一半

    为什么要在VS2008中使用QT静态编译呢?很简单,因为VS2008编译器编译出来的文件比mingw编译的要几乎小一半. 好了现在我们来做些准备工作,VS2008自然要安装的,然后打上SP1的补丁.然 ...

  5. android java 堆栈的实现

    android和java不提供堆栈的实现,只提供了list,vector,deque得存储结构,对于以前做面向过程语言的程序员来说,总觉得缺少了些什么: Stack.java文件: public cl ...

  6. bzoj2285

    完全是为了拼凑才出出来的吧先分数规划求出到基地入口的最小安全系数然后再最小点权覆盖集,只不过这里是带一定精度实数的流,其实是一样的 ; eps=0.001; type way=record po,ne ...

  7. ThreadPoolExecutor原理及使用

    大家先从ThreadPoolExecutor的总体流程入手: 针对ThreadPoolExecutor代码,我们来看下execute方法: public void execute(Runnable c ...

  8. Ruby入门教程和技巧

    转自:http://blog.csdn.net/cqfz123/article/details/1349050   Ruby真的比Java更好? Ruby On Rails 创始人:对Java 说再见 ...

  9. HDU 5969 最大的位或 【贪心】 (2016年中国大学生程序设计竞赛(合肥))

    最大的位或 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem De ...

  10. C# 客户端判断是否安装office03、07或WPS

    using Microsoft.Office.Interop.Excel;//转换为excel时,对比一下c#.需要引用此命名空间 using ET;//转换为wps时,相比看.需要引用此命名空间us ...