Leadtools.WinForms Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ViewerChanged Event
See Also  Example
Leadtools.WinForms Namespace > RasterImagePanViewer Class : ViewerChanged Event



Occurs when the value of the Viewer property changes.

Syntax

Visual Basic (Declaration) 
Public Event ViewerChanged() As EventHandler
Visual Basic (Usage)Copy Code
Dim instance As RasterImagePanViewer
Dim handler As EventHandler
 
AddHandler instance.ViewerChanged, handler
C# 
public event EventHandler ViewerChanged()
C++/CLI 
public:
event EventHandler^ ViewerChanged();

Example

This example displays events when various properties of the RasterImagePanViewer changed

Visual BasicCopy Code
Public Sub RasterImagePanViewer_ViewerChanged(ByVal panViewer As RasterImagePanViewer)
   ' set up the event handlers
   AddHandler panViewer.RectangleColorChanged, AddressOf panViewer_RectColorChanged
   AddHandler panViewer.ImageColorChanged, AddressOf panViewer_ImageColorChanged
   AddHandler panViewer.ClipCursorChanged, AddressOf panViewer_ClipCursorChanged
   AddHandler panViewer.ViewerChanged, AddressOf panViewer_ViewerChanged
   Dim viewerOld As RasterImageViewer = panViewer.Viewer
   ' fires the ViewerChanged event twice
   panViewer.Viewer = Nothing
   panViewer.Viewer = viewerOld

   ' change some properties
   If panViewer.BorderStyle <> BorderStyle.None Then
      panViewer.BorderStyle = BorderStyle.None
   End If
   panViewer.RectangleColor = Color.Black
   panViewer.ImageColor = Color.Red
   panViewer.ClipCursor = False
   panViewer.Refresh()
End Sub

Private Sub panViewer_RectColorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim panViewer As RasterImagePanViewer = CType(sender, RasterImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Rectangle Color Changed to " & panViewer.RectangleColor.ToString())
   End If
End Sub

Private Sub panViewer_ImageColorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim panViewer As RasterImagePanViewer = CType(sender, RasterImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Image Color Changed to " & panViewer.ImageColor.ToString())
   End If
End Sub

Private Sub panViewer_ClipCursorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim panViewer As RasterImagePanViewer = CType(sender, RasterImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Clip Cursor changed to " & panViewer.ClipCursor.ToString())
   End If
End Sub
Private Sub panViewer_ViewerChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim panViewer As RasterImagePanViewer = CType(sender, RasterImagePanViewer)
   If Not panViewer Is Nothing Then
      If panViewer.Viewer Is Nothing Then
         Console.WriteLine("There is no Viewer control associated with the RasterImagePanViewer Control")
      Else
         Console.WriteLine("A Viewer is now associated with the RasterImagePanViewer Control")
      End If
   End If
End Sub
C#Copy Code
public void RasterImagePanViewer_ViewerChanged(RasterImagePanViewer panViewer) 

   // set up the event handlers 
   panViewer.RectangleColorChanged += new EventHandler(panViewer_RectColorChanged); 
   panViewer.ImageColorChanged += new EventHandler(panViewer_ImageColorChanged); 
   panViewer.ClipCursorChanged += new EventHandler(panViewer_ClipCursorChanged); 
   panViewer.ViewerChanged += new EventHandler(panViewer_ViewerChanged); 
   RasterImageViewer viewerOld = panViewer.Viewer; 
   // fires the ViewerChanged event twice 
   panViewer.Viewer = null; 
   panViewer.Viewer = viewerOld; 
 
   // change some properties 
   if(panViewer.BorderStyle != BorderStyle.None) 
   { 
      panViewer.BorderStyle = BorderStyle.None; 
   } 
   panViewer.RectangleColor = Color.Black; 
   panViewer.ImageColor = Color.Red; 
   panViewer.ClipCursor = false; 
   panViewer.Refresh(); 

 
private void panViewer_RectColorChanged(object sender, EventArgs e) 

   RasterImagePanViewer panViewer = (RasterImagePanViewer)sender; 
   if (panViewer != null) 
      Console.WriteLine("Rectangle Color Changed to " + panViewer.RectangleColor.ToString()); 

 
private void panViewer_ImageColorChanged(object sender, EventArgs e) 

   RasterImagePanViewer panViewer = (RasterImagePanViewer)sender; 
   if(panViewer != null) 
      Console.WriteLine("Image Color Changed to " + panViewer.ImageColor.ToString()); 

 
private void panViewer_ClipCursorChanged(object sender, EventArgs e) 

   RasterImagePanViewer panViewer = (RasterImagePanViewer)sender; 
   if(panViewer != null) 
      Console.WriteLine("Clip Cursor changed to " + panViewer.ClipCursor.ToString()); 

private void panViewer_ViewerChanged(object sender, EventArgs e) 

   RasterImagePanViewer panViewer = (RasterImagePanViewer)sender; 
   if(panViewer != null) 
   { 
      if(panViewer.Viewer == null) 
         Console.WriteLine("There is no Viewer control associated with the RasterImagePanViewer Control"); 
      else 
         Console.WriteLine("A Viewer is now associated with the RasterImagePanViewer Control"); 
   } 
}

Remarks

This event is raised if the Viewer property is changed by either a programmatic modification or user interaction.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also