Beispiel #1
0
 protected virtual void OnAfterItemProcessingFinished(RenderingTask item)
 {
     if (AfterItemProcessingFinished != null)
     {
         AfterItemProcessingFinished(this, new RenderingTaskEventArgs(item));
     }
 }
Beispiel #2
0
 protected virtual void OnItemIndexChanged(RenderingTask item)
 {
     if (ItemIndexChanged != null)
     {
         ItemIndexChanged(this, new RenderingTaskEventArgs(item));
     }
 }
Beispiel #3
0
 protected virtual void OnItemRendering(RenderingTask item)
 {
     if (ItemRendering != null)
     {
         ItemRendering(this, new RenderingTaskEventArgs(item));
     }
 }
Beispiel #4
0
 protected virtual void OnBeforeItemProcessingStarted(RenderingTask item)
 {
     if (BeforeItemProcessingStarted != null)
     {
         BeforeItemProcessingStarted(this, new RenderingTaskEventArgs(item));
     }
 }
Beispiel #5
0
 public void Add(Stage stage, string source, int prescale, string destination, string fileType)
 {
     lock (mQueue)
     {
         stage.ProgressMessageReport += HandleStageProgressMessageReport;
         RenderingTask rt = new RenderingTask(stage, source, prescale, destination, fileType);
         mQueue.Add(rt);
         OnItemAdded(rt);
     }
 }
Beispiel #6
0
 public void Remove(RenderingTask item)
 {
     lock (item)
     {
         if (mQueue.Contains(item))
         {
             item.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;
             mQueue.Remove(item);
             OnItemRemoved(item);
         }
     }
 }
Beispiel #7
0
        void HandleStageProgressMessageReport(object sender, ReportStageProgressMessageEventArgs e)
        {
            RenderingTask rt = mInProgress;

            if (mCancelItem == true)
            {
                throw new UserCancelException();
            }
            if (mCancelAllItems == true)
            {
                throw new UserCancelException();
            }

            OnQueueProgressMessageReport(rt.Source, rt.Destination, e.Progress, e.Status, rt.Stage.CurrentImage);
        }
