Пример #1
0
 private void frmCalendar_Load(object sender, EventArgs e)
 {
     _dbManager.DataSource = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Personal TV Organiser" + "\\db.sqlite";
     _dbManager.InitializeConnection();
     _dbManager.OpenConnection();
     _episodes = _dbManager.GetEpisodesWithDates(false);
     _dbManager.CloseConnection();
     foreach (Episode episode in _episodes.Values)
     {
         DateTime startDate = episode.FirstAired;
         if (episode.TimeAirs > Convert.ToDateTime("01/01/0001"))
         {
             string airDate = episode.FirstAired.ToString("dd MMM yyyy");
             string airTime = episode.TimeAirs.ToString("HH:mm");
             startDate = Convert.ToDateTime(airDate + " " + airTime);
         }
         DateTime     endDate      = episode.Runtime <= 0 ? startDate.AddHours(1) : startDate.AddMinutes(episode.Runtime);
         CalendarItem calendarItem = new CalendarItem(calendar1, startDate, endDate, episode.ToString());
         calendarItem.Tag = episode.EpisodeID;
         if (episode.Watched)
         {
             calendarItem.ApplyColor(Color.FromArgb(0, 192, 192, 192));
         }
         else if (episode.FirstAired <= DateTime.Now)
         {
             calendarItem.ApplyColor(Color.FromArgb(0, 255, 0, 0));
         }
         _items.Add(episode.EpisodeID, calendarItem);
     }
     calendar1.MaximumFullDays = 7;
     SetCalendarView();
     lblMonth.Text = DateTime.Today.ToString("MMMM yyyy");
     lineShape1.X2 = Width - calendar1.Width - 35;
 }