public DisplayForm() { InitializeComponent(); displayController = new DisplayController(); InitScheduleAndPlay(); this.SetDesktopBounds(0,0,20,20); }
public void InitScheduleAndPlay() { //displayController List<Schedule> schedules = new List<Schedule>(); Schedule schedule = new Schedule(); schedule.PlayItems.Add(new PlayItem("C:\\contents\\Custom_02_2012_64x128_1.avi", 0)); schedule.PlayItems.Add(new PlayItem("C:\\contents\\Lotus.JPG", 1)); schedules.Add(schedule); schedule = new Schedule(); schedule.PlayItems.Add(new PlayItem("C:\\contents\\Catching.JPG", 1)); schedule.PlayItems.Add(new PlayItem("C:\\contents\\Fairyland.JPG", 1)); schedules.Add(schedule); displayController = new DisplayController(schedules); PlayItem item = displayController.ReadSchedule(); if (item != null && File.Exists(item.Path)) Play(item); else Thread.Sleep(100); }
public DisplayForm() { Status = PlayerStatus.Init; InitializeComponent(); this.SetDesktopBounds(0,0,256,128); formClose = false; newScheUpdated = false; DownloadDir = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Download\\"); if (!Directory.Exists(DownloadDir)) Directory.CreateDirectory(DownloadDir); ContentDir = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Content\\"); if (!Directory.Exists(ContentDir)) Directory.CreateDirectory(ContentDir); ScheduleDir = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Schedule\\"); if (!Directory.Exists(ScheduleDir)) Directory.CreateDirectory(ScheduleDir); workthread = new Thread(new ThreadStart(ReceiveInformation)); workthread.Start(); displayController = new DisplayController(); InitScheduleAndPlay(); }
public void InitScheduleAndPlay() { //displayController List<Schedule> schedules = new List<Schedule>(); Schedule schedule = new Schedule(); schedule.PlayItems.Add(new PlayItem("1","C:\\contents\\Custom_02_2012_64x128_1.avi", 0)); schedule.PlayItems.Add(new PlayItem("2","C:\\contents\\Lotus.JPG", 1)); schedules.Add(schedule); schedule = new Schedule(); schedule.PlayItems.Add(new PlayItem("3","C:\\contents\\Catching.JPG", 1)); schedule.PlayItems.Add(new PlayItem("4","C:\\contents\\Fairyland.JPG", 1)); schedules.Add(schedule); String schepath = Path.Combine(ScheduleDir, "Schedule.xml"); displayController = new DisplayController(); displayController.ReadFromXML(schepath); Status = PlayerStatus.Finished; }
private void timerSchedule_Tick(object sender, EventArgs e) { if (Status == PlayerStatus.Playing || Status == PlayerStatus.Init) { return; } if (newScheUpdated) { displayController = new DisplayController(); String schepath = Path.Combine(ScheduleDir, "Schedule.xml"); displayController.ReadFromXML(schepath); newScheUpdated = false; } PlayItem item = displayController.GetNextFileFromSchedule(); if (item != null && File.Exists(item.Path)) Play(item); }
private void ReceiveInformation() { while (!formClose) { try { string UserName=""; string Password=""; int waittime = 0; AccountHelper accounthelper = new AccountHelper(); if (accounthelper.ReadFromFile()) { UserName = accounthelper.Account; Password = accounthelper.Password; waittime = accounthelper.UpdateInterval; WCFClient client = new WCFClient(UserName, Password); int count = client.CheckScheduleCount(); List<Schedule> schedules = new List<Schedule>(); if (count >= 0) { for (int i = 0; i < count; i++) { Schedule sche = client.CheckSchedule(i); if (sche != null) schedules.Add(sche); } if (downloadAllFiles(schedules, client)) { DisplayController newController = new DisplayController(schedules); String tmppath = Path.Combine(DownloadDir, "Schedule.xml"); String schepath = Path.Combine(ScheduleDir, "Schedule.xml"); String oldschepath = Path.Combine(ScheduleDir, DateTime.Now.ToString("MMddyy_Hmmss")+"Schedule.old"); try { if (File.Exists(oldschepath)) { File.Delete(oldschepath); } if (File.Exists(tmppath)) { File.Delete(tmppath); } newController.WriteToXML(tmppath); if (!FileCompare(tmppath, schepath)) { if (File.Exists(schepath)) File.Move(schepath, oldschepath); File.Move(tmppath, schepath); newScheUpdated = true; } // better make a lock here } catch (Exception exp) { } } } DateTime time = DateTime.Now; while (DateTime.Now.Subtract(time).TotalMinutes < waittime) { Thread.Sleep(100); if (formClose) return; } } else { Thread.Sleep(10000); } } catch (Exception exp) { } } }