示例#1
0
 private void RaiseStatusRequest(PrintStatus arg, UInt32 CurrentPosition, UInt32 MaxPosition, PrintStatusTimeArgs TimeArgs)
 {
     StatusRequest?.Invoke(arg, CurrentPosition, MaxPosition, TimeArgs);
 }
示例#2
0
 private void StatusRequestTimerHandler()
 {
     while (Printing)
     {
         var res = ph.PrintStatus();
         if (res.Status == PrintStatus.FailGetStatus)
         {
             RaiseErrorEvent(PrintErrorType.CantGetStatus);
         }
         if (res.Status == PrintStatus.NotPrinting)
         {
             Printing = false;
             RaiseEndEvent();
         }
         var OnseSecondProgress = (Int32)res.Curr - LasProgress;
         LasProgress  = (Int32)res.Curr;
         CountOfData += OnseSecondProgress;
         double Speed = 0, LeftTime = 0;
         if (lSpeed == 0)
         {
             Speed = (double)OnseSecondProgress * 2;
         }
         else
         {
             Speed = (lSpeed + (double)OnseSecondProgress * 2) / 2;
         }
         lSpeed = Speed;
         if (LastLeftTime == 0 || LastLeftTime == float.PositiveInfinity)
         {
             if (OnseSecondProgress == 0)
             {
                 LeftTime = float.PositiveInfinity;
             }
             else
             {
                 LeftTime = (res.Max - CountOfData) / OnseSecondProgress / 2;
             }
         }
         else
         {
             if (OnseSecondProgress == 0)
             {
                 LeftTime = float.PositiveInfinity;
             }
             else
             {
                 LeftTime = (LastLeftTime + (res.Max - CountOfData) / OnseSecondProgress / 2) / 2;
             }
         }
         LastLeftTime = LeftTime;
         PrintStatusTimeArgs TimeArgs = new PrintStatusTimeArgs()
         {
             StartTime    = StartTime,
             SecondsLeft  = LeftTime,
             SecondsSpend = (DateTime.Now - StartTime).TotalSeconds,
             Speed        = Speed
         };
         RaiseStatusRequest(res.Status, res.Curr, res.Max, TimeArgs);
         Thread.Sleep(500);
     }
 }