资源简介
用c#实现窗体绘制椭圆,圆,矩形等,属于初级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 鼠标绘图程序
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Pen pen;
private SolidBrush sBrush;
private Image btsbt;
private Graphics g_btg_sbt;
private bool f = false;//////////是否按下鼠标开始画图
private bool fill = false;///////是否填充对象
private int x1 x2 y1 y2;
private int type = 0;
private void Form1_Load(object sender EventArgs e)
{
pen = new Pen(Color.Black);
sBrush = new SolidBrush(Color.Black);
bt = new Bitmap(pictureBox1.Width pictureBox1.Height);
sbt = new Bitmap(pictureBox1.Width pictureBox1.Height);
g_bt = Graphics.FromImage(bt);
g_sbt = Graphics.FromImage(sbt);
g_bt.Clear(Color.White);
pic_colorbox.BackColor = Color.Black;/////默认填充颜色为黑色
radioButton1.Checked = true;//默认选择“画笔“绘图类型
}
private void pictureBox1_MouseDown(object sender MouseEventArgs e)
{
f = true;
x1 = e.X; y1 = e.Y;
}
private void pictureBox1_MouseUp(object sender MouseEventArgs e)
{
g_bt.DrawImage(sbt 0 0);
f = false;
}
private void pictureBox1_MouseMove(object sender MouseEventArgs e)
{
if (f)
{
x2 = e.X; y2 = e.Y;
pictureBox1.Invalidate();
}
}
private void radioButton1_CheckedChanged(object sender EventArgs e)
{
type = 0;
}
private void radioButton2_CheckedChanged(object sender EventArgs e)
{
type = 1;
}
private void radioButton3_CheckedChanged(object sender EventArgs e)
{
type = 2;
}
private void radioButton4_CheckedChanged(object sender EventArgs e)
{
type = 3;
}
private void button1_Click(object sender EventArgs e)
{
g_bt.Clear(Color.White);
pictureBox1.Image = bt;
}
private void pictureBox1_Paint(object sender PaintEventArgs e)
{
int x y w h;
if (f)
{
g_sbt.DrawImage(bt 0 0);
switch (type)
{
case 0:
g_sbt.DrawLine(pen x1 y1 x2 y2);
g_bt.DrawLine(pen x1 y1 x2 y2);
x1 = x2; y1 = y2;
break;
case 1:
g_sbt.DrawLine(pen x1 y1 x2 y2);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 15872 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\bin\Debug\鼠标绘图程序.exe
文件 42496 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\bin\Debug\鼠标绘图程序.pdb
文件 14328 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\bin\Debug\鼠标绘图程序.vshost.exe
文件 490 2007-07-21 02:33 鼠标绘图程序\鼠标绘图程序\bin\Debug\鼠标绘图程序.vshost.exe.manifest
文件 5406 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\Form1.cs
文件 16322 2010-09-22 00:40 鼠标绘图程序\鼠标绘图程序\Form1.Designer.cs
文件 5814 2010-09-22 00:40 鼠标绘图程序\鼠标绘图程序\Form1.resx
文件 2875 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.csproj.FileListAbsolute.txt
文件 847 2010-09-22 00:40 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.csproj.GenerateResource.Cache
文件 15872 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.exe
文件 180 2010-09-22 00:40 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.Form1.resources
文件 42496 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.pdb
文件 180 2010-09-05 11:31 鼠标绘图程序\鼠标绘图程序\obj\Debug\鼠标绘图程序.Properties.Resources.resources
文件 499 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Program.cs
文件 1368 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Properties\AssemblyInfo.cs
文件 2886 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Properties\Resources.Designer.cs
文件 5612 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Properties\Resources.resx
文件 1103 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Properties\Settings.Designer.cs
文件 249 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序\Properties\Settings.settings
文件 3747 2010-09-05 11:08 鼠标绘图程序\鼠标绘图程序\鼠标绘图程序.csproj
文件 944 2010-09-05 10:08 鼠标绘图程序\鼠标绘图程序.sln
..A..H. 15360 2010-09-22 00:47 鼠标绘图程序\鼠标绘图程序.suo
目录 0 2010-09-21 13:10 鼠标绘图程序\鼠标绘图程序\obj\Debug\Refactor
目录 0 2010-09-21 13:07 鼠标绘图程序\鼠标绘图程序\obj\Debug\TempPE
目录 0 2010-09-21 13:07 鼠标绘图程序\鼠标绘图程序\bin\Debug
目录 0 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序\obj\Debug
目录 0 2010-09-21 13:07 鼠标绘图程序\鼠标绘图程序\bin
目录 0 2010-09-21 13:07 鼠标绘图程序\鼠标绘图程序\obj
目录 0 2010-09-21 13:07 鼠标绘图程序\鼠标绘图程序\Properties
目录 0 2010-09-22 00:46 鼠标绘图程序\鼠标绘图程序
............此处省略4个文件信息
- 上一篇:ASP.NET简单留言板(C#)
- 下一篇:C# 语法全解
评论
共有 条评论