- 浏览: 185751 次
- 性别:
- 来自: 湖南
文章分类
- 全部博客 (52)
- 一般 (2)
- java (2)
- 硬件的学习,软件的呼应 (1)
- 硬件知识 (2)
- 数组和队列基础的研究 (1)
- 初步了解文件保存与对io刘深刻的理解 (1)
- io与文件 (1)
- android五大布局 (1)
- Java与mySQL之间的概述 (0)
- mySQL命令口的概述 (1)
- android.多线程.生命周期 (1)
- java.android.the development of voice (1)
- android ConcurrentModificationException 异常 (1)
- linux (1)
- linux shell (1)
- linux 操作系统 进程 c++ 解析 (1)
- C# 画板 实现和通信解析 (0)
- java Mina TCP/IP UDP/IP (1)
- java Mina 通信源码的解析 (1)
- java中数据结构二分查法 (1)
- java中数据结构Bitmap查找相等元素 (1)
- java Bitmap 数据结构 (1)
- 二进制 低级语言 高级语言 (1)
- C# 画板 问题解析 (1)
- C# UDP TCP (1)
- C# 聊天室 过程 (1)
- java Mina 解析 (1)
- web html 语言的标示解析 (1)
- html jsp 乱码解决 (1)
- web java lib jsp的javamail (1)
- JAVA Spring STRUCTS Hibernate (0)
- Java Spring Struts Hibernate (0)
- TCP UDP (1)
- Java Web Spring Struts Hibernate (1)
- LabSQL (1)
- labview labSQL mySQL (1)
- Windows DLL 操作系统 (1)
- R语言 学习包 (1)
- B树 算法 数据结构 (1)
- labview TCP/IP 波形图 (1)
- C++ KMP 数据结构 算法 (1)
- C++ KMP 数据结构 算法 理论 (1)
- 数据结构 B+ B* (1)
- B树 数据结构 结构体 思路 (1)
- B树 高度 性能 思路 (1)
- 顺序Gauss消除法 矩阵 数值分析 C++ (1)
- C++ 排序 数据结构 算法 理论 (1)
- Java 重绘 继承 对象 Wallpaper (0)
- Java 对象 继承 重绘 多态 Wallpaper (1)
- Java Tomcat web 错误解析 (1)
- Java 队列 堆解析 (1)
- Java JDK 优先队列 PriorityQueue (0)
- Java JDK 优先队列 PriorityQueue (1)
- Android JNI C语言 Ubuntu Linux ADB工具 动态链接库so (0)
- Android JNI C语言 Ubuntu Linux ADB工具 动态链接库so (1)
- 研发 核心技术 产品 技术 市场 (0)
最新评论
-
q114687576:
http://www.blue-zero.com/Chat/ ...
C# 聊天室的框架设计实现源码 -
chinesejie:
你用了byte 数组, 其实 空间最多节省 4倍
Bitmap算法查找相等元素源码 -
luozhong915127:
JuliaAilse 写道那个桢布局的。覆盖后可以在需要时再显 ...
android 界面布局 -
这不是我:
很好,很有帮助
R语言中的机器学习包 -
luozhong915127:
什么意思,踩别人连个意见都不给。
优先队列与堆的解析
C#项目的解析
C#语言继承了C和C++语言的特性,并且与java有紧密的联系。C#语言和.NET框架协调工作,一起构建了一个高度优雅的编程环境。可以说C#的核心是面向对象程序设计(opp); 好吧,我说这么多,就进入软件的操作,呵呵。首先要注意的问题是,Main的m要大些,代码如下:static void Main()。在命令口编写,应该start/Visual Studio 2005/Visual Studio Tools/Visual Stdio 2005 Command Prompt, 你就可以在命令口操作了,呵呵,这是高手来的地方哟!嗯,我能发现这个地方我也是高手的高手哟!代码如下:\>csc Example.cs. 现在我讲一下我的画板的重绘是怎样实现的,首先,你要清楚重绘在C#的方法是什么,则是onPaint(object sender,PaintEventArgs e),这个方法是重写Froms的方法,而这个界面类继承了它,格式这样的From1:Froms,在这里我讲一下抽象类的用方法,因为下面我要用直线类去实现抽象类,我遇到一个问题,嗯,就是我去是实现这个抽象类时,就是要重写抽象类的方法,在void加override,可是提示如不加override,否则加new,但是运行报错说“你级别不高”经过一番的查找,终于找到了问题,那就是你的抽象类的方法中的abstract改为Virtual方法。即可。 如果是抽象类的方法时候
public override void draw();
如果是虚拟类的方法时候
public new void draw();
每一次画的你要你要保存下来,在这里我使用的是List,没有使用ArrayList,List是一个接口,是Collection接口的一个子接口。是一个有序的集合。而ArrayList是List的一个实现类,可以实现数组大小的可变,可以很方便的进行增加和删减数组内元素的操作。 List list=new ArrayList();这种形式成为向上转型,ArrayList实现了List接口,可以看成是从List继承而来,一个子类的对象可以指向它父类。比如,狗从动物继承而来,狗是一只动物,所以狗的对象可以当作一只普通的动物来看待。肯定你要使用泛类才能保存。把你要的颜色和点和paint等等一些属性封装起来。 在C#画曲线,没有想java里有MoseDrag方法,可是有一个MouseMove这个方法。代码如下:
From1.cs类 C#代码 <P><SPAN style="FONT-SIZE: 14pt"><DIV class=Section0> <PRE class=c# name="code">using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { //定义坐标 int x1, y1, x2, y2,x3,y3; //定义画布 Graphics g; // 创建画笔 Pen paint = new Pen(Color.Red, 3); // 定义按钮名字 String name; // 创建保存形状集合 List<NetShape> shapes = new List<NetShape>(); //新建形状对象 NetShape shape; public Form1() { InitializeComponent(); //获得画布 g = this.panel1.CreateGraphics(); // 给panel加画笔监听 this.panel1.Paint += new PaintEventHandle(this.OnPaint); // // 给panel加鼠标监听 this.panel1.MouseMove += new MouseEventHandler (this.F_MouseMove); } private void Form1_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { //获得按钮的字符串 name = ((Button)sender).Name; } public void Form1_MouseDown(object sender, MouseEventArgs e) { //得到坐标 x1 = e.X; y1 = e.Y; } public void F_MouseMove(object sender, MouseEventArgs e) { //判断是否按钮符合 if (name.Equals("button1")) { x3 = e.X; y3 = e.Y; // 用包装好的类画直线 shape = new ImpLine(paint, x1, y1, x3, y3); shape.draw(g); // 添加到集合 shapes.Add(shape); x1 = x3; y1 = y3; } } public void Form1_MouseUp(object sender, MouseEventArgs e) { x2 = e.X; y2 = e.Y; if (name.Equals("button2")) { shape = new ImpLine(paint, x1, y1, x2, y2); } shape.draw(g); shapes.Add(shape); } /* *重绘 * */ public void OnPaint(object sender, PaintEventArgs e) { //遍历集合的形状 for(int i=0;i < shapes.Count;i++) { NetShape shape = shapes.ElementAt<NetShape>(i); shape.draw(g); } } } } </PRE> </DIV> <P class=p0 style="MARGIN-TOP: 0pt; MARGIN-BOTTOM: 0pt"> 直线 类</P> <DIV class=Section0> <PRE class=c# name="code">using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public class ImpLine:NetShape { int x1, y1, x2, y2; Pen paint; public ImpLine(Pen paint,int x1, int y1, int x2, int y2) { this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; this.paint = paint; } public override void draw(Graphics g) { g.DrawLine( paint,x1, y1, x2, y2); } } } </PRE> </DIV> <P class=p0 style="MARGIN-TOP: 0pt; MARGIN-BOTTOM: 0pt"> </P> <P class=p0 style="MARGIN-TOP: 0pt; MARGIN-BOTTOM: 0pt"> </P> <P class=p0 style="MARGIN-TOP: 0pt; MARGIN-BOTTOM: 0pt">形状 类</P> <P class=p0 style="MARGIN-TOP: 0pt; MARGIN-BOTTOM: 0pt"> </P> <DIV class=Section0> <PRE class=c# name="code">using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public abstract class NetShape { public abstract void draw(Graphics g); } } </PRE> </DIV> </SPAN> <P></P><DIV class=Section0> <PRE class=c# name="code"></PRE> </DIV> C#代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { int x1, y1, x2, y2,x3,y3; Graphics g; Pen paint = new Pen(Color.Red, 3); String name; List<NetShape> shapes = new List<NetShape>(); NetShape shape; public Form1() { InitializeComponent(); g = this.panel1.CreateGraphics(); this.panel1.Paint += new PaintEventHandler(this.OnPaint); this.panel1.MouseMove += new MouseEventHandle(this.F_MouseMove); } private void Form1_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { name = ((Button)sender).Name; } public void Form1_MouseDown(object sender, MouseEventArgs e) { x1 = e.X; y1 = e.Y; } public void F_MouseMove(object sender, MouseEventArgs e) { if (name.Equals("button1")) { x3 = e.X; y3 = e.Y; shape = new ImpLine(paint, x1, y1, x3, y3); shape.draw(g); shapes.Add(shape); x1 = x3; y1 = y3; } } public void Form1_MouseUp(object sender, MouseEventArgs e) { x2 = e.X; y2 = e.Y; if (name.Equals("button2")) { shape = new ImpLine(paint, x1, y1, x2, y2); } shape.draw(g); shapes.Add(shape); } public void OnPaint(object sender, PaintEventArgs e) { for(int i=0;i < shapes.Count;i++) { NetShape shape = shapes.ElementAt<NetShape>(i); shape.draw(g); } } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { int x1, y1, x2, y2,x3,y3; Graphics g; Pen paint = new Pen(Color.Red, 3); String name; List<NetShape> shapes = new List<NetShape>(); NetShape shape; public Form1() { InitializeComponent(); g = this.panel1.CreateGraphics(); this.panel1.Paint += new PaintEventHandler(this.OnPaint); this.panel1.MouseMove += new MouseEventHandler (this.F_MouseMove); } private void Form1_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { name = ((Button)sender).Name; } public void Form1_MouseDown(object sender, MouseEventArgs e) { x1 = e.X; y1 = e.Y; } public void F_MouseMove(object sender, MouseEventArgs e) { if (name.Equals("button1")) { x3 = e.X; y3 = e.Y; shape = new ImpLine(paint, x1, y1, x3, y3); shape.draw(g); shapes.Add(shape); x1 = x3; y1 = y3; } } public void Form1_MouseUp(object sender, MouseEventArgs e) { x2 = e.X; y2 = e.Y; if (name.Equals("button2")) { shape = new ImpLine(paint, x1, y1, x2, y2); } shape.draw(g); shapes.Add(shape); } public void OnPaint(object sender, PaintEventArgs e) { for(int i=0;i < shapes.Count;i++) { NetShape shape = shapes.ElementAt<NetShape>(i); shape.draw(g); } } } } 直线类 C#代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public class ImpLine:NetShape { int x1, y1, x2, y2; Pen paint; public ImpLine(Pen paint,int x1, int y1, int x2, int y2) { this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; this.paint = paint; } public override void draw(Graphics g) { g.DrawLine( paint,x1, y1, x2, y2); } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public class ImpLine:NetShape { int x1, y1, x2, y2; Pen paint; public ImpLine(Pen paint,int x1, int y1, int x2, int y2) { this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; this.paint = paint; } public override void draw(Graphics g) { g.DrawLine( paint,x1, y1, x2, y2); } } } 形状类 C#代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public abstract class NetShape { public abstract void draw(Graphics g); } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace WindowsFormsApplication1 { public abstract class NetShape { public abstract void draw(Graphics g); } }
相关推荐
c#简单画板程序 有c#代码编写的简单画板程序 代码类资源
C#版画板
学习中的一个demo,编写的也比较简单,语法都很简单,而且注释很完整,初学者都基本能够看懂,而且扩展也是十分简单。
Winform画板,可以导入图片,画图,对图片进行缩放拖动,局部放大。从论坛下载了别人的,总是不尽如人意,花了两周把Bug解决了。5分绝对超值!
C#编程实现画板功能C#编程实现画板功能C#编程实现画板功能
一个简单地画板程序,基于C#设计
C# 画画板,基本实现window自带画画功能,也具有相应提示
这是一个用C#编制的画板,可以改变画板的颜色,可以改变字体的大小,可以改变笔的大小,实现用鼠标在电脑上面写字!!!!!
实现多种算法(DDA、midpoint、bresenhanm画直线,中点画圆,区域填充扫面线等多种计算机图形学算法)是课堂演示,课程设计,毕业设计的必需参考资料,欢迎大家踊跃积极下载
C#编写的简单画板 源代码 功能实现基本如:画笔 直线 颜色选择器
一个用C#只做的画板程序,能够画直线,矩形,椭圆,圆,多边形,并且进行填色。在画多边形时,最后完成的时候反键下鼠标完成绘画。
这是用C# GDI实现的简易画板Demo,对应博文http://blog.csdn.net/luols/article/details/7171668,有需要的朋友可以下载样例试用
可以实现win 上面所有功能,除了选择特定一部分进行移动,花费10天时间,希望下面有人继续完善
C#326-画板工具,源代码
T395559890.zip c#做画板画直线 https://bbs.csdn.net/topics/395559890 问题的回答
用c#语言编写的简易画板程序,可以实现简易的绘画功能,可以绘制直线矩形…… 有参考一下别人的代码
C#编写的绘画板,可以画圆直线输入文本等
通过学习C#以来 由于平常无聊时 做的一个小画板 出现点小问题 !
使用 C# 仿windows画板程序 只是实现了一部分
能实现新建、保存、取色、设置画笔大小,还能画出不同图形