public void load_schedule(string f) { videoList = new VideoFile[1024]; for (int i = 0; i < 7; i++) { dailyList[i] = new DailyVideoFiles(); } Schedule s = new Schedule(); s = XMLReader.ReadSchedule(f); List <DailyVideoFiles> list = s.DailyVideoFilesList; list.CopyTo(dailyList, 0); foreach (DailyVideoFiles dailyFile in list) { //MessageBox.Show("how many days?" + dailyFile.VideoFileList.Count); foreach (VideoFile v in dailyFile.VideoFileList) { int index = v.Index; videoList[index] = v; } } get_diff(dailyList); }
public void save_weekSchedule_with_ads() { sc.DailyVideoFilesList = new List <DailyVideoFiles>(); String[] dates = new String[7]; videoList_with_ads = videoList; dailyList_with_ads = dailyList; dates = date_gen(); for (int i = 0; i < 7; i++) { dailyList[i] = new DailyVideoFiles(); } foreach (VideoFile video in videoList) { if (video != null) { int day = video.Col - 1; MessageBox.Show(day.ToString()); dailyList[day].Date = dates[day]; dailyList[day].VideoFileList.Add(video); } } foreach (VideoFile video in videoList_with_ads) { if (video != null) { int day = video.Col - 1; dailyList_with_ads[day].Date = dates[day]; dailyList_with_ads[day].VideoFileList.Add(video); } } for (int i = 0; i < 7; i++) { sc.DailyVideoFilesList.Add(dailyList[i]); sc.DailyVideoFilesList.Add(dailyList_with_ads[i]); } string file = schedule_file + "_ads" + ".xml"; XMLWriter.WriteSchedule(sc, file); }
private void calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { //Update the schedule list with the display date DateTime date = calendar.SelectedDate.Value; displayDate.Text = Utilities.FormatDateDMY(date.Day, date.Month, date.Year); string scheduleFileName = "C:\\PeopleBAWX\\" + Utilities.GetMonday(date) + ".xml"; DailyVideoFiles dvf = Utilities.GetTodayScheduleList(scheduleFileName, Utilities.FormatDateYMD(date.Year, date.Month, date.Day)); ResetScheduleList(); if (dvf != null) { UpdateScheduleList(dvf); } //tjl.AddRecent(scheduleFileName); //for jumplist }
private void ScheduleList_Loaded(object sender, RoutedEventArgs e) { //tjl.AddTask(); //for jumplist //Update the schedule list with the display date string scheduleFileName = "C:\\PeopleBAWX\\" + Utilities.GetMonday(DateTime.Now) + ".xml"; DailyVideoFiles dvf = Utilities.GetTodayScheduleList(scheduleFileName, Utilities.FormatDateYMD(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); ResetScheduleList(); if (dvf != null) { UpdateScheduleList(dvf); } //tjl.AddRecent(scheduleFileName);//for jumplist }
private void UpdateScheduleList(DailyVideoFiles dvf) { /* * MessageBox.Show(scheduleList.Children.Count + ""); * string list = ""; * for (int i = 0; i < scheduleList.Children.Count; i++) * { * list += ("i=" + i + ": " + scheduleList.Children[i].ToString() + "\n"); * if ((i+1) % 40 == 0) * { * MessageBox.Show(list); * list = ""; * } * } * MessageBox.Show(list); */ foreach (VideoFile vf in dvf.VideoFileList) { //MessageBox.Show(vf.Row + ""); TextBlock tb = (TextBlock)scheduleList.Children[24 + vf.Row]; tb.Text = vf.Path; tb.Background = Brushes.DeepPink; int noOfTextBlock = GetNoOfOccupiedTextBlock(vf.Length); //MessageBox.Show("noOfTextBlock:" + noOfTextBlock); if (noOfTextBlock > 1) { Grid.SetRowSpan(tb, noOfTextBlock); for (int i = 1; i < noOfTextBlock; i++) { TextBlock tb1 = (TextBlock)scheduleList.Children[24 + vf.Row + i]; tb1.Text = ""; tb1.Background = Brushes.Transparent; } } } }
private void bw_DoWork(object sender, DoWorkEventArgs e) { /* * UpdatePlayerUriDelegate update = new UpdatePlayerUriDelegate(UpdateNowPlaying); * Dispatcher meDispatcher = mediaElement.Dispatcher; * meDispatcher.BeginInvoke(update, "C:\\1.wmv"); */ int prevDay; string[] timeSplit; int[] timeInInt; int videoCount; bool isNewDay = true; UpdatePlayerUriDelegate updateNowPlaying = new UpdatePlayerUriDelegate(UpdateNowPlaying); Dispatcher mediaElementDispatcher = mediaElement.Dispatcher; UpdateCurrentTimeDelegate updateDisplayTime = new UpdateCurrentTimeDelegate(UpdateDisplayTime); Dispatcher displayTimeDispatcher = displayTime.Dispatcher; do { //get videos ready prevDay = DateTime.Now.Day; string scheduleFileName = "C:\\PeopleBAWX\\" + Utilities.GetMonday(DateTime.Now) + ".xml"; dvf = Utilities.GetTodayScheduleList( scheduleFileName, Utilities.FormatDateYMD(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); if (dvf == null) { if (isNewDay) { MessageBox.Show("Nothing to broadcast today!"); videoCount = 0; isNewDay = false; } displayTimeDispatcher.BeginInvoke(updateDisplayTime, String.Format("{0:00}", DateTime.Now.Hour) + ":" + String.Format("{0:00}", DateTime.Now.Minute) + ":" + String.Format("{0:00}", DateTime.Now.Second)); Thread.Sleep(1000); //wait for 1 sec } else //do the broadcasting { isNewDay = false; videoCount = dvf.VideoFileList.Count; filesTime = new DateTime[videoCount]; filesLength = new DateTime[videoCount]; filesPath = new string[videoCount]; for (int i = 0; i < videoCount; i++) { VideoFile vf = dvf.VideoFileList.ElementAt(i); timeSplit = vf.Start_Time.Split(':'); timeInInt = new int[3]; for (int j = 0; j < 3; j++) { timeInInt[j] = Int32.Parse(timeSplit[j]); } filesTime[i] = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, timeInInt[0], timeInInt[1], timeInInt[2]); filesPath[i] = vf.Path; timeSplit = vf.Length.Split(':'); timeInInt = new int[3]; for (int j = 0; j < 3; j++) { timeInInt[j] = Int32.Parse(timeSplit[j]); } filesLength[i] = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, timeInInt[0], timeInInt[1], timeInInt[2]); } int videoChecked = 0; while (true) { if (comingUpNext.ToLongTimeString() == DateTime.Now.ToLongTimeString()) { string path = Directory.GetCurrentDirectory() + "..\\Assets\\ComingUp.jpg"; mediaElementDispatcher.BeginInvoke(updateNowPlaying, path); } if (DateTime.Now.Day != prevDay) //next day reached { isNewDay = true; break; } else if (videoChecked == videoCount) { //all the videos for today have been broadcasted //wait for the next day } else { //the schedule for today came late //some shows scheduled early need not be broadcast if (filesTime[videoChecked].Hour < DateTime.Now.Hour || (filesTime[videoChecked].Hour == DateTime.Now.Hour && filesTime[videoChecked].Minute < DateTime.Now.Minute) || (filesTime[videoChecked].Hour == DateTime.Now.Hour && filesTime[videoChecked].Minute == DateTime.Now.Minute && filesTime[videoChecked].Second < DateTime.Now.Second)) { videoChecked++; continue; //skip this iteration } //the time for broadcasting this particular video is reached if (filesTime[videoChecked].ToLongTimeString() == DateTime.Now.ToLongTimeString()) { mediaElementDispatcher.BeginInvoke(updateNowPlaying, "C:\\PeopleBAWX\\" + filesPath[videoChecked]); comingUpNext = DateTime.Now.Add(new TimeSpan( filesLength[videoChecked].Hour, filesLength[videoChecked].Minute, filesLength[videoChecked].Second)); videoChecked++; } } displayTimeDispatcher.BeginInvoke(updateDisplayTime, String.Format("{0:00}", DateTime.Now.Hour) + ":" + String.Format("{0:00}", DateTime.Now.Minute) + ":" + String.Format("{0:00}", DateTime.Now.Second)); Thread.Sleep(1000); //wait for 1 sec } } } while (true); }