Leadtools.Windows.Controls Namespace : ImageList Class |
public class ImageList : System.Windows.Controls.ListBox, System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Declaration Public Class ImageList Inherits System.Windows.Controls.ListBox Implements System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Usage Dim instance As ImageList
public sealed class ImageList : System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
function Leadtools.Windows.Controls.ImageList()
public ref class ImageList : public System.Windows.Controls.ListBox, System.ComponentModel.ISupportInitialize, System.Windows.Controls.Primitives.IContainItemStorage, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
The ImageList control derives from the WPF/Silverlight System.Windows.Controls.ListBox control and lets you display and manipulate a list of images. The ImageList control contains a list of items that can be used to view thumbnails of WPF/Silverlight System.Windows.Media.ImageSource or LEADTOOLS Leadtools.RasterImage objects.
A ImageList control allows you to display a list of items with text and an image. For example, the Windows Explorer in Thumbnails mode is similar in appearance to a ImageList control. The ImageListItem class represents an item within a ImageList control. The items that are displayed in the list can be shown using one of the ImageListItemStyle styles.
ImageList supports single or multiple item selection. The multiple selection feature lets the user select from a list of items in a way similar to a System.Windows.Controls.ListBox control. Additionally, the user can activate selected items to perform a task. For example, you could use a ImageList control to display a list of files that the application can then open and utilize. The user can select the files to open and then double-click them to activate the items and open the files in the application.
ImageList provides a large number of properties that provide flexibility in appearance and behavior. The ItemStyle property allows you to change the way in which items are displayed. Items are added and removed from the ImageList through the ItemsSource property. The ItemsSource property allows you to access the ObservableCollection of the control, which provides methods for manipulating the items in the control. When your control contains a large number of items, it is often easier for the user to see them in a sorted list. You can use the Sort method to sort the items alphabetically.
In addition to the many properties that are available for a ImageList control, You you may want to provide functionality when the user right-clicks an item. To determine the item which is being clicked, you can use the HitTest(Point) method. Sometimes you want to display a specific item to the user to view. The EnsureVisible method can be called to ensure that the specific item is in the visible area of the control.
The ImageList control also supports populating the items directly from the pages of a multi-page TIF file or stream through the LoadTiff(Stream) method and saving the current items to a multi-page TIF file or stream using the SaveTiff method.
Private Class MyWindow1 : Inherits Window Public imageList As ImageList 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 ImageList() 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 = LEAD_VARS.ImagesDir For i As Integer = 0 To 2 ' Load the image Dim index As Integer = i + 1 Dim imageFileName As String = Path.Combine(imagesPath, "ImageProcessingDemo\Image" & index.ToString() & ".jpg") Dim item As ImageListItem = New ImageListItem() item.Source = New BitmapImage(New Uri(imageFileName)) item.Text = "item" & index.ToString() ' 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 ' Add the ImageList to the Window. Content = imageList End Sub End Class Public Sub ImageList_ImageList(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 MyWindow1 : Window { public ImageList imageList; public MyWindow1(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.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); imageList.BorderThickness = new Thickness(5, 5, 5, 5); // Create three items string imagesPath = LEAD_VARS.ImagesDir; for (int i = 0; i < 3; i++) { // Load the image int index = i + 1; string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".jpg"); ImageListItem item = new ImageListItem(); item.Source = new BitmapImage(new Uri(imageFileName)); item.Text = "item" + index.ToString(); // Select the first item if (i == 0) item.IsSelected = true; // Add the item to the image list imageList.Items.Add(item); } // Add the ImageList to the Window. Content = imageList; } } public void ImageList_ImageList(string title) { MyWindow1 window = new MyWindow1(title); window.ShowDialog(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
class MyWindow1 : ChildWindow { public ImageList imageList; public MyWindow1(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.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); imageList.BorderThickness = new Thickness(5, 5, 5, 5); // Create three items string imagesPath = LeadtoolsExamples.Common.ImagesPath.Path; for (int i = 0; i < 3; i++) { // Load the image int index = i + 1; string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg"; ImageListItem item = new ImageListItem(); item.Source = new BitmapImage(new Uri(imageFileName)); item.Text = "item" + index.ToString(); // Select the first item if (i == 0) item.IsSelected = true; // Add the item to the image list imageList.Items.Add(item); } // Add the ImageList to the Window. Content = imageList; } } public void ImageList_ImageList(string title) { MyWindow1 window = new MyWindow1(title); window.Show(); }
Private Class MyWindow1 : Inherits ChildWindow Public imageList As ImageList 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 ImageList() 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 For i As Integer = 0 To 2 ' Load the image Dim index As Integer = i + 1 Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg" Dim item As ImageListItem = New ImageListItem() item.Source = New BitmapImage(New Uri(imageFileName)) item.Text = "item" & index.ToString() ' 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 ' Add the ImageList to the Window. Content = imageList End Sub End Class Public Sub ImageList_ImageList(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:ImageListItem Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg"/> <Leadtools_Windows_Controls:ImageListItem Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg"/> <Leadtools_Windows_Controls:ImageListItem Source="file:///c:\users\Public\Documents\LEADTOOLS Images\eye.gif"/> </Leadtools_Windows_Controls:ImageList> </DockPanel> </Window>
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