LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly)
LEAD Technologies, Inc

TransformChanged Event (ImageBox)

Example 





Occurs when any visual transformation properties changes in the control. .NET support Silverlight support
Syntax
public event EventHandler TransformChanged
'Declaration
 
Public Event TransformChanged As EventHandler
'Usage
 
Dim instance As ImageBox
Dim handler As EventHandler
 
AddHandler instance.TransformChanged, handler
public event EventHandler TransformChanged
add_TransformChanged(function(sender, e))
remove_TransformChanged(function(sender, e))

public:
event EventHandler^ TransformChanged
Remarks

This event is raised if any of the properties of the controls that effects the way the image will be displayed is changed such as:

You can use the TransformChanged event as catch all placeholder to update external properties or UI elements whenever the user scrolls or zooms the image for example instead of hooking to individual properties OnXYZChanged events.

Example
Copy CodeCopy Code  
Private Sub viewer_TransformChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim viewer As ImageBox = TryCast(sender, ImageBox)
    Dim s As String = String.Format("TransformChanged Event: {0}", viewer.Transform.ToString())
    MessageBox.Show(s)
End Sub
Public Sub ImageBox_TransformChanged(ByVal viewer As ImageBox)
    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
private void viewer_TransformChanged(object sender, EventArgs e)
{
   ImageBox viewer = sender as ImageBox;
   string s = string.Format("TransformChanged Event: {0}", viewer.Transform.ToString());
   MessageBox.Show(s);
}
public void ImageBox_TransformChanged(ImageBox 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);
}
private void viewer_TransformChanged(object sender, EventArgs e)
{
   ImageBox viewer = sender as ImageBox;
   string s = string.Format("TransformChanged Event: {0}", viewer.Transform.ToString());
   MessageBox.Show(s);
}
public void ImageBox_TransformChanged(ImageBox 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);
}
Private Sub viewer_TransformChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim viewer As ImageBox = TryCast(sender, ImageBox)
   Dim s As String = String.Format("TransformChanged Event: {0}", viewer.Transform.ToString())
   MessageBox.Show(s)
End Sub
Public Sub ImageBox_TransformChanged(ByVal viewer As ImageBox)
   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: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ImageBox Class
ImageBox Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.