Пример #1
0
 public static string BuildRecordingBaseFileName(string recordingsPath, UpcomingProgram program)
 {
     StringBuilder filePath = new StringBuilder();
     if (recordingsPath != null)
     {
         filePath.Append(recordingsPath);
         if (filePath[filePath.Length - 1] != Path.DirectorySeparatorChar)
         {
             filePath.Append(Path.DirectorySeparatorChar);
         }
         filePath.Append(MakeValidFileName(program.Title)).Append(Path.DirectorySeparatorChar);
     }
     string programTitle = program.CreateProgramTitle();
     if (programTitle.Length > 80)
     {
         programTitle = programTitle.Substring(0, 80);
     }
     filePath.Append(MakeValidFileName(programTitle));
     filePath.Append("_");
     filePath.AppendFormat(MakeValidFileName(program.Channel.DisplayName));
     filePath.Append("_");
     filePath.AppendFormat(CultureInfo.InvariantCulture, @"{0:yyyy-MM-dd_HH-mm}", program.StartTime);
     return filePath.ToString();
 }
        private float DrawProgramText(Graphics g, SolidBrush textBrush, float left, float top, UpcomingProgram program, bool showDate)
        {
            left = DrawAndMeasureString(g, SystemFonts.MessageBoxFont, textBrush, left, top, "• ");

            string times = program.StartTime.ToShortTimeString() + "-" + program.StopTime.ToShortTimeString() + " ";
            float titleLeft = DrawAndMeasureString(g, SystemFonts.MessageBoxFont, Brushes.Black, left, top, times);

            StringFormat trimmedFormat = (StringFormat)StringFormat.GenericTypographic.Clone();
            trimmedFormat.Trimming = StringTrimming.EllipsisCharacter;

            using (Font boldFont = new Font(SystemFonts.MessageBoxFont, FontStyle.Bold))
            {
                g.DrawString(program.CreateProgramTitle(), boldFont, Brushes.Black,
                    new RectangleF(titleLeft, top, this.Width - titleLeft - 8, boldFont.Height), trimmedFormat);
                top += boldFont.Height;
            }

            float onLeft = DrawAndMeasureString(g, SystemFonts.MessageBoxFont, textBrush, left, top, "on ");

            string onText = program.Channel.DisplayName;
            if (showDate)
            {
                onText += ", " + program.StartTime.Date.ToLongDateString();
            }
            g.DrawString(onText, SystemFonts.MessageBoxFont, Brushes.Black,
                new RectangleF(onLeft, top, this.Width - onLeft - 8, SystemFonts.MessageBoxFont.Height), trimmedFormat);

            return top + SystemFonts.MessageBoxFont.Height + _programsGap;
        }