Gets or sets a value that determine how the control displays the image and the automatic adjustments of the display. This is a dependency property.
public SizeMode SizeMode { get; set; }
Public Property SizeMode As Leadtools.Windows.Controls.SizeMode
public:
property Leadtools.Windows.Controls.SizeMode SizeMode {
Leadtools.Windows.Controls.SizeMode get();
void set ( Leadtools.Windows.Controls.SizeMode );
}
A SizeMode enumeration member value that determines how the control displays the image and the automatic adjustments of the display. Default value is SizeMode.Normal.
The control will use the base class FrameworkElement.MeasureOverride to determine how to fit the image in the viewing area.
When using the SizeMode.Normal size mode with; The image size is determined by the image physical pixel width and height and the values of the UseDpi and ScaleFactor properties. The AspectRatioCorrection will also play a role in determining the image size of its value is other than 1. The viewing area size is determined from the current pixel size of the control client area.
When the using the SizeMode.Fit, SizeMode.FitAlways, SizeMode.FitWidth and SizeMode.Stretch size modes; the value of ScaleFactor will always be reset back to 1 and will not be used. Instead, use the read only CurrentXScaleFactor and CurrentYScaleFactor properties to get the actual scale factors used. Note that AspectRatioCorrection will still be used.
using Leadtools.Help;
using Leadtools.Windows.Controls;
class MyWindow1 : Window
{
ImageViewer theViewer;
public MyWindow1()
{
// Create the viewer
theViewer = new ImageViewer();
// Create Dock Panel
DockPanel panel = new DockPanel();
Content = panel;
DockPanel.SetDock(theViewer, Dock.Bottom);
theViewer.HorizontalAlignment = HorizontalAlignment.Center;
theViewer.VerticalAlignment = VerticalAlignment.Bottom;
theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;
theViewer.ImageVerticalAlignment = VerticalAlignment.Top;
theViewer.UseDpi = true;
theViewer.ScreenDpiX = 96;
theViewer.ScreenDpiY = 96;
panel.Children.Add(theViewer);
// load an image into the viewer
theViewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));
Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
theViewer.MouseDoubleClick += new MouseButtonEventHandler(theViewer_MouseDoubleClick);
}
void theViewer_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
switch (theViewer.SizeMode)
{
case SizeMode.Normal:
theViewer.SizeMode = SizeMode.Stretch;
break;
case SizeMode.Stretch:
theViewer.SizeMode = SizeMode.Fit;
break;
case SizeMode.Fit:
theViewer.SizeMode = SizeMode.FitAlways;
break;
case SizeMode.FitAlways:
theViewer.SizeMode = SizeMode.FitWidth;
break;
case SizeMode.FitWidth:
theViewer.SizeMode = SizeMode.Normal;
break;
}
Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools.Windows.Controls
Private Class MyWindow1 : Inherits Window
Private theViewer As ImageViewer
Public Sub New()
' Create the viewer
theViewer = New ImageViewer()
' Create Dock Panel
Dim panel As DockPanel = New DockPanel()
Content = panel
DockPanel.SetDock(theViewer, Dock.Bottom)
theViewer.HorizontalAlignment = HorizontalAlignment.Center
theViewer.VerticalAlignment = VerticalAlignment.Bottom
theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left
theViewer.ImageVerticalAlignment = VerticalAlignment.Top
theViewer.UseDpi = True
theViewer.ScreenDpiX = 96
theViewer.ScreenDpiY = 96
panel.Children.Add(theViewer)
' load an image into the viewer
theViewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))
Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)
AddHandler theViewer.MouseDoubleClick, AddressOf theViewer_MouseDoubleClick
End Sub
Private Sub theViewer_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Select Case theViewer.SizeMode
Case SizeMode.Normal
theViewer.SizeMode = SizeMode.Stretch
Case SizeMode.Stretch
theViewer.SizeMode = SizeMode.Fit
Case SizeMode.Fit
theViewer.SizeMode = SizeMode.FitAlways
Case SizeMode.FitAlways
theViewer.SizeMode = SizeMode.FitWidth
Case SizeMode.FitWidth
theViewer.SizeMode = SizeMode.Normal
End Select
Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)
End Sub
End Class
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools.Help;
using Leadtools.Windows.Controls;
class MyWindow1 : ChildWindow
{
ImageViewer theViewer;
public MyWindow1()
{
// Create the viewer
theViewer = new ImageViewer();
// Create Dock Panel
StackPanel panel = new StackPanel();
Content = panel;
theViewer.HorizontalAlignment = HorizontalAlignment.Center;
theViewer.VerticalAlignment = VerticalAlignment.Bottom;
theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;
theViewer.ImageVerticalAlignment = VerticalAlignment.Top;
theViewer.UseDpi = true;
theViewer.ScreenDpiX = 96;
theViewer.ScreenDpiY = 96;
panel.Children.Add(theViewer);
// load an image into the viewer
theViewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));
Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
theViewer.MouseLeftButtonDown += new MouseButtonEventHandler(theViewer_MouseLeftButtonDown);
}
void theViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
switch (theViewer.SizeMode)
{
case SizeMode.Normal:
theViewer.SizeMode = SizeMode.Stretch;
break;
case SizeMode.Stretch:
theViewer.SizeMode = SizeMode.Fit;
break;
case SizeMode.Fit:
theViewer.SizeMode = SizeMode.FitAlways;
break;
case SizeMode.FitAlways:
theViewer.SizeMode = SizeMode.FitWidth;
break;
case SizeMode.FitWidth:
theViewer.SizeMode = SizeMode.Normal;
break;
}
Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
}
}
Imports Leadtools
Imports Leadtools.Windows.Controls
Private Class MyWindow1 : Inherits ChildWindow
Private theViewer As ImageViewer
Public Sub New()
' Create the viewer
theViewer = New ImageViewer()
' Create Dock Panel
Dim panel As StackPanel = New StackPanel()
Content = panel
theViewer.HorizontalAlignment = HorizontalAlignment.Center
theViewer.VerticalAlignment = VerticalAlignment.Bottom
theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left
theViewer.ImageVerticalAlignment = VerticalAlignment.Top
theViewer.UseDpi = True
theViewer.ScreenDpiX = 96
theViewer.ScreenDpiY = 96
panel.Children.Add(theViewer)
' load an image into the viewer
theViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))
Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)
AddHandler theViewer.MouseLeftButtonDown, AddressOf theViewer_MouseLeftButtonDown
End Sub
Private Sub theViewer_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Select Case theViewer.SizeMode
Case SizeMode.Normal
theViewer.SizeMode = SizeMode.Stretch
Case SizeMode.Stretch
theViewer.SizeMode = SizeMode.Fit
Case SizeMode.Fit
theViewer.SizeMode = SizeMode.FitAlways
Case SizeMode.FitAlways
theViewer.SizeMode = SizeMode.FitWidth
Case SizeMode.FitWidth
theViewer.SizeMode = SizeMode.Normal
End Select
Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)
End Sub
End 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