Leadtools.WinForms Namespace : RasterImageViewer Class |
[DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=17.5.0.0, Culture=neutral, PublicKeyToken=null")] [ToolboxBitmapAttribute()] public class RasterImageViewer : System.Windows.Forms.Control, System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
'Declaration <DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=17.5.0.0, Culture=neutral, PublicKeyToken=null")> <ToolboxBitmapAttribute()> Public Class RasterImageViewer Inherits System.Windows.Forms.Control Implements System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
'Usage Dim instance As RasterImageViewer
public sealed class RasterImageViewer : System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, IClosable //In WinRT the IDisposable interface is replaced by IClosable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
function Leadtools.WinForms.RasterImageViewer()
[DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=17.5.0.0, Culture=neutral, PublicKeyToken=null")] [ToolboxBitmapAttribute()] public ref class RasterImageViewer : public System.Windows.Forms.Control, System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
Public Sub RasterImageViewer_RasterImageViewer() Dim form As MyForm1 = New MyForm1() form.ShowDialog() End Sub Private Class MyForm1 : Inherits Form Private theViewer As RasterImageViewer Public Sub New() ' Create the raster viewer theViewer = New RasterImageViewer() theViewer.Dock = DockStyle.Fill theViewer.DoubleBuffer = True theViewer.BorderStyle = BorderStyle.Fixed3D theViewer.AutoResetScaleFactor = True theViewer.AutoResetScrollPosition = True theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center theViewer.VerticalAlignMode = RasterPaintAlignMode.Far theViewer.FrameSize = New SizeF(10, 5) theViewer.FrameColor = Color.Red theViewer.FramesIsPartOfImage = True theViewer.FrameShadowSize = New SizeF(5, 5) theViewer.FrameShadowColor = Color.Blue theViewer.AutoScroll = True theViewer.UseDpi = True ' Set the paint properties Dim p As RasterPaintProperties = New RasterPaintProperties() p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic p.PaintEngine = RasterPaintEngine.GdiPlus p.UsePaintPalette = True theViewer.PaintProperties = p theViewer.AnimateRegion = True theViewer.EnableTimer = True theViewer.EnableScrollingInterface = True Controls.Add(theViewer) theViewer.BringToFront() ' load an image into the viewer Dim codecs As RasterCodecs = New RasterCodecs() theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp")) codecs.Dispose() Text = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) AddHandler theViewer.DoubleClick, AddressOf theViewer_DoubleClick End Sub Private Sub theViewer_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Select Case theViewer.SizeMode Case RasterPaintSizeMode.Normal theViewer.SizeMode = RasterPaintSizeMode.Stretch Case RasterPaintSizeMode.Stretch theViewer.SizeMode = RasterPaintSizeMode.Fit Case RasterPaintSizeMode.Fit theViewer.SizeMode = RasterPaintSizeMode.FitAlways Case RasterPaintSizeMode.FitAlways theViewer.SizeMode = RasterPaintSizeMode.FitWidth Case RasterPaintSizeMode.FitWidth theViewer.SizeMode = RasterPaintSizeMode.Normal End Select Text = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) MyBase.OnDoubleClick(e) End Sub End Class Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void RasterImageViewer_RasterImageViewer() { MyForm1 form = new MyForm1(); form.ShowDialog(); } class MyForm1 : Form { RasterImageViewer theViewer; public MyForm1() { // Create the raster viewer theViewer = new RasterImageViewer(); theViewer.Dock = DockStyle.Fill; theViewer.DoubleBuffer = true; theViewer.BorderStyle = BorderStyle.Fixed3D; theViewer.AutoResetScaleFactor = true; theViewer.AutoResetScrollPosition= true; theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center; theViewer.VerticalAlignMode = RasterPaintAlignMode.Far; theViewer.FrameSize = new SizeF(10,5); theViewer.FrameColor = Color.Red; theViewer.FramesIsPartOfImage = true; theViewer.FrameShadowSize = new SizeF(5, 5); theViewer.FrameShadowColor = Color.Blue; theViewer.AutoScroll = true; theViewer.UseDpi = true; // Set the paint properties RasterPaintProperties p = new RasterPaintProperties(); p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; p.PaintEngine = RasterPaintEngine.GdiPlus; p.UsePaintPalette = true; theViewer.PaintProperties = p; theViewer.AnimateRegion = true; theViewer.EnableTimer = true; theViewer.EnableScrollingInterface = true; Controls.Add(theViewer); theViewer.BringToFront(); // load an image into the viewer RasterCodecs codecs = new RasterCodecs(); theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp")); codecs.Dispose(); Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); theViewer.DoubleClick += new EventHandler(theViewer_DoubleClick); } void theViewer_DoubleClick(object sender, EventArgs e) { switch (theViewer.SizeMode) { case RasterPaintSizeMode.Normal: theViewer.SizeMode = RasterPaintSizeMode.Stretch; break; case RasterPaintSizeMode.Stretch: theViewer.SizeMode = RasterPaintSizeMode.Fit; break; case RasterPaintSizeMode.Fit: theViewer.SizeMode = RasterPaintSizeMode.FitAlways; break; case RasterPaintSizeMode.FitAlways: theViewer.SizeMode = RasterPaintSizeMode.FitWidth; break; case RasterPaintSizeMode.FitWidth: theViewer.SizeMode = RasterPaintSizeMode.Normal; break; } Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); base.OnDoubleClick(e); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
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