Represents a control that displays a WPF/Silverlight System.Windows.Media.ImageSource.
public class ImageBox : Panel Public Class ImageBoxInherits System.Windows.Controls.PanelImplements System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
public ref class ImageBox : public System.Windows.Controls.Panel, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable The ImageBox class enables you to display a WPF/Silverlight System.Windows.Media.ImageSource or one of its derived classes. To display a LEADTOOLS Leadtools.RasterImage, use the RasterImageBox control.
This control is suitable when you want to display a static image, i.e. an image that does not require scrolling or any other interactive operations in your WPF/Silverlight application. If such interactive operations are required, use the ImageViewer or RasterImageViewer controls.
Until the image content is loaded, the System.Windows.FrameworkElement.ActualWidth and System.Windows.FrameworkElement.ActualHeight of the control will report as zero, because the image content is used to determine the final size and location of the control.
For a fixed size control, the System.Windows.FrameworkElement.Width and/or System.Windows.FrameworkElement.Height properties can be set. However, to preserve the media's aspect ratio, set the System.Windows.FrameworkElement.Width or System.Windows.FrameworkElement.Height properties but not both.
The ImageBox controls supports the following functionality:
Viewing a WPF/Silverlight image using the Source property
Determining how the control displays the image and automatic adjustment for viewing when the control size changes using the SizeMode property
Changing the zoom value used to display the image using the ScaleFactor property
Manual adjustment of extra horizontal and vertical stretching values using the AspectRatioCorrection property
Support for viewing an image using its actual resolution through the UseDpi property
Image viewing transformation using the Flip, Reverse and RotateAngle properties
Using animation to control how the image is displayed with the Transition property
Converting a point or a rectangle between image (logical) and control (display or physical) properties using the PointToImageCoordinates, BoundsToImageCoordinates, PointFromImageCoordinates and BoundsFromImageCoordinates methods
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : Window{ImageBox theImage;public MyWindow1(){// Create the viewertheImage = new ImageBox();// Create Dock PanelDockPanel panel = new DockPanel();Content = panel;DockPanel.SetDock(theImage, Dock.Bottom);theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment = VerticalAlignment.Bottom;theImage.UseDpi = true;theImage.ScreenDpiX = 96;theImage.ScreenDpiY = 96;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick);}void theImage_MouseClick(object sender, MouseButtonEventArgs e){switch (theImage.SizeMode){case SizeMode.Normal:theImage.SizeMode = SizeMode.Stretch;break;case SizeMode.Stretch:theImage.SizeMode = SizeMode.Fit;break;case SizeMode.Fit:theImage.SizeMode = SizeMode.FitAlways;break;case SizeMode.FitAlways:theImage.SizeMode = SizeMode.FitWidth;break;case SizeMode.FitWidth:theImage.SizeMode = SizeMode.Normal;break;}Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits WindowPrivate theImage As ImageBoxPublic Sub New()' Create the viewertheImage = New ImageBox()' Create Dock PanelDim panel As DockPanel = New DockPanel()Content = panelDockPanel.SetDock(theImage, Dock.Bottom)theImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment = VerticalAlignment.BottomtheImage.UseDpi = TruetheImage.ScreenDpiX = 96theImage.ScreenDpiY = 96panel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)AddHandler theImage.MouseDown, AddressOf theImage_MouseClickEnd SubPrivate Sub theImage_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Select Case theImage.SizeModeCase SizeMode.NormaltheImage.SizeMode = SizeMode.StretchCase SizeMode.StretchtheImage.SizeMode = SizeMode.FitCase SizeMode.FittheImage.SizeMode = SizeMode.FitAlwaysCase SizeMode.FitAlwaystheImage.SizeMode = SizeMode.FitWidthCase SizeMode.FitWidththeImage.SizeMode = SizeMode.NormalEnd SelectTitle = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)End SubEnd ClassPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : ChildWindow{ImageBox theImage;public MyWindow1(){// Create the viewertheImage = new ImageBox();// Create Dock PanelStackPanel panel = new StackPanel();Content = panel;theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment = VerticalAlignment.Bottom;theImage.UseDpi = true;theImage.ScreenDpiX = 96;theImage.ScreenDpiY = 96;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseLeftButtonDown += new MouseButtonEventHandler(theImage_MouseLeftButtonDown);}void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){switch (theImage.SizeMode){case SizeMode.Normal:theImage.SizeMode = SizeMode.Stretch;break;case SizeMode.Stretch:theImage.SizeMode = SizeMode.Fit;break;case SizeMode.Fit:theImage.SizeMode = SizeMode.FitAlways;break;case SizeMode.FitAlways:theImage.SizeMode = SizeMode.FitWidth;break;case SizeMode.FitWidth:theImage.SizeMode = SizeMode.Normal;break;}Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);}}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits ChildWindowPrivate theImage As ImageBoxPublic Sub New()' Create the viewertheImage = New ImageBox()' Create Dock PanelDim panel As StackPanel = New StackPanel()Content = paneltheImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment = VerticalAlignment.BottomtheImage.UseDpi = TruetheImage.ScreenDpiX = 96theImage.ScreenDpiY = 96panel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)AddHandler theImage.MouseLeftButtonDown, AddressOf theImage_MouseLeftButtonDownEnd SubPrivate Sub theImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Select Case theImage.SizeModeCase SizeMode.NormaltheImage.SizeMode = SizeMode.StretchCase SizeMode.StretchtheImage.SizeMode = SizeMode.FitCase SizeMode.FittheImage.SizeMode = SizeMode.FitAlwaysCase SizeMode.FitAlwaystheImage.SizeMode = SizeMode.FitWidthCase SizeMode.FitWidththeImage.SizeMode = SizeMode.NormalEnd SelectTitle = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)End SubEnd Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
