Leadtools.Windows.Controls Send comments on this topic. | Back to Introduction - LEADTOOLS WPF | Help Version 16.5.9.25
SourceChanged Event
See Also  Example
Leadtools.Windows.Controls Namespace > ImagePanViewer Class : SourceChanged Event





Occurs when the value of the Source property changes.

Syntax

Visual Basic (Declaration) 
Public Event SourceChanged() As RoutedPropertyChangedEventHandler(Of BitmapSourceViewer)
Visual Basic (Usage)Copy Code
Dim instance As ImagePanViewer
Dim handler As RoutedPropertyChangedEventHandler(Of BitmapSourceViewer)
 
AddHandler instance.SourceChanged, handler
C# 
public event RoutedPropertyChangedEventHandler<BitmapSourceViewer> SourceChanged()
C++/CLI 
public:
event RoutedPropertyChangedEventHandler<BitmapSourceViewer> SourceChanged();
XAML Attributes Usage 

<object SourceChanged=EventHandler<ExceptionRoutedEventArgs>/> ...

Routed Event Information 

Identifier field

SourceChangedEvent

Routing strategy

Bubbling

Delegate

EventHandler<(Of <(TEventArgs>)>)

XAML Attributes Usage 

<object SourceChanged=EventHandler<ExceptionRoutedEventArgs>/> ...

Routed Event Information 

Identifier field

SourceChangedEvent

Routing strategy

Bubbling

Delegate

EventHandler<(Of <(TEventArgs>)>)

Example

This example uses the SourceChanged event to show how the Source has changed.

Visual BasicCopy Code
Public Sub ImagePanViewer_SourceChanged(ByVal panViewer As ImagePanViewer)
   ' set up the event handlers
   AddHandler panViewer.RectanglePenChanged, AddressOf panViewer_RectanglePenChanged
   AddHandler panViewer.SourceChanged, AddressOf panViewer_SourceChanged
   AddHandler panViewer.InnerBrushChanged, AddressOf panViewer_InnerBrushChanged
   AddHandler panViewer.OuterBrushChanged, AddressOf panViewer_OuterBrushChanged
   AddHandler panViewer.PositionChanged, AddressOf panViewer_PositionChanged
   Dim viewerOld As BitmapSourceViewer = panViewer.Source
   ' fires the SourceChanged event twice
   panViewer.Source = Nothing
   panViewer.Source = viewerOld

   ' change some properties
   panViewer.RectanglePen = New Pen(Brushes.Black, 2)
   panViewer.Position = New System.Windows.Point(20, 20)
End Sub

Private Sub panViewer_PositionChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of System.Windows.Point))
   Dim panViewer As ImagePanViewer = CType(sender, ImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Position Changed to " & panViewer.Position.ToString())
   End If
End Sub

Private Sub panViewer_OuterBrushChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Brush))
   Dim panViewer As ImagePanViewer = CType(sender, ImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Inner Brush Changed to " & panViewer.OuterBrush.ToString() & "Color")
   End If
End Sub

Private Sub panViewer_InnerBrushChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Brush))
   Dim panViewer As ImagePanViewer = CType(sender, ImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Inner Brush Changed to " & panViewer.InnerBrush.ToString() & "Color")
   End If
End Sub

Private Sub panViewer_RectanglePenChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Pen))
   Dim panViewer As ImagePanViewer = CType(sender, ImagePanViewer)
   If Not panViewer Is Nothing Then
      Console.WriteLine("Rectangle Pen Changed to " & panViewer.RectanglePen.Thickness.ToString() & "Thickness and to" & panViewer.RectanglePen.Brush.ToString() & "Color")
   End If
End Sub

Private Sub panViewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of BitmapSourceViewer))
   Dim panViewer As ImagePanViewer = CType(sender, ImagePanViewer)
   If Not panViewer Is Nothing Then
      If panViewer.Source Is Nothing Then
         Console.WriteLine("There is no Viewer control associated with the ImagePanViewer Control")
      Else
         Console.WriteLine("A Viewer is now associated with the ImagePanViewer Control")
      End If
   End If
End Sub
C#Copy Code
public void ImagePanViewer_SourceChanged(ImagePanViewer panViewer) 

   // set up the event handlers 
   panViewer.RectanglePenChanged += new RoutedPropertyChangedEventHandler<Pen>(panViewer_RectanglePenChanged); 
   panViewer.SourceChanged += new RoutedPropertyChangedEventHandler<BitmapSourceViewer>(panViewer_SourceChanged); 
   panViewer.InnerBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(panViewer_InnerBrushChanged); 
   panViewer.OuterBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(panViewer_OuterBrushChanged); 
   panViewer.PositionChanged += new RoutedPropertyChangedEventHandler<Point>(panViewer_PositionChanged); 
   BitmapSourceViewer viewerOld = panViewer.Source; 
   // fires the SourceChanged event twice 
   panViewer.Source = null; 
   panViewer.Source = viewerOld; 
 
   // change some properties 
   panViewer.RectanglePen = new Pen(Brushes.Black, 2); 
 
   panViewer.Position = new Point(20, 20); 

 
void panViewer_PositionChanged(object sender, RoutedPropertyChangedEventArgs<Point> e) 

   ImagePanViewer panViewer = (ImagePanViewer)sender; 
   if (panViewer != null) 
      Console.WriteLine("Position Changed to " + panViewer.Position.ToString()); 

 
void panViewer_OuterBrushChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e) 

   ImagePanViewer panViewer = (ImagePanViewer)sender; 
   if (panViewer != null) 
      Console.WriteLine("Inner Brush Changed to " + panViewer.OuterBrush.ToString() + "Color"); 

 
void panViewer_InnerBrushChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e) 

   ImagePanViewer panViewer = (ImagePanViewer)sender; 
   if (panViewer != null) 
      Console.WriteLine("Inner Brush Changed to " + panViewer.InnerBrush.ToString() + "Color"); 

 
private void panViewer_RectanglePenChanged(object sender, RoutedPropertyChangedEventArgs<Pen> e) 

   ImagePanViewer panViewer = (ImagePanViewer)sender; 
   if(panViewer != null) 
      Console.WriteLine("Rectangle Pen Changed to " + panViewer.RectanglePen.Thickness.ToString() +"Thickness and to"  + panViewer.RectanglePen.Brush.ToString()+ "Color"); 

 
private void panViewer_SourceChanged(object sender, RoutedPropertyChangedEventArgs<BitmapSourceViewer> e) 

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

Remarks

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

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also