• 大小: 42KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签:

资源简介

手写签名图片,可保存为图片或到数据库 ,简单易懂,涉及控件pictureBox1

资源截图

代码片段和文件信息

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 WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //记录直线或者曲线的对象
        private System.Drawing.Drawing2D.GraphicsPath mousePath = new System.Drawing.Drawing2D.GraphicsPath();
        //画笔透明度
        private int myAlpha = 100;
        //画笔颜色对象
        private Color myUserColor = new Color();
        //画笔宽度
        private int myPenWidth = 3;
        //签名的图片对象
        public Bitmap SavedBitmap;
        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void pictureBox1_MouseMove(object sender MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                try
                {
                    mousePath.AddLine(e.X e.Y e.X e.Y);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            pictureBox1.Invalidate();
        }

        private void pictureBox1_MouseDown(object sender MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                mousePath.StartFigure();
            }
        }

        private void pictureBox1_Paint(object sender PaintEventArgs e)
        {
            try
            {
                myUserColor = System.Drawing.Color.Blue;
                myAlpha = 255;
                Pen CurrentPen = new Pen(Color.FromArgb(myAlpha myUserColor) myPenWidth);
                e.Graphics.DrawPath(CurrentPen mousePath);
            }
            catch { }
        }

        private void button1_Click(object sender EventArgs e)
        {
            pictureBox1.CreateGraphics().Clear(Color.White);
            mousePath.Reset();
        }

        private void button2_Click(object sender EventArgs e)
        {
            Bitmap SavedBitmap = new Bitmap(pictureBox1.Width pictureBox1.Height);
            pictureBox1.DrawToBitmap(SavedBitmap new Rectangle(0 0 pictureBox1.Width pictureBox1.Height));
            SavedBitmap.Save(“c://1.jpg“ System.Drawing.Imaging.ImageFormat.Jpeg);
            MessageBox.Show(“保存成功!“);
            button1_Click(null null);
        }
    }
}

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

     文件      11264  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe

     文件      26112  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb

     文件      11600  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe

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

     文件       2667  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs

     文件       3936  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs

     文件       5817  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx

     文件       2867  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6374  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        799  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt

     文件        975  2015-10-19 14:12  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache

     文件      11264  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.exe

     文件        180  2015-10-19 14:12  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.Form1.resources

     文件      26112  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.pdb

     文件        180  2015-10-19 14:06  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.Properties.Resources.resources

     文件        505  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Program.cs

     文件       1398  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Properties\AssemblyInfo.cs

     文件       2900  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.Designer.cs

     文件       5612  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.resx

     文件       1111  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.Designer.cs

     文件        249  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.settings

     文件       3707  2015-10-19 14:06  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2.csproj

     文件        914  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2.sln

    ..A..H.     19456  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2.suo

     目录          0  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\TempPE

     目录          0  2015-10-19 14:15  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug

     目录          0  2015-10-19 14:06  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug

     目录          0  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86

     目录          0  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\bin

     目录          0  2015-10-19 14:00  WindowsFormsApplication2\WindowsFormsApplication2\obj

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

评论

共有 条评论

相关资源