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

RasterImageListItem Class

Example 





Members 
Represents an item in a ImageList control containing a LEADTOOLS Leadtools.RasterImage. .NET support Silverlight support
Object Model
RasterImageListItem Class
Syntax
Remarks

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

In addition to all the features supported by the ImageListItem class, RasterImageListItem adds the following:

Example
Copy CodeCopy Code  
Private Class MyWindow2 : Inherits Window
         Public imageList As ListBox
         Public Sub New(ByVal title As String)
             title = title
             ' Set the size of the window
             Width = 400
             Height = 200

             ' Create a new ImageList control.
             imageList = New ListBox()
             imageList.Width = Double.NaN
             imageList.Height = Double.NaN

             imageList.Items.SortDescriptions.Clear()
             imageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)
             imageList.Items.SortDescriptions.Add(New SortDescription("Text", ListSortDirection.Ascending))

             imageList.BorderThickness = New Thickness(5, 5, 5, 5)


             ' Create three items
             Dim imagesPath As String = LEAD_VARS.ImagesDir
             Try

                 Using codecs As RasterCodecs = New RasterCodecs()
                     For i As Integer = 0 To 2
                         Dim index As Integer = i + 1
                         Dim imageFileName As String = Path.Combine(imagesPath, "ImageProcessingDemo\Image" & index.ToString() & ".jpg")

                         Dim item As RasterImageListItem = New RasterImageListItem()
                         item.Uri = New Uri(imageFileName)
                         item.Text = imageFileName
                         item.ShowText = True

                         item.Image = codecs.Load(imageFileName)
                         item.ImageSize = New Size(120, 120)
                         item.Width = 150
                         item.Height = 150
                         item.SelectedBackground = Brushes.White
                         item.SelectedForeground = Brushes.Blue

                         ' Select the first item
                         If i = 0 Then
                             item.IsSelected = True
                         End If

                         ' Add the item to the image list
                         imageList.Items.Add(item)
                     Next i
                 End Using
             Catch ex As Exception
                 MessageBox.Show(ex.Message)
             Finally
             End Try

             ' Add the ImageList to the Window.
             Content = imageList
         End Sub
     End Class

     Public Sub ImageListItem_RasterImageListItem(ByVal title As String)
         Dim window As MyWindow1 = New MyWindow1(title)
         window.ShowDialog()
     End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
class MyWindow2 : Window
   {
      public ImageList imageList;
      public MyWindow2(string title)
      {
         Title = title;
         // Set the size of the window
         Width = 400;
         Height = 200;

         // Create a new ImageList control.
         imageList = new ImageList();
         imageList.Width = Double.NaN;
         imageList.Height = Double.NaN;

         imageList.Items.SortDescriptions.Clear();
         imageList.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray);
         imageList.Items.SortDescriptions.Add(new SortDescription("Text", ListSortDirection.Ascending));

         imageList.BorderThickness = new Thickness(5, 5, 5, 5);


         // Create three items
         string imagesPath = LEAD_VARS.ImagesDir;
         try
         {

            using (RasterCodecs codecs = new RasterCodecs())
            {
               for (int i = 0; i < 3; i++)
               {
                  int index = i + 1;
                  string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".jpg");

                  RasterImageListItem item = new RasterImageListItem();
                  item.Uri = new Uri(imageFileName);
                  item.Text = imageFileName;
                  item.ShowText = true;

                  item.Image = codecs.Load(imageFileName);
                  item.ImageSize = new Size(120, 120);
                  item.Width = 150;
                  item.Height = 150;
                  item.SelectedBackground = Brushes.White;
                  item.SelectedForeground = Brushes.Blue;

                  // Select the first item
                  if (i == 0)
                     item.IsSelected = true;

                  // Add the item to the image list
                  imageList.Items.Add(item);
               }
            }
         }
         catch (Exception ex)
         {
            MessageBox.Show(ex.Message);
         }
         finally
         {
         }

         // Add the ImageList to the Window.
         Content = imageList;
      }
   }

   public void ImageListItem_RasterImageListItem(string title)
   {
      MyWindow1 window = new MyWindow1(title);
      window.ShowDialog();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
class MyWindow2 : ChildWindow
{
   public ListBox imageList;
   public MyWindow2(string title)
   {
      Title = title;
      // Set the size of the window
      Width = 400;
      Height = 200;

      // Create a new ImageList control.
      imageList = new ListBox();
      imageList.Width = Double.NaN;
      imageList.Height = Double.NaN;

      imageList.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray);
      imageList.BorderThickness = new Thickness(5, 5, 5, 5);


      // Create three items
      string imagesPath = LeadtoolsExamples.Common.ImagesPath.Path;
      try
      {
         RasterCodecs codecs = new RasterCodecs();
         for (int i = 0; i < 3; i++)
         {
            int index = i + 1;
            string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg";

            RasterImageListItem item = new RasterImageListItem();
            item.Uri = new Uri(imageFileName);
            item.Text = imageFileName;
            item.ShowText = true;

            item.Image = codecs.Load(imageFileName);
            item.ImageSize = new Size(120, 120);
            item.Width = 150;
            item.Height = 150;
            item.SelectedBackground = new SolidColorBrush(Colors.White);
            item.SelectedForeground = new SolidColorBrush(Colors.Blue);

            // Select the first item
            if (i == 0)
               item.IsSelected = true;

            // Add the item to the image list
            imageList.Items.Add(item);
         }
      }
      catch (Exception ex)
      {
         MessageBox.Show(ex.Message);
      }
      finally
      {
      }

      // Add the ImageList to the Window.
      Content = imageList;
   }
}

