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





Gets or sets the viewer currently assigned for the panning process by the control. This is a dependency property.

Syntax

Visual Basic (Declaration) 
Public Property Source As BitmapSourceViewer
Visual Basic (Usage)Copy Code
Dim instance As ImagePanViewer
Dim value As BitmapSourceViewer
 
instance.Source = value
 
value = instance.Source
C# 
public BitmapSourceViewer Source {get; set;}
C++/CLI 
public:
property BitmapSourceViewer^ Source {
   BitmapSourceViewer^ get();
   void set (BitmapSourceViewer^ value);
}
XAML Syntax 
For XAML information, see the BitmapSource type.
XAML Attributes Usage 

<object Source=Leadtools.Windows.Controls.BitmapSourceViewer />

Dependencies Property Information 

Identifier field

SourceProperty

Metadata properties set to true

AffectsRender

XAML Property Element Usage 

<object> <object.Source> <Size .../> </object.Source> </object>

XAML Syntax 
For XAML information, see the BitmapSource type.
XAML Attributes Usage 

<object Source=Leadtools.Windows.Controls.BitmapSourceViewer />

Dependencies Property Information 

Identifier field

SourceProperty

Metadata properties set to true

AffectsRender

XAML Property Element Usage 

<object> <object.Source> <Size .../> </object.Source> </object>

Return Value

The viewer object, which has an image to be panned using the ImagePanViewer control.

Example

This example shows how to use a pan window with a BitmapSourceViewer.

Visual BasicCopy Code
Private Class MyWindow1 : Inherits Window
   Public panViewer As ImagePanViewer
   Public viewer As BitmapSourceViewer
   Public dockPanel As DockPanel
   Public Sub New(ByVal title As String)
      MyBase.New()
      title = title

      ' Set the size of the window
      Width = 800
      Height = 600

      ' Create the viewer
      viewer = New BitmapSourceViewer()
      viewer.Width = 400
      viewer.Height = 400

      ' Load an image
          viewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.jpg"))

      panViewer = New ImagePanViewer()
      panViewer.Width = 200
      panViewer.Height = 200
      panViewer.HorizontalAlignment = System.Windows.HorizontalAlignment.Center
      panViewer.VerticalAlignment = System.Windows.VerticalAlignment.Center
      AddHandler panViewer.Pan, AddressOf panViewer_Pan

      dockPanel = New DockPanel()
      Content = dockPanel
      dockPanel.Children.Add(viewer)
      dockPanel.Children.Add(panViewer)
      System.Windows.Controls.DockPanel.SetDock(panViewer, System.Windows.Controls.Dock.Top)

      panViewer.RectanglePen = New Pen(Brushes.Blue, 2)

      Dim brush As Brush = New LinearGradientBrush(Colors.Red, Colors.Black, 45)

      panViewer.InnerBrush = New SolidColorBrush(Color.FromArgb(128, 192, 192, 192))
      panViewer.OuterBrush = New SolidColorBrush(Color.FromArgb(128, 200, 192, 192))
      panViewer.Position = New System.Windows.Point(10, 10)

      panViewer.Cursor = Cursors.Hand
      panViewer.Source = viewer
   End Sub

   Private Sub panViewer_Pan(ByVal sender As Object, ByVal e As ImagePanViewerEventArgs)
      Select Case e.Status
         Case ImagePanViewerStatus.Begin, ImagePanViewerStatus.Panning, ImagePanViewerStatus.End
            Title = "Pan Status = " & e.Status.ToString() & " Rectangle =" & e.Rectangle.ToString() & " Cancel = " & e.Cancel.ToString()
            Console.WriteLine(Title)
            Exit Select
      End Select
   End Sub
End Class

Public Sub ImagePanViewer_Source()
   Dim window As MyWindow1 = New MyWindow1("Test_MyImagePanViewer: Writes events to console")
   window.ShowDialog()
