Image display and rollover controls (user-defined controls)--I'll join in the fun--(turn)
Source: Internet
Author: User
Control | Displays the using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Drawing;
Using System.Data;
Using System.Windows.Forms;
Namespace Imagezoomer
{
<summary>
///
</summary>
Enumeration type definition, defining four ways to flip the image
public enum Flipmodestyle
{
noflip=0,//not Flip
flipx=1,//Horizontal Flip
flipy=2,//Vertical Flip
flipxy=3//Horizontal Vertical Flip
}
event data class definition, report image display dimensions
public class DisplaySizeChangedEventArgs:System.EventArgs
{
public int Width;
public int Height;
Public Displaysizechangedeventargs ()
{
}
}
Statement of event representatives
public delegate void Displaysizechangedeventhandler (Object Sender,displaysizechangedeventargs e);
User-defined control classes
public class ImageZoomerControl:System.Windows.Forms.Control
{
private int width;//Control width
private int height;//Control height
The image on the private System.Drawing.Bitmap bitmap;//control
Flip mode of private Flipmodestyle flip;//image
Private Event Displaysizechangedeventhandler eventhandler;//event
Construct method to initialize data members
Public Imagezoomercontrol ()
{
Width=this.width;
Height=this.height;
Bitmap=null;
Eventhandler=null;
}
Width Property
[
Category ("Imagezoomer"),
Description ("the displayed image width.")
]
public int Displaywidth
{
Get
{
return width;
}
Set
{
if (value>=0)
{
Width=value;
Invalidate (this. ClientRectangle);
}
}
}
Height attribute
[
Category ("Imagezoomer"),
Description ("the displayed image height.")
]
public int Displayheight
{
Get
{
return height;
}
Set
{
if (value>=0)
{
Height=value;
This. Invalidate (this. ClientRectangle);
}
}
}
Image Properties
[
Category ("Imagezoomer"),
Description ("The image displayed by-control."),
DefaultValue (NULL)
]
Public Bitmap DisplayImage
{
Get
{
return bitmap;
}
Set
{
Bitmap=value;
if (bitmap!=null)
{
Width=bitmap. Width;
Height=bitmap. Height;
}
Else
{
Width=this.width;
Height=this.height;
}
This. Invalidate (this. ClientRectangle);
}
}
Flip Style properties
[
Category ("Imagezoomer"),
Description ("Specify how the image would be flipped.")
]
Public Flipmodestyle Flipmode
{
Get
{
return flip;
}
Set
{
Flip=value;
This. Invalidate (this. ClientRectangle);
}
}
Event Properties
[
Category ("Imagezoomer"),
Description ("occurs when" the image size is changed.)
]
Public event Displaysizechangedeventhandler Displaysizechanged
{
Add
{
Eventhandler+=value;
}
Remove
{
Eventhandler-=value;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service