/*********************** * 说明:PDF签名控件 * 创建人:龚宇超 * 创建日期:2018-05-29 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ***********************/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using iTextSharp.text.pdf; using System.IO; using O2S.Components.PDFView4NET; using Lskj.Util; using Lskj.Model; using System.Runtime.Serialization.Formatters.Binary; using Lskj.Core; using System.Diagnostics; using Lskj.Business; using System.Text.RegularExpressions; using Lskj.Business.Impl; using DevExpress.XtraGrid.Columns; using DevExpress.Utils; using DevExpress.XtraGrid.Views.Grid; namespace Lskj.Control { public partial class PdfEditorEx : UserControl { #region 公开变量 /// /// 当前保存签名的ID /// public int CurrentId; /// /// 当前页码 /// public int CurrentPageNo; /// /// 源文件(该文件不进行编辑) /// public string TempletFilePath = string.Empty; /// /// 签名图片 /// public Image SignImage; /// /// 记录签名预制体pictureBox坐标 /// public PointF SignBoxPoint; /// /// 签名载体 /// public PictureBox PicBox { get { return this.pictureBox; } } /// /// 保存回调 /// public event EventHandler OnSaveCallBack; /// /// 删除回调 /// public event EventHandler OnDeleteCallBack; /// /// 另存为回调 /// public event EventHandler OnSaveAsCallBack; #endregion #region 私有变量 /// /// 当前操作文件 /// private string _currentPdf; /// /// 上一次编辑的文件地址,保存失误后可以返回 /// private string _pdfHistory; /// /// 后台合成的PDf /// private string _pdfNew; /// /// 签名预制体集 /// private List _signBoxList; /// /// pdf模板 /// public Dictionary pdfTempDic = new Dictionary(); #endregion public PdfEditorEx() { InitializeComponent(); } /// /// 窗体初始化时 /// public void OnLoad() { InitLeftSignGrid(); InitTempComboBox(); } /// /// 初始化左侧签名表 /// private void InitLeftSignGrid() { try { GridColumn signColumn = new GridColumn(); signColumn.FieldName = "signName"; signColumn.Caption = "签名"; signColumn.VisibleIndex = 0; signColumn.OptionsColumn.AllowEdit = false; this.leftSignGrid.GridView.Columns.Add(signColumn); DataTable LeftSignDataSource = new DataTable(); LeftSignDataSource.Columns.Add("signName"); LeftSignDataSource.Columns.Add("signPath"); if (Directory.Exists(PubUtil.PdfSignImagePath)) { DirectoryInfo dirInfo = new DirectoryInfo(PubUtil.PdfSignImagePath); FileInfo[] fileInfos = dirInfo.GetFiles(); foreach (FileInfo fileInfo in fileInfos) { DataRow dataRow = LeftSignDataSource.NewRow(); dataRow["signName"] = Path.GetFileNameWithoutExtension(fileInfo.FullName); dataRow["signPath"] = fileInfo.FullName; LeftSignDataSource.Rows.Add(dataRow); } } this.leftSignGrid.GridView.OptionsBehavior.EditorShowMode = EditorShowMode.MouseDownFocused; this.leftSignGrid.GridControl.DataSource = LeftSignDataSource; this.leftSignGrid.GridView.DoubleClick += new EventHandler(OnGridView_DoubleClick); } catch (Exception ex) { MessageUtil.Show(ex.Message); } } private void OnGridView_DoubleClick(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this._currentPdf)) { GridView gridView = (GridView)sender; DataRow dataRow = gridView.GetFocusedDataRow(); if (dataRow != null) { AddSignPicControl(dataRow); } } } private void InitTempComboBox() { try { this.checkTemp.Properties.AllowNullInput = DefaultBoolean.True; this.checkTemp.Properties.NullText = "请选择模板"; if (Directory.Exists(PubUtil.PdfSignTempPath)) { DirectoryInfo dirInfo = new DirectoryInfo(PubUtil.PdfSignTempPath); FileInfo[] fileInfos = dirInfo.GetFiles(); foreach (FileInfo fileInfo in fileInfos) { string tempKey = Path.GetFileNameWithoutExtension(fileInfo.FullName); this.pdfTempDic.Add(tempKey, fileInfo); this.checkTemp.Properties.Items.Add(tempKey); } } this.checkTemp.SelectedIndexChanged += new EventHandler(OnCheckTemp_SelectedIndexChanged); } catch (Exception ex) { MessageUtil.Show(ex.Message); } } private void OnCheckTemp_SelectedIndexChanged(object sender, EventArgs e) { string tempKey = this.checkTemp.SelectedText; TempletFilePath = this.pdfTempDic[tempKey].FullName; if (_signBoxList != null) { foreach (SignBox item in _signBoxList) { item.ParentPicBox.Dispose(); } } _signBoxList = new List(); InitPdfPage(null); } /// /// 添加签名控件 /// public void AddSignPicControl(DataRow dataRow) { string imgPath = dataRow["signPath"] + ""; PictureBox pictureBox = new PictureBox(); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; SignBox signBox = new SignBox(); _signBoxList.Add(signBox); try { Image image = Image.FromFile(imgPath); signBox.ParentPicBox = pictureBox; signBox.PageNumber = this.CurrentPageNo + 1; signBox.ParentPicBoxImagePath = imgPath; signBox.SignHeight = image.Height; signBox.SignWidth = image.Width; signBox.SignTop = 0; signBox.SignLeft = 0; pictureBox.BorderStyle = BorderStyle.None; pictureBox.Image = image; //pictureBox.Height = signHeight; //pictureBox.Width = signWidth; pictureBox.Tag = signBox; pictureBox.Parent = this.pdfPageView; ContextMenuStrip cms = new ContextMenuStrip(); cms.Items.Add("删除"); cms.Items[0].Click += new EventHandler(OnItemClick); cms.Items[0].Tag = pictureBox; pictureBox.ContextMenuStrip = cms; pictureBox.BringToFront(); //pictureBox.Location = new Point(signLeft, signTop); pictureBox.MouseDown += new MouseEventHandler(OnPictureBox_MouseDown); pictureBox.MouseMove += new MouseEventHandler(OnPictureBox_MouseMove); pictureBox.MouseUp += new MouseEventHandler(OnPictureBox_MouseUp); pictureBox.MouseClick += new MouseEventHandler(OnPictureBox_MouseClick); pictureBox.MouseLeave += new EventHandler(OnPictureBox_MouseLeave); } catch (Exception ex) { MessageBox.Show(ex.Message); _signBoxList.Remove(signBox); pictureBox.Dispose(); } } private void OnPictureBox_MouseLeave(object sender, EventArgs e) { PictureBox pictureBox = (PictureBox)sender; pictureBox.Cursor = Cursors.Default; } private void OnPictureBox_MouseClick(object sender, MouseEventArgs e) { PictureBox pictureBox = (PictureBox)sender; SignBox signBox = (SignBox)pictureBox.Tag; if (e.Button == MouseButtons.Left) { pictureBox.Focus(); this.propertyGrid.SelectedObject = signBox; pictureBox.Cursor = Cursors.SizeAll; } } /// /// 签名删除 /// /// /// private void OnItemClick(object sender, EventArgs e) { ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)sender; PictureBox pictureBox = (PictureBox)toolStripMenuItem.Tag; SignBox signBox = (SignBox)pictureBox.Tag; this._signBoxList.Remove(signBox); pictureBox.Dispose(); } private void OnPictureBox_MouseUp(object sender, MouseEventArgs e) { PictureBox pictureBox = (PictureBox)sender; SignBox signBox = (SignBox)pictureBox.Tag; signBox.IsMove = false; } private void OnPictureBox_MouseDown(object sender, MouseEventArgs e) { PictureBox pictureBox = (PictureBox)sender; SignBox signBox = (SignBox)pictureBox.Tag; signBox.IsMove = true; signBox.MouseDownPoint = pictureBox.PointToClient(System.Windows.Forms.Control.MousePosition); } private void OnPictureBox_MouseMove(object sender, MouseEventArgs e) { PictureBox pictureBox = (PictureBox)sender; SignBox signBox = (SignBox)pictureBox.Tag; if (pictureBox.Focused) { pictureBox.Cursor = Cursors.SizeAll; } else { pictureBox.Cursor = Cursors.Default; } if (signBox.IsMove && e.Button == MouseButtons.Left && pictureBox.Focused) { signBox.SignLeft = pictureBox.Location.X + (e.X - signBox.MouseDownPoint.X); signBox.SignTop = pictureBox.Location.Y + (e.Y - signBox.MouseDownPoint.Y); //pictureBox.Location = new Point(pictureBox.Location.X + (e.X - signBox.MouseDownPoint.X), pictureBox.Location.Y + (e.Y - signBox.MouseDownPoint.Y)); } } /// /// 说明:添加图片到Pdf /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 图片地址 /// 页码 /// 坐标点 /// stamper /// 是否计算,由于初始绘制点是计算好的不用计算. private void AddImageToPdf(Image pic, int pageNo, PointF point, PdfStamper stamper, bool isCalc = false) { //插入图片 iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(pic, pic.RawFormat); PdfContentByte pdfContentByte = stamper.GetOverContent(Convert.ToInt32(pageNo + 1)); int percent = GetPercentSize(image.Height, image.Width); image.ScalePercent(percent); if (isCalc) { //手动画点时,进行图片缩放 this.SignBoxPoint = point = new PointF(point.X, float.Parse(point.Y - image.Height * percent * 0.01 / 2 + "")); } image.SetAbsolutePosition(point.X, point.Y); pdfContentByte.AddImage(image); } /// /// 说明:关闭PDf进程 /// 创建人:龚宇超 /// 创建日期:2018-06-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void Close() { try { this.pdfDocument.Close(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:画签名 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void DrawSignBox(Point point) { pictureBox.Visible = true; pictureBox.Image = this.SignImage; pictureBox.Width = this.SignImage.Width; pictureBox.Height = this.SignImage.Height; //设置pictureBox 透明 pictureBox.Parent = this.pdfPageView; pictureBox.BackColor = Color.Transparent; pictureBox.Location = new Point(point.X, point.Y - this.pictureBox.Height / 2); } /// /// 说明:删除 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void Delete() { _signBoxList = _signBoxList.Where(o => o.PageNumber != this.pdfPageView.PageNumber).ToList(); foreach (SignBox item in _signBoxList) { item.ParentPicBox.Dispose(); } } /// /// 说明:找到记录的sign坐标并画 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void FindSignBox() { //翻页切换时候进行画点操作 //List signBoxs = _signBoxList.Where(o => o.PageNumber == this.pdfPageView.PageNumber).ToList(); foreach (SignBox item in this._signBoxList) { if (item.PageNumber != this.CurrentPageNo + 1) { item.ParentPicBox.Parent = null; } else { item.ParentPicBox.Parent = this.pdfPageView; } } } /// /// 说明:初始化pdf控件 /// 创建人:龚宇超 /// 创建日期:2018-05-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitPdfEditor() { try { //存储记录picBox在页面打的点 this._signBoxList = new List(); this.pdfPageView.MouseWheel += new MouseEventHandler(OnMouseWheelClick); DirectoryInfo dir = new DirectoryInfo(PubUtil.MenuExcelPath); //初始化时清除掉文件 foreach (FileInfo f in dir.GetFiles("*.pdf")) { f.Delete(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:初始在源文件上描点 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void InitPdfPage(DataTable dt) { this.CurrentId = 0; if (dt == null || dt.Rows.Count == 0) { this._pdfHistory = this._currentPdf = this.TempletFilePath; } else { this._pdfHistory = this._currentPdf = PubUtil.MenuExcelPath + Guid.NewGuid() + ".pdf"; using (Stream outputPdfStream = new FileStream(this._currentPdf, FileMode.Create, FileAccess.Write, FileShare.None)) { PdfReader reader = new PdfReader(this.TempletFilePath); PdfStamper stamper = new PdfStamper(reader, outputPdfStream); foreach (DataRow row in dt.Rows) { PdfSignModel model = new PdfSignModel(row); PointF point = new PointF(model.ImageX, model.ImageY); Image pic = Image.FromStream(new MemoryStream(model.PicStream), true); ; AddImageToPdf(pic, model.PageNo, point, stamper); } stamper.Close(); } } this.pdfDocument.Load(this._currentPdf); this.CurrentPageNo = 0; this.pdfPageView.PageNumber = this.CurrentPageNo; } /// /// 说明:记录保存的签名 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void SaveSignBox(Point point) { //先移除本页原有的点 this._signBoxList.Remove(_signBoxList.FirstOrDefault(o => o.PageNumber == this.CurrentPageNo)); SignBox signBox = new SignBox(); signBox.PageNumber = this.CurrentPageNo; signBox.PointObj = point; this._signBoxList.Add(signBox); } /// /// 说明:保存 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public void Save(string savePath) { using (FileStream fileStream = new FileStream(savePath, FileMode.Create, FileAccess.ReadWrite)) { using (iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(this._currentPdf)) { PdfStamper stamper = new PdfStamper(reader, fileStream); int readPageNum = reader.NumberOfPages; for (int j = 0; j < readPageNum; j++) { List signBoxes = this._signBoxList.Where(n => n.PageNumber == j + 1).ToList(); foreach (SignBox item in signBoxes) { PdfContentByte pdfContentByte = stamper.GetOverContent(j + 1);//获取内容 using (Stream inputImageStream = new FileStream(item.ParentPicBoxImagePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);//获取图片 PDFPoint startPoint = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft, item.SignTop)); PDFPoint endPoint = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft + item.SignWidth, item.SignTop + item.SignHeight)); image.ScaleAbsolute((float)(endPoint.X - startPoint.X), (float)(startPoint.Y - endPoint.Y));//设置图片比例 image.SetAbsolutePosition((float)startPoint.X, (float)startPoint.Y - (float)(startPoint.Y - endPoint.Y));//设置图片的绝对位置 pdfContentByte.AddImage(image); } } } stamper.Close(); } } } /// /// 说明:根据比例缩放图片 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 高度 /// 宽度 /// System.Int32. private int GetPercentSize(float height, float width) { float percent = height / width * 100; return Convert.ToInt32(Math.Round(percent)); } /// /// 说明:另存为 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public bool SaveAs() { if (string.IsNullOrEmpty(this._currentPdf)) return false; string defaultSavePath = string.Format("{0}{1}", PubUtil.FileDownLoadTempPath, "signTempFile.pdf"); string tempSavePath = string.Format("{0}{1}", PubUtil.PdfSignTempSavePath, "signTempFile.pdf"); this.Save(defaultSavePath); this.pdfDocument.Close(); this.pdfDocument.Load(this._currentPdf); //加载到保存前的页码位置 this.pdfPageView.PageNumber = this.CurrentPageNo; string fileName = string.Empty; bool saveState = false; using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.Title = "另存为"; saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveFileDialog.Filter = "pdf(*.pdf)|*.pdf"; saveFileDialog.AddExtension = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { fileName = saveFileDialog.FileName; File.Copy(defaultSavePath, fileName, true); saveState = true; } else { //另存操作失误,取消另存时候,加载到保存前状态 this._currentPdf = this._pdfHistory; this.pdfDocument.Load(this._currentPdf); this.pdfPageView.PageNumber = this.CurrentPageNo; } return saveState; } } /// /// 说明:打开本地文件 /// 创建人:龚宇超 /// 创建日期:2018-05-28 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// System.String. private string OpenLocalFile() { string fileName = string.Empty; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); openFileDialog.Filter = "(*.pdf)|*.pdf"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { TempletFilePath = fileName = openFileDialog.FileName; InitPdfPage(null); } return fileName; } #region 事件部分 /// /// 说明:清除签名点 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnDeleteClick(object sender, EventArgs e) { try { if (OnDeleteCallBack != null) { OnDeleteCallBack(null, null); } else { this.Delete(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:鼠标滑轮滚动事件 /// 创建人:龚宇超 /// 创建日期:2018-05-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. void OnMouseWheelClick(object sender, MouseEventArgs e) { try { //向前滑 if (e.Delta > 0) { OnPageUpClick(null, null); } else { OnPageNextClick(null, null); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:打开文件 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. void OnOpenClick(object sender, EventArgs e) { try { OpenLocalFile(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明: /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnPageClick(object sender, O2S.Components.PDFView4NET.PageClickEventArgs e) { try { //初始化签名键值 this.CurrentId = 0; this.CurrentPageNo = this.pdfPageView.PageNumber; PdfReader reader = new PdfReader(this._currentPdf); //记录上次操作文件,操作失误能返回 this._pdfHistory = this._currentPdf; //合成的文件地址 this._pdfNew = PubUtil.MenuExcelPath + Guid.NewGuid() + ".pdf"; using (Stream outPutPdfStream = new FileStream(_pdfNew, FileMode.Create, FileAccess.Write, FileShare.None)) { PdfStamper stamper = new PdfStamper(reader, outPutPdfStream); PointF point = new PointF(float.Parse(e.PDFPoint.X + ""), float.Parse(e.PDFPoint.Y + "")); this.AddImageToPdf(this.SignImage, this.CurrentPageNo, point, stamper, true); stamper.Close(); } reader.Close(); DrawSignBox(e.ControlPoint); //将打的点记录下来 SaveSignBox(e.ControlPoint); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:上一页 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnPageUpClick(object sender, EventArgs e) { try { if (this.pdfPageView.PageNumber > 0) { this.pdfPageView.PageNumber--; this.CurrentPageNo = this.pdfPageView.PageNumber; this.FindSignBox(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:下一页 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnPageNextClick(object sender, EventArgs e) { try { if (this.pdfPageView.PageNumber < this.pdfDocument.PageCount - 1) { this.pdfPageView.PageNumber++; this.CurrentPageNo = this.pdfPageView.PageNumber; this.FindSignBox(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:保存事件 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnSaveClick(object sender, EventArgs e) { try { if (OnSaveCallBack != null) { OnSaveCallBack(null, null); } else { if (string.IsNullOrEmpty(this._currentPdf)) return; string defaultSavePath = string.Format("{0}{1}", PubUtil.FileDownLoadTempPath, "signTempFile.pdf"); string tempSavePath = string.Format("{0}{1}", PubUtil.PdfSignTempSavePath, "signTempFile.pdf"); this.Save(defaultSavePath); this.pdfDocument.Close(); File.Copy(defaultSavePath, tempSavePath, true); foreach (SignBox item in this._signBoxList) { item.ParentPicBox.Dispose(); } this._signBoxList = new List(); this._currentPdf = tempSavePath; this.pdfDocument.Load(this._currentPdf); //加载到保存前的页码位置 this.pdfPageView.PageNumber = this.CurrentPageNo; } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:另存事件 /// 创建人:龚宇超 /// 创建日期:2018-05-30 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnSaveAsClick(object sender, EventArgs e) { try { if (OnSaveAsCallBack != null) { OnSaveAsCallBack(null, null); } else { this.SaveAs(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } #endregion } /// /// 签名box对象 /// public class SignBox { /// /// 父图片控件 /// [BrowsableAttribute(false)] public PictureBox ParentPicBox { get; set; } /// /// 图片地址 /// [BrowsableAttribute(false)] public string ParentPicBoxImagePath { get; set; } /// /// 页码 /// /// The page number. [BrowsableAttribute(false)] public int PageNumber { get; set; } /// /// 坐标 /// /// The point. [BrowsableAttribute(false)] public Point PointObj { get; set; } private int _signWidth; /// /// 宽度 /// [Category("基本属性")] [DisplayName("宽度")] [Description("宽度")] public int SignWidth { get { return _signWidth; } set { _signWidth = value; ParentPicBox.Width = _signWidth; } } private int _signHeight; /// /// 高度 /// [Category("基本属性")] [DisplayName("高度")] [Description("高度")] public int SignHeight { get { return _signHeight; } set { _signHeight = value; ParentPicBox.Height = _signHeight; } } private int _signLeft; /// /// 左边距 /// [Category("基本属性")] [DisplayName("左边距")] [Description("左边距")] public int SignLeft { get { return _signLeft; } set { _signLeft = value; ParentPicBox.Left = _signLeft; } } private int _signTop; /// /// 上边距 /// [Category("基本属性")] [DisplayName("上边距")] [Description("上边距")] public int SignTop { get { return _signTop; } set { _signTop = value; ParentPicBox.Top = _signTop; } } /// /// 是否移动状态 /// [BrowsableAttribute(false)] public bool IsMove { get; set; } /// /// 鼠标点击位置 /// [BrowsableAttribute(false)] public Point MouseDownPoint { get; set; } } }