Beispiel #8
0
 public bool StepUp(RenderingTask item)
 {
     lock (item)
     {
         int inx = mQueue.IndexOf(item);
         if (inx > 0 && inx < mQueue.Count)
         {
             RenderingTask prev = mQueue[inx - 1];
             mQueue[inx - 1] = item;
             mQueue[inx]     = prev;
             OnItemIndexChanged(item);
             OnItemIndexChanged(prev);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #9
0
 public bool StepDown(RenderingTask item)
 {
     lock (item)
     {
         int inx = mQueue.IndexOf(item);
         if (inx >= 0 && inx < mQueue.Count - 1)
         {
             RenderingTask next = mQueue[inx + 1];
             mQueue[inx + 1] = item;
             mQueue[inx]     = next;
             OnItemIndexChanged(item);
             OnItemIndexChanged(next);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #10
0
 public bool StepUp(RenderingTask item)
 {
     lock (item)
     {
         int inx = mQueue.IndexOf(item);
         if (inx > 0 && inx < mQueue.Count)
         {
             RenderingTask prev = mQueue[inx - 1];
             mQueue[inx - 1] = item;
             mQueue[inx] = prev;
             OnItemIndexChanged(item);
             OnItemIndexChanged(prev);
             return true;
         }
         else
             return false;
     }
 }
Beispiel #11
0
 public bool StepDown(RenderingTask item)
 {
     lock (item)
     {
         int inx = mQueue.IndexOf(item);
         if (inx >= 0 && inx < mQueue.Count - 1)
         {
             RenderingTask next = mQueue[inx + 1];
             mQueue[inx + 1] = item;
             mQueue[inx] = next;
             OnItemIndexChanged(item);
             OnItemIndexChanged(next);
             return true;
         }
         else
             return false;
     }
 }
Beispiel #12
0
 public void Remove(RenderingTask item)
 {
     lock (item)
     {
         if (mQueue.Contains(item))
         {
             item.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;
             mQueue.Remove(item);
             OnItemRemoved(item);
         }
     }
 }
Beispiel #13
0
 public int IndexOf(RenderingTask item)
 {
     return mQueue.IndexOf(item);
 }
Beispiel #14
0
 public RenderingTaskEventArgs(RenderingTask target)
 {
     _Target = target;
 }
Beispiel #15
0
 protected virtual void OnItemIndexChanged(RenderingTask item)
 {
     if (ItemIndexChanged != null)
         ItemIndexChanged(this, new RenderingTaskEventArgs(item));
 }
Beispiel #16
0
        private void ProcessingThread()
        {
            mCancelItem     = false;
            mCancelAllItems = false;

            OnThreadStarted();
            while (!mThreadStopped)
            {
                if (mQueue.Count > 0)
                {
                    try
                    {
                        mIsProcessingItem = true;
                        RenderingTask cur_task = mQueue[0];
                        lock (cur_task)
                        {
                            if (mQueue.Contains(cur_task))
                            {
                                lock (mQueue)
                                {
                                    mInProgress = cur_task;
                                    mQueue.Remove(cur_task);
                                    OnItemRemoved(cur_task);
                                }
                            }
                        }

                        OnBeforeItemProcessingStarted(mInProgress);

                        if (!mInProgress.Stage.LoadImage(mInProgress.Source, mInProgress.Prescale))
                        {
                            throw new UserCancelException();
                        }

                        mInProgress.Stage.Process();
                        OnQueueProgressMessageReport(mInProgress.Source, mInProgress.Destination, 1, "Saving image to file...", mInProgress.Stage.CurrentImage);
                        OnItemRendering(mInProgress);
                        OnQueueProgressMessageReport(mInProgress.Source, mInProgress.Destination, 1, "Image saved", mInProgress.Stage.CurrentImage);

                        mInProgress.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;

                        OnAfterItemProcessingFinished(mInProgress);
                    }
                    catch (UserCancelException
#if DEBUG
                           exp
#endif
                           )
                    {
#if DEBUG
                        Console.WriteLine("User has sent " + exp.GetType().Name + " exception.");
#endif
                    }
                    finally
                    {
                        mIsProcessingItem = false;
                        mCancelItem       = false;
                        mCancelAllItems   = false;
                        if (mQueue.Count == 0)
                        {
                            OnQueueEmpty();
                        }
                    }
                }
                else
                {
                    Thread.Sleep(30);
                }
            }

            OnThreadStopped();
            mWorkingThread = null;
        }
Beispiel #17
0
 public int IndexOf(RenderingTask item)
 {
     return(mQueue.IndexOf(item));
 }
Beispiel #18
0
 protected virtual void OnAfterItemProcessingFinished(RenderingTask item)
 {
     if (AfterItemProcessingFinished != null)
         AfterItemProcessingFinished(this, new RenderingTaskEventArgs(item));
 }
Beispiel #19
0
 protected virtual void OnBeforeItemProcessingStarted(RenderingTask item)
 {
     if (BeforeItemProcessingStarted != null)
         BeforeItemProcessingStarted(this, new RenderingTaskEventArgs(item));
 }
Beispiel #20
0
        private void ProcessingThread()
        {
            mCancelItem = false;
            mCancelAllItems = false;

            OnThreadStarted();
            while (!mThreadStopped)
            {
                if (mQueue.Count > 0)
                {
                    try
                    {
                        mIsProcessingItem = true;
                        RenderingTask cur_task = mQueue[0];
                        lock (cur_task)
                        {
                            if (mQueue.Contains(cur_task))
                            {
                                lock (mQueue)
                                {
                                    mInProgress = cur_task;
                                    mQueue.Remove(cur_task);
                                    OnItemRemoved(cur_task);
                                }
                            }
                        }

                        OnBeforeItemProcessingStarted(mInProgress);

                        if (!mInProgress.Stage.LoadImage(mInProgress.Source, mInProgress.Prescale))
                            throw new UserCancelException();

                        mInProgress.Stage.Process();
                        OnQueueProgressMessageReport(mInProgress.Source, mInProgress.Destination, 1, "Saving image to file...", mInProgress.Stage.CurrentImage);
                        OnItemRendering(mInProgress);
                        OnQueueProgressMessageReport(mInProgress.Source, mInProgress.Destination, 1, "Image saved", mInProgress.Stage.CurrentImage);

                        mInProgress.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;

                        OnAfterItemProcessingFinished(mInProgress);
                    }
                    catch (UserCancelException
            #if DEBUG
                        exp
            #endif
                        )
                    {
            #if DEBUG
                        Console.WriteLine("User has sent " + exp.GetType().Name + " exception.");
            #endif
                    }
                    finally
                    {
                        mIsProcessingItem = false;
                        mCancelItem = false;
                        mCancelAllItems = false;
                        if (mQueue.Count == 0)
                            OnQueueEmpty();
                    }
                }
                else
                {
                    Thread.Sleep(30);
                }
            }

            OnThreadStopped();
            mWorkingThread = null;
        }
Beispiel #21
0
 protected virtual void OnItemRendering(RenderingTask item)
 {
     if (ItemRendering != null)
         ItemRendering(this, new RenderingTaskEventArgs(item));
 }
 public RenderingTaskTreeNode(RenderingTask task)
 {
     mTask = task;
 }
Beispiel #23
0
 public void Add(Stage stage, string source, int prescale, string destination, string fileType)
 {
     lock (mQueue)
     {
         stage.ProgressMessageReport += HandleStageProgressMessageReport;
         RenderingTask rt = new RenderingTask(stage, source, prescale, destination, fileType);
         mQueue.Add(rt);
         OnItemAdded(rt);
     }
 }
Beispiel #24
0
 public RenderingTaskEventArgs(RenderingTask target)
 {
     _Target = target;
 }