コード例 #1
0
ファイル: TimeControl.cs プロジェクト: mbrys/SubtitlesEditor
        public void SetTimeRelatedLabels(ILineInfo lineInfo, string text)
        {
            int chars;

            if (!String.IsNullOrEmpty(text))
            {
                chars = text.Count(x => (x != ' ' && x != '|'));
            }
            else
            {
                chars = lineInfo.Line.Count(x => (x != ' ' && x != '|'));
            }

            double secs = (lineInfo.TimeToSeconds(lineInfo.End) - lineInfo.TimeToSeconds(lineInfo.Begin));

            lbLineTimeValue.Text = String.Format("{0:0.000}s", secs);
            double cpsRatio = Math.Round(chars / secs, 3);

            if (cpsRatio > 20)
            {
                lbCharsPerSecValue.BackColor = Color.IndianRed;
                lbCharsPerSecValue.BackColor = Color.Red;
            }
            else
            {
                lbCharsPerSecValue.BackColor = SystemColors.Control;
                lbCharsPerSecValue.ForeColor = Color.Black;
            }
            lbCharsPerSecValue.Text = String.Format("{0:0.00}", cpsRatio);
        }