←Select platform

Transform Property

Summary

Gets the current display matrix used in this control.

Syntax

C#
VB
C++
public virtual Matrix Transform { get; } 
  
Public Overridable ReadOnly Property Transform As Matrix 
public: 
virtual property Matrix Transform { 
   Matrix get(); 
} 

Property Value

A System.Windows.Media.Matrix that contains the current display matrix used in this control.

Remarks

The Transform property will contain the accumulative transforms performed on the image before it is being displayed by the control. The following properties determine the final transformation of the image:

  • The control size

  • The image physical size in pixels and if using the image resolution is enabled with the UseDpi property

  • Any manual correction with the AspectRatioCorrection

  • The current zoom using the ScaleFactor property

  • The current display and automatic adjustment set with the SizeMode property

  • Image viewing transformation using the Flip, Reverse and RotateAngle properties

Although you can use the Transform property to calculate where a location or bounds on the image will be displayed on the control and vice versa using the Matrix.Transform methods, you can easily achieve this task with the control PointToImageCoordinates, BoundsToImageCoordinates, PointFromImageCoordinates and BoundsFromImageCoordinates methods

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
 
private void viewer_TransformChanged(object sender, EventArgs e) 
{ 
   ImageViewer viewer = sender as ImageViewer; 
   string s = string.Format("TransformChanged Event: {0}", viewer.Transform.ToString()); 
   MessageBox.Show(s); 
} 
 
public void ImageViewer_TransformChanged(ImageViewer viewer) 
{ 
   viewer.TransformChanged += new EventHandler(viewer_TransformChanged); 
 
   switch (viewer.SizeMode) 
   { 
      case SizeMode.Fit: 
         viewer.SizeMode = SizeMode.FitAlways; 
         break; 
 
      case SizeMode.FitAlways: 
         viewer.SizeMode = SizeMode.FitWidth; 
         break; 
 
      case SizeMode.FitWidth: 
         viewer.SizeMode = SizeMode.Normal; 
         break; 
 
      case SizeMode.Normal: 
         viewer.SizeMode = SizeMode.Stretch; 
         break; 
 
      case SizeMode.Stretch: 
         viewer.SizeMode = SizeMode.Fit; 
         break; 
   } 
 
   viewer.TransformChanged -= new EventHandler(viewer_TransformChanged); 
} 
Imports Leadtools.Windows.Controls 
 
Private Sub viewer_TransformChanged(ByVal sender As Object, ByVal e As EventArgs) 
   Dim viewer As ImageViewer = TryCast(sender, ImageViewer) 
   Dim s As String = String.Format("TransformChanged Event: {0}", viewer.Transform.ToString()) 
   MessageBox.Show(s) 
End Sub 
 
Public Sub ImageViewer_TransformChanged(ByVal viewer As ImageViewer) 
   AddHandler viewer.TransformChanged, AddressOf viewer_TransformChanged 
 
   Select Case viewer.SizeMode 
      Case SizeMode.Fit 
         viewer.SizeMode = SizeMode.FitAlways 
 
      Case SizeMode.FitAlways 
         viewer.SizeMode = SizeMode.FitWidth 
 
      Case SizeMode.FitWidth 
         viewer.SizeMode = SizeMode.Normal 
 
      Case SizeMode.Normal 
         viewer.SizeMode = SizeMode.Stretch 
 
      Case SizeMode.Stretch 
         viewer.SizeMode = SizeMode.Fit 
   End Select 
 
   RemoveHandler viewer.TransformChanged, AddressOf viewer_TransformChanged 
End Sub 
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
 
private void viewer_TransformChanged(object sender, EventArgs e) 
{ 
   ImageViewer viewer = sender as ImageViewer; 
   string s = string.Format("TransformChanged Event: {0}", viewer.Transform.ToString()); 
   MessageBox.Show(s); 
} 
 
public void ImageViewer_TransformChanged(ImageViewer viewer) 
{ 
   viewer.TransformChanged += new EventHandler(viewer_TransformChanged); 
 
   switch (viewer.SizeMode) 
   { 
      case SizeMode.Fit: 
         viewer.SizeMode = SizeMode.FitAlways; 
         break; 
 
      case SizeMode.FitAlways: 
         viewer.SizeMode = SizeMode.FitWidth; 
         break; 
 
      case SizeMode.FitWidth: 
         viewer.SizeMode = SizeMode.Normal; 
         break; 
 
      case SizeMode.Normal: 
         viewer.SizeMode = SizeMode.Stretch; 
         break; 
 
      case SizeMode.Stretch: 
         viewer.SizeMode = SizeMode.Fit; 
         break; 
   } 
 
   viewer.TransformChanged -= new EventHandler(viewer_TransformChanged); 
} 
Imports Leadtools 
Imports Leadtools.Windows.Controls 
 
Private Sub viewer_TransformChanged(ByVal sender As Object, ByVal e As EventArgs) 
   Dim viewer As ImageViewer = TryCast(sender, ImageViewer) 
   Dim s As String = String.Format("TransformChanged Event: {0}", viewer.Transform.ToString()) 
   MessageBox.Show(s) 
End Sub 
 
Public Sub ImageViewer_TransformChanged(ByVal viewer As ImageViewer) 
   AddHandler viewer.TransformChanged, AddressOf viewer_TransformChanged 
 
   Select Case viewer.SizeMode 
      Case SizeMode.Fit 
         viewer.SizeMode = SizeMode.FitAlways 
 
      Case SizeMode.FitAlways 
         viewer.SizeMode = SizeMode.FitWidth 
 
      Case SizeMode.FitWidth 
         viewer.SizeMode = SizeMode.Normal 
 
      Case SizeMode.Normal 
         viewer.SizeMode = SizeMode.Stretch 
 
      Case SizeMode.Stretch 
         viewer.SizeMode = SizeMode.Fit 
   End Select 
 
   RemoveHandler viewer.TransformChanged, AddressOf viewer_TransformChanged 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Controls Assembly