@@ -147,11 +147,12 @@ private void selectCardFacesToolStripMenuItem_Click(object sender, EventArgs e)
147147 private void setCardCountsToolStripMenuItem_Click ( object sender , EventArgs e )
148148 {
149149 var zQuery = new QueryPanelDialog ( "Set Card Count" , 400 , false ) ;
150- zQuery . AddNumericBox ( "Count" , 1 , 0 , int . MaxValue , 1 , 0 , numericDPI ) ;
150+ const string CARD_COUNT = "CARD_COUNT" ;
151+ zQuery . AddNumericBox ( "Count" , 1 , 0 , int . MaxValue , 1 , 0 , CARD_COUNT ) ;
151152
152153 if ( DialogResult . OK == zQuery . ShowDialog ( this ) )
153154 {
154- SetSelectedItemsValue ( listViewCards . SelectedItems , zQuery . GetDecimal ( numericDPI ) . ToString ( ) , ItemSubIndex . Count ) ;
155+ SetSelectedItemsValue ( listViewCards . SelectedItems , zQuery . GetDecimal ( CARD_COUNT ) . ToString ( ) , ItemSubIndex . Count ) ;
155156 }
156157 }
157158
@@ -234,6 +235,11 @@ private void listViewCards_KeyDown(object sender, KeyEventArgs e)
234235 }
235236 }
236237
238+ private void PdfConstructForm_FormClosing ( object sender , FormClosingEventArgs e )
239+ {
240+ SaveOnClose ( e ) ;
241+ }
242+
237243 #endregion
238244
239245 #region Export Thread
@@ -245,10 +251,8 @@ private void ExportThread(object zParam)
245251 //zDocument.Options.NoCompression = true;
246252
247253 var listFiles = ( List < string > ) zParam ;
248- Func < decimal > funcGetDpi = ( ) => numericDPI . Value ;
249254 Func < string > funcGetOutputPath = ( ) => txtOutputPath . Text ;
250255
251- var dDPI = ( double ) numericDPI . InvokeFunc ( funcGetDpi ) ;
252256 var sOutputPth = txtOutputPath . InvokeFunc ( funcGetOutputPath ) ;
253257
254258 listFiles . ForEach ( sFile =>
@@ -257,19 +261,23 @@ private void ExportThread(object zParam)
257261
258262 // wipe out any transparency on the images
259263 var zImgDestination = new Bitmap ( zImgSrc . Width , zImgSrc . Height , PixelFormat . Format24bppRgb ) ;
264+ zImgDestination . SetResolution ( zImgSrc . HorizontalResolution , zImgSrc . VerticalResolution ) ;
265+
260266 var zImageGfx = Graphics . FromImage ( zImgDestination ) ;
261267 zImageGfx . Clear ( Color . White ) ;
262268 zImageGfx . DrawImage ( zImgSrc , 0 , 0 ) ;
263269
264270 var zPage = zDocument . AddPage ( new PdfPage ( )
265271 {
266- Width = XUnit . FromInch ( ( double ) zImgSrc . Width / dDPI ) ,
267- Height = XUnit . FromInch ( ( double ) zImgSrc . Height / dDPI )
272+ Width = XUnit . FromInch ( ( double ) zImgSrc . Width / ( double ) zImgSrc . HorizontalResolution ) ,
273+ Height = XUnit . FromInch ( ( double ) zImgSrc . Height / ( double ) zImgSrc . VerticalResolution )
268274 } ) ;
269275 var zGfx = XGraphics . FromPdfPage ( zPage ) ;
270276 using ( var zMem = new MemoryStream ( ) )
271277 {
272278 zImgDestination . Save ( zMem , ImageFormat . Bmp ) ;
279+ // just for testing
280+ //zImgDestination.Save("C:\\temp.bmp", ImageFormat.Bmp);
273281 var zXImage = XImage . FromStream ( zMem ) ;
274282 zGfx . DrawImage ( zXImage , new XPoint ( ) ) ;
275283 zXImage . Dispose ( ) ;
@@ -360,7 +368,6 @@ protected override bool OpenFormData(string sFileName)
360368 if ( SerializationUtils . DeserializeFromXmlFile ( sFileName , Encoding . UTF8 , ref zConstruct ) )
361369 {
362370 listViewCards . Items . Clear ( ) ;
363- numericDPI . Value = zConstruct . DPI ;
364371 txtOutputPath . Text = zConstruct . OutputPath ;
365372 var nTargetIndex = 0 ;
366373 zConstruct . CardEntries . ForEach ( e =>
@@ -378,7 +385,6 @@ protected override bool SaveFormData(string sFileName)
378385 {
379386 var zConstruct = new Construct ( )
380387 {
381- DPI = ( int ) numericDPI . Value ,
382388 OutputPath = txtOutputPath . Text ,
383389 CardEntries = new List < CardEntry > ( listViewCards . Items . Count )
384390 } ;
@@ -395,7 +401,6 @@ protected override bool SaveFormData(string sFileName)
395401 return SerializationUtils . SerializeToXmlFile ( sFileName , zConstruct , Encoding . UTF8 ) ;
396402 }
397403
398- #endregion
399-
404+ #endregion
400405 }
401406}
0 commit comments