LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
ResetImageViewOptions Property
See Also 
Leadtools.Windows.Controls Namespace > ImageBox Class : ResetImageViewOptions Property



Gets or sets a value that determines which properties gets reset when a new image is set into the Source property. This is a dependency property. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Property ResetImageViewOptions As ResetImageViewOptions
Visual Basic (Usage)Copy Code
Dim instance As ImageBox
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.

Example

Visual BasicCopy Code
Private Class ResetImageViewOptionsWindow : Inherits Window
         Private theImage As ImageBox
         Public Sub New()
             ' Create the  viewer
             theImage = New ImageBox()

             ' 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
   {
      ImageBox theImage;
      public ResetImageViewOptionsWindow()
      {
         // Create the  viewer
         theImage = new ImageBox();

         // 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";
}
SilverlightCSharpCopy Code
class ResetImageViewOptionsWindow : ChildWindow
{
   ImageBox theImage;
   public ResetImageViewOptionsWindow()
   {
      // Create the  viewer
      theImage = new ImageBox();

      // 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"));
   }
}
SilverlightVBCopy Code
Private Class ResetImageViewOptionsWindow : Inherits ChildWindow
   Private theImage As ImageBox
   Public Sub New()
      ' Create the  viewer
      theImage = New ImageBox()

      ' 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
XAMLCopy Code
<Window x:Class="WPFSamples.ImageBox" 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:ImageBox Name="theImage" Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg" DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" ResetImageViewOptions="All"></Leadtools_Windows_Controls:ImageBox>
  </DockPanel>
  <Window.Title>
        "Apply a effect"
      </Window.Title>
</Window>

Remarks

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.

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also