using System;
using System.Drawing;
using System.Windows.Forms;
class BetterImageFromFile:Form
{
Image image;
public static void Main()
{
Application.Run(new BetterImageFromFile());
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
public BetterImageFromFile()
{
string strFileName = "Color.jpg";
ResizeRedraw = true;
try
{
image = Image.FromFile(strFileName);
}catch {
MessageBox.Show("Cannot find file " + strFileName + "!",
Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
if (image == null)
return;
grfx.DrawImage(image, 0, 0);
}
}
ASP.NET & Csharp (C#)
ASP.NET & Csharp (C#) , Here you can find my posts about .NET c# .
Get Image Decoder information
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Imaging;
public class Test
{
static void Main()
{
ImageCodecInfo[] availableCodecs;
availableCodecs = ImageCodecInfo.GetImageEncoders();
int numCodecs = availableCodecs.Length;
for (int i = 0; i < numCodecs; i++) { Console.WriteLine("Codec Name = " + availableCodecs[i].CodecName); Console.WriteLine("Class ID = " + availableCodecs[i].Clsid.ToString()); Console.WriteLine("Filename Extension = " + availableCodecs[i].FilenameExtension); Console.WriteLine("Flags = " + availableCodecs[i].Flags.ToString()); Console.WriteLine("Format Description = " + availableCodecs[i].FormatDescription); Console.WriteLine("Format ID = " + availableCodecs[i].FormatID.ToString()); Console.WriteLine("MimeType = " + availableCodecs[i].MimeType); Console.WriteLine("Version = " + availableCodecs[i].Version.ToString()); Console.WriteLine(); } } } [/csharp]
Image Flip
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow
Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ImageFlip
{
/// <summary>
/// Summary description for ImageFlip.
/// </summary>
public class ImageFlip : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.RadioButton radioButton1;
Image im = null;
Image im2 = null;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ImageFlip()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Text = "Flipping and Rotating";
this.radioButton1.Checked = false;
this.label1.Text = "";
this.groupBox1.Text = "RotateFlipType";
this.checkBox1.Text = "Paint";
this.radioButton1.Text = "Rotate180FlipY";
this.radioButton2.Text = "Rotate180FlipX";
this.radioButton3.Text = "Rotate180FlipNone";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.radioButton3,
this.radioButton2,
this.radioButton1,
this.checkBox1});
this.groupBox1.Location = new System.Drawing.Point(312, 64);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(248, 80);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(120, 16);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(112, 24);
this.radioButton1.TabIndex = 1;
this.radioButton1.Text = "radioButton1";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(16, 16);
this.checkBox1.Name = "checkBox1";
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(304, 200);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(16, 48);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 2;
this.radioButton2.Text = "radioButton2";
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(120, 48);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(120, 24);
this.radioButton3.TabIndex = 3;
this.radioButton3.Text = "radioButton3";
//
// ImageFlip
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(560, 214);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.groupBox1});
this.Name = "ImageFlip";
this.Text = "ImageFlip";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new ImageFlip());
}
protected override void OnPaint(PaintEventArgs e)
{ RotateFlip(); }
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{ RotateFlip(); }
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{ RotateFlip(); }
private void radioButtons_CheckedChanged(object sender, System.EventArgs e)
{ RotateFlip(); }
protected void RotateFlip()
{
Graphics g = Graphics.FromHwnd(this.label1.Handle);
Brush b = new SolidBrush(this.label1.BackColor);
if (this.checkBox1.Checked)
{
if (im == null) ReadImage();
Graphics g2 = Graphics.FromImage(im); // For text "Himalaya"
FontFamily ff = new FontFamily("Times New Roman");
Font f = new Font(ff, 25, FontStyle.Bold);
g2.DrawString("HIMALAYA", f, new SolidBrush(Color.Yellow), 170, 210);
g2.Dispose();
im2 = (Image)im.Clone();
int w2 = label1.Width/2, h2 = label1.Height/2;
g.DrawImage(im, 0, 0, w2, h2);
if(this.radioButton1.Checked) // Rotate180FlipY
{
im2.RotateFlip(RotateFlipType.Rotate180FlipY);
g.DrawImage(im2, w2, 0, w2, h2);
}
else g.FillRectangle(b, w2, 0, w2, h2); // Clear old
if(this.radioButton2.Checked) // Rotate180FlipX
{
im2.RotateFlip(RotateFlipType.Rotate180FlipX);
g.DrawImage(im2, 0, h2, w2, h2);
}
else g.FillRectangle(b, 0, h2, w2, h2); // Clear old
if(this.radioButton3.Checked) // Rotate180FlipNone
{
im2.RotateFlip(RotateFlipType.Rotate180FlipNone);
g.DrawImage(im2, w2, h2, w2, h2); // Clear old
}
else g.FillRectangle(b, w2, h2, w2, h2);
im2.Dispose();
}
else Clear(g);
b.Dispose(); g.Dispose();
}
protected void ReadImage()
{
string path = @"Himalaya.bmp";
im = Image.FromFile(path);
this.radioButton1.Enabled = true;
this.radioButton2.Enabled = true;
this.radioButton3.Enabled = true;
}
protected void Clear(Graphics g)
{
g.Clear(this.BackColor);
g.Dispose();
im = null;
im2 = null;
this.radioButton1.Checked = false;
this.radioButton2.Checked = false;
this.radioButton3.Checked = false;
this.radioButton1.Enabled = false;
this.radioButton2.Enabled = false;
this.radioButton3.Enabled = false;
}
}
}
P16_RotateFlip.zip( 240 k)
Image Zoom 1
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow
Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ImageZoom
{
/// <summary>
/// Summary description for ImageZoom.
/// </summary>
public class ImageZoom1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox checkBox1;
Image im = null;
Image im2 = null;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ImageZoom1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Text = "Zooming";
this.label1.Text = "";
this.groupBox1.Text = "Zoom";
this.checkBox1.Text = "Paint";
this.radioButton1.Checked = false;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 240);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.checkBox1,
this.radioButton1,
this.radioButton2,
this.radioButton3,
this.radioButton4});
this.groupBox1.Location = new System.Drawing.Point(232, 48);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(72, 128);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(8, 32);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(56, 24);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "checkBox1";
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(8, 64);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(16, 24);
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "radioButton1";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(40, 64);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(16, 24);
this.radioButton2.TabIndex = 0;
this.radioButton2.Text = "radioButton1";
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(8, 96);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(16, 24);
this.radioButton3.TabIndex = 0;
this.radioButton3.Text = "radioButton1";
//
// radioButton4
//
this.radioButton4.Location = new System.Drawing.Point(40, 96);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(16, 24);
this.radioButton4.TabIndex = 0;
this.radioButton4.Text = "radioButton1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(328, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(200, 240);
this.label2.TabIndex = 0;
this.label2.Text = "label1";
//
// ImageZoom
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(536, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox1,
this.label1,
this.label2});
this.Name = "ImageZoom";
this.Text = "ImageZoom";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new ImageZoom1());
}
protected override void OnPaint(PaintEventArgs e)
{ ImageZoom(); }
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{ ImageZoom(); }
private void radioButtons_CheckedChanged(object sender, System.EventArgs e)
{ ImageZoom(); }
protected void ImageZoom()
{
Graphics g1 = Graphics.FromHwnd(this.label1.Handle);
Graphics g2 = Graphics.FromHwnd(this.label2.Handle);
Rectangle rec;
Rectangle recPart;
if (this.checkBox1.Checked)
{
if (im == null) ReadImage();
rec = new Rectangle(0, 0, label1.Width, label1.Height);
g1.DrawImage(im, rec);
// Center part:
recPart = new Rectangle(im.Width/4, im.Height/4, im.Width/2,
im.Height/2);
if(this.radioButton1.Checked) // Left-Top part
recPart = new Rectangle(0, 0, im.Width/2, im.Height/2);
if(this.radioButton2.Checked) // Right-Top part
recPart = new Rectangle(im.Width/2, 0, im.Width/2, im.Height/2);
if(this.radioButton3.Checked) // Left-Down part
recPart = new Rectangle(0, im.Height/2, im.Width/2, im.Height/2);
if(this.radioButton4.Checked) // Right-Down part
recPart = new Rectangle(im.Width/2, im.Height/2, im.Width/2,
im.Height/2);
g2.DrawImage(im, rec, recPart, GraphicsUnit.Pixel);
}
else
{
Clear(g1);
Clear(g2);
}
g1.Dispose(); g2.Dispose();
}
protected void ReadImage()
{
string path = @"szeret3.BMP";
im = Image.FromFile(path);
this.radioButton1.Enabled = true;
this.radioButton2.Enabled = true;
this.radioButton3.Enabled = true;
this.radioButton4.Enabled = true;
}
protected void Clear(Graphics g)
{
g.Clear(this.BackColor);
g.Dispose();
im = null;
im2 = null;
this.radioButton1.Checked = false;
this.radioButton2.Checked = false;
this.radioButton3.Checked = false;
this.radioButton4.Checked = false;
this.radioButton1.Enabled = false;
this.radioButton2.Enabled = false;
this.radioButton3.Enabled = false;
this.radioButton4.Enabled = false;
}
}
}
P15_ImageZoom.zip( 397 k)
Cube Image
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow
Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Cube
{
/// <summary>
/// Summary description for CubeImage.
/// </summary>
public class CubeImage : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public CubeImage()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Text = "Picture Cube";
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// CubeImage
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 189);
this.Name = "CubeImage";
this.Text = "CubeImage";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new CubeImage());
}
protected override void OnPaint(PaintEventArgs pea)
{
CubeDBuf();
}
private void CubeDBuf()
{
Graphics g;
string path;
int x = 100, y = 40;
Point A = new Point( 10, 50);
Point B = new Point(180, 50);
Point C = new Point( 10, 170);
Point a = new Point(A.X + x, A.Y - y);
Point b = new Point(B.X + x, B.Y - y);
Point Z = new Point(B.X, C.Y);
Point[] p3Fro = {A, B, C};
Point[] p3Top = {a, b, A};
Point[] p3Rig = {B, b, Z};
Bitmap bm = new Bitmap(B.X +x, C.Y + y);
g = Graphics.FromImage(bm);
path = @"IndonHouses.bmp";
Image im1 = Image.FromFile(path);
g.DrawImage(im1, p3Fro);
path = @"Pyramids.BMP";
Image im3 = Image.FromFile(path);
g.DrawImage(im3, p3Top);
path = @"TadjMahal.bmp";
Image im2 = Image.FromFile(path);
g.DrawImage(im2, p3Rig);
g = Graphics.FromHwnd(this.Handle);
g.DrawImage(bm, 1, 1);
g.Dispose();
}
}
}
P14_ImageCube.zip( 317 k)
Control Palette
/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald
Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
/// <summary>
/// Summary description for ControlPalette.
/// </summary>
public class ControlPalette : System.Windows.Forms.Form
{
internal System.Windows.Forms.ImageList images;
internal System.Windows.Forms.Label lblPictureThree;
internal System.Windows.Forms.Label lblPictureTwo;
internal System.Windows.Forms.Label lblPictureOne;
private System.ComponentModel.IContainer components;
public ControlPalette()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ControlPalette));
this.images = new System.Windows.Forms.ImageList(this.components);
this.lblPictureThree = new System.Windows.Forms.Label();
this.lblPictureTwo = new System.Windows.Forms.Label();
this.lblPictureOne = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// images
//
this.images.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.images.ImageSize = new System.Drawing.Size(16, 16);
this.images.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("images.ImageStream")));
this.images.TransparentColor = System.Drawing.Color.Transparent;
//
// lblPictureThree
//
this.lblPictureThree.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblPictureThree.Image = ((System.Drawing.Bitmap)(resources.GetObject("lblPictureThree.Image")));
this.lblPictureThree.ImageIndex = 2;
this.lblPictureThree.ImageList = this.images;
this.lblPictureThree.Location = new System.Drawing.Point(8, 112);
this.lblPictureThree.Name = "lblPictureThree";
this.lblPictureThree.Size = new System.Drawing.Size(56, 48);
this.lblPictureThree.TabIndex = 3;
this.lblPictureThree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown);
//
// lblPictureTwo
//
this.lblPictureTwo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblPictureTwo.Image = ((System.Drawing.Bitmap)(resources.GetObject("lblPictureTwo.Image")));
this.lblPictureTwo.ImageIndex = 1;
this.lblPictureTwo.ImageList = this.images;
this.lblPictureTwo.Location = new System.Drawing.Point(8, 60);
this.lblPictureTwo.Name = "lblPictureTwo";
this.lblPictureTwo.Size = new System.Drawing.Size(56, 48);
this.lblPictureTwo.TabIndex = 2;
this.lblPictureTwo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown);
//
// lblPictureOne
//
this.lblPictureOne.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblPictureOne.Image = ((System.Drawing.Bitmap)(resources.GetObject("lblPictureOne.Image")));
this.lblPictureOne.ImageIndex = 0;
this.lblPictureOne.ImageList = this.images;
this.lblPictureOne.Location = new System.Drawing.Point(8, 8);
this.lblPictureOne.Name = "lblPictureOne";
this.lblPictureOne.Size = new System.Drawing.Size(56, 48);
this.lblPictureOne.TabIndex = 1;
this.lblPictureOne.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown);
//
// ControlPalette
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(76, 174);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblPictureThree,
this.lblPictureTwo,
this.lblPictureOne});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Name = "ControlPalette";
this.Text = "Pictures";
this.ResumeLayout(false);
}
#endregion
private void lbl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Label lbl = (Label)sender;
lbl.DoDragDrop(lbl.Image, DragDropEffects.Copy);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new ControlPalette());
}
}
Picture Controls
/*
GDI+ Programming in C# and VB .NET
by Nick Symmonds
Publisher: Apress
ISBN: 159059035X
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PicControls
{
/// <summary>
/// Summary description for PicControls.
/// </summary>
public class PicControls : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox p;
private System.Windows.Forms.Panel PicPanel;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public PicControls()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.p = new System.Windows.Forms.PictureBox();
this.PicPanel = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// p
//
this.p.Location = new System.Drawing.Point(32, 40);
this.p.Name = "p";
this.p.Size = new System.Drawing.Size(136, 104);
this.p.TabIndex = 0;
this.p.TabStop = false;
//
// PicPanel
//
this.PicPanel.Location = new System.Drawing.Point(200, 120);
this.PicPanel.Name = "PicPanel";
this.PicPanel.Size = new System.Drawing.Size(200, 184);
this.PicPanel.TabIndex = 1;
//
// PicControls
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 349);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.PicPanel,
this.p});
this.Name = "PicControls";
this.Text = "PicControls";
this.Load += new System.EventHandler(this.PicControls_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new PicControls());
}
private void PicControls_Load(object sender, System.EventArgs e)
{
Bitmap b = new Bitmap("crane.jpg");
//PictureBox is "p"
p.Image = (Image)b;
}
}
}
PicControls.zip( 7 k)