CodeProject - DrawTools(画图工具)
2004-10-19 15:57
423 查看
原作者:Alex Farber
原文:http://www.codeproject.com/csharp/DrawTools.asp(源代码请参见原文)
private void Form1_Load(object sender, System.EventArgs e)
private void Application_Idle(object sender, EventArgs e)
public void SetStateOfControls()
// Rectangle tool is selected
private void CommandRectangle()
public virtual int HitTest(Point point)
Derived classes use virtual
继承类使用虚拟的
protected override bool PointInObject(Point point)
protected override bool PointInObject(Point point)
序列化
public virtual void SaveToStream(SerializationInfo info, int orderNumber)
public virtual void LoadFromStream(SerializationInfo info, int orderNumber)
These functions are implemented in every derived class. Binary file has the following format:
这些函数在每一个继承类中都实现了。二进制文件有以下格式:
This allows to write generic serialization code in the GraphicList class without knowing any details about serialized objects:
这样就可以在GraphicList类里写普通的序列化代码,而不需要了解序列化对象的任何细节。
private const string entryCount = "Count";
private const string entryType = "Type";
// Save list to stream
[SecurityPermissionAttribute(SecurityAction.Demand,
SerializationFormatter=true)]
public virtual void GetObjectData(SerializationInfo info,
StreamingContext context)
// Load from stream
protected GraphicsList(SerializationInfo info, StreamingContext context)
原文:http://www.codeproject.com/csharp/DrawTools.asp(源代码请参见原文)
private void Form1_Load(object sender, System.EventArgs e)
private void Application_Idle(object sender, EventArgs e)
public void SetStateOfControls()
// Rectangle tool is selected
private void CommandRectangle()
Hit Test
DrawObjectclass has virtual
HitTestfunction which detects whether point belongs to graphic object:
Hit Test
DrawObject类有一个叫
HitTest的虚拟函数,用来侦测是否Point属于图形对象。
public virtual int HitTest(Point point)
Derived classes use virtual
PointInObjectto make hit test. This function is called from
HitTest.
DrawRectangleclass implements this function by a simple way:
继承类使用虚拟的
PointInObject来做点击测试。这个函数调用自
HitTest。
DrawRectangle类使用了一种简单的方法实现了这个函数:
protected override bool PointInObject(Point point)
DrawLineimplementation of this function is more complicated:
DrawLine对这个函数的实现更加复杂:
protected override bool PointInObject(Point point)
DrawPolygonfunction works by the same way, but
AreaPathcontains all lines in the polygon.
DrawPolygon函数使用了同样的方法,但是
AreaPath包含了多边形的所有线。
Serialization
GraphicListclass implements
ISerializableinterface which allows to make binary serialization of the class object.
DrawObjectclass has two virtual functions which are used for serialization:
序列化
GraphicList类实现了
ISerializable接口,这个接口用作类对象的二进制序列化。
DrawObject类有两个虚函数用来做序列化。
public virtual void SaveToStream(SerializationInfo info, int orderNumber)
public virtual void LoadFromStream(SerializationInfo info, int orderNumber)
These functions are implemented in every derived class. Binary file has the following format:
这些函数在每一个继承类中都实现了。二进制文件有以下格式:
Number of objects
Type name
Object
Type name
Object
...
Type name
Object
This allows to write generic serialization code in the GraphicList class without knowing any details about serialized objects:
这样就可以在GraphicList类里写普通的序列化代码,而不需要了解序列化对象的任何细节。
private const string entryCount = "Count";
private const string entryType = "Type";
// Save list to stream
[SecurityPermissionAttribute(SecurityAction.Demand,
SerializationFormatter=true)]
public virtual void GetObjectData(SerializationInfo info,
StreamingContext context)
// Load from stream
protected GraphicsList(SerializationInfo info, StreamingContext context)
相关文章推荐
- CodeProject - DrawTools(画图工具)
- CodeProject - DrawTools(画图工具)
- DrawTools(画图工具) From CodeProject
- DrawTools(画图工具) From CodeProject
- DrawTools(画图工具)原始版本
- VS2012中自定义工具“MyApplicationCodeGenerator”与文件“My Project\Application.myapp”相关联,但在项目中找不到该自定义工具的输出
- 画图的绝好js工具
- QR编码设置基础概念(zxing 和 d_project qrcode)
- 完全支持双层PDF!开源的PDF分离与合并软件,C#版本(转自codeproject)
- Project 所需工具的配置及使用
- Xenocode Postbuild 2010 for .NET 混淆工具的详细使用步骤
- 在google code上开了一个java版的ETL小工具project:jmyetl
- CodeProject每日精选: Edit Controls (TextBox, RichTextBox)
- 开源代码2004/12/23 CodeProject上最新代码
- CodeProject - 在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)
- DLINQ Introduction Part 2 Of 3 By Sacha Barber(Refer from codeproject)
- ListControl參考:http://www.codeproject.com/KB/list/SubItemSel.aspx
- CodeProject 文章阅读
- 右键管理工具2.0 Code.By.HackWm.
- http://www.codeproject.com 代码营,找学习文档的好去处