|
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using EasyProgressBarPacket.Components;
namespace EasyProgressBarPacket
{
public class AnimatedEasyProgressControl : Control
{
#region Event
/// <summary>
/// Represents an event which occurs when the index of the active frame changed.
/// </summary>
[Description("Represents an event which occurs when the index of the active frame changed")]
public event EventHandler<ReportTaskProgressEventArgs> FrameChanged;
#endregion
#region Instance Members
private Image newFrameImage = null;
private AniEasyProgressTaskManager easyProgressTaskManager = null;
#endregion
#region Constructor
public AnimatedEasyProgressControl()
{
this.SetStyle(ControlStyles.Selectable, false);
this.SetStyle(ControlStyles.ResizeRedraw, false);
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
// Object Initializer
this.Size = new Size()
{
Width = 100,
Height = 50
};
}
#endregion
#region Destructor
~AnimatedEasyProgressControl()
{
GC.SuppressFinalize(this);
}
#endregion
#region Property
/// <summary>
/// Gets or Sets the task manager for painting this control.
/// </summary>
[Description("Gets or Sets the task manager for painting this control")]
public AniEasyProgressTaskManager EasyProgressTaskManager
{
get { return easyProgressTaskManager; }
set
{
try
{
if (!value.Equals(easyProgressTaskManager))
{
if (easyProgressTaskManager != null)
easyProgressTaskManager.TaskProgress -= OnFrameChanged;
easyProgressTaskManager = value;
easyProgressTaskManager.TaskProgress += new EventHandler<ReportTaskProgressEventArgs>(OnFrameChanged);
}
}
catch (NullReferenceException)
{
if (easyProgressTaskManager != null)
easyProgressTaskManager.TaskProgress -= OnFrameChanged;
easyProgressTaskManager = null;
}
}
}
#endregion
#region Virtual Methods
protected virtual void OnFrameChanged(object sender, ReportTaskProgressEventArgs e)
{
if (FrameChanged != null)
FrameChanged(this, e);
newFrameImage = e.GetActiveFrameImage;
this.Invalidate();
this.Update();
}
#endregion
#region Override Methods
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
EasyProgressTaskManager = null;
}
base.Dispose(disposing);
}
protected override void OnPaint(PaintEventArgs e)
{
if (Visible)
{
try
{
if (newFrameImage != null)
{
Rectangle rct = this.ClientRectangle;
e.Graphics.DrawImageUnscaled(newFrameImage, rct);
}
}
catch { ;}
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Since 1998...
MCPD - Enterprise Application Developer
“Hesaplı hareket ettiğini zanneden ve onunla iftihar eyliyen dar kafalar; kurtulmağa, yükselmeğe elverişli hiç bir eser vücüda getirmezler. Kurtuluş ve yükselişi, ancak varlığına dayanan ve mülkü milletin gizli kapalı hazinelerini verimli hale getirmesini bilen, şahsi menfaatini millet menfaati uğruna feda eden, ruhu idealist, dimağı realist şahsiyetlerde aramalıdır.”
Nuri Demirağ, 1947