Author: gonzalo
Date: 2006-05-17 17:10:16 -0400 (Wed, 17 May 2006)
New Revision: 60807
Modified:
trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
Log:
2006-05-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* ImageAnimator.cs: get the FrameDelay from the image properties, if
available. Remove ^Ms.
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-05-17
20:09:39 UTC (rev 60806)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-05-17
21:10:16 UTC (rev 60807)
@@ -1,3 +1,8 @@
+2006-05-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * ImageAnimator.cs: get the FrameDelay from the image properties, if
+ available. Remove ^Ms.
+
2006-05-17 Sebastien Pouliot <[EMAIL PROTECTED]>
* Pen.cs: Get the pen color from the solid brush (when applicable).
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
2006-05-17 20:09:39 UTC (rev 60806)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
2006-05-17 21:10:16 UTC (rev 60807)
@@ -38,51 +38,51 @@
namespace System.Drawing
{
//AnimateEventArgs class
- class AnimateEventArgs : EventArgs
- {
- private int frameCount;
- private int activeFrameCount = 0;
- private Thread thread;
-
- //Constructor.
- //
- public AnimateEventArgs(Image img)
- {
+ class AnimateEventArgs : EventArgs
+ {
+ private int frameCount;
+ private int activeFrameCount = 0;
+ private Thread thread;
+
+ //Constructor.
+ //
+ public AnimateEventArgs(Image img)
+ {
Guid[] dimensionList = img.FrameDimensionsList;
int length = dimensionList.Length;
for (int i=0; i<length; i++) {
- if (dimensionList
[i].Equals(FrameDimension.Time.Guid))
+ if (dimensionList
[i].Equals(FrameDimension.Time.Guid))
this.frameCount = img.GetFrameCount
(FrameDimension.Time);
- }
- }
-
- public int FrameCount {
- get {
- return frameCount;
- }
- }
-
- public int ActiveFrameCount {
- get {
- return activeFrameCount;
- }
-
- set {
- activeFrameCount = value;
- }
- }
-
- public Thread RunThread{
- get {
- return thread;
- }
-
- set {
- thread = value;
- }
- }
- }
+ }
+ }
+
+ public int FrameCount {
+ get {
+ return frameCount;
+ }
+ }
+
+ public int ActiveFrameCount {
+ get {
+ return activeFrameCount;
+ }
+ set {
+ activeFrameCount = value;
+ }
+ }
+
+ public Thread RunThread{
+ get {
+ return thread;
+ }
+
+ set {
+ thread = value;
+ }
+ }
+ }
+
/// <summary>
/// Summary description for ImageAnimator.
/// </summary>
@@ -106,7 +106,16 @@
if (!ht.ContainsKey (img)) {
AnimateEventArgs evtArgs = new AnimateEventArgs
(img);
- WorkerThread WT = new
WorkerThread(onFrameChangeHandler, evtArgs);
+ int delay;
+ try {
+ PropertyItem item = img.GetPropertyItem
(0x5100); // FrameDelay in libgdiplus
+ // Time is in 1/100th of a second
+ delay = (item.Value [0] + item.Value
[1] * 256) * 10;
+ } catch {
+ delay = 200;
+ }
+
+ WorkerThread WT = new WorkerThread
(onFrameChangeHandler, evtArgs, delay);
ThreadStart TS = new
ThreadStart(WT.LoopHandler);
Thread thread = new Thread(TS);
thread.IsBackground = true;
@@ -132,9 +141,9 @@
Guid[] dimensionList = img.FrameDimensionsList;
int length = dimensionList.Length;
int frameCount;
- for (int i=0; i<length; i++)
+ for (int i=0; i<length; i++)
{
- if (dimensionList
[i].Equals(FrameDimension.Time.Guid))
+ if (dimensionList
[i].Equals(FrameDimension.Time.Guid))
{
frameCount = img.GetFrameCount
(FrameDimension.Time);
if (frameCount > 1)
@@ -142,7 +151,7 @@
}
}
- return false;
+ return false;
}
public static void StopAnimate (Image img, EventHandler
onFrameChangeHandler)
@@ -175,7 +184,7 @@
if (evtArgs.ActiveFrameCount <
evtArgs.FrameCount-1){
evtArgs.ActiveFrameCount ++;
img.SelectActiveFrame
(FrameDimension.Time, evtArgs.ActiveFrameCount);
- }
+ }
else
evtArgs.ActiveFrameCount = 0;
ht [img] = evtArgs;
@@ -185,34 +194,30 @@
class WorkerThread
{
- private EventHandler frameChangeHandler;
- private AnimateEventArgs animateEventArgs;
+ EventHandler frameChangeHandler;
+ AnimateEventArgs animateEventArgs;
+ int delay;
- public WorkerThread(EventHandler frmChgHandler,
AnimateEventArgs aniEvtArgs)
+ public WorkerThread (EventHandler frmChgHandler,
AnimateEventArgs aniEvtArgs, int delay)
{
frameChangeHandler = frmChgHandler;
animateEventArgs = aniEvtArgs;
+ this.delay = delay;
}
public void LoopHandler()
{
- try
- {
+ try {
while (true) {
- //Need a way to get the delay during
animation
- Thread.Sleep (100);
- frameChangeHandler (null,
animateEventArgs);
+ Thread.Sleep (delay);
+ frameChangeHandler (null,
animateEventArgs);
}
- }
- catch(ThreadAbortException)
- {
- //lets not bother ourselves with tae
- //it will be thrown anyway
- }
- catch(Exception er)
- {
+ } catch (ThreadAbortException) {
+ Thread.ResetAbort (); // we're going to finish
anyway
+ } catch (Exception er) {
throw er;
}
}
- }
+ }
}
+
Property changes on:
trunk/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches