Represents a LEADTOOLS image pan control for displaying a scaled view of an image.
public class ImagePanViewer : IComponentConnector, UserControl Public Class ImagePanViewerInherits System.Windows.Controls.UserControlImplements System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
public ref class ImagePanViewer : public System.Windows.Controls.UserControl, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable The ImagePanViewer control is used to display a scaled view of an image, which is also being displayed in the ImageViewer or RasterImageViewer controls at a size that would require scrolling.
ImagePanViewer will maintain the images aspect ratio, a colored pan rectangle will be displayed to indicate the portion of the image currently being displayed in the ImageViewer or RasterImageViewer associated with this pan control.
When a user clicks inside the ImagePanViewer and moves the mouse while holding down the button, the pan rectangle will move with the mouse pointer.
Set the Source property to the ImageViewer or RasterImageViewer object to be panned.
The control draws the pan rectangle using the Stroke as its color, StrokeThickness as the size of the rectangle border in pixels. You can fill the area inside the pan rectangle with InnerBrush and the area outside the pan rectangle with OuterBrush.
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : Window{public ImagePanViewer panViewer;public ImageViewer viewer;public DockPanel dockPanel;public MyWindow1(string title): base(){Title = title;// Set the size of the windowWidth = 800;Height = 600;// Create the viewerviewer = new ImageViewer();viewer.Width = 400;viewer.Height = 400;// Load an imageviewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));panViewer = new ImagePanViewer();panViewer.Width = 200;panViewer.Height = 200;panViewer.HorizontalAlignment = HorizontalAlignment.Center;panViewer.VerticalAlignment = VerticalAlignment.Center;panViewer.Pan += new EventHandler<ImagePanViewerEventArgs>(panViewer_Pan);dockPanel = new DockPanel();Content = dockPanel;dockPanel.Children.Add(viewer);dockPanel.Children.Add(panViewer);DockPanel.SetDock(panViewer, Dock.Top);panViewer.Stroke = Brushes.Blue;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();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits WindowPublic panViewer As ImagePanViewerPublic viewer As ImageViewerPublic dockPanel As DockPanelPublic Sub New(ByVal title As String)MyBase.New()title = title' Set the size of the windowWidth = 800Height = 600' Create the viewerviewer = New ImageViewer()viewer.Width = 400viewer.Height = 400' Load an imageviewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))panViewer = New ImagePanViewer()panViewer.Width = 200panViewer.Height = 200panViewer.HorizontalAlignment = HorizontalAlignment.CenterpanViewer.VerticalAlignment = VerticalAlignment.CenterAddHandler panViewer.Pan, AddressOf panViewer_PandockPanel = New DockPanel()Content = dockPaneldockPanel.Children.Add(viewer)dockPanel.Children.Add(panViewer)dockPanel.SetDock(panViewer, Dock.Top)panViewer.Stroke = Brushes.BlueDim 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 Point(10, 10)panViewer.Cursor = Cursors.HandpanViewer.Source = viewerEnd SubPrivate Sub panViewer_Pan(ByVal sender As Object, ByVal e As ImagePanViewerEventArgs)Select Case e.StatusCase ImagePanViewerStatus.Begin, ImagePanViewerStatus.Panning, ImagePanViewerStatus.EndTitle = "Pan Status = " & e.Status.ToString() & " Rectangle =" & e.Rectangle.ToString() & " Cancel = " & e.Cancel.ToString()Console.WriteLine(Title)Exit SelectEnd SelectEnd SubEnd ClassPublic Sub ImagePanViewer_Source()Dim window As MyWindow1 = New MyWindow1("Test_MyImagePanViewer: Writes events to console")window.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : ChildWindow{public ImagePanViewer panViewer;public ImageViewer viewer;public StackPanel stackPanel;public MyWindow1(string title): base(){Title = title;// Set the size of the windowWidth = 800;Height = 600;// Create the viewerviewer = new ImageViewer();viewer.Width = 400;viewer.Height = 400;// Load an imageviewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));panViewer = new ImagePanViewer();panViewer.Width = 200;panViewer.Height = 200;panViewer.HorizontalAlignment = HorizontalAlignment.Center;panViewer.VerticalAlignment = VerticalAlignment.Center;panViewer.Pan += new EventHandler<ImagePanViewerEventArgs>(panViewer_Pan);stackPanel = new StackPanel();Content = stackPanel;stackPanel.Children.Add(viewer);stackPanel.Children.Add(panViewer);panViewer.Stroke = new SolidColorBrush(Colors.Blue);GradientStop color1 = new GradientStop();color1.Color = Colors.Red;GradientStop color2 = new GradientStop();color2.Color = Colors.Black;GradientStopCollection csc = new GradientStopCollection();csc.Add(color1);csc.Add(color2);Brush brush = new LinearGradientBrush(csc, 45.0);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.Show();}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits ChildWindowPublic panViewer As ImagePanViewerPublic viewer As ImageViewerPublic stackPanel As StackPanelPublic Sub New(ByVal title As String)MyBase.New()title = title' Set the size of the windowWidth = 800Height = 600' Create the viewerviewer = New ImageViewer()viewer.Width = 400viewer.Height = 400' Load an imageviewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))panViewer = New ImagePanViewer()panViewer.Width = 200panViewer.Height = 200panViewer.HorizontalAlignment = HorizontalAlignment.CenterpanViewer.VerticalAlignment = VerticalAlignment.CenterAddHandler panViewer.Pan, AddressOf panViewer_PanstackPanel = New StackPanel()Content = stackPanelstackPanel.Children.Add(viewer)stackPanel.Children.Add(panViewer)panViewer.Stroke = New SolidColorBrush(Colors.Blue)Dim color1 As GradientStop = New GradientStop()color1.Color = Colors.RedDim color2 As GradientStop = New GradientStop()color2.Color = Colors.BlackDim csc As GradientStopCollection = New GradientStopCollection()csc.Add(color1)csc.Add(color2)Dim brush As Brush = New LinearGradientBrush(csc, 45.0)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.HandpanViewer.Source = viewerEnd SubPrivate Sub panViewer_Pan(ByVal sender As Object, ByVal e As ImagePanViewerEventArgs)Select Case e.StatusCase ImagePanViewerStatus.Begin, ImagePanViewerStatus.Panning, ImagePanViewerStatus.EndTitle = "Pan Status = " & e.Status.ToString() & " Rectangle =" & e.Rectangle.ToString() & " Cancel = " & e.Cancel.ToString()Console.WriteLine(Title)Exit SelectEnd SelectEnd SubEnd ClassPublic Sub ImagePanViewer_Source()Dim window As MyWindow1 = New MyWindow1("Test_MyImagePanViewer: Writes events to console")window.Show()End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
