Modified Open File menu click event handler in Visual Studio .NET

Create ANSI/AIM Code 128 in Visual Studio .NET Modified Open File menu click event handler
Listing 79 Modified Open File menu click event handler
Code 128A Creator In .NET Framework
Using Barcode creator for VS .NET Control to generate, create Code-128 image in VS .NET applications.
private void OpenFileMenu_Click(object sender, SystemEventArgs e) { // Create OpenFileDialog
Code 128A Reader In VS .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
This document was created by an unregistered ChmMagic, please go to http://wwwbisentercom to register it Thanks
Bar Code Creation In .NET
Using Barcode creator for .NET framework Control to generate, create barcode image in Visual Studio .NET applications.
OpenFileDialog opnDlg = new OpenFileDialog(); // Set a filter for images opnDlgFilter = "All Image files|*bmp;*gif;*jpg;*ico;"+ "*emf;,*wmf|Bitmap Files(*bmp;*gif;*jpg;"+ "*ico)|*bmp;*gif;*jpg;*ico|"+ "Meta Files(*emf;*wmf;*png)|*emf;*wmf;*png"; opnDlgTitle = "ImageViewer: Open Image File"; opnDlgShowHelp = true; // If OK, selected if(opnDlgShowDialog() == DialogResultOK) { // Read current selected file name curFileName = opnDlgFileName; // Create the Image object using // ImageFromFile try { curImage = ImageFromFile(curFileName); } catch(Exception exp) { MessageBoxShow(expMessage); } // Activate scrolling thisAutoScroll = true; thisAutoScrollMinSize = new Size ((int)(curImageWidth), (int)(curImageHeight)); // Repaint the form, which forces the paint // event handler thisInvalidate(); } // Create current rectangle curRect = new Rectangle(0, 0, curImageWidth, curImageHeight); // Save original size of the image originalSizeWidth = curImageWidth; originalSizeHeight = curImageHeight; } The paint event handler must also be modified The new code is given in Listing 710 We use the curRect rectangle to view the image
Decode Bar Code In VS .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
Listing 710 Modified paint event handler
Code-128 Printer In C#.NET
Using Barcode printer for .NET framework Control to generate, create Code 128 Code Set B image in .NET framework applications.
private void Form1_Paint(object sender, SystemWindowsFormsPaintEventArgs e) { Graphics g = eGraphics; if(curImage != null) { // Draw image using the DrawImage method gDrawImage(curImage, new Rectangle (thisAutoScrollPositionX, thisAutoScrollPositionY, (int)(curRectWidth),
Generating Code128 In .NET
Using Barcode creation for ASP.NET Control to generate, create USS Code 128 image in ASP.NET applications.
This document was created by an unregistered ChmMagic, please go to http://wwwbisentercom to register it Thanks
Encode Code 128 In Visual Basic .NET
Using Barcode maker for VS .NET Control to generate, create Code 128 Code Set B image in .NET applications.
(int)(curRectHeight))); } } The last step is to add event handler code for the Fit Height, Fit Width, Fit Original, and Fit All menu options, as shown inListing 711 For the Fit Width option, we set the width of the current rectangle to the width of the form; for theFit Height option, we set the height of the current rectangle to the height of the form; for the Fit All option, we set both the height and width of the current rectangle to the height and width of the form; and for Fit Original, we set the current rectangle's height and width to the height and width of the original file saved as originalSize
ECC200 Drawer In .NET
Using Barcode encoder for .NET Control to generate, create Data Matrix ECC200 image in .NET framework applications.
Listing 711 Fit menu item event handlers
Bar Code Generation In .NET Framework
Using Barcode encoder for VS .NET Control to generate, create barcode image in VS .NET applications.
private void FitWidthMenu_Click(object sender, SystemEventArgs e) { if(curImage != null) { curRectWidth = thisWidth; Invalidate(); } } private void FitHeightMenu_Click(object sender, SystemEventArgs e) { if(curImage != null) { curRectHeight = thisHeight; Invalidate(); } } private void FitOriginalMenu_Click(object sender, SystemEventArgs e) { if(curImage != null) { curRectHeight = originalSizeHeight; curRectWidth = originalSizeWidth; Invalidate(); } } private void FitAllMenu_Click(object sender, SystemEventArgs e) { if(curImage != null) { curRectHeight = thisHeight; curRectWidth = thisWidth; Invalidate(); } } Now we compile and run the application, and we view an image The original image looks like Figure 718
Barcode Printer In Visual Studio .NET
Using Barcode creation for .NET Control to generate, create bar code image in VS .NET applications.
This document was created by an unregistered ChmMagic, please go to http://wwwbisentercom to register it Thanks
Create GS1 128 In VS .NET
Using Barcode maker for .NET Control to generate, create GS1 128 image in .NET applications.
Figure 718 An image in ImageViewer
Creating OneCode In VS .NET
Using Barcode encoder for VS .NET Control to generate, create USPS Intelligent Mail image in .NET applications.
The Fit Width option generates the image shown inFigure 719
Barcode Drawer In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Figure 719 The image of Figure 718 after Fit Width
EAN / UCC - 13 Encoder In Java
Using Barcode creation for Java Control to generate, create GTIN - 128 image in Java applications.
The Fit Height option generates the image shown inFigure 720
Barcode Reader In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Figure 720 The image of Figure 718 after Fit Height
Generate Bar Code In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create barcode image in ASP.NET applications.
This document was created by an unregistered ChmMagic, please go to http://wwwbisentercom to register it Thanks
Data Matrix Decoder In VS .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET framework applications.
Aspect Ratio
Creating Data Matrix 2d Barcode In Java
Using Barcode drawer for Java Control to generate, create Data Matrix 2d barcode image in Java applications.
To see an image correctly, you may want to maintain its aspect ratio (the ratio of height to width) To do so, you need to modify the code so that when you select Fit Width or Fit Height, the width and the height are changed according to the original ratio
USS Code 128 Drawer In C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create ANSI/AIM Code 128 image in .NET applications.
The Fit Original option generates the image shown inFigure 721
Print Code 39 In .NET
Using Barcode printer for ASP.NET Control to generate, create Code 3/9 image in ASP.NET applications.
Figure 721 The image of Figure 718 after Fit Original
The Fit All option generates the image shown inFigure 722
Figure 722 The image of Figure 718 after Fit All
This document was created by an unregistered ChmMagic, please go to http://wwwbisentercom to register it Thanks
735 Zooming In and Out
Before we finish our ImageViewer application, let's add one more option: zooming Adding zoom-in and zoom-out features requires only one operation: multiplying the height and width of the image by a zoom factor The zoom factor is the ratio of the current size of the image to the desired new size of the image For example, suppose that we want to zoom in an image by 200 percent We must multiply the current size of the image by 200 percent, or 2 (200/100 = 2 times) If we want to zoom out an image by 25 percent, we need to multiply the size of the image by 25 percent, or 025 (25/100 = 025 times) Now let's add the zoom features to our application As is typically done, we add five items to the Zoom submenu: 25, 50, 100, 200, and 500 (see Figure 723) In our code we use Zoom25, Zoom50, Zoom100, Zoom200, and Zoom500, respectively, to represent these menu items, and we add the appropriate menu item click event handlers by double-clicking on the menu items