LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly)
LEAD Technologies, Inc

RasterImageBox Class

Example 





Members 
Represents a control that displays a LEADTOOLS Leadtools.RasterImage in WPF/Silverlight. .NET support Silverlight support
Object Model
RasterImageBox Class
Syntax
Remarks

The RasterImageBox class derives from ImageBox and adds functionality to display a LEADTOOLS Leadtools.RasterImage object in WPF/Silverlight applications. To display a System.Windows.Media.ImageSource or one of its derived classes, use the ImageBox control.

In addition to all the features supported by the ImageBox class, RasterImageBox adds the following:

Example
Copy CodeCopy Code  
Private Class MyWindow1 : Inherits Window
      Private theViewer As RasterImageBox
      Public Sub New()
         ' Create the  viewer
         theViewer = New RasterImageBox()

         ' Create Dock Panel

         Dim panel As DockPanel = New DockPanel()
         Content = panel

         DockPanel.SetDock(theViewer, Dock.Bottom)

         theViewer.HorizontalAlignment = HorizontalAlignment.Center
         theViewer.VerticalAlignment = VerticalAlignment.Bottom
         theViewer.UseDpi = True

         panel.Children.Add(theViewer)

         ' Load an image into the viewer

         Using codecs As RasterCodecs = New RasterCodecs()
            theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 1, CodecsLoadByteOrder.Bgr, 1, 1)
         End Using

         Dim flip As FlipCommand = New FlipCommand()
         flip.Run(theViewer.Image)

         Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)

         AddHandler theViewer.MouseDown, AddressOf theViewer_MouseClick
      End Sub

      Private Sub theViewer_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
         Select Case theViewer.SizeMode
            Case SizeMode.Normal
               theViewer.SizeMode = SizeMode.Stretch

            Case SizeMode.Stretch
               theViewer.SizeMode = SizeMode.Fit

            Case SizeMode.Fit
               theViewer.SizeMode = SizeMode.FitAlways

            Case SizeMode.FitAlways
               theViewer.SizeMode = SizeMode.FitWidth

            Case SizeMode.FitWidth
               theViewer.SizeMode = SizeMode.Normal
         End Select

         Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)

      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
class MyWindow1 : Window
   {
      RasterImageBox theViewer;
      public MyWindow1()
      {
         // Create the  viewer
         theViewer = new RasterImageBox();

         // Create Dock Panel

         DockPanel panel = new DockPanel();
         Content = panel;

         DockPanel.SetDock(theViewer, Dock.Bottom);

         theViewer.HorizontalAlignment = HorizontalAlignment.Center;
         theViewer.VerticalAlignment = VerticalAlignment.Bottom;
         theViewer.UseDpi = true;

         panel.Children.Add(theViewer);

         // Load an image into the viewer

         using (RasterCodecs codecs = new RasterCodecs())
         {
            theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 1, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1);
         }

         FlipCommand flip = new FlipCommand();
         flip.Run(theViewer.Image);

         Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);

         theViewer.MouseDown += new MouseButtonEventHandler(theViewer_MouseClick);
      }

      void theViewer_MouseClick(object sender, MouseButtonEventArgs e)
      {
         switch (theViewer.SizeMode)
         {
            case SizeMode.Normal:
               theViewer.SizeMode = SizeMode.Stretch;
               break;

            case SizeMode.Stretch:
               theViewer.SizeMode = SizeMode.Fit;
               break;

            case SizeMode.Fit:
               theViewer.SizeMode = SizeMode.FitAlways;
               break;

            case SizeMode.FitAlways:
               theViewer.SizeMode = SizeMode.FitWidth;
               break;

            case SizeMode.FitWidth:
               theViewer.SizeMode = SizeMode.Normal;
               break;
         }

         Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);

      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
class MyWindow1 : ChildWindow
{
   RasterImageBox theViewer;
   public MyWindow1()
   {
      // Create the  viewer
      theViewer = new RasterImageBox();

      // Create Dock Panel

      StackPanel panel = new StackPanel();
      Content = panel;

      theViewer.HorizontalAlignment = HorizontalAlignment.Center;
      theViewer.VerticalAlignment = VerticalAlignment.Bottom;
      theViewer.UseDpi = true;

      panel.Children.Add(theViewer);

      // Load an image into the viewer

      RasterCodecs codecs = new RasterCodecs();
      theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 1, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1);

      FlipCommand flip = new FlipCommand();
      flip.Run(theViewer.Image);

      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);

      theViewer.MouseLeftButtonDown += new MouseButtonEventHandler(theViewer_MouseLeftButtonDown);
   }

   void theViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
   {
      switch (theViewer.SizeMode)
      {
         case SizeMode.Normal:
            theViewer.SizeMode = SizeMode.Stretch;
            break;

         case SizeMode.Stretch:
            theViewer.SizeMode = SizeMode.Fit;
            break;

         case SizeMode.Fit:
            theViewer.SizeMode = SizeMode.FitAlways;
            break;

         case SizeMode.FitAlways:
            theViewer.SizeMode = SizeMode.FitWidth;
            break;

         case SizeMode.FitWidth:
            theViewer.SizeMode = SizeMode.Normal;
            break;
      }

      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
   }
}
Private Class MyWindow1 : Inherits ChildWindow
   Private theViewer As RasterImageBox
   Public Sub New()
      ' Create the  viewer
      theViewer = New RasterImageBox()

      ' Create Dock Panel

      Dim panel As StackPanel = New StackPanel()
      Content = panel

      theViewer.HorizontalAlignment = HorizontalAlignment.Center
      theViewer.VerticalAlignment = VerticalAlignment.Bottom
      theViewer.UseDpi = True

      panel.Children.Add(theViewer)

      ' Load an image into the viewer

      Dim codecs As RasterCodecs = New RasterCodecs()
      theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path & "Image1.cmp", 1, CodecsLoadByteOrder.Bgr, 1, 1)

      Dim flip As FlipCommand = New FlipCommand()
      flip.Run(theViewer.Image)

      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)

      AddHandler theViewer.MouseLeftButtonDown, AddressOf theViewer_MouseLeftButtonDown
   End Sub

   Private Sub theViewer_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
      Select Case theViewer.SizeMode
         Case SizeMode.Normal
            theViewer.SizeMode = SizeMode.Stretch

         Case SizeMode.Stretch
            theViewer.SizeMode = SizeMode.Fit

         Case SizeMode.Fit
            theViewer.SizeMode = SizeMode.FitAlways

         Case SizeMode.FitAlways
            theViewer.SizeMode = SizeMode.FitWidth

         Case SizeMode.FitWidth
            theViewer.SizeMode = SizeMode.Normal
      End Select

      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)
   End Sub
End Class
<Window x:Class="WPFSamples.RasterImageBox"
    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"
    Height="600" Width="800">
  <DockPanel>
    <Leadtools_Windows_Controls:RasterImageBox
                Name="theImage"
                Image="file:///c:\users\Public\Documents\LEADTOOLS Images\Image1.cmp"
                DockPanel.Dock= "Bottom"
                HorizontalAlignment="Center" VerticalAlignment="Bottom"
                UseDpi="false"
                    />
  </DockPanel>
  <Window.Title>
    "RasterImageBox"
  </Window.Title>
</Window>
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImageBox Members
Leadtools.Windows.Controls Namespace
RasterImage and WPF/Silverlight

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.