Пример #1
0
 public RasterAnimation(RasterAnimationFrame[] frames) : this()
 {
     RasterAnimationFrame frame = null;
     foreach (RasterAnimationFrame frame2 in frames)
     {
         if (frame != null)
         {
             frame.NextFrame = frame2;
             frame2.PreviousFrame = frame;
         }
         frame = frame2;
     }
     this.Frames.InnerList.AddRange(frames);
     base.Image = frames[0].Image;
 }
Пример #2
0
 private void Run()
 {
     if (this.Frames.Count >= 1)
     {
         ThreadPool.QueueUserWorkItem(delegate (object state) {
             VGen0 method = null;
             try
             {
                 this.CancelRun = true;
                 while (this.IsRunning)
                 {
                     Thread.Sleep(20);
                 }
                 this.CancelRun = false;
                 this.mIsRunning = true;
                 if (this.Frames.Count >= 2)
                 {
                     this.CurrentFrame = this.Frames[1];
                     DateTime now = DateTime.Now;
                     this.Elapsed = 0.0;
                     while (this.IsRunning)
                     {
                         if (this.CancelRun)
                         {
                             return;
                         }
                         if (!this.CanRun || this.Paused)
                         {
                             Thread.Sleep(20);
                             continue;
                         }
                         TimeSpan span = (TimeSpan) (DateTime.Now - now);
                         this.Elapsed += span.TotalSeconds;
                         if (this.Elapsed < this.CurrentFrame.Duration)
                         {
                             goto Label_0150;
                         }
                         if (this.CurrentFrame.NextFrame == null)
                         {
                             if (this.Loop)
                             {
                                 this.CurrentFrame = this.Frames[1];
                                 goto Label_0107;
                             }
                             this.Stop();
                             continue;
                         }
                         this.CurrentFrame = this.CurrentFrame.NextFrame;
                     Label_0107:
                         if (this.CancelRun || ((!base.IsHandleCreated || base.Disposing) || base.IsDisposed))
                         {
                             return;
                         }
                         if (method == null)
                         {
                             method = delegate {
                                 base.Image = this.CurrentFrame.Image;
                             };
                         }
                         base.Invoke(method);
                         this.Elapsed = 0.0;
                     Label_0150:
                         now = DateTime.Now;
                         Thread.Sleep(10);
                     }
                 }
             }
             catch (Exception exception)
             {
                 ErrorLog.WriteLine(exception);
             }
             finally
             {
                 this.mIsRunning = false;
             }
         });
     }
 }