ImageGear for .NET User Guide > Getting Started > ImageGear for .NET Visual Studio 2008/2005 Tutorials > ImageGear for .NET C# WPF Tutorial > Adding the Code Behind |
C# |
Copy Code |
---|---|
using System.IO; using System.Windows.Forms; using System.Diagnostics; using ImageGear; using ImageGear.Core; using ImageGear.Display; using ImageGear.Windows.Forms; using ImageGear.Windows.Controls; using ImageGear.Processing; using ImageGear.Formats; using ImageGear.WPF; using ImageGear.WPF.HDP; |
C# |
Copy Code |
---|---|
ImGearPage igPage = null; ImGearPresentationPageDisplay igPageDisplay = 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..."); |
C# |
Copy Code |
---|---|
ImGearFileFormats.Filters.Insert(0, ImGearHDPhoto.CreateHDPhotoFormat()); ImGearCommonFormats.Initialize(); |
C# |
Copy Code |
---|---|
ImGearLoadingSelection selection = ImGearWinForms.SelectLocalFileToLoad(null, "Select File"); if (null != selection) { using (FileStream fileContent = ((ImGearLocalFile) selection.File).OpenToRead()) { try { igPage = ImGearFileFormats.LoadPage(fileContent, 0); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } if (null != igPage && null != igPage.DIB && !igPage.DIB.IsEmpty()) { // Create a new page display igPageDisplay = new ImGearPresentationPageDisplay(igPage); // Associate the page display with the page view imGearPageView1.Display = igPageDisplay; // Cause the page view to update imGearPageView1.Update(); } } |
C# |
Copy Code |
---|---|
private void ZoomInExecuted(object sender, ExecutedRoutedEventArgs e) { // Get the current zoom info ImGearZoomInfo igZoomInfo = igPageDisplay.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 igPageDisplay.UpdateZoomFrom(igZoomInfo); // Trigger an update, letting it know only the layout has changed. imGearPageView1.Update(true); } private void ZoomOutExecuted(object sender, ExecutedRoutedEventArgs e) { // Get the current zoom info ImGearZoomInfo igZoomInfo = igPageDisplay.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 igPageDisplay.UpdateZoomFrom(igZoomInfo); // Trigger an update, letting it know only the layout has changed. imGearPageView1.Update(true); } |
C# |
Copy Code |
---|---|
private void ExectutedRotate90(object sender, ExecutedRoutedEventArgs e) { try { ImGearProcessing.Rotate(igPage, ImGearRotationValues.VALUE_90); imGearPageView1.Update(); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } private void ExectutedRotate180(object sender, ExecutedRoutedEventArgs e) { try { ImGearProcessing.Rotate(igPage, ImGearRotationValues.VALUE_180); imGearPageView1.Update(); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } private void ExectutedRotate270(object sender, ExecutedRoutedEventArgs e) { try { ImGearProcessing.Rotate(igPage, ImGearRotationValues.VALUE_270); imGearPageView1.Update(); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } |
C# |
Copy Code |
---|---|
private void ExitExecuted(object sender, ExecutedRoutedEventArgs e) { this.Close(); } |
C# |
Copy Code |
---|---|
private void CanExectutePageAvailable(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = (null != igPage && null != igPage.DIB && !igPage.DIB.IsEmpty() && null != igPageDisplay); } |