F-IN-BOX .NET Help >> Classes >> f_in_box__control and f_in_box__form >> Events >> Extensions

OnPaintStage

Syntax

[ C# ]
public delegate void OnPaintStageEventHandler(object sender, PaintStage stage, System.Drawing.Graphics Canvas);
public event OnPaintStageEventHandler OnPaintStage;

Description

A movie (f_in_box__control) is in the transparent mode: TransparentMode = true, see TransparentMode for more information. How the movie is painting:
  1. Backgroung is filled by the background color (see also: FlashProperty_BGColor and FlashProperty_BackgroundColor)
  2. OnPaintStage with stage = f_in_box__lib.PrePaint is called. You can modify background here
  3. The movie is painting over the background
  4. OnPaintStage with stage = f_in_box__lib.AfterPaint is called. You can modify the final image here

OnPaintStage is useful when you should provide custom background for a movie. For example, to simulate transparent effect:

[ C# ]
private void f_in_box__control1_OnPaintStage(object sender, f_in_box__lib.PaintStage stage, System.Drawing.Graphics Canvas)
{
	if (f_in_box__lib.PaintStage.PrePaint == stage)
	{
		f_in_box__lib.f_in_box__control f_in_box__control = (f_in_box__lib.f_in_box__control)sender;

		Bitmap b = new Bitmap(Width, Height);
		Graphics g = Graphics.FromImage(b);
		PaintEventArgs pea = new PaintEventArgs(g, new Rectangle(new Point(0, 0), Size));

		this.OnPaintBackground(pea);
		this.OnPaint(pea);

		g.DrawImage(
			pictureBox1.Image, 
			new Rectangle(pictureBox1.Location, pictureBox1.Size), 
			new Rectangle(new Point(0, 0), pictureBox1.Image.Size), 
			GraphicsUnit.Pixel);

		Canvas.DrawImage(
			b, 
			new Rectangle(new Point(0, 0), f_in_box__control.Size), 
			new Rectangle(f_in_box__control.Location, f_in_box__control.Size), 
			GraphicsUnit.Pixel);
	}
}

[ VB.Net ]
    Private Sub f_in_box__control1_OnPaintStage(ByVal sender As Object, ByVal stage As f_in_box__lib.PaintStage, ByVal Canvas As System.Drawing.Graphics) Handles f_in_box__control1.OnPaintStage, F_in_box__control2.OnPaintStage
        If f_in_box__lib.PaintStage.PrePaint = stage Then
            Dim f_in_box__control As f_in_box__lib.f_in_box__control = sender

            Dim b As Bitmap = New Bitmap(Width, Height)
            Dim g As Graphics = Graphics.FromImage(b)
            Dim pea As PaintEventArgs = New PaintEventArgs(g, New Rectangle(f_in_box__control.Location, f_in_box__control.Size))

            Me.OnPaintBackground(pea)
            Me.OnPaint(pea)

            g.DrawImage( _
                pictureBox1.Image, _
                New Rectangle(pictureBox1.Location, pictureBox1.Size), _
                New Rectangle(New Point(0, 0), pictureBox1.Image.Size), _
                GraphicsUnit.Pixel)

            Canvas.DrawImage( _
                b, _
                New Rectangle(New Point(0, 0), f_in_box__control.Size), _
                New Rectangle(f_in_box__control.Location, f_in_box__control.Size), _
                GraphicsUnit.Pixel)

        End If
    End Sub


Copyright © Softanics. All rights reserved.
F-IN-BOX is a trademark of Softanics.
Macromedia and Shockwave Flash are trademarks of Adobe