@@ -18,7 +18,7 @@ public partial class Form1 : Form
1818 DataTable dt = new DataTable ( ) ; //PDF列表
1919 DataTable dtPos = new DataTable ( ) ; //PDF各文件印章位置表
2020 string sourcePath = "" , outputPath = "" , imgPath = "" , previewPath = null , signText = "" , password = "" ;
21- int wjType = 1 , qfzType = 0 , yzType = 0 , djType = 0 , qmType = 0 , sizeType = 1 , size = 40 , rotation = 0 , opacity = 100 , wz = 50 ;
21+ int wjType = 1 , qfzType = 0 , yzType = 0 , djType = 0 , qmType = 0 , sizeType = 1 , size = 40 , rotation = 0 , opacity = 100 , wz = 50 , yzr = 10 , maximg = 250 ;
2222 Bitmap imgYz = null ;
2323 X509Certificate2 cert = null ; //证书
2424
@@ -829,16 +829,20 @@ private void GzPath_Click(object sender, EventArgs e)
829829 private void pictureBox1_Click ( object sender , EventArgs e )
830830 {
831831 Point pt = pictureBox1 . PointToClient ( Control . MousePosition ) ;
832- int picw = pictureBox1 . Width ;
833- int pich = pictureBox1 . Height ;
832+ pt . X = pt . X - yzr ;
833+ pt . Y = pt . Y - yzr ;
834+ int picw = pictureBox1 . Width - 2 * yzr ;
835+ int pich = pictureBox1 . Height - 2 * yzr ;
834836
837+ if ( pt . X < 0 ) pt . X = 0 ;
838+ if ( pt . Y < 0 ) pt . Y = 0 ;
835839 if ( pt . X > picw ) pt . X = picw ;
836840 if ( pt . Y > pich ) pt . Y = pich ;
837841 float px = 1f * pt . X / picw ;
838842 float py = 1f * pt . Y / pich ;
839843 textPx . Text = px . ToString ( "#0.0000" ) ;
840844 textPy . Text = py . ToString ( "#0.0000" ) ;
841- DataRow [ ] arrRow = dtPos . Select ( "Path = '" + previewPath + "' and Page = " + imgStartPage ) ;
845+ DataRow [ ] arrRow = dtPos . Select ( "Path = '" + previewPath + "' and Page = " + imgStartPage ) ;
842846 if ( arrRow == null || arrRow . Length == 0 )
843847 {
844848 dtPos . Rows . Add ( new object [ ] { previewPath , imgStartPage , px , py } ) ;
@@ -852,10 +856,10 @@ private void pictureBox1_Click(object sender, EventArgs e)
852856 dr . EndEdit ( ) ;
853857 dtPos . AcceptChanges ( ) ;
854858 }
855- Point pt1 = pictureBox1 . Location ;
856859
860+ Point pt1 = pictureBox1 . Location ;
857861 pictureBox2 . Visible = true ;
858- pictureBox2 . Location = new Point ( pt1 . X + pt . X - 10 , pt1 . Y + pt . Y - 10 ) ;
862+ pictureBox2 . Location = new Point ( pt1 . X + pt . X , pt1 . Y + pt . Y ) ;
859863
860864 }
861865 //印章比例类型
@@ -922,11 +926,11 @@ private void buttonUp_Click(object sender, EventArgs e)
922926 px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
923927 py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
924928 }
925- int X = Convert . ToInt32 ( pictureBox1 . Width * px ) ;
926- int Y = Convert . ToInt32 ( pictureBox1 . Height * py ) ;
929+ int X = Convert . ToInt32 ( ( pictureBox1 . Width - 2 * yzr ) * px ) ;
930+ int Y = Convert . ToInt32 ( ( pictureBox1 . Height - 2 * yzr ) * py ) ;
927931 Point pt1 = pictureBox1 . Location ;
928932
929- pictureBox2 . Location = new Point ( pt1 . X + X - 10 , pt1 . Y + Y - 10 ) ;
933+ pictureBox2 . Location = new Point ( pt1 . X + X , pt1 . Y + Y ) ;
930934
931935 }
932936 }
@@ -960,11 +964,11 @@ private void buttonNext_Click(object sender, EventArgs e)
960964 px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
961965 py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
962966 }
963- int X = Convert . ToInt32 ( pictureBox1 . Width * px ) ;
964- int Y = Convert . ToInt32 ( pictureBox1 . Height * py ) ;
967+ int X = Convert . ToInt32 ( ( pictureBox1 . Width - 2 * yzr ) * px ) ;
968+ int Y = Convert . ToInt32 ( ( pictureBox1 . Height - 2 * yzr ) * py ) ;
965969 Point pt1 = pictureBox1 . Location ;
966970
967- pictureBox2 . Location = new Point ( pt1 . X + X - 10 , pt1 . Y + Y - 10 ) ;
971+ pictureBox2 . Location = new Point ( pt1 . X + X , pt1 . Y + Y ) ;
968972
969973 }
970974 }
@@ -1142,6 +1146,18 @@ private void comboPDFlist_SelectionChangeCommitted(object sender, EventArgs e)
11421146 {
11431147 PDFFile pdfFile = PDFFile . Open ( previewPath ) ;
11441148 Bitmap pageImage = pdfFile . GetPageImage ( 0 , 56 * 1 ) ;
1149+ Point point = new Point ( pictureBox1 . Location . X + pictureBox1 . Width / 2 , pictureBox1 . Location . Y + pictureBox1 . Height / 2 ) ;
1150+ if ( pageImage . Width < pageImage . Height )
1151+ {
1152+ pictureBox1 . Height = maximg ;
1153+ pictureBox1 . Width = pictureBox1 . Height * pageImage . Width / pageImage . Height ;
1154+ }
1155+ else
1156+ {
1157+ pictureBox1 . Width = maximg ;
1158+ pictureBox1 . Height = pictureBox1 . Width * pageImage . Height / pageImage . Width ;
1159+ }
1160+ pictureBox1 . Location = new Point ( point . X - pictureBox1 . Width / 2 , point . Y - pictureBox1 . Height / 2 ) ;
11451161 pictureBox1 . Image = pageImage ;
11461162 imgStartPage = 1 ;
11471163 imgPageCount = pdfFile . PageCount ;
@@ -1161,11 +1177,11 @@ private void comboPDFlist_SelectionChangeCommitted(object sender, EventArgs e)
11611177 px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
11621178 py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
11631179 }
1164- int X = Convert . ToInt32 ( pictureBox1 . Width * px ) ;
1165- int Y = Convert . ToInt32 ( pictureBox1 . Height * py ) ;
1180+ int X = Convert . ToInt32 ( ( pictureBox1 . Width - 2 * yzr ) * px ) ;
1181+ int Y = Convert . ToInt32 ( ( pictureBox1 . Height - 2 * yzr ) * py ) ;
11661182 Point pt1 = pictureBox1 . Location ;
11671183
1168- pictureBox2 . Location = new Point ( pt1 . X + X - 10 , pt1 . Y + Y - 10 ) ;
1184+ pictureBox2 . Location = new Point ( pt1 . X + X , pt1 . Y + Y ) ;
11691185 }
11701186 else
11711187 {
0 commit comments