![]() |
Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Controls Assembly > Leadtools.Controls Namespace : RasterPictureBox Class |
public class RasterPictureBox : System.Windows.Forms.Control
'Declaration
Public Class RasterPictureBox Inherits System.Windows.Forms.Control
This example will create an instance of the RasterPictureBox control and add it to a form
Imports Leadtools Imports Leadtools.Controls Imports Leadtools.Codecs Imports Leadtools.Drawing <TestMethod> Public Sub RasterPictureBox_RasterPictureBox() Dim form As MyForm1 = New MyForm1() form.ShowDialog() End Sub Private Class MyForm1 : Inherits Form Private pictureBoxInstance As RasterPictureBox Public Sub New() ' Create the raster PictureBox pictureBoxInstance = New RasterPictureBox() pictureBoxInstance.Dock = DockStyle.Fill pictureBoxInstance.BorderStyle = BorderStyle.FixedSingle pictureBoxInstance.UseDpi = False ' Set the paint properties Dim paintProperties As RasterPaintProperties = New RasterPaintProperties() paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic paintProperties.PaintEngine = RasterPaintEngine.GdiPlus paintProperties.UsePaintPalette = True pictureBoxInstance.PaintProperties = paintProperties Me.Controls.Add(pictureBoxInstance) pictureBoxInstance.BringToFront() ' load an image into the viewer Using codecs As RasterCodecs = New RasterCodecs() pictureBoxInstance.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "eye.gif")) End Using Text = String.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode) AddHandler pictureBoxInstance.DoubleClick, AddressOf pictureBoxInstance_DoubleClick End Sub Private Sub pictureBoxInstance_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Select Case pictureBoxInstance.SizeMode Case RasterPictureBoxSizeMode.Normal pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.StretchImage Case RasterPictureBoxSizeMode.StretchImage pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Fit Case RasterPictureBoxSizeMode.Fit pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.AutoSize Case RasterPictureBoxSizeMode.AutoSize pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.CenterImage Case RasterPictureBoxSizeMode.CenterImage pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Normal End Select Text = String.Format("Size mode = {0}, double click to change", pictureBoxInstance.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
using Leadtools; using Leadtools.Controls; using Leadtools.Codecs; using Leadtools.Drawing; public void RasterPictureBox_RasterPictureBox() { MyForm1 form = new MyForm1(); form.ShowDialog(); } class MyForm1 : Form { private RasterPictureBox pictureBoxInstance; public MyForm1() { // Create the raster PictureBox pictureBoxInstance = new RasterPictureBox(); pictureBoxInstance.Dock = DockStyle.Fill; pictureBoxInstance.BorderStyle = BorderStyle.FixedSingle; pictureBoxInstance.UseDpi = false; // Set the paint properties RasterPaintProperties paintProperties = new RasterPaintProperties(); paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; paintProperties.PaintEngine = RasterPaintEngine.GdiPlus; paintProperties.UsePaintPalette = true; pictureBoxInstance.PaintProperties = paintProperties; this.Controls.Add(pictureBoxInstance); pictureBoxInstance.BringToFront(); // load an image into the viewer using (RasterCodecs codecs = new RasterCodecs()) pictureBoxInstance.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "eye.gif")); Text = string.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode); pictureBoxInstance.DoubleClick += new EventHandler(pictureBoxInstance_DoubleClick); } void pictureBoxInstance_DoubleClick(object sender, EventArgs e) { switch (pictureBoxInstance.SizeMode) { case RasterPictureBoxSizeMode.Normal: pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.StretchImage; break; case RasterPictureBoxSizeMode.StretchImage: pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Fit; break; case RasterPictureBoxSizeMode.Fit: pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.AutoSize; break; case RasterPictureBoxSizeMode.AutoSize: pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.CenterImage; break; case RasterPictureBoxSizeMode.CenterImage: pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Normal; break; } Text = string.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode); base.OnDoubleClick(e); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }