基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using O2S.Components.PDFView4NET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
public static class ControlExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置控件移动和调整大小
|
||||
/// </summary>
|
||||
public static void SetMove(this System.Windows.Forms.Control control)
|
||||
{
|
||||
//边框控件
|
||||
ResizeControl fControl = null;
|
||||
//上一个鼠标坐标
|
||||
Point lastPoint = new Point();
|
||||
|
||||
#region 绑定事件
|
||||
|
||||
//鼠标键按下时
|
||||
control.MouseDown += (sender, e) =>
|
||||
{
|
||||
//记录鼠标坐标
|
||||
lastPoint = Cursor.Position;
|
||||
|
||||
SignBox signBox = (SignBox)control.Tag;
|
||||
//清除所有控件的边框区域,最主要的是清除上次点击控件的边框,恢复原来状态
|
||||
foreach (System.Windows.Forms.Control ctrl in control.Parent.Controls)
|
||||
if (ctrl is ResizeControl)
|
||||
ctrl.Visible = false;
|
||||
if (fControl == null)
|
||||
{
|
||||
fControl = new ResizeControl(control);
|
||||
signBox.ParentResizeControl = fControl;
|
||||
}
|
||||
//设置边框背景色为透明,可以设置其它颜色
|
||||
fControl.BackColor = Color.Transparent;
|
||||
//把边框控件添加到当前控件的父控件中
|
||||
control.Parent.Controls.Add(fControl);
|
||||
if (control.Parent != null && control.Parent is PDFPageView)
|
||||
{
|
||||
if (control.Parent.Parent != null && control.Parent.Parent is PdfEditorEx)
|
||||
{
|
||||
(control.Parent.Parent as PdfEditorEx)._selectedSignBox = signBox;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//鼠标单击时
|
||||
control.MouseClick += (sender, e) =>
|
||||
{
|
||||
control.BringToFront();
|
||||
};
|
||||
|
||||
//鼠标在控件上移动时
|
||||
control.MouseMove += (sender, e) =>
|
||||
{
|
||||
Point currentPoint = new Point();
|
||||
Cursor.Current = Cursors.SizeAll;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
currentPoint = Cursor.Position;
|
||||
control.Location = new Point(control.Location.X + currentPoint.X - lastPoint.X,
|
||||
control.Location.Y + currentPoint.Y - lastPoint.Y);
|
||||
|
||||
//移动时刷新实线
|
||||
fControl.DrawSolids();
|
||||
control.BringToFront();
|
||||
}
|
||||
|
||||
lastPoint = currentPoint;
|
||||
};
|
||||
|
||||
//鼠标键释放时
|
||||
control.MouseUp += (sender, e) =>
|
||||
{
|
||||
//设置控件区域
|
||||
fControl.SetControlRegion();
|
||||
System.Windows.Forms.Control pictureBox = (System.Windows.Forms.Control)sender;
|
||||
if (pictureBox.Tag != null && pictureBox.Tag is SignBox)
|
||||
{
|
||||
(pictureBox.Tag as SignBox).UpdateLocation();
|
||||
}
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
partial class PdfEditorEx
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PdfEditorEx));
|
||||
this.pdfDocument = new O2S.Components.PDFView4NET.PDFDocument();
|
||||
this.editToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.btn_NextPage = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.btn_UpPage = new System.Windows.Forms.ToolStripButton();
|
||||
this.pdfPageView = new O2S.Components.PDFView4NET.PDFPageView();
|
||||
this.editToolStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pdfDocument
|
||||
//
|
||||
this.pdfDocument.Metadata = null;
|
||||
this.pdfDocument.PageLayout = O2S.Components.PDFView4NET.PDFPageLayout.SinglePage;
|
||||
this.pdfDocument.PageMode = O2S.Components.PDFView4NET.PDFPageMode.UseNone;
|
||||
//
|
||||
// editToolStrip
|
||||
//
|
||||
this.editToolStrip.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
this.editToolStrip.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.editToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.editToolStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.editToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.btn_NextPage,
|
||||
this.toolStripSeparator1,
|
||||
this.btn_UpPage});
|
||||
this.editToolStrip.Location = new System.Drawing.Point(0, 548);
|
||||
this.editToolStrip.Name = "editToolStrip";
|
||||
this.editToolStrip.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
||||
this.editToolStrip.ShowItemToolTips = false;
|
||||
this.editToolStrip.Size = new System.Drawing.Size(1027, 32);
|
||||
this.editToolStrip.TabIndex = 19;
|
||||
//
|
||||
// btn_NextPage
|
||||
//
|
||||
this.btn_NextPage.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
this.btn_NextPage.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.btn_NextPage.Image = ((System.Drawing.Image)(resources.GetObject("btn_NextPage.Image")));
|
||||
this.btn_NextPage.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btn_NextPage.Name = "btn_NextPage";
|
||||
this.btn_NextPage.Size = new System.Drawing.Size(73, 29);
|
||||
this.btn_NextPage.Text = "下一页";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 32);
|
||||
//
|
||||
// btn_UpPage
|
||||
//
|
||||
this.btn_UpPage.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
this.btn_UpPage.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.btn_UpPage.Image = ((System.Drawing.Image)(resources.GetObject("btn_UpPage.Image")));
|
||||
this.btn_UpPage.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btn_UpPage.Name = "btn_UpPage";
|
||||
this.btn_UpPage.Size = new System.Drawing.Size(73, 29);
|
||||
this.btn_UpPage.Text = "上一页";
|
||||
//
|
||||
// pdfPageView
|
||||
//
|
||||
this.pdfPageView.BackColor = System.Drawing.Color.White;
|
||||
this.pdfPageView.DefaultEllipseAnnotationBorderWidth = 1D;
|
||||
this.pdfPageView.DefaultInkAnnotationWidth = 1D;
|
||||
this.pdfPageView.DefaultRectangleAnnotationBorderWidth = 1D;
|
||||
this.pdfPageView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pdfPageView.Document = this.pdfDocument;
|
||||
this.pdfPageView.DownscaleLargeImages = false;
|
||||
this.pdfPageView.EnableRepeatedKeys = false;
|
||||
this.pdfPageView.Location = new System.Drawing.Point(0, 0);
|
||||
this.pdfPageView.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.pdfPageView.Name = "pdfPageView";
|
||||
this.pdfPageView.PageNumber = 0;
|
||||
this.pdfPageView.RenderingProgressColor = System.Drawing.Color.Empty;
|
||||
this.pdfPageView.RenderingProgressDisplay = O2S.Components.PDFView4NET.PDFRenderingProgressDisplayMode.None;
|
||||
this.pdfPageView.RequiredFormFieldHighlightColor = System.Drawing.Color.Empty;
|
||||
this.pdfPageView.ScrollPosition = new System.Drawing.Point(0, 0);
|
||||
this.pdfPageView.Size = new System.Drawing.Size(1027, 548);
|
||||
this.pdfPageView.SubstituteFonts = null;
|
||||
this.pdfPageView.TabIndex = 20;
|
||||
this.pdfPageView.WorkMode = O2S.Components.PDFView4NET.UserInteractiveWorkMode.None;
|
||||
this.pdfPageView.ZoomMode = O2S.Components.PDFView4NET.PDFZoomMode.FitVisible;
|
||||
//
|
||||
// PdfEditorEx
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Controls.Add(this.pdfPageView);
|
||||
this.Controls.Add(this.editToolStrip);
|
||||
this.Name = "PdfEditorEx";
|
||||
this.Size = new System.Drawing.Size(1027, 580);
|
||||
this.editToolStrip.ResumeLayout(false);
|
||||
this.editToolStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private O2S.Components.PDFView4NET.PDFDocument pdfDocument;
|
||||
private System.Windows.Forms.ToolStrip editToolStrip;
|
||||
private System.Windows.Forms.ToolStripButton btn_NextPage;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton btn_UpPage;
|
||||
private O2S.Components.PDFView4NET.PDFPageView pdfPageView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,694 @@
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using Lskj.Business;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control;
|
||||
using Lskj.Core;
|
||||
using O2S.Components.PDFView4NET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
public partial class PdfEditorEx : UserControl
|
||||
{
|
||||
public PdfEditorEx()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.pdfPageView.ZoomMode = PDFZoomMode.Custom;
|
||||
this.SizeChanged += OnPdfEditorExSizeChanged;
|
||||
this.pdfPageView.SizeChanged += OnPdfEditorExSizeChanged;
|
||||
this.btn_UpPage.Click += OnBtnUpPageClick;
|
||||
this.btn_NextPage.Click += OnBtnNextPageClick;
|
||||
}
|
||||
/// <summary>
|
||||
/// PDF页面大小改变时
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnPdfPageViewSizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// PDF页面大小改变时
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnPdfEditorExSizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
int pageIndex = pdfPageView.PageNumber;
|
||||
if (pdfDocument.Pages.Count == 0 || pdfPageView.PageNumber > pdfDocument.Pages.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<SignBox> signBoxes = _signBoxList.Where(n => n.PageNumber == pdfPageView.PageNumber + 1).ToList();
|
||||
foreach (SignBox item in signBoxes)
|
||||
{
|
||||
if (item.ParentResizeControl != null)
|
||||
{
|
||||
item.ParentResizeControl.Visible = false;
|
||||
}
|
||||
ToSignBoxImage(item, pageIndex, item.AbsoluteX, item.AbsoluteY, item.PdfImageWidth, item.PdfImageHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 记录全局选中控件
|
||||
/// </summary>
|
||||
public SignBox _selectedSignBox;
|
||||
/// <summary>
|
||||
/// 步骤表
|
||||
/// </summary>
|
||||
public DataTable StepTable = new DataTable();
|
||||
/// <summary>
|
||||
/// 保存完成后
|
||||
/// </summary>
|
||||
public event EventHandler OnAfterSignSaveCallback;
|
||||
/// <summary>
|
||||
/// 添加签章完成后
|
||||
/// </summary>
|
||||
public event EventHandler OnAfterSignAddCallback;
|
||||
public ToolStrip EditToolStrip { get { return this.editToolStrip; } }
|
||||
/// <summary>
|
||||
/// 关联模板id
|
||||
/// </summary>
|
||||
public string VersionCode;
|
||||
/// <summary>
|
||||
/// 源文件(该文件不进行编辑)
|
||||
/// </summary>
|
||||
public string TempletFilePath;
|
||||
/// <summary>
|
||||
/// 当前页码
|
||||
/// </summary>
|
||||
public int CurrentPageNo;
|
||||
/// <summary>
|
||||
/// 签名集合
|
||||
/// </summary>
|
||||
public List<SignBox> _signBoxList = new List<SignBox>();
|
||||
/// <summary>
|
||||
/// 当前操作文件
|
||||
/// </summary>
|
||||
private string _currentPdf;
|
||||
#region 事件
|
||||
/// <summary>
|
||||
/// 下一页
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnNextPageClick(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)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 上一页
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnUpPageClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.pdfPageView.PageNumber > 0)
|
||||
{
|
||||
this.pdfPageView.PageNumber--;
|
||||
this.CurrentPageNo = this.pdfPageView.PageNumber;
|
||||
this.FindSignBox();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void OnBtnSaveClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(VersionCode))
|
||||
{
|
||||
MessageUtil.Show("请先设置版本名称并保存后再设计");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(this._currentPdf)) return;
|
||||
string defaultSavePath = $"{Application.StartupPath}\\PdfSign\\PdfFileTemp\\signTempFile.pdf";
|
||||
string tempSavePath = $"{Application.StartupPath}\\PdfSign\\PdfFileSaveTemp\\signTempFile.pdf";
|
||||
if (!Directory.Exists(Path.GetDirectoryName(defaultSavePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(defaultSavePath));
|
||||
}
|
||||
if (!Directory.Exists(Path.GetDirectoryName(tempSavePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(tempSavePath));
|
||||
}
|
||||
this.Save(defaultSavePath);
|
||||
this.pdfDocument.Close();
|
||||
File.Copy(defaultSavePath, tempSavePath, true);
|
||||
foreach (SignBox signBox in this._signBoxList)
|
||||
{
|
||||
if (signBox.ParentPicBox != null)
|
||||
{
|
||||
signBox.ParentPicBox.Dispose();
|
||||
}
|
||||
if (signBox.ParentResizeControl != null)
|
||||
{
|
||||
signBox.ParentResizeControl.Dispose();
|
||||
}
|
||||
}
|
||||
this._signBoxList = new List<SignBox>();
|
||||
this._currentPdf = tempSavePath;
|
||||
this.pdfDocument.Load(this._currentPdf);
|
||||
LoadSign(VersionCode, true);
|
||||
//加载到保存前的页码位置
|
||||
this.pdfPageView.PageNumber = this.CurrentPageNo;
|
||||
if (OnAfterSignSaveCallback != null)
|
||||
{
|
||||
OnAfterSignSaveCallback(null, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开文件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnOpenClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpenLocalFile();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 签名删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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);
|
||||
if (signBox.ParentPicBox != null)
|
||||
{
|
||||
signBox.ParentPicBox.Dispose();
|
||||
}
|
||||
if (signBox.ParentResizeControl != null)
|
||||
{
|
||||
signBox.ParentResizeControl.Dispose();
|
||||
}
|
||||
if (OnAfterSignAddCallback != null)
|
||||
{
|
||||
OnAfterSignAddCallback(null, null);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加签名控件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void OnBtnAddSignClick(object sender, EventArgs e)
|
||||
{
|
||||
string selectSql = $"select * from P_SignLocationTable where mainId = '{VersionCode}'";
|
||||
DataTable dataTable = SqlHelper.ExecuteDataTable(selectSql);
|
||||
foreach (DataRow item in StepTable.Rows)
|
||||
{
|
||||
string stepCode = item["stepCode"] + "";
|
||||
string stepName = item["stepName"] + "";
|
||||
bool allowAdd = _signBoxList.Where(n => n.StepCode.Equals(stepCode)).Count() == 0;
|
||||
if (!allowAdd || dataTable.Rows.Cast<DataRow>().Where(n => (n["stepCode"] + "").Equals(stepCode)).Count() > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddSignPicControl(stepCode);
|
||||
}
|
||||
}
|
||||
if (OnAfterSignAddCallback != null)
|
||||
{
|
||||
OnAfterSignAddCallback(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 方法
|
||||
/// <summary>
|
||||
/// 打开本地PDF文件
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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)
|
||||
{
|
||||
this._currentPdf = TempletFilePath = fileName = openFileDialog.FileName;
|
||||
this.pdfDocument.Load(this._currentPdf);
|
||||
//LoadSign();
|
||||
this.CurrentPageNo = 0;
|
||||
this.pdfPageView.PageNumber = this.CurrentPageNo;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
public void OpenLocalFile(DataRow dataRow, bool allowSetMove = true)
|
||||
{
|
||||
ClearSignBox();
|
||||
string defaultDownPath = $"{Application.StartupPath}\\PdfSign\\PdfFileTemp\\downTempFile.pdf";
|
||||
string pdfUrl = dataRow["pdfUrl"] + "";
|
||||
pdfUrl = pdfUrl.StartsWith("http") ? pdfUrl : SystemInfo.Instance.OAUrl + pdfUrl;
|
||||
CloseDocument();
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(Path.GetDirectoryName(defaultDownPath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(defaultDownPath));
|
||||
}
|
||||
File.Delete(defaultDownPath);
|
||||
webClient.DownloadFile(pdfUrl, defaultDownPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
this._currentPdf = TempletFilePath = defaultDownPath;
|
||||
this.pdfDocument.Load(this._currentPdf);
|
||||
LoadSign(VersionCode, allowSetMove);
|
||||
this.CurrentPageNo = 0;
|
||||
this.pdfPageView.PageNumber = this.CurrentPageNo;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载已经存在的标签
|
||||
/// </summary>
|
||||
public void LoadSign(string versionCode, bool allowSetMove = true)
|
||||
{
|
||||
string selectSql = $"select * from P_SignLocationTable where mainId = '{versionCode}'";
|
||||
DataTable dataTable = SqlHelper.ExecuteDataTable(selectSql);
|
||||
string url = string.Empty;
|
||||
if (dataTable != null && dataTable.Rows.Count > 0)
|
||||
{
|
||||
this._signBoxList = new List<SignBox>();
|
||||
foreach (DataRow item in dataTable.Rows)
|
||||
{
|
||||
string stepName = string.Empty;
|
||||
url = item["pdfAdditionalUrl"] + "";
|
||||
string stepCode = item["stepCode"] + "";
|
||||
int imageHeight = (int)Convert.ToDecimal(item["pdfImageHeight"] + "");
|
||||
int imageWidth = (int)Convert.ToDecimal(item["pdfImageWidth"] + "");
|
||||
Bitmap image = new Bitmap(150, 50);
|
||||
if (stepCode.Equals("9999"))
|
||||
{
|
||||
url = "@select convert(varchar,getdate(),23)";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
if (url.StartsWith("http"))
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
byte[] data = webClient.DownloadData(url);
|
||||
using (MemoryStream stream = new MemoryStream(data))
|
||||
{
|
||||
image = new Bitmap(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (url.StartsWith("@"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string addInfo = BaseImpl.GetResult(url.TrimStart('@')) + "";
|
||||
using (Graphics graphics = Graphics.FromImage(image))
|
||||
{
|
||||
graphics.Clear(Color.Transparent);
|
||||
StringFormat stringFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Center,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
RectangleF rect = new RectangleF(0, 0, 150, 50);
|
||||
graphics.DrawString(addInfo, new System.Drawing.Font("微软雅黑", 16, FontStyle.Regular), new SolidBrush(Color.Black), rect, stringFormat);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image = new Bitmap(100, 50);
|
||||
Graphics graphics = Graphics.FromImage(image);
|
||||
DataRow dataRow = StepTable.Rows.Cast<DataRow>().Where(n => (n["stepCode"] + "").Equals(stepCode)).FirstOrDefault();
|
||||
stepName = dataRow["stepName"] + "";
|
||||
StringFormat stringFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Center,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
RectangleF rect = new RectangleF(0, 0, 100, 50);
|
||||
graphics.DrawString(stepName, new System.Drawing.Font("微软雅黑", 24, FontStyle.Bold), new SolidBrush(Color.Green), rect, stringFormat);
|
||||
}
|
||||
SignBox signBox = new SignBox(pdfPageView, pdfDocument.Pages[pdfPageView.PageNumber]);
|
||||
PictureBox pictureBox = new PictureBox();
|
||||
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
_signBoxList.Add(signBox);
|
||||
try
|
||||
{
|
||||
signBox.pdfAdditionalUrl = url;
|
||||
signBox.StepCode = stepCode;
|
||||
signBox.StepName = stepName;
|
||||
signBox.ParentPicBox = pictureBox;
|
||||
signBox.PageNumber = (int)Convert.ToDecimal(item["pageNum"] + "");
|
||||
pictureBox.BorderStyle = BorderStyle.None;
|
||||
pictureBox.Image = image;
|
||||
int pdfImageHeight = (int)Convert.ToDecimal(item["pdfImageHeight"] + "");
|
||||
int pdfImageWidth = (int)Convert.ToDecimal(item["pdfImageWidth"] + "");
|
||||
int absoluteY = (int)Convert.ToDecimal(item["absoluteY"] + "");
|
||||
int absoluteX = (int)Convert.ToDecimal(item["absoluteX"] + "");
|
||||
ToSignBoxImage(signBox, signBox.PageNumber - 1, absoluteX, absoluteY, pdfImageWidth, pdfImageHeight);
|
||||
//pictureBox.Height = signHeight;
|
||||
//pictureBox.Width = signWidth;
|
||||
pictureBox.Tag = signBox;
|
||||
pictureBox.Parent = this.pdfPageView;
|
||||
if (allowSetMove)
|
||||
{
|
||||
pictureBox.SetMove();
|
||||
}
|
||||
signBox.UpdateLocation();
|
||||
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)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
_signBoxList.Remove(signBox);
|
||||
pictureBox.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
FindSignBox();
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载记录的sign坐标
|
||||
/// </summary>
|
||||
private void FindSignBox()
|
||||
{
|
||||
//翻页切换时候进行画点操作
|
||||
//List<SignBox> signBoxs = _signBoxList.Where(o => o.PageNumber == this.pdfPageView.PageNumber).ToList();
|
||||
foreach (SignBox item in this._signBoxList)
|
||||
{
|
||||
if (item.PageNumber != this.CurrentPageNo + 1)
|
||||
{
|
||||
if (item.ParentPicBox != null)
|
||||
{
|
||||
item.ParentPicBox.Parent = null;
|
||||
}
|
||||
if (item.ParentResizeControl != null)
|
||||
{
|
||||
item.ParentResizeControl.Parent = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.ParentPicBox != null)
|
||||
{
|
||||
item.ParentPicBox.Parent = this.pdfPageView;
|
||||
}
|
||||
if (item.ParentResizeControl != null)
|
||||
{
|
||||
item.ParentResizeControl.Parent = this.pdfPageView;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="savePath"></param>
|
||||
public void Save(string savePath)
|
||||
{
|
||||
StringBuilder sqlBulider = new StringBuilder();
|
||||
sqlBulider.Append($"delete from P_SignLocationTable where mainId = '{VersionCode}';\r\n");
|
||||
using (FileStream fileStream = new FileStream(savePath, FileMode.Create, FileAccess.ReadWrite))
|
||||
{
|
||||
using (PdfReader reader = new PdfReader(this._currentPdf))
|
||||
{
|
||||
PdfStamper stamper = new PdfStamper(reader, fileStream);
|
||||
int readPageNum = reader.NumberOfPages;
|
||||
for (int j = 0; j < readPageNum; j++)
|
||||
{
|
||||
double height = this.pdfDocument.Pages[j].Height;
|
||||
float width = (float)this.pdfDocument.Pages[j].Width;
|
||||
List<SignBox> signBoxes = this._signBoxList.Where(n => n.PageNumber == j + 1).ToList();
|
||||
foreach (SignBox item in signBoxes)
|
||||
{
|
||||
using (Bitmap cloneBitmap = new Bitmap(item.ParentPicBox.Image))
|
||||
{
|
||||
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(cloneBitmap, ImageFormat.Png);
|
||||
}
|
||||
PDFPageRotation rotation = this.pdfDocument.Pages[this.CurrentPageNo].Rotation;
|
||||
int absoluteX = 0;
|
||||
int absoluteY = 0;
|
||||
int pdfImageWidth = 0;
|
||||
int pdfImageHeight = 0;
|
||||
if (rotation == PDFPageRotation.Rotate0Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft, item.SignTop));
|
||||
PDFPoint pdfpoint2 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft + item.SignWidth, item.SignTop + item.SignHeight));
|
||||
absoluteX = (int)pdfpoint.X;
|
||||
absoluteY = (int)pdfpoint2.Y;
|
||||
pdfImageWidth = (int)(pdfpoint2.X - pdfpoint.X);
|
||||
pdfImageHeight = (int)(pdfpoint.Y - pdfpoint2.Y);
|
||||
}
|
||||
else if (rotation == PDFPageRotation.Rotate90Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint4 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft + item.SignWidth, item.SignTop));
|
||||
PDFPoint pdfpoint5 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(item.SignLeft, item.SignTop + item.SignHeight));
|
||||
absoluteX = (int)pdfpoint5.Y;
|
||||
absoluteY = (int)(width - (float)pdfpoint5.X);
|
||||
pdfImageWidth = (int)(pdfpoint4.Y - pdfpoint5.Y);
|
||||
pdfImageHeight = (int)(pdfpoint5.X - pdfpoint4.X);
|
||||
}
|
||||
PdfContentByte pdfContentByte = stamper.GetOverContent(j + 1);
|
||||
sqlBulider.Append($"insert into P_SignLocationTable (mainId, stepCode, pageNum, absoluteY, absoluteX, pdfImageWidth, pdfImageHeight, pdfAdditionalUrl) values ('{VersionCode}', '{item.StepCode}', '{item.PageNumber}', '{absoluteY}', '{absoluteX}', '{pdfImageWidth}', '{pdfImageHeight}', '{item.pdfAdditionalUrl}');\r\n");
|
||||
}
|
||||
}
|
||||
stamper.Close();
|
||||
}
|
||||
}
|
||||
SqlHelper.ExecuteNonQuery(sqlBulider.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// 清理签名控件
|
||||
/// </summary>
|
||||
public void ClearSignBox()
|
||||
{
|
||||
foreach (SignBox signBox in _signBoxList)
|
||||
{
|
||||
if (signBox.ParentPicBox != null)
|
||||
{
|
||||
signBox.ParentPicBox.Dispose();
|
||||
}
|
||||
if (signBox.ParentResizeControl != null)
|
||||
{
|
||||
signBox.ParentResizeControl.Dispose();
|
||||
}
|
||||
}
|
||||
this._signBoxList.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加签名控件
|
||||
/// </summary>
|
||||
public void AddSignPicControl(string stepCode, String urlPath = "")
|
||||
{
|
||||
Bitmap image = new Bitmap(100, 50);
|
||||
|
||||
string stepName = string.Empty;
|
||||
if (!String.IsNullOrEmpty(urlPath))
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
byte[] data = webClient.DownloadData(urlPath);
|
||||
using (MemoryStream stream = new MemoryStream(data))
|
||||
{
|
||||
image = new Bitmap(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics graphics = Graphics.FromImage(image);
|
||||
Pen pen = new Pen(Color.Black, 2);//
|
||||
graphics.DrawRectangle(pen, 0, 0, 100, 50);
|
||||
DataRow dataRow = StepTable.Rows.Cast<DataRow>().Where(n => (n["stepCode"] + "").Equals(stepCode)).FirstOrDefault();
|
||||
stepName = dataRow["stepName"] + "";
|
||||
graphics.DrawString(stepName, new System.Drawing.Font("微软雅黑", 26, FontStyle.Bold), Brushes.Green, new PointF(0, 0));
|
||||
}
|
||||
PictureBox pictureBox = new PictureBox();
|
||||
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
SignBox signBox = new SignBox(pdfPageView, pdfDocument.Pages[pdfPageView.PageNumber]);
|
||||
_signBoxList.Add(signBox);
|
||||
try
|
||||
{
|
||||
signBox.StepName = stepName;
|
||||
signBox.pdfAdditionalUrl = urlPath;
|
||||
signBox.StepCode = stepCode;
|
||||
signBox.ParentPicBox = pictureBox;
|
||||
signBox.PageNumber = this.CurrentPageNo + 1;
|
||||
if (string.IsNullOrEmpty(urlPath))
|
||||
{
|
||||
signBox.SignHeight = 30;
|
||||
signBox.SignWidth = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
pictureBox.SetMove();
|
||||
signBox.UpdateLocation();
|
||||
|
||||
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)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
_signBoxList.Remove(signBox);
|
||||
pictureBox.Dispose();
|
||||
}
|
||||
}
|
||||
public iTextSharp.text.Image ToPdfImage(SignBox signBox, int pageIndex)
|
||||
{
|
||||
float width = (float)this.pdfDocument.Pages[pageIndex].Width;
|
||||
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(signBox.ParentPicBox.Image, ImageFormat.Bmp);//获取图片
|
||||
PDFPageRotation rotation = this.pdfDocument.Pages[this.CurrentPageNo].Rotation;
|
||||
if (rotation == PDFPageRotation.Rotate0Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(signBox.SignLeft, signBox.SignTop));
|
||||
PDFPoint pdfpoint2 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(signBox.SignLeft + signBox.SignWidth, signBox.SignTop + signBox.SignHeight));
|
||||
image.ScaleAbsolute((float)(pdfpoint2.X - pdfpoint.X), (float)(pdfpoint.Y - pdfpoint2.Y));
|
||||
image.SetAbsolutePosition((float)pdfpoint.X, (float)pdfpoint2.Y);
|
||||
}
|
||||
else if (rotation == PDFPageRotation.Rotate90Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint4 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(signBox.SignLeft + signBox.SignWidth, signBox.SignTop));
|
||||
PDFPoint pdfpoint5 = this.pdfPageView.ConvertScreenPointToPDFPoint(new Point(signBox.SignLeft, signBox.SignTop + signBox.SignHeight));
|
||||
image.ScaleAbsolute((float)(pdfpoint4.Y - pdfpoint5.Y), (float)(pdfpoint5.X - pdfpoint4.X));
|
||||
image.SetAbsolutePosition((float)pdfpoint5.Y, width - (float)pdfpoint5.X);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
public SignBox ToSignBoxImage(SignBox signBox, int pageIndex, double absoluteX, double absoluteY, double pdfImageWidth, double pdfImageHeight)
|
||||
{
|
||||
float width = (float)this.pdfDocument.Pages[pageIndex].Width;
|
||||
PDFPageRotation rotation = this.pdfDocument.Pages[this.CurrentPageNo].Rotation;
|
||||
if (rotation == PDFPageRotation.Rotate0Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint = new PDFPoint(absoluteX, pdfImageHeight + absoluteY);
|
||||
PDFPoint pdfpoint2 = new PDFPoint(pdfImageWidth + absoluteX, absoluteY);
|
||||
Point point = this.pdfPageView.ConvertPDFPointToScreenPoint(pdfpoint);
|
||||
Point point2 = this.pdfPageView.ConvertPDFPointToScreenPoint(pdfpoint2);
|
||||
signBox.SignLeft = point.X;
|
||||
signBox.SignTop = point.Y;
|
||||
signBox.SignWidth = point2.X - signBox.SignLeft;
|
||||
signBox.SignHeight = point2.Y - signBox.SignTop;
|
||||
}
|
||||
else if (rotation == PDFPageRotation.Rotate90Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint4 = new PDFPoint(width - absoluteY - pdfImageHeight, pdfImageWidth + absoluteX);
|
||||
PDFPoint pdfpoint5 = new PDFPoint(width - absoluteY, absoluteX);
|
||||
Point point4 = this.pdfPageView.ConvertPDFPointToScreenPoint(pdfpoint4);
|
||||
Point point5 = this.pdfPageView.ConvertPDFPointToScreenPoint(pdfpoint5);
|
||||
signBox.SignLeft = point5.X;
|
||||
signBox.SignTop = point4.Y;
|
||||
signBox.SignWidth = point4.X - signBox.SignLeft;
|
||||
signBox.SignHeight = point5.Y - signBox.SignTop;
|
||||
}
|
||||
return signBox;
|
||||
}
|
||||
/// <summary>
|
||||
/// 关闭文档
|
||||
/// </summary>
|
||||
public void CloseDocument()
|
||||
{
|
||||
this.pdfDocument.Close();
|
||||
this.pdfDocument.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="pdfDocument.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="editToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>480, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="btn_NextPage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="btn_UpPage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
partial class ResizeControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
public partial class ResizeControl : UserControl
|
||||
{
|
||||
public ResizeControl(System.Windows.Forms.Control control)
|
||||
{
|
||||
//InitializeComponent();
|
||||
this.control = control;
|
||||
|
||||
#region 绑定事件
|
||||
|
||||
//鼠标按下时
|
||||
MouseDown += (sender, e) =>
|
||||
{
|
||||
//记录鼠标位置
|
||||
lastPoint = Cursor.Position;
|
||||
|
||||
//改变鼠标状态
|
||||
SetCursor(e.X, e.Y);
|
||||
};
|
||||
|
||||
//鼠标移动时,即在调整控件大小
|
||||
MouseMove += (sender, e) =>
|
||||
{
|
||||
//鼠标左键
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//移动时刷新实线
|
||||
DrawSolids();
|
||||
|
||||
//调整控件大小
|
||||
ReCtrlSize();
|
||||
}
|
||||
//不是鼠标左键,则表示只是在控件上移动
|
||||
else
|
||||
{
|
||||
//改变鼠标状态
|
||||
SetCursor(e.X, e.Y);
|
||||
}
|
||||
};
|
||||
|
||||
//鼠标键释放时
|
||||
MouseUp += (sender, e) =>
|
||||
{
|
||||
control.Refresh();
|
||||
//显示虚线
|
||||
SetControlRegion();
|
||||
|
||||
System.Windows.Forms.Control pictureBox = (System.Windows.Forms.Control)sender;
|
||||
if (pictureBox.Tag != null && pictureBox.Tag is SignBox)
|
||||
{
|
||||
(pictureBox.Tag as SignBox).UpdateLocation();
|
||||
}
|
||||
};
|
||||
|
||||
////鼠标离开控件隐藏边框
|
||||
//MouseLeave += (sender, e) =>
|
||||
//{
|
||||
// this.Visible = false;
|
||||
//};
|
||||
|
||||
//大小改变时
|
||||
SizeChanged += (sender, e) =>
|
||||
{
|
||||
isSizeChanged = true;
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否已经改变大小,默认大小(150,150)不运行OnPaint方法,避免出现异常绘制
|
||||
/// </summary>
|
||||
bool isSizeChanged = false;
|
||||
|
||||
/// <summary>
|
||||
/// 设置控件支持透明
|
||||
/// </summary>
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
{
|
||||
CreateParams cp = base.CreateParams;
|
||||
cp.ExStyle |= 0x20;
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘制虚线:4条虚线和8个小矩形
|
||||
/// </summary>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
//默认大小,去除绘制,避免出现异常绘制
|
||||
if (isSizeChanged == false) return;
|
||||
|
||||
DrawDottedLines(e.Graphics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前控件
|
||||
/// </summary>
|
||||
System.Windows.Forms.Control control;
|
||||
|
||||
/// <summary>
|
||||
/// 上一个鼠标坐标
|
||||
/// </summary>
|
||||
Point lastPoint = new Point();
|
||||
|
||||
/// <summary>
|
||||
/// 包括边框的局域
|
||||
/// </summary>
|
||||
Rectangle controlRect;
|
||||
/// <summary>
|
||||
/// 4条底边的集合
|
||||
/// </summary>
|
||||
Rectangle[] borderRects = new Rectangle[4];
|
||||
|
||||
/// <summary>
|
||||
/// 组成4条虚线的点
|
||||
/// </summary>
|
||||
Point[] linePoints = new Point[5];
|
||||
|
||||
/// <summary>
|
||||
/// 8个小矩形大小
|
||||
/// </summary>
|
||||
const int size = 6;
|
||||
/// <summary>
|
||||
/// 8个小矩形的大小
|
||||
/// </summary>
|
||||
Size smallRectSize = new Size(size, size);
|
||||
/// <summary>
|
||||
/// 8个小矩形
|
||||
/// </summary>
|
||||
Rectangle[] smallRects = new Rectangle[8];
|
||||
|
||||
#region 设置控件区域,绘制虚线,绘制实线
|
||||
|
||||
/// <summary>
|
||||
/// 设置控件区域:4条底边,点击控件后显示
|
||||
/// </summary>
|
||||
public void SetControlRegion()
|
||||
{
|
||||
//显示边框并置顶
|
||||
Visible = true;
|
||||
BringToFront();
|
||||
|
||||
#region 设置控件区域
|
||||
|
||||
int x = control.Bounds.X - smallRectSize.Width;
|
||||
int y = control.Bounds.Y - smallRectSize.Height;
|
||||
int width = control.Bounds.Width + (smallRectSize.Width * 2);
|
||||
int height = control.Bounds.Height + (smallRectSize.Height * 2);
|
||||
Bounds = new Rectangle(x, y, width, height);
|
||||
|
||||
//包括边框的局域
|
||||
controlRect = new Rectangle(new Point(0, 0), Bounds.Size);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 4条底边
|
||||
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
//上底边
|
||||
borderRects[0] = new Rectangle(0, 0, Width + size * 2, smallRectSize.Height + 1);
|
||||
//左底边
|
||||
borderRects[1] = new Rectangle(0, size + 1, smallRectSize.Width + 1, Height - size * 2 - 2);
|
||||
//下底边
|
||||
borderRects[2] = new Rectangle(0, Height - size - 1, Width + size * 2, smallRectSize.Height + 1);
|
||||
//右底边
|
||||
borderRects[3] = new Rectangle(Width - size - 1, size + 1, smallRectSize.Width + 1, Height - size * 2 - 2);
|
||||
|
||||
path.AddRectangle(borderRects[0]);
|
||||
path.AddRectangle(borderRects[1]);
|
||||
path.AddRectangle(borderRects[2]);
|
||||
path.AddRectangle(borderRects[3]);
|
||||
|
||||
Region = new Region(path);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘制虚线:4条虚线和8个小矩形
|
||||
/// </summary>
|
||||
public void DrawDottedLines(Graphics g)
|
||||
{
|
||||
#region 4条虚线
|
||||
|
||||
//左上
|
||||
linePoints[0] = new Point(3, 3);
|
||||
//右上
|
||||
linePoints[1] = new Point(Width - 3 - 1, 3);
|
||||
//右下
|
||||
linePoints[2] = new Point(Width - 3 - 1, Height - 3 - 1);
|
||||
//左下
|
||||
linePoints[3] = new Point(3, Height - 3 - 1);
|
||||
//左上
|
||||
linePoints[4] = new Point(3, 3);
|
||||
|
||||
Pen pen = new Pen(Color.Black, 1) { DashStyle = DashStyle.Dot };
|
||||
|
||||
g.DrawLines(pen, linePoints);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 8个小矩形
|
||||
|
||||
//左上
|
||||
smallRects[0] = new Rectangle(new Point(0, 0), smallRectSize);
|
||||
//右上
|
||||
smallRects[1] = new Rectangle(new Point(Width - size - 1, 0), smallRectSize);
|
||||
//左下
|
||||
smallRects[2] = new Rectangle(new Point(0, Height - size - 1), smallRectSize);
|
||||
//右下
|
||||
smallRects[3] = new Rectangle(new Point(Width - size - 1, Height - size - 1), smallRectSize);
|
||||
//上中
|
||||
smallRects[4] = new Rectangle(new Point(Width / 2 - 1, 0), smallRectSize);
|
||||
//下中
|
||||
smallRects[5] = new Rectangle(new Point(Width / 2 - 1, Height - size - 1), smallRectSize);
|
||||
//左中
|
||||
smallRects[6] = new Rectangle(new Point(0, Height / 2 - size / 2), smallRectSize);
|
||||
//右中
|
||||
smallRects[7] = new Rectangle(new Point(Width - size - 1, Height / 2 - size / 2), smallRectSize);
|
||||
|
||||
//填充矩形内部为白色
|
||||
g.FillRectangles(Brushes.White, smallRects);
|
||||
//绘制矩形
|
||||
g.DrawRectangles(Pens.Black, smallRects);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘制实线:4条实线,移动控件和调整控件大小时显示
|
||||
/// </summary>
|
||||
public void DrawSolids()
|
||||
{
|
||||
//隐藏边框
|
||||
Visible = false;
|
||||
Graphics g = control.CreateGraphics();
|
||||
int width = control.Width;
|
||||
int height = control.Height;
|
||||
Point[] points = new Point[5] { new Point(0,0),new Point(width - 1,0),
|
||||
new Point(width - 1,height-1),new Point(0,height-1),new Point(0,0)};
|
||||
g.DrawLines(new Pen(Color.Gray, 3), points);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 调整控件大小
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标在控件中的位置
|
||||
/// </summary>
|
||||
enum MousePos
|
||||
{
|
||||
None,
|
||||
Top,
|
||||
Right,
|
||||
Bottom,
|
||||
Left,
|
||||
LeftTop,
|
||||
LeftBottom,
|
||||
RightTop,
|
||||
RightBottom
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标在控件中的位置
|
||||
/// </summary>
|
||||
MousePos mousePos;
|
||||
|
||||
/// <summary>
|
||||
/// 改变鼠标状态,鼠标在控件上,下,左,右,左上,右上,左下,右下,向上不同的光标
|
||||
/// </summary>
|
||||
private void SetCursor(int x, int y)
|
||||
{
|
||||
Point point = new Point(x, y);
|
||||
|
||||
if (!controlRect.Contains(point))//不在边框局域内直接退出
|
||||
{
|
||||
Cursor.Current = Cursors.Arrow;
|
||||
return;
|
||||
}
|
||||
else if (smallRects[0].Contains(point))//左上
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNWSE;
|
||||
mousePos = MousePos.LeftTop;
|
||||
}
|
||||
else if (smallRects[1].Contains(point))//右上
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNESW;
|
||||
mousePos = MousePos.RightTop;
|
||||
}
|
||||
else if (smallRects[2].Contains(point))//左下
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNESW;
|
||||
mousePos = MousePos.LeftBottom;
|
||||
}
|
||||
else if (smallRects[3].Contains(point))//右下
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNWSE;
|
||||
mousePos = MousePos.RightBottom;
|
||||
}
|
||||
|
||||
else if (borderRects[0].Contains(point))//上
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNS;
|
||||
mousePos = MousePos.Top;
|
||||
}
|
||||
else if (borderRects[1].Contains(point))//左
|
||||
{
|
||||
Cursor.Current = Cursors.SizeWE;
|
||||
mousePos = MousePos.Left;
|
||||
}
|
||||
else if (borderRects[2].Contains(point))//下
|
||||
{
|
||||
Cursor.Current = Cursors.SizeNS;
|
||||
mousePos = MousePos.Bottom;
|
||||
}
|
||||
else if (borderRects[3].Contains(point))//右
|
||||
{
|
||||
Cursor.Current = Cursors.SizeWE;
|
||||
mousePos = MousePos.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.Current = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控件的最小高度
|
||||
/// </summary>
|
||||
const int MinHeight = 10;
|
||||
/// <summary>
|
||||
/// 控件的最小宽度
|
||||
/// </summary>
|
||||
const int MinWeight = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 调整控件大小:鼠标在控件中的不同位置,调整控件大小
|
||||
/// </summary>
|
||||
private void ReCtrlSize()
|
||||
{
|
||||
//获取当前鼠标位置
|
||||
Point currentPoint = Cursor.Position;
|
||||
int x = currentPoint.X - lastPoint.X;
|
||||
int y = currentPoint.Y - lastPoint.Y;
|
||||
switch (mousePos)
|
||||
{
|
||||
case MousePos.None:
|
||||
break;
|
||||
case MousePos.Top://上,调整
|
||||
if (control.Height - y > MinHeight)
|
||||
{
|
||||
control.Top += y;
|
||||
control.Height -= y;
|
||||
}
|
||||
break;
|
||||
case MousePos.Right:
|
||||
if (control.Width + x > MinWeight)
|
||||
{
|
||||
control.Width += x;
|
||||
}
|
||||
break;
|
||||
case MousePos.Bottom:
|
||||
if (control.Height + y > MinHeight)
|
||||
{
|
||||
control.Height += y;
|
||||
}
|
||||
break;
|
||||
case MousePos.Left:
|
||||
if (control.Width - x > MinWeight)
|
||||
{
|
||||
control.Left += x;
|
||||
control.Width -= x;
|
||||
}
|
||||
break;
|
||||
case MousePos.LeftTop://左上
|
||||
if (control.Width - x > MinWeight)
|
||||
{
|
||||
control.Left += x;
|
||||
control.Width -= x;
|
||||
}
|
||||
if (control.Height - y > MinHeight)
|
||||
{
|
||||
control.Top += y;
|
||||
control.Height -= y;
|
||||
}
|
||||
break;
|
||||
case MousePos.LeftBottom:
|
||||
if (control.Width - x > MinWeight)
|
||||
{
|
||||
control.Left += x;
|
||||
control.Width -= x;
|
||||
}
|
||||
if (control.Height + y > MinHeight)
|
||||
{
|
||||
control.Height += y;
|
||||
}
|
||||
break;
|
||||
case MousePos.RightTop:
|
||||
if (control.Width + x > MinWeight)
|
||||
{
|
||||
control.Width += x;
|
||||
}
|
||||
if (control.Height - y > MinHeight)
|
||||
{
|
||||
control.Top += y;
|
||||
control.Height -= y;
|
||||
}
|
||||
break;
|
||||
case MousePos.RightBottom:
|
||||
if (control.Width + x > MinWeight)
|
||||
{
|
||||
control.Width += x;
|
||||
}
|
||||
if (control.Height + y > MinHeight)
|
||||
{
|
||||
control.Height += y;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
lastPoint = Cursor.Position;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
using O2S.Components.PDFView4NET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubPdfSign.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 签名box对象
|
||||
/// </summary>
|
||||
public class SignBox
|
||||
{
|
||||
public SignBox(PDFPageView _PageView, PDFPage _Page)
|
||||
{
|
||||
PageView = _PageView;
|
||||
Page = _Page;
|
||||
}
|
||||
/// <summary>
|
||||
/// PDF文档控件
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public PDFPageView PageView { get; set; }
|
||||
/// <summary>
|
||||
/// 父图片控件
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public PictureBox ParentPicBox { get; set; }
|
||||
/// <summary>
|
||||
/// 父边框控件
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public ResizeControl ParentResizeControl { get; set; }
|
||||
/// <summary>
|
||||
/// 图片地址
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string ParentPicBoxImagePath { get; set; }
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
/// <value>The page number.</value>
|
||||
[Browsable(false)]
|
||||
public int PageNumber { get; set; }
|
||||
/// <summary>
|
||||
/// PDF页面
|
||||
/// </summary>
|
||||
/// <value>The page number.</value>
|
||||
[Browsable(false)]
|
||||
public PDFPage Page { get; set; }
|
||||
/// <summary>
|
||||
/// 坐标
|
||||
/// </summary>
|
||||
/// <value>The point.</value>
|
||||
[Browsable(false)]
|
||||
public Point PointObj { get; set; }
|
||||
/// <summary>
|
||||
/// 步骤
|
||||
/// </summary>
|
||||
/// <value>The point.</value>
|
||||
[Browsable(false)]
|
||||
public string StepCode { get; set; }
|
||||
/// <summary>
|
||||
/// 步骤名字
|
||||
/// </summary>
|
||||
/// <value>The point.</value>
|
||||
[Browsable(false)]
|
||||
public string StepName { get; set; }
|
||||
/// <summary>
|
||||
/// 宽度
|
||||
/// </summary>
|
||||
public int PdfImageWidth { get; private set; }
|
||||
/// <summary>
|
||||
/// 宽度
|
||||
/// </summary>
|
||||
public int SignWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return ParentPicBox.Width;
|
||||
}
|
||||
set
|
||||
{
|
||||
ParentPicBox.Width = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 高度
|
||||
/// </summary>
|
||||
public int PdfImageHeight { get; private set; }
|
||||
/// <summary>
|
||||
/// 高度
|
||||
/// </summary>
|
||||
public int SignHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return ParentPicBox.Height;
|
||||
}
|
||||
set
|
||||
{
|
||||
ParentPicBox.Height = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 左边距
|
||||
/// </summary>
|
||||
public int AbsoluteX { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 左边距
|
||||
/// </summary>
|
||||
public int SignLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return ParentPicBox.Left;
|
||||
}
|
||||
set
|
||||
{
|
||||
ParentPicBox.Left = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 左边距
|
||||
/// </summary>
|
||||
public int AbsoluteY { get; private set; }
|
||||
/// <summary>
|
||||
/// 上边距
|
||||
/// </summary>
|
||||
public int SignTop
|
||||
{
|
||||
get
|
||||
{
|
||||
return ParentPicBox.Top;
|
||||
}
|
||||
set
|
||||
{
|
||||
ParentPicBox.Top = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否移动状态
|
||||
/// </summary>
|
||||
[BrowsableAttribute(false)]
|
||||
public bool IsMove { get; set; }
|
||||
/// <summary>
|
||||
/// 鼠标点击位置
|
||||
/// </summary>
|
||||
[BrowsableAttribute(false)]
|
||||
public Point MouseDownPoint { get; set; }
|
||||
/// <summary>
|
||||
/// 附加文件地址
|
||||
/// </summary>
|
||||
public string pdfAdditionalUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 更新位置信息
|
||||
/// </summary>
|
||||
public void UpdateLocation()
|
||||
{
|
||||
float width = (float)Page.Width;
|
||||
if (Page.Rotation == PDFPageRotation.Rotate0Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint = PageView.ConvertScreenPointToPDFPoint(new Point(SignLeft, SignTop));
|
||||
PDFPoint pdfpoint2 = PageView.ConvertScreenPointToPDFPoint(new Point(SignLeft + SignWidth, SignTop + SignHeight));
|
||||
AbsoluteX = (int)pdfpoint.X;
|
||||
AbsoluteY = (int)pdfpoint2.Y;
|
||||
PdfImageWidth = (int)(pdfpoint2.X - pdfpoint.X);
|
||||
PdfImageHeight = (int)(pdfpoint.Y - pdfpoint2.Y);
|
||||
}
|
||||
else if (Page.Rotation == PDFPageRotation.Rotate90Degrees)
|
||||
{
|
||||
PDFPoint pdfpoint4 = PageView.ConvertScreenPointToPDFPoint(new Point(SignLeft + SignWidth, SignTop));
|
||||
PDFPoint pdfpoint5 = PageView.ConvertScreenPointToPDFPoint(new Point(SignLeft, SignTop + SignHeight));
|
||||
AbsoluteX = (int)pdfpoint5.Y;
|
||||
AbsoluteY = (int)(width - (float)pdfpoint5.X);
|
||||
PdfImageWidth = (int)(pdfpoint4.Y - pdfpoint5.Y);
|
||||
PdfImageHeight = (int)(pdfpoint5.X - pdfpoint4.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user