Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.5.10
|
Leadtools.Windows.Controls Namespace : RasterImageListItem Class |
public class RasterImageListItem : ImageListItem, IImageListItem, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Declaration Public Class RasterImageListItem Inherits ImageListItem Implements IImageListItem, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Usage Dim instance As RasterImageListItem
public ref class RasterImageListItem : public ImageListItem, IImageListItem, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
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:
Adding items with a LEADTOOLS Leadtools.RasterImage object using the Image property.
In WPF/Silverlight, an image that is displayed must be an System.Windows.Media.ImageSource or one of its derived classes, the RasterImageListItem class keeps the ImageListItem.Source property synchronized with RasterImageListItem.Image, any changes that occur to the LEADTOOLS Leadtools.RasterImage is reflected in the Source property and a standard System.Windows.FrameworkPropertyMetadata.AffectsMeasure or System.Windows.FrameworkPropertyMetadata.AffectsRender is performed. Also, this control will subscribe to the RasterImage.Changed to monitor any changes that may occur to the image (through image processing for example) and reflect these changes to the Source property.
If the Source property is changed, the RasterImageListItem must be informed so it can reflect the changes into the Image object. The UpdateImageFromSource can be used to perform this task.
Imports Leadtools.Windows.Controls Imports Leadtools.Codecs 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
using Leadtools.Help; using Leadtools.Windows.Controls; using Leadtools.Codecs; 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"; }
using Leadtools.Help; using Leadtools.Windows.Controls; using Leadtools.Codecs; 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(); }
Imports Leadtools.Windows.Controls Imports Leadtools.Codecs 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>