Visual Basic (Declaration) | |
---|---|
Public Property ResetImageViewOptions As ResetImageViewOptions |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As ImageViewer Dim value As ResetImageViewOptions instance.ResetImageViewOptions = value value = instance.ResetImageViewOptions |
C# | |
---|---|
public ResetImageViewOptions ResetImageViewOptions {get; set;} |
C++/CLI | |
---|---|
public: property ResetImageViewOptions ResetImageViewOptions { ResetImageViewOptions get(); void set ( ResetImageViewOptions value); } |
Property Value
One or more of the ResetImageViewOptions enumeration members that determine which properties gets reset to their default values when a new image is set into the Source properties. Default value is ResetImageViewOptions.All.
Visual Basic | Copy Code |
---|---|
Private Class ResetImageViewOptionsWindow : Inherits Window Private theImage As ImageViewer Public Sub New() ' Create the viewer theImage = New ImageViewer() ' Create Dock Panel Dim panel As DockPanel = New DockPanel() Content = panel DockPanel.SetDock(theImage, Dock.Bottom) theImage.HorizontalAlignment = HorizontalAlignment.Center theImage.VerticalAlignment = VerticalAlignment.Bottom panel.Children.Add(theImage) ' load an image into the viewer theImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))) theImage.SizeMode = SizeMode.Fit Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode) AddHandler theImage.MouseDown, AddressOf theImage_MouseClick End Sub Private Sub theImage_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs) ' Assign a new image and keep the size mode set to fit. theImage.ResetImageViewOptions = ResetImageViewOptions.All And Not ResetImageViewOptions.SizeMode theImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "LittleGFlyingAlpha.png"))) End Sub End Class Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
class ResetImageViewOptionsWindow : Window { ImageViewer theImage; public ResetImageViewOptionsWindow() { // Create the viewer theImage = new ImageViewer(); // Create Dock Panel DockPanel panel = new DockPanel(); Content = panel; DockPanel.SetDock(theImage, Dock.Bottom); theImage.HorizontalAlignment = HorizontalAlignment.Center; theImage.VerticalAlignment = VerticalAlignment.Bottom; panel.Children.Add(theImage); // load an image into the viewer theImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))); theImage.SizeMode = SizeMode.Fit; Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode); theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick); } void theImage_MouseClick(object sender, MouseButtonEventArgs e) { // Assign a new image and keep the size mode set to fit. theImage.ResetImageViewOptions = ResetImageViewOptions.All & ~ResetImageViewOptions.SizeMode; theImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "LittleGFlyingAlpha.png"))); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
SilverlightCSharp | Copy Code |
---|---|
class ResetImageViewOptionsWindow : ChildWindow { ImageViewer theImage; public ResetImageViewOptionsWindow() { // Create the viewer theImage = new ImageViewer(); // Create Dock Panel StackPanel panel = new StackPanel(); Content = panel; theImage.HorizontalAlignment = HorizontalAlignment.Center; theImage.VerticalAlignment = VerticalAlignment.Bottom; panel.Children.Add(theImage); // load an image into the viewer theImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg")); theImage.SizeMode = SizeMode.Fit; Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode); theImage.MouseLeftButtonDown += new MouseButtonEventHandler(theImage_MouseLeftButtonDown); } void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // Assign a new image and keep the size mode set to fit. theImage.ResetImageViewOptions = ResetImageViewOptions.All & ~ResetImageViewOptions.SizeMode; theImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "LittleGFlyingAlpha.png")); } } |
SilverlightVB | Copy Code |
---|---|
Private Class ResetImageViewOptionsWindow : Inherits ChildWindow Private theImage As ImageViewer Public Sub New() ' Create the viewer theImage = New ImageViewer() ' Create Dock Panel Dim panel As StackPanel = New StackPanel() Content = panel theImage.HorizontalAlignment = HorizontalAlignment.Center theImage.VerticalAlignment = VerticalAlignment.Bottom panel.Children.Add(theImage) ' load an image into the viewer theImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg")) theImage.SizeMode = SizeMode.Fit Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode) AddHandler theImage.MouseLeftButtonDown, AddressOf theImage_MouseLeftButtonDown End Sub Private Sub theImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) ' Assign a new image and keep the size mode set to fit. theImage.ResetImageViewOptions = ResetImageViewOptions.All And Not ResetImageViewOptions.SizeMode theImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "LittleGFlyingAlpha.png")) End Sub End Class |
XAML | Copy Code |
---|---|
<Window x:Class="WPFSamples.ImageViewer" Height="600" Width="800" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> <DockPanel> <Leadtools_Windows_Controls:ImageViewer Name="theViewer" Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg" DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" ResetImageViewOptions="All"></Leadtools_Windows_Controls:ImageViewer> </DockPanel> <Window.Title> "Reset Image View Options" </Window.Title> </Window> |
You can use this property to control which of the display properties of the controls resets back to its default value when a new image is set into the Source property.
The following table lists the options than can be specified:
Option | Description |
---|---|
ResetImageViewOptions.None |
None of the following properties will reset back to their default values, instead they will keep their current values when a new image is set in Source. |
ResetImageViewOptions.ScrollPosition |
The horizontal and vertical bars (if applicable) location will reset back to the top-left position. |
ResetImageViewOptions.ScaleFactor |
The ScaleFactor property will reset back to 1.0. |
ResetImageViewOptions.AspectRatioCorrection |
The AspectRatioCorrection property will reset back to 1.0. |
ResetImageViewOptions.SizeMode |
The SizeMode property will reset back to SizeMode.Normal. |
ResetImageViewOptions.Reverse |
The Reverse property will reset back to false. |
ResetImageViewOptions.Flip |
The Flip property will reset back to false. |
ResetImageViewOptions.RotateAngle |
The RotateAngle property will reset back to 0. |
ResetImageViewOptions.All |
All the above properties will reset back to their default values. |
You can use a logical OR operation to combine any of the above options together. By setting these options, you can achieve effects such as if the control has a scale factor value of 1.5 (150 percent) and a new image is set, the scale factor does not reset and stays at 150 percent instead of going back to 100 percent.
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family