string colonizeTime(int time, ColonType cType = ColonType.MIN2HR) { string result = ""; int HR, min, sec; string strHR, strMin, strSec; bool isHr, isMin; switch (cType) { case ColonType.MIN2HR: HR = time / 60; strHR = (HR == 0) ? ":" : (HR.ToString() + ":"); strMin = (time % 60).ToString().PadLeft(2, '0');; result = strHR + strMin; break; case ColonType.SEC4DIGITS: // 13500 = 135min 0sec min = time / 100; sec = time % 100; if (sec >= 60) { min += sec / 60; sec = sec % 60; } HR = min / 60; isHr = HR != 0; isMin = min != 0; strHR = !isHr ? (isMin ? ":" : "") : HR.ToString() + ":"; strMin = !isMin ? "::" : (min.ToString().PadLeft(2, '0') + "::"); strSec = sec.ToString().PadLeft(2, '0'); result = strHR + strMin + strSec; break; case ColonType.SEC_ONLY: // 123 = 2min 3sec min = time / 60; sec = time % 60; if (sec >= 60) { min += sec / 60; sec = sec % 60; } HR = min / 60; min = min % 60; isHr = HR != 0; isMin = min != 0; strHR = !isHr ? (isMin ? ":" : "") : HR.ToString() + ":"; strMin = !isMin ? "::" : (min.ToString().PadLeft(2, '0') + "::"); strSec = sec.ToString().PadLeft(2, '0'); result = strHR + strMin + strSec; break; default: return(""); } return(result); }
// function that draws a colon in the middle of the rectangular panel // possible modes are circular or rectangular points in the colon internal void DrawColon(Graphics g, ColonType type, bool dim) { pen.Width = dimPen.Width = linewidth; Pen p = (dim) ? dimPen : pen; // choose a pen for blinking switch (type) { case ColonType.Circular: g.DrawEllipse(p, colonRect1); g.DrawEllipse(p, colonRect2); break; case ColonType.Rectangular: g.DrawRectangle(p, colonRect1); g.DrawRectangle(p, colonRect2); break; } }
// function that draws a colon in the middle of the rectangular panel // possible modes are circular or rectangular points in the colon internal void DrawColon(Graphics g, ColonType type, bool dim) { pen.Width = dimPen.Width = linewidth; Pen p = (dim) ? dimPen : pen; // choose a pen for blinking switch(type) { case ColonType.Circular: g.DrawEllipse(p, colonRect1); g.DrawEllipse(p, colonRect2); break; case ColonType.Rectangular: g.DrawRectangle(p, colonRect1); g.DrawRectangle(p, colonRect2); break; } }