private void tmrUpdate_Tick(object sender, EventArgs e) { if (warmup && --warmup_time_left <= 0) { warmup = false; lblIP.Hide(); } if (currentProjection != null) { if (currentProjection.isDefault) //Check if scheduled projection is available { ProjectionObj schedProj = projectionManager.GetCurrentProjection(); if (schedProj != null) //Scheduled Projection is Available { currentProjection = schedProj; intervalWatch.Restart(); DisplaySlide(currentProjection.GetImages().First()); } else if (!projectionManager.GetDefaultProjection().Equals(currentProjection)) { currentProjection = projectionManager.GetDefaultProjection(); intervalWatch.Restart(); DisplaySlide(currentProjection.GetImages().First()); } } else //non-default projection { DateTimeRange currentRange = new DateTimeRange(DateTime.Now, DateTime.Now.AddSeconds(1)); bool isProjCurrent = currentProjection.scheduledDateTimes.Any(range => range.Intersects(currentRange)); if (!isProjCurrent) { //Cleanup //TODO_LATER make sure this won't collide with 'Save' being called when projection is being received projectionManager.DeleteProjection(currentProjection); Save(); currentProjection = null; GC.Collect(); } } if (currentProjection != null && currentProjection.GetImages().Count > 1) { if (intervalWatch.Elapsed.Seconds >= currentProjection.changeInterval.Seconds) { Console.WriteLine(DateTime.Now.ToString("HH:mm:ss")); intervalWatch.Restart(); ++iterator; if (iterator >= currentProjection.GetImages().Count) { iterator = 0; } DisplaySlide(currentProjection.GetImages()[iterator]); } } } //Current projection marked for removal, or initialization if (currentProjection == null) { //Display default image or retrieve current currentProjection = projectionManager.GetDefaultProjection(); intervalWatch.Restart(); //Add dummy image so fade will be executed if (pbProject.Image == null) { Bitmap bmp = new Bitmap(pbProject.Width, pbProject.Height); Graphics g = Graphics.FromImage(bmp); g.FillRectangle(Brushes.LightGray, 0, 0, pbProject.Width, pbProject.Height); pbProject.Image = bmp; } DisplaySlide(currentProjection.GetImages().First()); } }