资源简介
因项目需求,要实现简单的绘制矢量图形,因此自已写了几个自定义的Panel控件,有矩形,圆形,三角形,弧形,原则上可以实现各类形状的各类可视控件,并实现了拖拽和拉伸功能。代码在VS2010环境上生成。共享出来希望对有类似需求的童鞋有所帮助。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace TestPingtu
{
public class ExCirclePanel : Panel IPanelSet
{
private List lstAnchorPoint;
private int AnchorPointRange;
private MoveDirect curMoveDirect = MoveDirect.Default;
private bool isEditing = false;
private bool _IsEditable = false;
///
/// 控件当前是否处于可编辑状态
///
public bool IsEditable
{
get
{
return _IsEditable;
}
set
{
_IsEditable = value;
}
}
private enum MoveDirect
{
Left = 0
Right
Top
Bottom
Default
}
private class AnchorPoint
{
public Rectangle AnchorRec;
public MoveDirect AnchorDirect;
}
private Color _DefaultColor;
///
/// 默认背影色
///
public Color DefaultColor
{
get
{
return _DefaultColor;
}
set
{
this.BackColor = value;
_DefaultColor = value;
}
}
private Point mouse_offset;
public ExCirclePanel()
{
this.Height = 100;
this.Width = 100;
AnchorPointRange = 5;
InitialAnchorPoint();
}
public ExCirclePanel(Color defaultColor bool isEditable)
{
DefaultColor = defaultColor;
IsEditable = isEditable;
this.Height = 100;
this.Width = 100;
AnchorPointRange = 5;
InitialAnchorPoint();
}
public void SetBackColor(Color backColor)
{
this.DefaultColor = backColor;
}
public void SetBoldShow(bool isShow)
{
if (isShow)
this.Borderstyle = System.Windows.Forms.Borderstyle.FixedSingle;
else
this.Borderstyle = System.Windows.Forms.Borderstyle.None;
}
private void InitialAnchorPoint()
{
lstAnchorPoint = new List();
AnchorPoint ap = new AnchorPoint()
{
AnchorRec = new Rectangle(0 this.Height / 2 - AnchorPointRange /2 AnchorPointRange AnchorPointRange)
AnchorDirect = MoveDirect.Left
};
lstAnchorPoint.Add(ap);
ap = new AnchorPoint()
{
AnchorRec = new Rectangle(this.Width - AnchorPointRange this.Height / 2 - AnchorPointRange / 2 AnchorPointRange AnchorPointRange)
AnchorDirect
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 43008 2014-04-24 16:41 TestPingtu\TestPingtu\bin\Debug\TestPingtu.exe
文件 73216 2014-04-24 16:41 TestPingtu\TestPingtu\bin\Debug\TestPingtu.pdb
文件 11600 2014-04-24 16:43 TestPingtu\TestPingtu\bin\Debug\TestPingtu.vshost.exe
文件 490 2010-03-17 22:39 TestPingtu\TestPingtu\bin\Debug\TestPingtu.vshost.exe.manifest
文件 7951 2014-04-24 16:29 TestPingtu\TestPingtu\ExCirclePanel.cs
文件 14975 2014-04-24 16:29 TestPingtu\TestPingtu\ExCurvedPanel.cs
文件 9585 2014-04-24 16:29 TestPingtu\TestPingtu\ExRectanglePanel.cs
文件 21134 2014-04-24 16:27 TestPingtu\TestPingtu\ExTrianglePanel.cs
文件 6159 2014-04-24 16:41 TestPingtu\TestPingtu\Form1.cs
文件 12393 2014-04-24 16:41 TestPingtu\TestPingtu\Form1.Designer.cs
文件 6221 2014-04-24 16:41 TestPingtu\TestPingtu\Form1.resx
文件 1120 2014-04-24 16:30 TestPingtu\TestPingtu\Form2.cs
文件 5380 2014-04-24 16:17 TestPingtu\TestPingtu\Form2.Designer.cs
文件 19417 2014-04-24 16:17 TestPingtu\TestPingtu\Form2.resx
文件 277 2014-04-24 16:21 TestPingtu\TestPingtu\IPanelSet.cs
文件 9134 2014-04-24 14:57 TestPingtu\TestPingtu\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6347 2014-04-24 16:41 TestPingtu\TestPingtu\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1783 2014-04-24 16:43 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.csproj.FileListAbsolute.txt
文件 1033 2014-04-24 16:41 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.csproj.GenerateResource.Cache
文件 43008 2014-04-24 16:41 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.exe
文件 180 2014-04-24 16:41 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.Form1.resources
文件 73216 2014-04-24 16:41 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.pdb
文件 180 2014-04-24 16:29 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.Properties.Resources.resources
文件 9228 2014-04-24 16:29 TestPingtu\TestPingtu\obj\x86\Debug\TestPingtu.SetForm.resources
文件 502 2014-04-08 09:52 TestPingtu\TestPingtu\Program.cs
文件 1432 2014-04-08 09:52 TestPingtu\TestPingtu\Properties\AssemblyInfo.cs
文件 2849 2014-04-08 09:52 TestPingtu\TestPingtu\Properties\Resources.Designer.cs
文件 5612 2014-04-08 09:52 TestPingtu\TestPingtu\Properties\Resources.resx
文件 1096 2014-04-08 09:52 TestPingtu\TestPingtu\Properties\Settings.Designer.cs
文件 249 2014-04-08 09:52 TestPingtu\TestPingtu\Properties\Settings.settings
............此处省略16个文件信息
相关资源
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
评论
共有 条评论