资源简介
因项目需求,要实现简单的绘制矢量图形,因此自已写了几个自定义的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个文件信息
相关资源
- C#一机一码注册方式演示样例
- c#飞机订票系统sql
- C#空气质量监测管理系统.7z
- Delaunay三角剖分源码C#版本和算法的具
- _01_DllPrctise.zip
- 果壳中的C#:5.0权威指南_带书签_超清
- 基于C#和SQL简易通讯录
- C#房屋出租管理系统
- c# winform usercontrol用户控件传值
- c# SetWindowsHookEx 钩子
- 根据年龄和姓名排序C#
- C# 分隔WAV文件,将一段汉语语音分割
- 武汉理工大学C#实验4源代码_窗体和控
- C#酒店管理系统课程设计报告
- C#版 spy++
- C#内存修改器
- 用C#做学习型人脸识别程序尝鲜版
- c# wpf全套教程视频教程
- .NET C# 在线招聘系统
- 停车场管理系统,C#实现,VS2017工程
- c#翻牌小游戏
- 远程监控数据采集GPRSC#源码
- Q757416.zip VB.NET WinForms 如何让label中的
- winform自定义滚动条
- Segy文件的读取c#)
- Visual C#从入门到精通 第九版.docx
- C#实现窗体换肤完整源码(经典)
- C#用NPOI固定模版导出数据到excel表格
- RPLIDAR A2 C#.rar
- c# 学生选课系统
评论
共有 条评论