扩展模型示例:
下面的程序段扩展了一个容器
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using CMC.Controls.Base;
5
using System.Drawing;
6
using System.Drawing.Drawing2D;
7
8
//扩展的名字空间必须以"CMC.Libs."开头 否者不能正常识别
9
namespace CMC.Libs.Normal.Container
10
{
11
/// <summary>
12
/// 派生类必须以CMC.Controls.Base.Control或其派生类为基类 否者不能正常识别
13
/// </summary>
14
public class ExtendCMC : CMC.Controls.NormalContainerControl
15
{
16
private CMC.Controls.Shapes.Ellipse _Ellipse = new CMC.Controls.Shapes.Ellipse(100, 100);
17
public float Width
18
{
19
get { return _Ellipse.Width; }
20
set
21
{
22
if (_Ellipse.Width != value)
23
{
24
_Ellipse.Width = value;
25
NeedRebuild = true;
26
}
27
}
28
}
29
public float Height
30
{
31
get { return _Ellipse.Height; }
32
set
33
{
34
if (_Ellipse.Height != value)
35
{
36
_Ellipse.Height = value;
37
NeedRebuild = true;
38
}
39
}
40
}
41
protected override void InitGraphicsPath(ref CMC.Controls.Base.Chain<System.Drawing.Drawing2D.GraphicsPath> GraphicsPaths)
42
{
43
if (GraphicsPaths.IsEmpty)
44
{
45
GraphicsPaths.AddItem(new GraphicsPath());
46
}
47
GraphicsPaths.First.Value.AddPath(_Ellipse.GraphicsPath, false);
48
}
49
}
50
}
51
下面的代码将CMC控件添加到窗体中
dll+范例+帮助下载但
控件可以随便使用,也欢迎发信询问细节,但暂时不考虑提供源代码。
下面的程序段扩展了一个容器
1
using System;2
using System.Collections.Generic;3
using System.Text;4
using CMC.Controls.Base;5
using System.Drawing;6
using System.Drawing.Drawing2D;7

8
//扩展的名字空间必须以"CMC.Libs."开头 否者不能正常识别9
namespace CMC.Libs.Normal.Container10
{11
/// <summary>12
/// 派生类必须以CMC.Controls.Base.Control或其派生类为基类 否者不能正常识别13
/// </summary>14
public class ExtendCMC : CMC.Controls.NormalContainerControl15
{16
private CMC.Controls.Shapes.Ellipse _Ellipse = new CMC.Controls.Shapes.Ellipse(100, 100);17
public float Width18
{19
get { return _Ellipse.Width; }20
set21
{22
if (_Ellipse.Width != value)23
{24
_Ellipse.Width = value;25
NeedRebuild = true;26
}27
}28
}29
public float Height30
{31
get { return _Ellipse.Height; }32
set33
{34
if (_Ellipse.Height != value)35
{36
_Ellipse.Height = value;37
NeedRebuild = true;38
}39
}40
}41
protected override void InitGraphicsPath(ref CMC.Controls.Base.Chain<System.Drawing.Drawing2D.GraphicsPath> GraphicsPaths)42
{43
if (GraphicsPaths.IsEmpty)44
{45
GraphicsPaths.AddItem(new GraphicsPath());46
}47
GraphicsPaths.First.Value.AddPath(_Ellipse.GraphicsPath, false);48
}49
}50
}51

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
9
namespace ExtendCMC
10
{
11
public partial class Form1 : Form
12
{
13
public Form1()
14
{
15
InitializeComponent();
16
this.Width = 800;
17
this.Height = 600;
18
19
CMC.CMCControl cc = new CMC.CMCControl();
20
cc.Dock = DockStyle.Fill;
21
this.Controls.Add(cc);
22
CMC.Chart c = cc.Chart;
23
CMC.Libs.Normal.Container.ExtendCMC ec = new CMC.Libs.Normal.Container.ExtendCMC();
24
c.AddControl(ec);
25
ec.MoveBy(100, 100);
26
}
27
}
28
}
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Text;7
using System.Windows.Forms;8

9
namespace ExtendCMC10
{11
public partial class Form1 : Form12
{13
public Form1()14
{15
InitializeComponent();16
this.Width = 800;17
this.Height = 600;18

19
CMC.CMCControl cc = new CMC.CMCControl();20
cc.Dock = DockStyle.Fill;21
this.Controls.Add(cc);22
CMC.Chart c = cc.Chart;23
CMC.Libs.Normal.Container.ExtendCMC ec = new CMC.Libs.Normal.Container.ExtendCMC();24
c.AddControl(ec);25
ec.MoveBy(100, 100);26
}27
}28
}dll+范例+帮助下载但
控件可以随便使用,也欢迎发信询问细节,但暂时不考虑提供源代码。


浙公网安备 33010602011771号