public static String DoubleToTime(double time) { long ticks = (long)(time * 1000); long hours = ticks / 3600000; ticks -= 3600000 * hours; long min = ticks / 60000; ticks -= 60000 * min; long sec = ticks / 1000; StringBuilder s = new StringBuilder(); if (hours > 0) { s.Append(Trans.T1("L_TIME_H:", hours.ToString())); //"h:"); } if (min > 0) { s.Append(Trans.T1("L_TIME_M:", min.ToString())); } s.Append(Trans.T1("L_TIME_S", sec.ToString())); return(s.ToString()); }
public GCode PopData() { GCode gc = null; bool finished = false; lock (jobList) { if (jobList.Count == 0) { return(null); } try { gc = new GCode(jobList.First.Value); jobList.RemoveFirst(); linesSend++; /*PrintTime pt = new PrintTime(); * pt.line = linesSend; * pt.time = DateTime.Now.Ticks; * lock (times) * { * times.AddLast(pt); * if (times.Count > 1500) * times.RemoveFirst(); * }*/ } catch { }; finished = jobList.Count == 0 && mode != 3; } if (finished) { dataComplete = false; mode = 2; jobFinished = DateTime.Now; long ticks = (jobFinished.Ticks - jobStarted.Ticks) / 10000; long hours = ticks / 3600000; ticks -= 3600000 * hours; long min = ticks / 60000; ticks -= 60000 * min; long sec = ticks / 1000; //Main.conn.log("Printjob finished at " + jobFinished.ToShortDateString()+" "+jobFinished.ToShortTimeString(),false,3); Main.conn.log(Trans.T1("L_PRINTJOB_FINISHED_AT", jobFinished.ToShortDateString() + " " + jobFinished.ToShortTimeString()), false, 3); StringBuilder s = new StringBuilder(); if (hours > 0) { s.Append(Trans.T1("L_TIME_H:", hours.ToString())); //"h:"); } if (min > 0) { s.Append(Trans.T1("L_TIME_M:", min.ToString())); } s.Append(Trans.T1("L_TIME_S", sec.ToString())); //Main.conn.log("Printing time:"+s.ToString(),false,3); //Main.conn.log("Lines send:" + linesSend.ToString(), false, 3); //Main.conn.firePrinterAction("Finished in "+s.ToString()); Main.conn.log(Trans.T1("L_PRINTING_TIME:", s.ToString()), false, 3); Main.conn.log(Trans.T1("L_LINES_SEND:X", linesSend.ToString()), false, 3); Main.conn.firePrinterAction(Trans.T1("L_FINISHED_IN", s.ToString())); DoEndKillActions(); Main.main.Invoke(Main.main.UpdateJobButtons); Main.main.printPanel.Invoke(Main.main.printPanel.SetStatusJobFinished); PiMakerHost.view.SoundConfig.PlayPrintFinished(false); } return(gc); }