Occurs when the value of the
Viewer property changes.
Syntax
Visual Basic (Declaration) | |
---|
Public Event ViewerChanged() As EventHandler |
Example
This example displays events when various properties of the RasterImagePanViewer changed
Visual Basic | Copy Code |
---|
Public Sub RasterImagePanViewer_ViewerChanged(ByVal panViewer As RasterImagePanViewer)
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
panViewer.Viewer = Nothing
panViewer.Viewer = viewerOld
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
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