public void ImageListItem_RasterImageListItem(string title)
{
   MyWindow1 window = new MyWindow1(title);
   window.Show();
}
Private Class MyWindow2 : Inherits ChildWindow
   Public imageList As ListBox
   Public Sub New(ByVal title As String)
      title = title
      ' Set the size of the window
      Width = 400
      Height = 200

      ' Create a new ImageList control.
      ImageList = New ListBox()
      ImageList.Width = Double.NaN
      ImageList.Height = Double.NaN

      ImageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)
      ImageList.BorderThickness = New Thickness(5, 5, 5, 5)


      ' Create three items
      Dim imagesPath As String = LeadtoolsExamples.Common.ImagesPath.Path
      Try
         Dim codecs As RasterCodecs = New RasterCodecs()
         For i As Integer = 0 To 2
            Dim index As Integer = i + 1
            Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg"

            Dim item As RasterImageListItem = New RasterImageListItem()
            item.Uri = New Uri(imageFileName)
            item.Text = imageFileName
            item.ShowText = True

            item.Image = codecs.Load(imageFileName)
            item.ImageSize = New Size(120, 120)
            item.Width = 150
            item.Height = 150
            item.SelectedBackground = New SolidColorBrush(Colors.White)
            item.SelectedForeground = New SolidColorBrush(Colors.Blue)

            ' Select the first item
            If i = 0 Then
               item.IsSelected = True
            End If

            ' Add the item to the image list
            ImageList.Items.Add(item)
         Next i
      Catch ex As Exception
         MessageBox.Show(ex.Message)
      Finally
      End Try

      ' Add the ImageList to the Window.
      Content = ImageList
   End Sub
End Class

Public Sub ImageListItem_RasterImageListItem(ByVal title As String)
   Dim window As MyWindow1 = New MyWindow1(title)
   window.Show()
End Sub
<Window
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"
x:Class="ScrollStyle.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">
    <DockPanel>
       <Leadtools_Windows_Controls:ImageList Margin="8,46,8,196" HorizontalContentAlignment="Center" VerticalContentAlignment="Top" 
                                             Orientation="Vertical" ShowText="False" ItemForeground="#FF000000" ItemStyle="Normal" 
                                             ItemBorderThickness="2,2,2,2" ItemMargin="0,0,0,0" ItemSize="120,128" ItemImageSize="102,102" 
                                             DockPanel.Dock="Left">
          <Leadtools_Windows_Controls:RasterImageListItem Image="file:///c:\users\Public\Documents\LEADTOOLS Images\Image1.cmp"/>
          <Leadtools_Windows_Controls:RasterImageListItem Image="file:///c:\users\Public\Documents\LEADTOOLS Images\Ocr1.tif"/>
       </Leadtools_Windows_Controls:ImageList>
    </DockPanel>
 </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

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

 

 


Products | Support | Contact Us | Copyright Notices

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