public void BuildTimeLineTest() { var timelineBuilder = new TimelineBuilder(); timelineBuilder.BuildTimeLine(); Assert.True(false, "This test needs an implementation"); }
public void SetLength() { var file = new MediaFile("transitions.wmv"); file.LengthInUnits = TimelineBuilder.ToUnits(2); Assert.AreEqual(2, file.Length); }
public NpcSystem(TimelineHandler handler) { _log.Trace($"Handling NpcSystem call: {handler}"); foreach (var timelineEvent in handler.TimeLineEvents) { if (string.IsNullOrEmpty(timelineEvent.Command)) { continue; } Timeline timeline; switch (timelineEvent.Command.ToLower()) { case "start": timeline = TimelineBuilder.GetLocalTimeline(); timeline.Status = Timeline.TimelineStatus.Run; TimelineBuilder.SetLocalTimeline(timeline); break; case "stop": timeline = TimelineBuilder.GetLocalTimeline(); timeline.Status = Timeline.TimelineStatus.Stop; StartupTasks.CleanupProcesses(); TimelineBuilder.SetLocalTimeline(timeline); break; } } }
protected void AssertLengths(double fps, string file1, string file2) { long length1 = MediaInspector.GetLength(file1); long length2 = MediaInspector.GetLength(file2); long frameLength = TimelineBuilder.ToUnits(1.0 / fps); long difference = Math.Abs(length1 - length2); Assert.IsTrue(difference <= frameLength); }
protected void AssertLengths(double fps, double expected, string file) { long length1 = TimelineBuilder.ToUnits(expected); long length2 = MediaInspector.GetLength(file); long frameLength = TimelineBuilder.ToUnits(1.0 / fps) * 4; // allow for 4 frames difference long difference = Math.Abs(length1 - length2); Assert.IsTrue(difference <= frameLength, string.Format("expected {0} +/- {1}, but was {2}", length1, frameLength, length2)); }
public void ConstructAndDispose() { var file = new MediaFile("..\\..\\transitions.wmv"); Assert.AreEqual("..\\..\\transitions.wmv", file.FileName); Assert.AreEqual(7.999, file.Length); Assert.AreEqual(TimelineBuilder.ToUnits(7.999), file.LengthInUnits); Assert.AreEqual(-1, file.LengthInFrames); // not assigned till later file.Dispose(); Assert.IsTrue(File.Exists("..\\..\\transitions.wmv")); }
public TimelineDisplayEvent( TimelineEvent e, TimelineTray tray, TimelineBuilder builder ) { if (e.Link == null) { e.Link = String.Empty; } if (e.Description == null) { e.Description = String.Empty; } m_timelineEvent = e; m_selected = e.Selected; m_timelineEvent.PropertyChanged += OnEventPropertyChanged; if (e.HeightOverride == -1.0) { m_eventDescriptionHeight = tray.MainBand.MaxEventHeight; } else { m_eventDescriptionHeight = e.HeightOverride; } if (e.WidthOverride == -1.0) { m_eventDescriptionWidth = tray.DescriptionWidth; } else { m_eventDescriptionWidth = e.WidthOverride; } if (e.TopOverride != -1) { SetCalculatedTop(e.TopOverride); } TimelineBuilder = builder; TimelineTray = tray; UpdateDisplayEvent(); }
private static void GetServerUpdates() { if (!Program.Configuration.ClientUpdates.IsEnabled) { return; } var machine = new ResultMachine(); Thread.Sleep(Program.Configuration.ClientUpdates.CycleSleep); while (true) { try { string s = string.Empty; using (var client = WebClientBuilder.Build(machine)) { try { using (var reader = new StreamReader(client.OpenRead(Program.Configuration.ClientUpdates.PostUrl))) { s = reader.ReadToEnd(); _log.Debug($"{DateTime.Now} - Received new configuration"); } } catch (WebException wex) { if (((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound) { _log.Debug($"{DateTime.Now} - No new configuration found"); } } catch (Exception e) { _log.Error(e); } } if (!string.IsNullOrEmpty(s)) { var update = JsonConvert.DeserializeObject <UpdateClientConfig>(s); switch (update.Type) { case UpdateClientConfig.UpdateType.Timeline: TimelineBuilder.SetLocalTimeline(update.Update.ToString()); break; case UpdateClientConfig.UpdateType.TimelinePartial: try { var timeline = JsonConvert.DeserializeObject <Timeline>(update.Update.ToString()); foreach (var timelineHandler in timeline.TimeLineHandlers) { _log.Trace($"PartialTimeline found: {timelineHandler.HandlerType}"); foreach (var timelineEvent in timelineHandler.TimeLineEvents) { if (string.IsNullOrEmpty(timelineEvent.TrackableId)) { timelineEvent.TrackableId = Guid.NewGuid().ToString(); } } var orchestrator = new Orchestrator(); orchestrator.RunCommand(timelineHandler); } } catch (Exception exc) { _log.Debug(exc); } break; case UpdateClientConfig.UpdateType.Health: { var newTimeline = JsonConvert.DeserializeObject <Ghosts.Domain.ResultHealth>(update.Update.ToString()); //save to local disk using (var file = File.CreateText(ApplicationDetails.ConfigurationFiles.Health)) { var serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(file, newTimeline); } break; } default: { _log.Debug($"Update {update.Type} has no handler, ignoring..."); break; } } } } catch (Exception e) { _log.Debug("Problem polling for new configuration"); _log.Error(e); } Thread.Sleep(Program.Configuration.ClientUpdates.CycleSleep); } }
public void SetLengthTooLong() { var file = new MediaFile("transitions.wmv"); file.LengthInUnits = TimelineBuilder.ToUnits(20); }
public void ToUnits() { Assert.AreEqual(10000000, TimelineBuilder.ToUnits(1)); Assert.AreEqual(-1, TimelineBuilder.ToUnits(-1)); }
public void ToSeconds() { Assert.AreEqual(1, TimelineBuilder.ToSeconds(10000000)); Assert.AreEqual(-1, TimelineBuilder.ToSeconds(-1)); }
public void CreateTimelineCalculator( string calendarType, DateTime currentDateTime, DateTime minDateTime, DateTime maxDateTime ) { Debug.Assert(this.TimelineTray != null); ItemsSource = new TimelineCalendar(calendarType, m_timelineType, minDateTime, maxDateTime); ItemsSource.TimeFormat24 = TimeFormat24; m_calendarType = calendarType; if (ItemTemplate == null) { ItemTemplate = DefaultItemTemplate; } if (TextItemTemplate == null) { TextItemTemplate = DefaultTextItemTemplate; } if (ShortEventTemplate == null) { ShortEventTemplate = DefaultShortEventTemplate; } if (EventTemplate == null) { EventTemplate = DefaultEventTemplate; } if (m_calc != null) { m_calc.ClearEvents(); m_calc.ClearColumns(); } m_calc = new TimelineBuilder( this, CanvasPart, ItemTemplate, TextItemTemplate, TimelineWindowSize, ItemsSource, !IsMainBand ? ShortEventTemplate : EventTemplate, MaxEventHeight, IsMainBand, currentDateTime); m_calc.BuildColumns(); m_calcInitialized = true; }
private static void GetServerUpdates() { if (!Program.Configuration.ClientUpdates.IsEnabled) { return; } // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; var machine = new ResultMachine(); GuestInfoVars.Load(machine); Thread.Sleep(ProcessManager.Jitter(Program.Configuration.ClientUpdates.CycleSleep)); while (true) { try { string s = string.Empty; using (var client = WebClientBuilder.Build(machine)) { try { using (var reader = new StreamReader(client.OpenRead(Program.Configuration.ClientUpdates.PostUrl))) { s = reader.ReadToEnd(); _log.Debug($"{DateTime.Now} - Received new configuration"); } } catch (WebException wex) { if (((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound) { _log.Debug($"{DateTime.Now} - No new configuration found"); } } catch (Exception e) { _log.Error(e); } } if (!string.IsNullOrEmpty(s)) { var update = JsonConvert.DeserializeObject <UpdateClientConfig>(s); if (update.Type == UpdateClientConfig.UpdateType.Timeline) { TimelineBuilder.SetLocalTimeline(update.Update.ToString()); } else if (update.Type == UpdateClientConfig.UpdateType.Health) { var newTimeline = JsonConvert.DeserializeObject <Domain.ResultHealth>(update.Update.ToString()); //save to local disk using (var file = File.CreateText(ApplicationDetails.ConfigurationFiles.Health)) { var serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(file, newTimeline); } } } } catch (Exception e) { _log.Debug("Problem polling for new configuration"); _log.Error(e); } Thread.Sleep(ProcessManager.Jitter(Program.Configuration.ClientUpdates.CycleSleep)); } }