• 大小: 182KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-04
  • 语言: C#
  • 标签: C#  鼠标    多边形  

资源简介

C#鼠标画多边形和矩形 C#实现类画图软件功能,可以用鼠标在界面上画多边形 矩形 圆形 或者充当画笔画任意形状

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace DrawDesigns
{
    public partial class Form1 : Form
    {
        Boolean mouseDown = false; //鼠标左键是否按下        
        String drawShape = “Line“; //椭什么形状,初始为线
        Point StartPoint = Point.Empty EndPoint = Point.Empty; //鼠标移动的起始点
        Color color = Color.Black; //定义图像边框颜色
        ArrayList appendList = new ArrayList(); //图形属性列表
        Cursor LineCursor CurveCursor EraserCursor; //鼠标样式        
        public Form1()
        {
            InitializeComponent();            
        }
        //移动
        private void MoveButton_Click(object sender EventArgs e)
        {
            this.Canvas.Cursor = Cursors.Default;
            this.drawShape = ““;
        }
        //直线
        private void DrawLine_Click(object sender EventArgs e)
        {
            LineCursor = new Cursor(“./MouseIcon/Pen.ico“);
            this.drawShape = “Line“;
            this.Canvas.Cursor = LineCursor;
        }
        //曲线
        private void DrawCurve_Click(object sender EventArgs e)
        {
            CurveCursor = new Cursor(“./MouseIcon/Curve.ico“);
            this.drawShape = “Curve“;
            this.Canvas.Cursor = CurveCursor;
        }
        //椭圆
        private void DrawEllipse_Click(object sender EventArgs e)
        {
            this.drawShape = “Ellipse“;
            this.Canvas.Cursor = Cursors.Cross;
        }
        //矩形
        private void DrawRectangle_Click(object sender EventArgs e)
        {
            this.drawShape = “Rectangle“;
            this.Canvas.Cursor = Cursors.Cross;
        }
        //擦除
        private void EraserTool_Click(object sender EventArgs e)
        {
            EraserCursor = new Cursor(“./MouseIcon/Eraser.ico“);
            this.drawShape = “Eraser“;
            this.Canvas.Cursor = EraserCursor;
        }
        /// 
        /// 图形属性列表
        /// 

        public struct ShapeType
        {
            public string type;
            public Point StartPoint EndPoint;
            public Color foreColor backColor;
            public Brush brush;
            public ShapeType(string type Point StartPoint Point EndPoint Color foreColor Color backColor Brush brush)
            {
                this.type = type;
                this.StartPoint = StartPoint;
                this.EndPoint = EndPoint;
                this.foreColor = foreColor;
                this.backColor = backColor;
                this.brush = brush;
            }
        }
        //鼠标按下事件
        private void Canvas_MouseDown(object sender MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.StartPoint = ne

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4258  2010-11-15 14:50  C#DrawDesign\Backup\DrawDesigns\DrawDesigns.csproj

     文件      15596  2010-11-15 14:59  C#DrawDesign\Backup\DrawDesigns\Form1.cs

     文件      15148  2010-11-15 14:59  C#DrawDesign\Backup\DrawDesigns\Form1.designer.cs

     文件       9871  2010-11-15 14:59  C#DrawDesign\Backup\DrawDesigns\Form1.resx

     文件       2238  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\ICO\Clear.ico

     文件       2238  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\ICO\Curve.ico

     文件       4710  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\ICO\Eraser.ico

     文件       2238  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\ICO\Icon.ico

     文件       3638  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\ICO\Pen.ico

     文件       2238  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Icon.ico

     文件       2374  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Image\CircleShape.png

     文件       8097  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Image\color.jpg

     文件       3819  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Image\cursor.png

     文件       3289  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Image\Rectangle.png

     文件        492  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns\Program.cs

     文件       1451  2010-11-15 15:01  C#DrawDesign\Backup\DrawDesigns\Properties\AssemblyInfo.cs

     文件       4609  2010-11-15 14:56  C#DrawDesign\Backup\DrawDesigns\Properties\Resources.Designer.cs

     文件       7621  2010-11-15 14:56  C#DrawDesign\Backup\DrawDesigns\Properties\Resources.resx

     文件       1094  2010-11-15 14:49  C#DrawDesign\Backup\DrawDesigns\Properties\Settings.Designer.cs

     文件        249  2010-11-15 14:49  C#DrawDesign\Backup\DrawDesigns\Properties\Settings.settings

     文件        923  2010-11-15 14:48  C#DrawDesign\Backup\DrawDesigns.sln

    ..A..H.     14848  2010-11-15 15:01  C#DrawDesign\Backup\DrawDesigns.suo

     文件      35328  2017-11-05 11:35  C#DrawDesign\DrawDesigns\bin\Debug\C#DrawDesigns.exe

     文件      34304  2017-11-05 11:35  C#DrawDesign\DrawDesigns\bin\Debug\C#DrawDesigns.pdb

     文件      11608  2017-11-05 11:34  C#DrawDesign\DrawDesigns\bin\Debug\C#DrawDesigns.vshost.exe

     文件      30208  2010-11-15 15:01  C#DrawDesign\DrawDesigns\bin\Debug\DrawDesigns.exe

     文件      32256  2010-11-15 15:01  C#DrawDesign\DrawDesigns\bin\Debug\DrawDesigns.pdb

     文件       2238  2010-07-27 23:25  C#DrawDesign\DrawDesigns\bin\Debug\MouseIcon\Curve.ico

     文件       4710  2010-07-27 10:52  C#DrawDesign\DrawDesigns\bin\Debug\MouseIcon\Eraser.ico

     文件       3638  2010-07-27 10:37  C#DrawDesign\DrawDesigns\bin\Debug\MouseIcon\Pen.ico

............此处省略61个文件信息

评论

共有 条评论