• 大小: 56KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-19
  • 语言: C#
  • 标签: 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;
using System.Drawing.Imaging;

namespace TestDrawing
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Color backColor = Color.White;
        Image theImage;
        string editName = string.Empty;
        Graphics ig;
        drawTools drawTool;
        Color foreColor = Color.Black;
        Point startPoint oldPoint;
        bool isDrawing;
        private void 新建ToolStripMenuItem_Click(object sender EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(backColor);
            toolStrip1.Enabled = true;
            theImage = new Bitmap(this.ClientRectangle.Width this.ClientRectangle.Height);
            editName = “新建文件“;
            this.Text = “MyDraw\t“ + editName;
            ig = Graphics.FromImage(theImage);
            ig.Clear(backColor);
        }
        private void 颜色ToolStripMenuItem_Click(object sender EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                foreColor = this.colorDialog1.Color;
            }
        }

        private void 打开ToolStripMenuItem_Click(object sender EventArgs e)
        {
            openFileDialog1.Multiselect = false;
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                editName = “打开文件“;
                this.Text = “MyDraw\t“ + editName;
                theImage = Image.FromFile(this.openFileDialog1.FileName);
                Graphics g = this.CreateGraphics();
                g.DrawImage(theImage this.ClientRectangle);

                ig = Graphics.FromImage(theImage);
                ig.DrawImage(theImage this.ClientRectangle);
                this.toolStrip1.Enabled = true;
            }
        }

        private void 保存ToolStripMenuItem_Click(object sender EventArgs e)
        {
            this.saveFileDialog1.Filter = “图像(*.bmp)|*.bmp“;
            saveFileDialog1.FileName = editName;
            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                theImage.Save(this.saveFileDialog1.FileName ImageFormat.Bmp);
                this.Text = “MyDraw\t“ + this.saveFileDialog1.FileName;
                editName = this.saveFileDialog1.FileName;
            }
        }

        private void Form1_Paint(object sender PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            if (theImage != null)
            {
                g.Clear(backColor);
                g.DrawImage(theImage this.ClientRectangle);
            }
        }

        private void Form1_MouseDown(object sender MouseEventArgs e)
        {
            if (e.Button == MouseB

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

     文件      22528  2012-06-08 17:01  TestDrawing\TestDrawing\bin\Debug\TestDrawing.exe

     文件      36352  2012-06-08 17:01  TestDrawing\TestDrawing\bin\Debug\TestDrawing.pdb

     文件      11600  2012-06-08 17:02  TestDrawing\TestDrawing\bin\Debug\TestDrawing.vshost.exe

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

     文件       7918  2012-06-08 17:02  TestDrawing\TestDrawing\Form1.cs

     文件      12341  2012-06-08 16:59  TestDrawing\TestDrawing\Form1.Designer.cs

     文件      13719  2012-06-08 16:59  TestDrawing\TestDrawing\Form1.resx

     文件       2152  2012-06-08 15:41  TestDrawing\TestDrawing\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6332  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        652  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\GenerateResource.read.1.tlog

     文件       2242  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       1178  2012-06-08 17:02  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.csproj.FileListAbsolute.txt

     文件      22528  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.exe

     文件       5366  2012-06-08 16:59  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.Form1.resources

     文件      36352  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.pdb

     文件        180  2012-06-08 16:57  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.Properties.Resources.resources

     文件        180  2012-06-08 17:01  TestDrawing\TestDrawing\obj\x86\Debug\TestDrawing.TextForm.resources

     文件        495  2012-06-08 15:41  TestDrawing\TestDrawing\Program.cs

     文件       1358  2012-06-08 15:41  TestDrawing\TestDrawing\Properties\AssemblyInfo.cs

     文件       2907  2012-06-08 15:41  TestDrawing\TestDrawing\Properties\Resources.Designer.cs

     文件       5612  2012-06-08 15:41  TestDrawing\TestDrawing\Properties\Resources.resx

     文件       1096  2012-06-08 15:41  TestDrawing\TestDrawing\Properties\Settings.Designer.cs

     文件        249  2012-06-08 15:41  TestDrawing\TestDrawing\Properties\Settings.settings

     文件       4000  2012-06-08 16:57  TestDrawing\TestDrawing\TestDrawing.csproj

     文件        701  2012-06-08 17:01  TestDrawing\TestDrawing\TextForm.cs

     文件       3240  2012-06-08 17:01  TestDrawing\TestDrawing\TextForm.Designer.cs

     文件       5817  2012-06-08 17:01  TestDrawing\TestDrawing\TextForm.resx

     文件        875  2012-06-08 15:41  TestDrawing\TestDrawing.sln

    ..A..H.      9728  2012-06-08 15:41  TestDrawing\TestDrawing.suo

     目录          0  2012-06-08 15:41  TestDrawing\TestDrawing\obj\x86\Debug\TempPE

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

评论

共有 条评论