Raises the
SourceChanged event.
Syntax
Example
Visual Basic | Copy Code |
---|
Public Sub ImagePanViewer_SourceChanged(ByVal panViewer As ImagePanViewer)
' set up the event handlers
AddHandler panViewer.StrokeChanged, AddressOf panViewer_StrokeChanged
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 ImageViewer = panViewer.Source
' fires the SourceChanged event twice
panViewer.Source = Nothing
panViewer.Source = viewerOld
' change some properties
panViewer.Stroke = Brushes.Black
panViewer.StrokeThickness = 2
panViewer.Position = New Point(20, 20)
End Sub
Private Sub panViewer_PositionChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of 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_StrokeChanged(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("Rectangle Stroke Changed to " & panViewer.StrokeThickness.ToString() & "Thickness and to" & panViewer.Stroke.ToString() & "Color")
End If
End Sub
Private Sub panViewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of ImageViewer))
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.StrokeChanged += new RoutedPropertyChangedEventHandler<Brush>(panViewer_StrokeChanged);
panViewer.SourceChanged += new RoutedPropertyChangedEventHandler<ImageViewer>(panViewer_SourceChanged);
panViewer.InnerBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(panViewer_InnerBrushChanged);
panViewer.OuterBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(panViewer_OuterBrushChanged);
panViewer.PositionChanged += new RoutedPropertyChangedEventHandler<Point>(panViewer_PositionChanged);
ImageViewer viewerOld = panViewer.Source;
// fires the SourceChanged event twice
panViewer.Source = null;
panViewer.Source = viewerOld;
// change some properties
panViewer.Stroke = Brushes.Black;
panViewer.StrokeThickness = 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_StrokeChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e)
{
ImagePanViewer panViewer = (ImagePanViewer)sender;
if(panViewer != null)
Console.WriteLine("Rectangle Stroke Changed to " + panViewer.StrokeThickness.ToString() +"Thickness and to" + panViewer.Stroke.ToString()+ "Color");
}
private void panViewer_SourceChanged(object sender, RoutedPropertyChangedEventArgs<ImageViewer> 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");
}
} |
SilverlightCSharp | Copy Code |
---|
public void ImagePanViewer_SourceChanged(ImagePanViewer panViewer)
{
// set up the event handlers
panViewer.StrokeChanged += new RoutedPropertyChangedEventHandler<Brush>(panViewer_StrokeChanged);
panViewer.SourceChanged += new RoutedPropertyChangedEventHandler<ImageViewer>(panViewer_SourceChanged);
panViewer.InnerBrushChanged += new RoutedPropertyChangedEventHandler<Brush>(panViewer_InnerBrushChanged);
panViewer.OuterBrushChanged += new RoutedPropertyChangedEventHandler<Brush>(panViewer_OuterBrushChanged);
panViewer.PositionChanged += new RoutedPropertyChangedEventHandler<Point>(panViewer_PositionChanged);
ImageViewer viewerOld = panViewer.Source;
// fires the SourceChanged event twice
panViewer.Source = null;
panViewer.Source = viewerOld;
// change some properties
panViewer.Stroke = new SolidColorBrush(Colors.Black);
panViewer.StrokeThickness = 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_StrokeChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e)
{
ImagePanViewer panViewer = (ImagePanViewer)sender;
if (panViewer != null)
Console.WriteLine("Rectangle Stroke Changed to " + panViewer.StrokeThickness.ToString() + "Thickness and to" + panViewer.Stroke.ToString() + "Color");
}
private void panViewer_SourceChanged(object sender, RoutedPropertyChangedEventArgs<ImageViewer> 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");
}
} |
SilverlightVB | Copy Code |
---|
Public Sub ImagePanViewer_SourceChanged(ByVal panViewer As ImagePanViewer)
' set up the event handlers
AddHandler panViewer.StrokeChanged, AddressOf panViewer_StrokeChanged
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 ImageViewer = panViewer.Source
' fires the SourceChanged event twice
panViewer.Source = Nothing
panViewer.Source = viewerOld
' change some properties
panViewer.Stroke = New SolidColorBrush(Colors.Black)
panViewer.StrokeThickness = 2
panViewer.Position = New Point(20, 20)
End Sub
Private Sub panViewer_PositionChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of 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_StrokeChanged(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("Rectangle Stroke Changed to " & panViewer.StrokeThickness.ToString() & "Thickness and to" & panViewer.Stroke.ToString() & "Color")
End If
End Sub
Private Sub panViewer_SourceChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of ImageViewer))
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 |
Remarks
Requirements
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also