예제 #1
0
 protected virtual void OnAfterItemProcessingFinished(RenderingTask item)
 {
     if (AfterItemProcessingFinished != null)
     {
         AfterItemProcessingFinished(this, new RenderingTaskEventArgs(item));
     }
 }
예제 #2
0
 protected virtual void OnItemIndexChanged(RenderingTask item)
 {
     if (ItemIndexChanged != null)
     {
         ItemIndexChanged(this, new RenderingTaskEventArgs(item));
     }
 }
예제 #3
0
 protected virtual void OnItemRendering(RenderingTask item)
 {
     if (ItemRendering != null)
     {
         ItemRendering(this, new RenderingTaskEventArgs(item));
     }
 }
예제 #4
0
 protected virtual void OnBeforeItemProcessingStarted(RenderingTask item)
 {
     if (BeforeItemProcessingStarted != null)
     {
         BeforeItemProcessingStarted(this, new RenderingTaskEventArgs(item));
     }
 }
예제 #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);
     }
 }
예제 #6
0
 public void Remove(RenderingTask item)
 {
     lock (item)
     {
         if (mQueue.Contains(item))
         {
             item.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;
             mQueue.Remove(item);
             OnItemRemoved(item);
         }
     }
 }
예제 #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);
        }
예제 #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);
         }
     }
 }
예제 #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);
         }
     }
 }
예제 #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;
     }
 }
예제 #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;
     }
 }
예제 #12
0
 public void Remove(RenderingTask item)
 {
     lock (item)
     {
         if (mQueue.Contains(item))
         {
             item.Stage.ProgressMessageReport -= HandleStageProgressMessageReport;
             mQueue.Remove(item);
             OnItemRemoved(item);
         }
     }
 }
예제 #13
0
 public int IndexOf(RenderingTask item)
 {
     return mQueue.IndexOf(item);
 }
예제 #14
0
 public RenderingTaskEventArgs(RenderingTask target)
 {
     _Target = target;
 }
예제 #15
0
 protected virtual void OnItemIndexChanged(RenderingTask item)
 {
     if (ItemIndexChanged != null)
         ItemIndexChanged(this, new RenderingTaskEventArgs(item));
 }
예제 #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;
        }
예제 #17
0
 public int IndexOf(RenderingTask item)
 {
     return(mQueue.IndexOf(item));
 }
예제 #18
0
 protected virtual void OnAfterItemProcessingFinished(RenderingTask item)
 {
     if (AfterItemProcessingFinished != null)
         AfterItemProcessingFinished(this, new RenderingTaskEventArgs(item));
 }
예제 #19
0
 protected virtual void OnBeforeItemProcessingStarted(RenderingTask item)
 {
     if (BeforeItemProcessingStarted != null)
         BeforeItemProcessingStarted(this, new RenderingTaskEventArgs(item));
 }
예제 #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;
        }
예제 #21
0
 protected virtual void OnItemRendering(RenderingTask item)
 {
     if (ItemRendering != null)
         ItemRendering(this, new RenderingTaskEventArgs(item));
 }
예제 #22
0
 public RenderingTaskTreeNode(RenderingTask task)
 {
     mTask = task;
 }
예제 #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);
     }
 }
예제 #24
0
 public RenderingTaskEventArgs(RenderingTask target)
 {
     _Target = target;
 }