图象显示和翻转控件(用户自定义控件)

2016-01-29 12:07 58 1 收藏

图象显示和翻转控件(用户自定义控件),图象显示和翻转控件(用户自定义控件)

【 tulaoshi.com - vb 】

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace ImageZoomer
{
///


///
///


//枚举类型定义,定义图象的四种翻转方式
public enum FlipModeStyle
{
NoFlip=0,//不翻转
FlipX=1,//水平翻转
FlipY=2,//垂直翻转
FlipXY=3//水平垂直翻转
}

//事件数据类定义,报告图象的显示尺寸
public class DisplaySizeChangedEventArgs:System.EventArgs
{
public int Width;
public int Height;
public DisplaySizeChangedEventArgs()
{
}
}

//事件代表的声明
public delegate void DisplaySizeChangedEventHandler(object sender,DisplaySizeChangedEventArgs e);

//用户自定义控件类
public class ImageZoomerControl : System.Windows.Forms.Control
{
private int width;//控件宽度
private int height;//控件高度
private System.Drawing.Bitmap bitmap;//控件上的图象
private FlipModeStyle flip;//图象的翻转方式
private event DisplaySizeChangedEventHandler eventHandler;//事件

//构造方法,初始化数据成员
public ImageZoomerControl()
{
width=this.width;
height=this.height;
bitmap=null;
eventHandler=null;
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/vb/)

//宽度属性
[
Category("ImageZoomer"),
Description("The displayed image width.")
]
public int DisplayWidth
{
get
{
return width;
}
set
{
if(value>=0)
{
width=value;
Invalidate(this.ClientRectangle);
}
}
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/vb/)

//高度属性
[
Category("ImageZoomer"),
Description("The displayed image height.")
]
public int DisplayHeight
{
get
{
return height;
}
set
{
if(value>=0)
{
height=value;
this.Invalidate(this.ClientRectangle);
}
}
}

//图象属性
[
Category("ImageZoomer"),
Description("The image displayed by this 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);
}
}

//翻转方式属性
[
Category("ImageZoomer"),
Description("Specify how the image will be flipped.")
]
public FlipModeStyle FlipMode
{
get
{
return flip;
}
set
{
flip=value;
this.Invalidate(this.ClientRectangle);
}
}

//事件属性
[
Category("ImageZoomer"),
Description("Occurs when the image size is changed.")

来源:https://www.tulaoshi.com/n/20160129/1484690.html

延伸阅读
标签: Web开发
(一) . 简要           AjaxPanel, 一个自定义控件, 只要在页面中将AjaxPanel作为父控件, 则它内部的控件在运行时无刷新.            做了个程序试了一下果然比较Cool !  下面介绍一下具体配置, 配置也比较简单. (二). 运...
自定义控件(类似按钮等)的使用,自定义一个SurfaceView。 如某一块的动态图(自定义相应),或者类似UC浏览器下面的工具栏。 如下图示例 :   自定义类代码 : 代码如下: public class ImageSurfaceView extends SurfaceView implements Callback{ //用于控制SurfaceView private SurfaceHolder sfh; private Handler handl...
  仅仅依靠Authorware 6.0本身的功能和它所提供的系统函数,来提高Authorware多媒体程序的灵活性是不够的。有些时候,用户需要利用其他的开发工具来生成用户自定义函数,用来拓展程序的功能。本章向大家展示的就是有关于这方面的应用。 1 概述1.1 什么是用户自定义函数 UCD的全名是User Code Dll,是用户自定义函数的缩写。目前任何...
using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; using System.Collections.Specialized; namespace MyWebControls { /// /// 创建一个派生于WEBCONTROL的类 /// 实现一个公有构造函数,它将调用基类构造函数来指定服务器控件应该输出一个input元素 /// 重写AddAttributesToRender...
标签: Web开发
今天在网上看到ASP.Net 2.0中注册自定义控件的好方法,记录如下。 在web.config 文件中全局注册自定义控件 system.web       pages         controls           add tagPrefix="rx" assembly="HYLQ.Component" ...