• 大小: 359KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: C#
  • 标签: c#  sh  

资源简介

C# 画画板,基本实现window自带画画功能,也具有相应提示

资源截图

代码片段和文件信息

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

namespace 画画板
{
    public partial class Form : System.Windows.Forms.Form
    {
        bool mark = false mark_copy = false;
        bool isSave = true;
        Graphics graphicsG;
        Point startpoint endpoint;//第一层相框
        int x y;//第二层相框
        Point selectpoint;
        Bitmap bitmap;//画纸
        Color g_color save_color;
        float g_width save_width;
        string shape= “pencil“;
        string saveName;
        Rectangle selectrectsaverect;
        bool isCopy = false;
        int clean = 0;

        public Form()
        {
            InitializeComponent();

            bitmap = new Bitmap(pictureBox.Width pictureBox.Height);
            graphicsG = Graphics.FromImage(bitmap); //第二层画笔,真正画在图片或pictureBox上
            graphicsG.Clear(Color.White);
            pictureBox.Image = bitmap;

            //画笔和鼠标初始化
            g_color = Color.Black;
            g_width = 1;
            save_color = g_color;
            save_width = g_width;
            pictureBox.Cursor = new Cursor(“../../../铅笔.cur“);
            shape = “pencil“;
            铅笔button.Checked = true;
            状态栏Label.Text = “00像素“;
        }

        //矩形公式
        Rectangle MakeRec(Point p1 Point p2)
        {
            int top left bottom right;
            top = p1.Y <= p2.Y ? p1.Y : p2.Y;
            left = p1.X <= p2.X ? p1.X : p2.X;
            bottom = p1.Y >= p2.Y ? p1.Y : p2.Y;
            right = p1.X >= p2.X ? p1.X : p2.X;
            return (new Rectangle(left top right - left bottom - top));
        }

        //鼠标左键按下
        private void pictureBox_MouseDown(object sender MouseEventArgs e)
        {
            if(shape!=“selectcolor“)
            {
                if (e.Button == MouseButtons.Left)
                {
                    mark = true;

                    startpoint = new Point(e.X e.Y);
                    endpoint = startpoint;
                }
            }
            else
            {
                selectpoint = new Point(e.X e.Y);
            }

            if (pictureBox_copy.Image != null && pictureBox_copy.Visible)
            {
                Bitmap bits = new Bitmap(pictureBox_copy.Image);
                if(clean>1)
                {
                    graphicsG.DrawImage(bits selectrect);
                }
                else
                {
                    graphicsG.DrawImage(bits saverect);
                }
                pictureBox_copy.Visible = false;
                pictureBox.Image = bitmap;
                clean = 0;
                isCopy = false;
            }

            isSave = false;
        }

        //鼠标左键按下后移动
        private void pictureBox_MouseMove(object 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-12 19:29  画画板\
     目录           0  2018-11-26 15:24  画画板\.git\
     文件          22  2018-11-26 15:24  画画板\.git\COMMIT_EDITMSG
     文件          23  2018-11-26 15:24  画画板\.git\HEAD
     文件         674  2018-11-26 15:24  画画板\.git\config
     文件          73  2018-11-26 15:24  画画板\.git\description
     目录           0  2018-11-26 15:24  画画板\.git\hooks\
     文件         478  2018-11-26 15:24  画画板\.git\hooks\applypatch-msg.sample
     文件         896  2018-11-26 15:24  画画板\.git\hooks\commit-msg.sample
     文件         189  2018-11-26 15:24  画画板\.git\hooks\post-update.sample
     文件         424  2018-11-26 15:24  画画板\.git\hooks\pre-applypatch.sample
     文件        1642  2018-11-26 15:24  画画板\.git\hooks\pre-commit.sample
     文件        1348  2018-11-26 15:24  画画板\.git\hooks\pre-push.sample
     文件        4898  2018-11-26 15:24  画画板\.git\hooks\pre-rebase.sample
     文件         544  2018-11-26 15:24  画画板\.git\hooks\pre-receive.sample
     文件        1239  2018-11-26 15:24  画画板\.git\hooks\prepare-commit-msg.sample
     文件        3610  2018-11-26 15:24  画画板\.git\hooks\update.sample
     文件        1360  2018-11-26 15:24  画画板\.git\index
     目录           0  2018-11-26 15:24  画画板\.git\info\
     文件         240  2018-11-26 15:24  画画板\.git\info\exclude
     目录           0  2018-11-26 15:24  画画板\.git\logs\
     文件         346  2018-11-26 15:24  画画板\.git\logs\HEAD
     目录           0  2018-11-26 15:24  画画板\.git\logs\refs\
     目录           0  2018-11-26 15:24  画画板\.git\logs\refs\heads\
     文件         346  2018-11-26 15:24  画画板\.git\logs\refs\heads\master
     文件         150  2018-12-03 18:59  画画板\.git\ms-persist.xml
     目录           0  2018-11-26 15:24  画画板\.git\objects\
     目录           0  2018-11-26 15:24  画画板\.git\objects\03\
     文件         190  2018-11-26 15:24  画画板\.git\objects\03\2f4eab94f5205b5145d48d62e3f8ddc872c0ac
     目录           0  2018-11-26 15:24  画画板\.git\objects\08\
     文件         161  2018-11-26 15:24  画画板\.git\objects\08\e763c24babe82fb9a3646db13b2594327b9c2b
............此处省略102个文件信息

评论

共有 条评论