End Sub
C#Copy Code
class MyWindow1 : Window 

   public ImagePanViewer panViewer; 
   public BitmapSourceViewer viewer; 
   public DockPanel dockPanel; 
   public MyWindow1(string title) 
      : base() 
   { 
      Title = title; 
 
      // Set the size of the window 
      Width = 800; 
      Height = 600; 
 
      // Create the viewer 
      viewer = new BitmapSourceViewer(); 
      viewer.Width = 400; 
      viewer.Height = 400; 
 
      // Load an image 
      viewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "slave.jpg")); 
 
      panViewer = new ImagePanViewer(); 
      panViewer.Width = 200; 
      panViewer.Height = 200; 
      panViewer.HorizontalAlignment = HorizontalAlignment.Center; 
      panViewer.VerticalAlignment = VerticalAlignment.Center; 
      panViewer.Pan += new ImagePanViewer.PanEventHandler(panViewer_Pan); 
 
      dockPanel = new DockPanel(); 
      Content = dockPanel; 
      dockPanel.Children.Add(viewer); 
      dockPanel.Children.Add(panViewer); 
      DockPanel.SetDock(panViewer, Dock.Top); 
 
      panViewer.RectanglePen = new Pen(Brushes.Blue, 2); 
      Brush brush = new LinearGradientBrush(Colors.Red, Colors.Black, 45); 
      panViewer.InnerBrush = new SolidColorBrush(Color.FromArgb(128, 192,192,192)); 
      panViewer.OuterBrush = new SolidColorBrush(Color.FromArgb(128, 200, 192, 192)); 
      panViewer.Position = new Point(10, 10); 
      panViewer.Cursor = Cursors.Hand; 
      panViewer.Source = viewer; 
   } 
 
   private void panViewer_Pan(object sender, ImagePanViewerEventArgs e) 
   { 
      switch(e.Status) 
      { 
         case ImagePanViewerStatus.Begin: 
         case ImagePanViewerStatus.Panning: 
         case ImagePanViewerStatus.End: 
            { 
               Title = "Pan Status = " + e.Status.ToString() + " Rectangle =" + e.Rectangle.ToString() + " Cancel = " + e.Cancel.ToString(); 
               Console.WriteLine(Title); 
               break; 
            } 
      } 
   } 

 
public void ImagePanViewer_Source() 

   MyWindow1 window = new MyWindow1("Test_MyImagePanViewer: Writes events to console"); 
   window.ShowDialog(); 
}
XAMLCopy Code
<Window x:Class="WPFSamples.ImagePanViewer" Title="ImagePanViewer" Height="600" Width="800" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> 
  <DockPanel> 
    <Leadtools_Windows_Controls:ImagePanViewer DockPanel.Dock="Bottom" Width="200" Height="200" Source="{Binding ElementName=Viewer}" Pan="panViewer_Pan" Posintion="10,10" OuterBrushChanged="panViewer_OuterBrushChanged" InnerBrushChanged="panViewer_InnerBrushChanged" SourceChanged="panViewer_SourceChanged" RectanglePenChanged="panViewer_RectanglePenChanged" PositionChanged="panViewer_PositionChanged" Cursor="Hand"> 
      <Leadtools_Windows_Controls:ImagePanViewer.RectanglePen> 
        <Pen Brush="Red" Thickness="2" /> 
      </Leadtools_Windows_Controls:ImagePanViewer.RectanglePen> 
      <Leadtools_Windows_Controls:ImagePanViewer.OuterBrush> 
        <SolidColorBrush Color="Gray" Opacity=".4" /> 
      </Leadtools_Windows_Controls:ImagePanViewer.OuterBrush> 
      <Leadtools_Windows_Controls:ImagePanViewer.InnerBrush> 
        <SolidColorBrush Color="Blue" Opacity=".3" /> 
      </Leadtools_Windows_Controls:ImagePanViewer.InnerBrush> 
    </Leadtools_Windows_Controls:ImagePanViewer> 
    <Leadtools_Windows_Controls:BitmapSourceViewer x:Name="Viewer" Source="file:///C:\Program Files\LEAD Technologies\LEADTOOLS 16\Images\slave.jpg" Width="400" Height="400" /> 
  </DockPanel> 
</Window>

Remarks

This property contains the BitmapSourceViewer object which contains an image to be panned using the ImagePanViewer control. Whenever the Viewer property is changed, the image displayed in the ImagePanViewer control is affected by this change.

Requirements

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

See Also