regionhandler.cs
来自「Fireball.CodeEditor is an source code ed」· CS 代码 · 共 101 行
CS
101 行
//ORIGINAL LGPL SOURCE CODE FINDED ON COMPONA LGPL SOURCE CODE
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Fireball.Windows.Forms
{
[ToolboxItem(true)]
public class RegionHandler : Component
{
private Container components = null;
#region PUBLIC PROPERTY TRANSPARENCYKEY
private Color _TransparencyKey = Color.FromArgb(255, 0, 255);
public Color TransparencyKey
{
get { return _TransparencyKey; }
set { _TransparencyKey = value; }
}
#endregion
#region PUBLIC PROPERTY CONTROL
private Control _Control;
public Control Control
{
get { return _Control; }
set { _Control = value; }
}
#endregion
#region PUBLIC PROPERTY MASKIMAGE
private Bitmap _MaskImage;
public Bitmap MaskImage
{
get { return _MaskImage; }
set { _MaskImage = value; }
}
#endregion
public void ApplyRegion(Control Target, Bitmap MaskImage, Color TransparencyKey)
{
this.Control = Target;
this.MaskImage = MaskImage;
this.TransparencyKey = TransparencyKey;
ApplyRegion();
}
public void ApplyRegion()
{
Region r = new Region(new Rectangle(0, 0, MaskImage.Width, MaskImage.Height));
for (int y = 0; y < this.MaskImage.Height; y++)
for (int x = 0; x < this.MaskImage.Width; x++)
{
if (this.MaskImage.GetPixel(x, y) == this.TransparencyKey)
{
r.Exclude(new Rectangle(x, y, 1, 1));
}
}
Control.Region = r;
Control.BackgroundImage = this.MaskImage;
}
public RegionHandler(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public RegionHandler()
{
InitializeComponent();
}
#region Component 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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?