using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.Windows.Forms;
namespace TestApplication
{
public partial class AnimatedStripControls : Form
{
public AnimatedStripControls()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (!aniEasyProgressTaskManager1.IsWorking)
{
aniEasyProgressTaskManager1.Start(toolStripAnimatedEasyProgressBarItem1.Control);
status.Text = "Please wait while the task is running.";
button1.Text = "Stop Running Tasks";
}
else
{
aniEasyProgressTaskManager1.StopTask();
status.Text = "task stopped.";
button1.Text = "Start Examples";
}
if (!aniEasyProgressTaskManager2.IsWorking)
{
aniEasyProgressTaskManager2.Start(toolStripAnimatedEasyProgressBarItem2.Control);
}
else
{
aniEasyProgressTaskManager2.StopTask();
}
if (!aniEasyProgressTaskManager3.IsWorking)
{
aniEasyProgressTaskManager3.Start(toolStripAnimatedEasyProgressBarItem3.Control);
}
else
{
aniEasyProgressTaskManager3.StopTask();
}
if (!aniEasyProgressTaskManager4.IsWorking)
{
aniEasyProgressTaskManager4.Start(toolStripAnimatedEasyProgressBarItem4.Control);
}
else
{
aniEasyProgressTaskManager4.StopTask();
}
}
private void AnimatedStripControls_Load(object sender, EventArgs e)
{
toolStripAnimatedEasyProgressBarItem2.AnimatedProgressBar.FrameChanged += new EventHandler<EasyProgressBarPacket.Components.ReportTaskProgressEventArgs>(Green_FrameChanged);
toolStripAnimatedEasyProgressBarItem3.AnimatedProgressBar.FrameChanged += new EventHandler<EasyProgressBarPacket.Components.ReportTaskProgressEventArgs>(Blue_FrameChanged);
toolStripAnimatedEasyProgressBarItem4.AnimatedProgressBar.FrameChanged += new EventHandler<EasyProgressBarPacket.Components.ReportTaskProgressEventArgs>(Red_FrameChanged);
}
void Green_FrameChanged(object sender, EasyProgressBarPacket.Components.ReportTaskProgressEventArgs e)
{
Size bitmapSize = e.GetActiveFrameImage.Size;
// Create a new empty image for manipulations. If you use this constructor, you get a new Bitmap object that represents a bitmap in memory with a PixelFormat of Format32bppARGB.
using (Bitmap overlay = new Bitmap(bitmapSize.Width, bitmapSize.Height),
overlay2 = new Bitmap(bitmapSize.Width, bitmapSize.Height))
{
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay2))
{
bmpGraphics.DrawImageUnscaled(e.GetActiveFrameImage, Point.Empty);
}
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay))
{
/* Create a new color matrix,
The value Alpha in row 4, column 4 specifies the alpha value */
float[][] jaggedMatrix = new float[][]
{
// Red component [from 0.0 to 1.0 increase red color component.]
new float[]{ 0.6f , 0.0f , 0.0f , 0.0f , 0.0f },
// Green component [from 0.0 to 1.0 increase green color component.]
new float[]{ 0.0f , 0.9f , 0.0f , 0.0f , 0.0f },
// Blue component [from 0.0 to 1.0 increase blue color component.]
new float[]{ 0.0f , 0.0f , 0.6f , 0.0f , 0.0f },
// Alpha component [from 1.0 to 0.0 increase transparency bitmap.]
new float[]{ 0.0f , 0.0f , 0.0f , 1.0f , 0.0f },
// White component [0.0: goes to Original color, 1.0: goes to white for all color component(Red, Green, Blue.)]
new float[]{ 0.2f , 0.2f , 0.2f , 0.0f , 1.0f }
};
ColorMatrix colorMatrix = new ColorMatrix(jaggedMatrix);
// Create an ImageAttributes object and set its color matrix
using (ImageAttributes attributes = new ImageAttributes())
{
attributes.SetColorMatrix(
colorMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
bmpGraphics.DrawImage(overlay2, new Rectangle(Point.Empty, new Size(overlay2.Width, overlay2.Height)), 0, 0, overlay2.Width, overlay2.Height, GraphicsUnit.Pixel, attributes);
}
}
e.GetActiveFrameImage = (Bitmap)overlay.Clone();
}
}
void Blue_FrameChanged(object sender, EasyProgressBarPacket.Components.ReportTaskProgressEventArgs e)
{
Size bitmapSize = e.GetActiveFrameImage.Size;
// Create a new empty image for manipulations. If you use this constructor, you get a new Bitmap object that represents a bitmap in memory with a PixelFormat of Format32bppARGB.
using (Bitmap overlay = new Bitmap(bitmapSize.Width, bitmapSize.Height),
overlay2 = new Bitmap(bitmapSize.Width, bitmapSize.Height))
{
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay2))
{
bmpGraphics.DrawImageUnscaled(e.GetActiveFrameImage, Point.Empty);
}
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay))
{
/* Create a new color matrix,
The value Alpha in row 4, column 4 specifies the alpha value */
float[][] jaggedMatrix = new float[][]
{
// Red component [from 0.0 to 1.0 increase red color component.]
new float[]{ 0.6f , 0.0f , 0.0f , 0.0f , 0.0f },
// Green component [from 0.0 to 1.0 increase green color component.]
new float[]{ 0.0f , 0.6f , 0.0f , 0.0f , 0.0f },
// Blue component [from 0.0 to 1.0 increase blue color component.]
new float[]{ 0.0f , 0.0f , 0.9f , 0.0f , 0.0f },
// Alpha component [from 1.0 to 0.0 increase transparency bitmap.]
new float[]{ 0.0f , 0.0f , 0.0f , 1.0f , 0.0f },
// White component [0.0: goes to Original color, 1.0: goes to white for all color component(Red, Green, Blue.)]
new float[]{ 0.2f , 0.2f , 0.2f , 0.0f , 1.0f }
};
ColorMatrix colorMatrix = new ColorMatrix(jaggedMatrix);
// Create an ImageAttributes object and set its color matrix
using (ImageAttributes attributes = new ImageAttributes())
{
attributes.SetColorMatrix(
colorMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
bmpGraphics.DrawImage(overlay2, new Rectangle(Point.Empty, new Size(overlay2.Width, overlay2.Height)), 0, 0, overlay2.Width, overlay2.Height, GraphicsUnit.Pixel, attributes);
}
}
e.GetActiveFrameImage = (Bitmap)overlay.Clone();
}
}
void Red_FrameChanged(object sender, EasyProgressBarPacket.Components.ReportTaskProgressEventArgs e)
{
Size bitmapSize = e.GetActiveFrameImage.Size;
// Create a new empty image for manipulations. If you use this constructor, you get a new Bitmap object that represents a bitmap in memory with a PixelFormat of Format32bppARGB.
using (Bitmap overlay = new Bitmap(bitmapSize.Width, bitmapSize.Height),
overlay2 = new Bitmap(bitmapSize.Width, bitmapSize.Height))
{
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay2))
{
bmpGraphics.DrawImageUnscaled(e.GetActiveFrameImage, Point.Empty);
}
// Make an associated Graphics object.
using (Graphics bmpGraphics = Graphics.FromImage(overlay))
{
/* Create a new color matrix,
The value Alpha in row 4, column 4 specifies the alpha value */
float[][] jaggedMatrix = new float[][]
{
// Red component [from 0.0 to 1.0 increase red color component.]
new float[]{ 0.9f , 0.0f , 0.0f , 0.0f , 0.0f },
// Green component [from 0.0 to 1.0 increase green color component.]
new float[]{ 0.0f , 0.6f , 0.0f , 0.0f , 0.0f },
// Blue component [from 0.0 to 1.0 increase blue color component.]
new float[]{ 0.0f , 0.0f , 0.6f , 0.0f , 0.0f },
// Alpha component [from 1.0 to 0.0 increase transparency bitmap.]
new float[]{ 0.0f , 0.0f , 0.0f , 1.0f , 0.0f },
// White component [0.0: goes to Original color, 1.0: goes to white for all color component(Red, Green, Blue.)]
new float[]{ 0.2f , 0.2f , 0.2f , 0.0f , 1.0f }
};
ColorMatrix colorMatrix = new ColorMatrix(jaggedMatrix);
// Create an ImageAttributes object and set its color matrix
using (ImageAttributes attributes = new ImageAttributes())
{
attributes.SetColorMatrix(
colorMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
bmpGraphics.DrawImage(overlay2, new Rectangle(Point.Empty, new Size(overlay2.Width, overlay2.Height)), 0, 0, overlay2.Width, overlay2.Height, GraphicsUnit.Pixel, attributes);
}
}
e.GetActiveFrameImage = (Bitmap)overlay.Clone();
}
}
}
}