• 大小: 81KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-13
  • 语言: C#
  • 标签: 画图  c#vs2010  原创  

资源简介

这是我做的一个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 Paint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        bool allowMouseMove = false;
        bool allowPaint = false;
        Point startPoint;
        Point endPoint;
        Graphics g;
        private void Form1_Load(object sender EventArgs e)
        {
            g = this.CreateGraphics();
        }
        private void 画椭圆ToolStripMenuItem_Click(object sender EventArgs e)
        {
            allowMouseMove = true;
        }

        private void Form1_MouseDown(object sender MouseEventArgs e)
        {
            allowPaint = true;
            startPoint = new Point(e.Xe.Y);

        }

        private void Form1_MouseMove(object sender MouseEventArgs e)
        {
            if (allowMouseMove)
            {
                endPoint=new Point(e.Xe.Y);
                if (allowPaint)
                {
                    this.Refresh();
                    g.DrawEllipse(new Pen(Color.Black1)startPoint.XstartPoint.YendPoint.X-startPoint.XendPoint.Y-startPoint.Y);
                }
            }
        }

        private void Form1_MouseUp(object sender MouseEventArgs e)
        {
            allowPaint = false;
        }

        
    }
}

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

     文件       9216  2012-04-10 22:33  MousePaint\Paint\Paint\bin\Debug\Paint.exe

     文件      24064  2012-04-10 22:33  MousePaint\Paint\Paint\bin\Debug\Paint.pdb

     文件      11600  2012-04-10 22:33  MousePaint\Paint\Paint\bin\Debug\Paint.vshost.exe

     文件        490  2010-03-17 22:39  MousePaint\Paint\Paint\bin\Debug\Paint.vshost.exe.manifest

     文件       1523  2012-04-10 22:33  MousePaint\Paint\Paint\Form1.cs

     文件       3254  2012-04-10 22:28  MousePaint\Paint\Paint\Form1.Designer.cs

     文件       6015  2012-04-10 22:28  MousePaint\Paint\Paint\Form1.resx

     文件       2152  2012-04-10 22:24  MousePaint\Paint\Paint\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6196  2012-04-10 22:33  MousePaint\Paint\Paint\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        184  2012-04-10 22:32  MousePaint\Paint\Paint\obj\x86\Debug\GenerateResource.read.1.tlog

     文件        458  2012-04-10 22:32  MousePaint\Paint\Paint\obj\x86\Debug\GenerateResource.write.1.tlog

     文件        613  2012-04-10 22:33  MousePaint\Paint\Paint\obj\x86\Debug\Paint.csproj.FileListAbsolute.txt

     文件       9216  2012-04-10 22:33  MousePaint\Paint\Paint\obj\x86\Debug\Paint.exe

     文件        180  2012-04-10 22:32  MousePaint\Paint\Paint\obj\x86\Debug\Paint.Form1.resources

     文件      24064  2012-04-10 22:33  MousePaint\Paint\Paint\obj\x86\Debug\Paint.pdb

     文件        180  2012-04-10 22:32  MousePaint\Paint\Paint\obj\x86\Debug\Paint.Properties.Resources.resources

     文件       3669  2012-04-10 22:25  MousePaint\Paint\Paint\Paint.csproj

     文件        497  2012-04-10 22:24  MousePaint\Paint\Paint\Program.cs

     文件       1440  2012-04-10 22:24  MousePaint\Paint\Paint\Properties\AssemblyInfo.cs

     文件       2838  2012-04-10 22:24  MousePaint\Paint\Paint\Properties\Resources.Designer.cs

     文件       5612  2012-04-10 22:24  MousePaint\Paint\Paint\Properties\Resources.resx

     文件       1090  2012-04-10 22:24  MousePaint\Paint\Paint\Properties\Settings.Designer.cs

     文件        249  2012-04-10 22:24  MousePaint\Paint\Paint\Properties\Settings.settings

     文件        857  2012-04-10 22:24  MousePaint\Paint\Paint.sln

    ..A..H.     26112  2012-04-10 22:33  MousePaint\Paint\Paint.suo

     文件      10240  2012-04-10 22:47  MousePaint\Paint and Save\Paint\bin\Debug\Paint.exe

     文件      34304  2012-04-10 22:47  MousePaint\Paint and Save\Paint\bin\Debug\Paint.pdb

     文件      11600  2012-04-10 22:47  MousePaint\Paint and Save\Paint\bin\Debug\Paint.vshost.exe

     文件        490  2010-03-17 22:39  MousePaint\Paint and Save\Paint\bin\Debug\Paint.vshost.exe.manifest

     文件        528  2012-04-10 22:42  MousePaint\Paint and Save\Paint\ellipse.cs

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

评论

共有 条评论