📄 gimage.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;
using gowk.common;
namespace gowk.controls
{
/// <summary>
/// GImage 的摘要说明。
/// </summary>
public class GImage:System.ComponentModel.Component
{
private Image _Image,_NormalImage,_ActiveImage,_PressedImage;
public GImage()
{
}
private Image GetNewImage(Image org,int a)
{
Image img=(Image)org.Clone();
Bitmap bm=new Bitmap(img);
for(int w=0;w<bm.Width;w++)
{
for(int h=0;h<bm.Height;h++)
{
Color c=bm.GetPixel(w,h);
int newA=(int)(c.A*a/100);
// int newA=Math.Abs((c.A+a)%256);
// int newR=Math.Abs((c.R+r)%256);
// int newG=Math.Abs((c.G+g)%256);
// int newB=Math.Abs((c.B+b)%256);
int newR=c.R;
int newG=c.G;
int newB=c.B;
bm.SetPixel(w,h,Color.FromArgb(newA,newR,newG,newB));
}
}
return bm;
}
public Image Image
{
get{return this._Image;}set{this._Image=value;}
}
public Image NormalImage
{
get
{
if((this._NormalImage==null)&& (this._Image!=null))
{
this._NormalImage=this.GetNewImage(this._Image,80);
}
return this._NormalImage;
}
set
{
this._NormalImage=value;
}
}
public Image ActiveImage
{
get
{
if((this._ActiveImage==null)&& (this._Image!=null))
{
this._ActiveImage=this.GetNewImage(this._Image,60);
}
return this._ActiveImage;
}
set{this._ActiveImage=value;}
}
public Image PressedImage
{
get
{
if((this._PressedImage==null)&& (this._Image!=null))
{
this._PressedImage=this.GetNewImage(this._Image,100);
}
return this._PressedImage;
}
set{this._PressedImage=value;}
}
public Image GetImageByState(State state)
{
Image img=null;
if(state==State.Pressed)
{
img=this.PressedImage;
}
else if(state==State.Actived)
{
img=this.ActiveImage;
}
img=(null==img)?this.NormalImage:img;
return img;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -