SearchMinimalPrograms() public méthode

public SearchMinimalPrograms ( System.DateTime startTime, System.DateTime endTime, string programName, TvDatabase.Channel channel ) : IList
startTime System.DateTime
endTime System.DateTime
programName string
channel TvDatabase.Channel
Résultat IList
    private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram)
    {
      int itemToSelect = -1;
      lstUpcomingEpsiodes.Clear();
      TvBusinessLayer layer = new TvBusinessLayer();
      DateTime dtDay = DateTime.Now;

      // build a list of all upcoming instances of program from EPG data based on program name alone
      List<Program> episodes = (List<Program>)layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(28), initialProgram.Title, null);

      // now if schedule is time based then build a second list for that schedule based on start time (see below)
      IList<Program> actualUpcomingEps = new List<Program>();      
      if (currentSchedule != null)
      {
        int scheduletype = currentSchedule.ScheduleType;        

        switch (scheduletype)
        {
          case (int)ScheduleRecordingType.Weekly:
            actualUpcomingEps = Program.RetrieveWeekly(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.Weekends:
            actualUpcomingEps = Program.RetrieveWeekends(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.WorkingDays:
            actualUpcomingEps = Program.RetrieveWorkingDays(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.Daily:
          actualUpcomingEps = Program.RetrieveDaily(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
          break;
        }
       
        // now if we have a time based schedule then loop through that and if entry does not exist
        // in the original list then add it
        // an entry will exist in the second list but not first if the program name is different
        // in reality this will probably be a series that has finished
        // eg. we have set a schedule for channel X for Monday 21:00 to 22:00 which happens to be when 
        // program A is on.   The series for program A finishes and now between 21:00 and 22:00 on 
        // channel X is program B.   A time based schedule does not take the program name into account
        // therefore program B will get recorded.
        if (actualUpcomingEps.Count > 0)
        {
          for (int i = actualUpcomingEps.Count - 1; i >= 0; i--)
          {
            Program ep = actualUpcomingEps[i];

            if (!episodes.Contains(ep))
            {
              episodes.Add(ep);
            }
          }
          episodes.Sort((x, y) => (x.StartTime.CompareTo(y.StartTime))); //resort list locally on starttime
        }

      }
      bool updateCurrentProgram = true;
      anyUpcomingEpisodesRecording = false;
      int activeRecordings = 0;
      for (int i = 0; i < episodes.Count; i++)
      {        
        Program episode = episodes[i];
        GUIListItem item = new GUIListItem();
        item.Label = TVUtil.GetDisplayTitle(episode);
        item.OnItemSelected += item_OnItemSelected;
        string logo = Utils.GetCoverArt(Thumbs.TVChannel, episode.ReferencedChannel().DisplayName);
        if (string.IsNullOrEmpty(logo))                      
        {
          item.Label = String.Format("{0} {1}", episode.ReferencedChannel().DisplayName, TVUtil.GetDisplayTitle(episode));
          logo = "defaultVideoBig.png";
        }

        bool isActualUpcomingEps = actualUpcomingEps.Contains(episode) ;
        bool isRecPrg = isActualUpcomingEps;
        Schedule recordingSchedule = currentSchedule;

        // appears a little odd but seems to work
        // if episode is not in second (time based) list then override isRecPrg by actually
        // checking if episode is due to be recorded (if it is in second (time based) list then
        // it is going to be recorded
        if (!isActualUpcomingEps)
        {
            isRecPrg = (episode.IsRecording || episode.IsRecordingOncePending || episode.IsRecordingSeriesPending || 
                        episode.IsPartialRecordingSeriesPending) && IsRecordingProgram(episode, out recordingSchedule, true);
        }
        if (isRecPrg)
        {          
          if (!recordingSchedule.IsSerieIsCanceled(recordingSchedule.GetSchedStartTimeForProg(episode), episode.IdChannel))
          {
            bool hasConflict = recordingSchedule.ReferringConflicts().Count > 0;
            bool isPartialRecording = false;
            bool isSeries = (recordingSchedule.ScheduleType != (int)ScheduleRecordingType.Once);

            //check for partial recordings.
            if (isActualUpcomingEps && currentSchedule != null)
            {
              isPartialRecording = Schedule.IsPartialRecording(currentSchedule, episode);
            }
            if (isPartialRecording)
            {
              item.PinImage = hasConflict ? 
                (isSeries? Thumbs.TvConflictPartialRecordingSeriesIcon : Thumbs.TvConflictPartialRecordingIcon) : 
                (isSeries? Thumbs.TvPartialRecordingSeriesIcon : Thumbs.TvPartialRecordingIcon);
            }
            else
            {
              item.PinImage = hasConflict ? 
                (isSeries? Thumbs.TvConflictRecordingSeriesIcon : Thumbs.TvConflictRecordingIcon) : 
                (isSeries? Thumbs.TvRecordingSeriesIcon : Thumbs.TvRecordingIcon);
            }

            if (updateCurrentProgram)
            {
              //currentProgram = episode;
            }
            activeRecordings++;
            anyUpcomingEpisodesRecording = true;
            updateCurrentProgram = false;
          }          
          item.TVTag = recordingSchedule;
        }
        else
        {
          if (episode.Notify)
          {
            item.PinImage = Thumbs.TvNotifyIcon;
          }
        }

        item.MusicTag = episode;
        item.ThumbnailImage = item.IconImageBig = item.IconImage = logo;

        item.Label2 = String.Format("{0} {1} - {2}",
                                    Utils.GetShortDayString(episode.StartTime),
                                    episode.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                    episode.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

        if (lastSelectedProgram != null)
        {
          if (lastSelectedProgram.IdChannel == episode.IdChannel &&
              lastSelectedProgram.StartTime == episode.StartTime &&
              lastSelectedProgram.EndTime == episode.EndTime && lastSelectedProgram.Title == episode.Title)
          {
            itemToSelect = lstUpcomingEpsiodes.Count;
          }
        }
        lstUpcomingEpsiodes.Add(item);
      }


      if (!anyUpcomingEpisodesRecording)
      {
        currentProgram = initialProgram;
      }

      if (itemToSelect != -1)
      {
        lstUpcomingEpsiodes.SelectedListItemIndex = itemToSelect;
      }

      lblUpcomingEpsiodes.Label = GUILocalizeStrings.Get(1203, new object[] { activeRecordings });

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Utils.GetObjectCountLabel(lstUpcomingEpsiodes.ListItems.Count));
    }
Exemple #2
0
      //-------------------------------------------------------------------------------------------------------------        
      // gets the recording time of a schedule
      //-------------------------------------------------------------------------------------------------------------
      public List<Schedule> GetRecordingTimes(Schedule rec, int days)
      {
          TvBusinessLayer layer = new TvBusinessLayer();
          List<Schedule> recordings = new List<Schedule>();

          DateTime dtDay = DateTime.Now;
          if (rec.ScheduleType == (int)ScheduleRecordingType.Once)
          {
              recordings.Add(rec);
              return recordings;
          }

          if (rec.ScheduleType == (int)ScheduleRecordingType.Daily)
          {
              for (int i = 0; i < days; ++i)
              {
                  Schedule recNew = rec.Clone();
                  recNew.ScheduleType = (int)ScheduleRecordingType.Once;
                  recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                                  0);
                  if (rec.EndTime.Day > rec.StartTime.Day)
                  {
                      dtDay = dtDay.AddDays(1);
                  }
                  recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
                  if (rec.EndTime.Day > rec.StartTime.Day)
                  {
                      dtDay = dtDay.AddDays(-1);
                  }
                  recNew.Series = true;
                  if (recNew.StartTime >= DateTime.Now)
                  {
                      if (rec.IsSerieIsCanceled(recNew.StartTime))
                      {
                          recNew.Canceled = recNew.StartTime;
                      }
                      recordings.Add(recNew);
                  }
                  dtDay = dtDay.AddDays(1);
              }
              return recordings;
          }

          if (rec.ScheduleType == (int)ScheduleRecordingType.WorkingDays)
          {

#if (TV100 || TV101 || TV12)
              for (int i = 0; i < days; ++i)
              {
                  if (dtDay.DayOfWeek != DayOfWeek.Saturday && dtDay.DayOfWeek != DayOfWeek.Sunday)
#elif(TV11)
              WeekEndTool weekEndTool = Setting.GetWeekEndTool();
              for (int i = 0; i < days; ++i)
              {
                  if (weekEndTool.IsWorkingDay(dtDay.DayOfWeek))  
#endif             
                  {
                      Schedule recNew = rec.Clone();
                      recNew.ScheduleType = (int)ScheduleRecordingType.Once;
                      recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                                      0);
                      if (rec.EndTime.Day > rec.StartTime.Day)
                      {
                          dtDay = dtDay.AddDays(1);
                      }
                      recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
                      if (rec.EndTime.Day > rec.StartTime.Day)
                      {
                          dtDay = dtDay.AddDays(-1);
                      }
                      recNew.Series = true;
                      if (rec.IsSerieIsCanceled(recNew.StartTime))
                      {
                          recNew.Canceled = recNew.StartTime;
                      }
                      if (recNew.StartTime >= DateTime.Now)
                      {
                          recordings.Add(recNew);
                      }
                  }
                  dtDay = dtDay.AddDays(1);
              }
              return recordings;
          }

          if (rec.ScheduleType == (int)ScheduleRecordingType.Weekends)
          {
#if(TV100)
              IList progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,rec.ReferencedChannel());
              foreach (Program prog in progList)
              {
                  if ((rec.IsRecordingProgram(prog, false)) &&
                      (prog.StartTime.DayOfWeek == DayOfWeek.Saturday || prog.StartTime.DayOfWeek == DayOfWeek.Sunday))
#elif(TV101 || TV12)
              IList<Program> progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,rec.ReferencedChannel());
              foreach (Program prog in progList)
              {
                  if ((rec.IsRecordingProgram(prog, false)) &&
                      (prog.StartTime.DayOfWeek == DayOfWeek.Saturday || prog.StartTime.DayOfWeek == DayOfWeek.Sunday))

#elif(TV11)
              IList<Program> progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel());
              WeekEndTool weekEndTool = Setting.GetWeekEndTool();
              foreach (Program prog in progList)
              {
                  if ((rec.IsRecordingProgram(prog, false)) &&
                      (weekEndTool.IsWeekend(prog.StartTime.DayOfWeek)))
#endif
              

              
                  {
                      Schedule recNew = rec.Clone();
                      recNew.ScheduleType = (int)ScheduleRecordingType.Once;
                      recNew.StartTime = prog.StartTime;
                      recNew.EndTime = prog.EndTime;
                      recNew.Series = true;

                      if (rec.IsSerieIsCanceled(recNew.StartTime))
                      {
                          recNew.Canceled = recNew.StartTime;
                      }
                      recordings.Add(recNew);
                  }
              }
              return recordings;


              




          }
          if (rec.ScheduleType == (int)ScheduleRecordingType.Weekly)
          {
              for (int i = 0; i < days; ++i)
              {
                  if ((dtDay.DayOfWeek == rec.StartTime.DayOfWeek) && (dtDay.Date >= rec.StartTime.Date))
                  {
                      Schedule recNew = rec.Clone();
                      recNew.ScheduleType = (int)ScheduleRecordingType.Once;
                      recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                                      0);
                      if (rec.EndTime.Day > rec.StartTime.Day)
                      {
                          dtDay = dtDay.AddDays(1);
                      }
                      recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
                      if (rec.EndTime.Day > rec.StartTime.Day)
                      {
                          dtDay = dtDay.AddDays(-1);
                      }
                      recNew.Series = true;
                      if (rec.IsSerieIsCanceled(recNew.StartTime))
                      {
                          recNew.Canceled = recNew.StartTime;
                      }
                      if (recNew.StartTime >= DateTime.Now)
                      {
                          recordings.Add(recNew);
                      }
                  }
                  dtDay = dtDay.AddDays(1);
              }
              return recordings;
          }

#if(TV100)
          IList programs = rec.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel
                                      ? layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                                    rec.ReferencedChannel())
                                      : layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, null);
