ImageGear for .NET User Guide > Getting Started > ImageGear for .NET Visual Studio 2010 Tutorials > ImageGear for .NET C# Tutorial > Developing the Application |
C# |
Copy Code |
---|---|
using System.IO; using System.Diagnostics; using ImageGear; using ImageGear.Core; using ImageGear.Windows.Forms; using ImageGear.Display; using ImageGear.Processing; using ImageGear.Formats; |
C# |
Copy Code |
---|---|
// holds the image data private ImGearPage imGearPage = null; // controls how the page is displayed private ImGearPageDisplay imGearPageDisplay = null; |
C# |
Copy Code |
---|---|
//***The SetSolutionName, SetSolutionKey and possibly the SetOEMLicenseKey
//methods must be called to distribute the runtime.***
//ImGearLicense.SetSolutionName("YourSolutionName");
//ImGearLicense.SetSolutionKey(12345, 12345, 12345, 12345);
//Manually Reported Runtime licenses also require the following method
//call to SetOEMLicenseKey.
//ImGearLicense.SetOEMLicenseKey("2.0.AStringForOEMLicensing..."); |
Please add the ImGearEvaluationManager.Initialize() call if you are evaluating the product.
C# |
Copy Code |
---|---|
// Support for common formats:
ImGearCommonFormats.Initialize(); |
C# |
Copy Code |
---|---|
private void loadPageToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = ImGearFileFormats.GetSavingFilter(ImGearSavingFormats.UNKNOWN); if (DialogResult.OK == openFileDialog1.ShowDialog()) { using (FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { try { // Load the image into the page imGearPage = ImGearFileFormats.LoadPage(stream, 0); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } if (null != imGearPage && null != imGearPage.DIB && !imGearPage.DIB.IsEmpty()) { // create a new page display imGearPageDisplay = new ImGearPageDisplay(imGearPage); // associate the page display with the page view imGearPageView1.Display = imGearPageDisplay; // cause the page view to repaint imGearPageView1.Invalidate(); } } } |
ImGearPageDisplay Class | Constructs a new PageDisplay object for the given page. |
ImGearPageView.Invalidate | Invalidates the control thus causing it to repaint. |
ImGearFileFormats.LoadPage Method | Loads a file from a given stream and returns a new ImGearPage Class. |
ImGearFileFormats.GetSavingFilter Method | Gets a filter string which can be passed to a windows common dialog filter member. |
C# |
Copy Code |
---|---|
if (null != imGearPageDisplay && !imGearPageDisplay.Page.DIB.IsEmpty()) { // Get the current zoom info ImGearZoomInfo igZoomInfo = imGearPageDisplay.GetZoomInfo(imGearPageView1); // Increase the zoom igZoomInfo.Horizontal.Value = igZoomInfo.Horizontal.Value * 1.25; igZoomInfo.Vertical.Value = igZoomInfo.Vertical.Value * 1.25; igZoomInfo.Horizontal.Fixed = true; igZoomInfo.Vertical.Fixed = true; // Set the new zoom values and repaint the view imGearPageDisplay.UpdateZoomFrom(igZoomInfo); imGearPageView1.Invalidate(); } |
ImGearPageDisplay.GetZoomInfo Method | Retrieves the current zoom information from the display and page view. |
ImGearPageDisplay.UpdateZoomFrom Method | Sets new zoom values from the given ImGearZoomInfo Structure object. |
ImGearZoomInfo Structure | Holds horizontal and vertical zoom values and settings. |
C# |
Copy Code |
---|---|
if (null != imGearPageDisplay && !imGearPageDisplay.Page.DIB.IsEmpty()) { // Get the current zoom info ImGearZoomInfo igZoomInfo = imGearPageDisplay.GetZoomInfo(imGearPageView1); igZoomInfo.Horizontal.Value = igZoomInfo.Horizontal.Value * (1/1.25); igZoomInfo.Vertical.Value = igZoomInfo.Vertical.Value * (1/1.25); igZoomInfo.Horizontal.Fixed = true; igZoomInfo.Vertical.Fixed = true; // Set the new zoom values and repaint the view imGearPageDisplay.UpdateZoomFrom(igZoomInfo); imGearPageView1.Invalidate(); } |
C# |
Copy Code |
---|---|
if (null != imGearPageDisplay && null != imGearPage && !imGearPageDisplay.Page.DIB.IsEmpty()) try { ImGearProcessing.Rotate(imGearPage, ImGearRotationValues.VALUE_90); imGearPageView1.Invalidate(); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } |
ImGearProcessing.Rotate Method | Rotates the given page by the given amount. |
C# |
Copy Code |
---|---|
this.Close(); |