| ImageGear Professional v18.2 > User Guide > Getting Started > MS Visual Studio .NET 2003 C# Application > Adding the Code |
|
Copy Code
|
|
|---|---|
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; |
|
Add the following other using statements to Form1.cs:
|
Copy Code
|
|
|---|---|
using GearDIALOGSLib; using GearCORELib; using GearFORMATSLib; using GearDISPLAYLib; using GearPROCESSINGLib; |
|
|
Copy Code
|
|
|---|---|
public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem mnuOpen; private System.Windows.Forms.MenuItem mnuZoomin; private System.Windows.Forms.MenuItem mnuZoomout; private AxGearCORELib.AxIGCoreCtl axIGCoreCtl1; private AxGearDISPLAYLib.AxIGDisplayCtl axIGDisplayCtl1; private AxGearFORMATSLib.AxIGFormatsCtl axIGFormatsCtl1; private AxGearDIALOGSLib.AxIGDlgsCtl axIGDlgsCtl1; private AxGearVIEWLib.AxIGPageViewCtl axIGPageViewCtl1; private AxGearPROCESSINGLib.AxIGProcessingCtl axIGProcessingCtl1; |
|
You'll need to add the following other private members to the Form1 class:
|
Copy Code
|
|
|---|---|
private IGFileDlg m_dlgFile = null;
private IGPage m_igPage = null;
private IGPageDisplay m_igPageDisp = null;
|
|

|
Copy Code
|
|
|---|---|
private void Form1_Load(object sender, System.EventArgs e) { axIGCoreCtl1.License.SetSolutionName("Accusoft"); axIGCoreCtl1.Result.NotificationFlags = enumIGErrorHandlingFlags.IG_ERR_OLE_ERROR; try { axIGCoreCtl1.AssociateComponent(axIGFormatsCtl1.ComponentInt erface); axIGCoreCtl1.AssociateComponent(axIGDisplayCtl1.ComponentInt erface); axIGCoreCtl1.AssociateComponent(axIGProcessingCtl1.Component Interface); axIGDlgsCtl1.GearFormats = axIGFormatsCtl1.ComponentInterface; axIGDlgsCtl1.GearCore = axIGCoreCtl1.ComponentInterface; axIGDlgsCtl1.GearDisplay = axIGDisplayCtl1.ComponentInterface; m_dlgFile = axIGDlgsCtl1.CreateFileDlg(); m_igPage = axIGCoreCtl1.CreatePage(); m_igPageDisp = axIGDisplayCtl1.CreatePageDisplay( m_igPage); axIGPageViewCtl1.PageDisplay = m_igPageDisp; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void Form1_Resize(object sender, System.EventArgs e) { axIGPageViewCtl1.Left = 0; axIGPageViewCtl1.Top = 0; axIGPageViewCtl1.Width = this.ClientSize.Width; axIGPageViewCtl1.Height = this.ClientSize.Height; } |
|
The code above includes:
| IGCoreCtl Control | License.SetSolutionName | This method of the IGLicense Object sets the solution name for the ImageGear license. |
| Result.NotificationFlag | This method of the IGResult Object tells ImageGear to report errors using the COM Error mechanism (caught as Exceptions). | |
| AssociateComponent | This method associates ImageGear components with the Core control. | |
| CreatePage | This method creates and returns a new IGPage Object . | |
| IGDlgsCtl Control | GearFormats | This property sets the current Formats control used by the Dialog control. |
| GearCore | This property sets the current Core control used by the Dialog control | |
| IGDisplayCtl Control | CreatePageDisplay | This method creates a new IGPageDisplay Object for the specified IGPage Object. |
| IGPageViewCtl Control | PageDisplay | This property sets the current Page Display object displayed by the Page View control. |
|
Copy Code
|
|
|---|---|
private void mnuOpen_Click(object sender, System.EventArgs e) { try { IGFileDlgPageLoadOptions dlgLoadOptions = null; dlgLoadOptions = (IGFileDlgPageLoadOptions) axIGDlgsCtl1.CreateFileDlgOptions( enumIGFileDlgOptionsType.IG_FILEDLGOPTIONS_PAGELOADOBJ); if(m_dlgFile.Show((IIGFileDlgOptions)dlgLoadOptions)) { axIGFormatsCtl1.LoadPageFromFile(m_igPage, dlgLoadOptions.FileName, dlgLoadOptions.PageNum); } axIGPageViewCtl1.UpdateView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } |
|
The code above includes:
| IGDlgsCtl Control | CreateFileDlgOptions | This method creates a file dialog options object that will contain example the filename and page number. |
| IGFileDlg Object | Show | This method shows the file dialog and returns True if the user clicked OK. |
| IGFormatsCtl Control | LoadPageFromFile | This method loads an image into the specified IGPage Object from the specified filename. |
|
Copy Code
|
|
|---|---|
private void mnuZoomin_Click(object sender,
System.EventArgs e)
{
try
{
IGDisplayZoomInfo zoominfo = null;
zoominfo = (IGDisplayZoomInfo)
m_igPageDisp.GetZoomInfo( axIGPageViewCtl1.hWnd );
zoominfo.HZoom = zoominfo.HZoom * 1.25;
zoominfo.VZoom = zoominfo.VZoom * 1.25;
zoominfo.Mode =
GearDISPLAYLib.enumIGDsplZoomModes.IG_DSPL_ZOOM_H_FIXED |
GearDISPLAYLib.enumIGDsplZoomModes.IG_DSPL_ZOOM_V_FIXED;
m_igPageDisp.UpdateZoomFrom(zoominfo);
axIGPageViewCtl1.UpdateView();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
The above code zooms the image to 125 percent, or 5/4ths, of its size (zoom in by 25 percent).
|
Copy Code
|
|
|---|---|
private void mnuZoomout_Click(object sender,
System.EventArgs e)
{
try
{
IGDisplayZoomInfo zoominfo = null;
zoominfo = (IGDisplayZoomInfo)
m_igPageDisp.GetZoomInfo(
axIGPageViewCtl1.hWnd );
zoominfo.HZoom = zoominfo.HZoom * 0.80;
zoominfo.VZoom = zoominfo.VZoom * 0.80;
zoominfo.Mode =
GearDISPLAYLib.enumIGDsplZoomModes.IG_DSPL_ZOOM_H_FIXED |
GearDISPLAYLib.enumIGDsplZoomModes.IG_DSPL_ZOOM_V_FIXED;
m_igPageDisp.UpdateZoomFrom(zoominfo);
axIGPageViewCtl1.UpdateView();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
The above code zooms "out", decreasing the image to 4/5ths of its size, thereby canceling the effect of the zoom in above.
The code above includes:
| IGPageDisplay Object | GetZoomInfo | This method creates and returns a new IGDisplayZoomInfo Object that contains zoom mode and values. |
| UpdateZoomFrom | This method sets zoom mode and values from the specified IGDisplayZoomInfo Object. |