public class Form1 : a.Forms.aForm
{
a.Api.BlendFunction BF;
bool draw=false;
IntPtr hB;
Bitmap B;
Rectangle posRec;
Rectangle posBothRec;
private System.ComponentModel.Container components = null;
public Form1()
{
B= (Bitmap)Image.FromFile("D:\\copy.bmp");
/*B= new Bitmap(200, 150);
Graphics g= Graphics.FromImage(B);
SolidBrush SB=new SolidBrush(Color.FromArgb(0,0,0,0));
g.FillRectangle(SB,0,0,B.Width, B.Height);
g.FillEllipse(Brushes.Red, 0,0, 200, 150);
g.Dispose();*/
this.BF= a.Api.GetBlendFunction(255);
//B.MakeTransparent(Color.White);
//B.MakeTransparent(Color.Black);
InitializeComponent();
//this.BackColor=Color.Blue;
this.BackgrdBrush=new HatchBrush(HatchStyle.LargeConfetti, Color.Blue, Color.Black);
//this.BackgrdBrush=new LinearGradientBrush(this.ClientRectangle, Color.Gray, Color.Beige, 20);
this.posRec=new Rectangle(0,0,0,0);
hB= B.GetHbitmap();
}
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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(788, 406);
this.Name = "Form1";
this.Text = "Form1";
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if(draw)
{
Draw(e);
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.draw=false;
//if(e.X.ToString().EndsWith("0"))
{
Rectangle curPos= this.posRec;
this.posRec=new Rectangle(e.X, e.Y, B.Width, B.Height);
posBothRec=new Rectangle(
(curPos.X < this.posRec.X ? curPos.X : this.posRec.X),
(curPos.Y < this.posRec.Y ? curPos.Y : this.posRec.Y),
Math.Abs(curPos.X-this.posRec.X)+B.Width*2+2,
Math.Abs(curPos.Y-this.posRec.Y)+B.Height
);
this.draw=true;
this.Invalidate(posBothRec);
}
}
static int i=255;
static int j=100;
void Draw(PaintEventArgs e)
{
a.Api.DrawBitBlt(e.Graphics, B, ref this.posRec, ref BF);
//a.Api.DrawBitBlt(e.Graphics, B, ref this.posRec);
//e.Graphics.DrawImageUnscaled(B, this.posRec);
ImageAttributes Ia= a.graphics.TrasparentImage(j);
Rectangle testRect=new Rectangle(this.posRec.X+B.Width+2, this.posRec.Y, B.Width, B.Height);
e.Graphics.DrawImage(B, testRect, 0, 0, B.Width, B.Height, GraphicsUnit.Pixel, Ia);
if(i < 1)
i= 255;
else
i= i-5;
BF.SourceConstantAlpha=(byte)i;
if(j < 1)
j= 100;
else
j= j-2;
//e.Graphics.FillRectangle(Brushes.Black, this.posRec);
}
}