#elif(TV101 || TV11 || TV12)
          IList<Program> programs = rec.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel
                                      ? layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                                    rec.ReferencedChannel())
                                      : layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, null);
#endif

          foreach (Program prog in programs)
          {
              if (rec.IsRecordingProgram(prog, false))
              {
                  Schedule recNew = rec.Clone();
                  recNew.ScheduleType = (int)ScheduleRecordingType.Once;
                  recNew.IdChannel = prog.IdChannel;
                  recNew.StartTime = prog.StartTime;
                  recNew.EndTime = prog.EndTime;
                  recNew.Series = true;
                  if (rec.IsSerieIsCanceled(recNew.StartTime))
                  {
                      recNew.Canceled = recNew.StartTime;
                  }
                  recordings.Add(recNew);
              }
          }
          return recordings;
      }
    public List<Schedule> GetRecordingTimes(Schedule rec, int days)
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      List<Schedule> recordings = new List<Schedule>();

      DateTime dtDay = DateTime.Now;
      if (rec.ScheduleType == (int)ScheduleRecordingType.Once)
      {
        recordings.Add(rec);
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.Daily)
      {
        for (int i = 0; i < days; ++i)
        {
          Schedule recNew = rec.Clone();
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                          0);
          if (rec.EndTime.Day > rec.StartTime.Day)
          {
            dtDay = dtDay.AddDays(1);
          }
          recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
          if (rec.EndTime.Day > rec.StartTime.Day)
          {
            dtDay = dtDay.AddDays(-1);
          }
          recNew.Series = true;
          if (recNew.StartTime >= DateTime.Now)
          {
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.WorkingDays)
      {
        for (int i = 0; i < days; ++i)
        {
          if (WeekEndTool.IsWorkingDay(dtDay.DayOfWeek))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                            0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.Weekends)
      {
        IList<Program> progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                              rec.ReferencedChannel());

        foreach (Program prog in progList)
        {
          if ((rec.IsRecordingProgram(prog, false)) &&
              (WeekEndTool.IsWeekend(prog.StartTime.DayOfWeek)))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;

            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
        }
        return recordings;
      }
      if (rec.ScheduleType == (int)ScheduleRecordingType.Weekly)
      {
        for (int i = 0; i < days; ++i)
        {
          if ((dtDay.DayOfWeek == rec.StartTime.DayOfWeek) && (dtDay.Date >= rec.StartTime.Date))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                            0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      IList<Program> programs;
      if (rec.ScheduleType == (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)
      {
        //Log.Debug("get {0} {1} EveryTimeOnThisChannel", rec.ProgramName, rec.ReferencedChannel().Name);
        programs = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel());
        foreach (Program prog in programs)
        {
          // dtDay.DayOfWeek == rec.StartTime.DayOfWeek
          // Log.Debug("BusinessLayer.cs Program prog in programs WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek);
          if (prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek && rec.IsRecordingProgram(prog, false))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.IdChannel = prog.IdChannel;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);

            //Log.Debug("BusinessLayer.cs Added Recording WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek);
          }
        }
        return recordings;
      }

      programs = rec.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel
                   ? layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                 rec.ReferencedChannel())
                   : layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, null);
      foreach (Program prog in programs)
      {
        if (rec.IsRecordingProgram(prog, false))
        {
          Schedule recNew = rec.Clone();
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.IdChannel = prog.IdChannel;
          recNew.StartTime = prog.StartTime;
          recNew.EndTime = prog.EndTime;
          recNew.Series = true;
          if (rec.IsSerieIsCanceled(rec.GetSchedStartTimeForProg(prog), prog.IdChannel))
          {
            recNew.Canceled = recNew.StartTime;
          }
          recordings.Add(recNew);
        }
      }
      return recordings;
    }
    /// <summary>
    /// Gets the Weekly every time on this channel schedules.
    /// </summary>
    /// <param name="schedulesList">The schedules list.</param>
    /// <returns></returns>
    private void getWeeklyEveryTimeOnThisChannelSchedules(IList<Schedule> schedulesList, IList<Schedule> refFillList)
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      foreach (Schedule schedule in schedulesList)
      {
        ScheduleRecordingType scheduleType = (ScheduleRecordingType)schedule.ScheduleType;
        if (schedule.Canceled != Schedule.MinSchedule) continue;
        if (scheduleType != ScheduleRecordingType.WeeklyEveryTimeOnThisChannel) continue;
        Channel channel = Channel.Retrieve(schedule.IdChannel);
        IList<Program> programsList = layer.SearchMinimalPrograms(DateTime.Now, DateTime.Now.AddMonths(1),
                                                                  schedule.ProgramName, channel);
        if (programsList != null)
        {
          foreach (Program program in programsList)
          {
            if (program.StartTime.DayOfWeek == schedule.StartTime.DayOfWeek)
            {
              Schedule incomingSchedule = schedule.Clone();
              incomingSchedule.IdChannel = program.IdChannel;
              incomingSchedule.ProgramName = program.Title;
              incomingSchedule.StartTime = program.StartTime;
              incomingSchedule.EndTime = program.EndTime;

              incomingSchedule.PreRecordInterval = schedule.PreRecordInterval;
              incomingSchedule.PostRecordInterval = schedule.PostRecordInterval;
              refFillList.Add(incomingSchedule);
            }
          }
        } //foreach (Program _program in _programsList)
      } //foreach (Schedule _Schedule in schedulesList)
      layer = null;
      foreach (Schedule sched in refFillList) schedulesList.Remove(sched);
    }