@@ -35,38 +35,34 @@ private void RenderQrCode()
35
35
string level = comboBoxECC . SelectedItem . ToString ( ) ;
36
36
QRCodeGenerator . ECCLevel eccLevel = ( QRCodeGenerator . ECCLevel ) ( level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3 ) ;
37
37
using ( QRCodeGenerator qrGenerator = new QRCodeGenerator ( ) )
38
+ using ( QRCodeData qrCodeData = qrGenerator . CreateQrCode ( textBoxQRCode . Text , eccLevel ) )
39
+ using ( QRCode qrCode = new QRCode ( qrCodeData ) )
38
40
{
39
- using ( QRCodeData qrCodeData = qrGenerator . CreateQrCode ( textBoxQRCode . Text , eccLevel ) )
40
- {
41
- using ( QRCode qrCode = new QRCode ( qrCodeData ) )
42
- {
43
- pictureBoxQRCode . BackgroundImage = qrCode . GetGraphic ( 20 , GetPrimaryColor ( ) , GetBackgroundColor ( ) ,
44
- GetIconBitmap ( ) , ( int ) iconSize . Value ) ;
41
+ pictureBoxQRCode . BackgroundImage = qrCode . GetGraphic ( 20 , GetPrimaryColor ( ) , GetBackgroundColor ( ) ,
42
+ GetIconBitmap ( ) , ( int ) iconSize . Value ) ;
45
43
46
- this . pictureBoxQRCode . Size = new System . Drawing . Size ( pictureBoxQRCode . Width , pictureBoxQRCode . Height ) ;
47
- //Set the SizeMode to center the image.
48
- this . pictureBoxQRCode . SizeMode = PictureBoxSizeMode . CenterImage ;
44
+ this . pictureBoxQRCode . Size = new System . Drawing . Size ( pictureBoxQRCode . Width , pictureBoxQRCode . Height ) ;
45
+ //Set the SizeMode to center the image.
46
+ this . pictureBoxQRCode . SizeMode = PictureBoxSizeMode . CenterImage ;
49
47
50
- pictureBoxQRCode . SizeMode = PictureBoxSizeMode . StretchImage ;
51
- }
52
- }
48
+ pictureBoxQRCode . SizeMode = PictureBoxSizeMode . StretchImage ;
53
49
}
54
50
}
55
51
56
52
private Bitmap GetIconBitmap ( )
57
53
{
58
- Bitmap img = null ;
59
- if ( iconPath . Text . Length > 0 )
54
+ if ( iconPath . Text . Length == 0 )
60
55
{
61
- try
62
- {
63
- img = new Bitmap ( iconPath . Text ) ;
64
- }
65
- catch ( Exception )
66
- {
67
- }
56
+ return null ;
57
+ }
58
+ try
59
+ {
60
+ return new Bitmap ( iconPath . Text ) ;
61
+ }
62
+ catch ( Exception )
63
+ {
64
+ return null ;
68
65
}
69
- return img ;
70
66
}
71
67
72
68
private void selectIconBtn_Click ( object sender , EventArgs e )
0 commit comments