private void SaveLightingData() { string fullPathToLightingFile = VideoAnimationManager.GetFullPathToLightsFile(SelectedSceneName); if (HasAnyLightingChanges(LightingSequence)) { LightingSequence compressedLightingSequence = LightingSequence.Compress(); string serializedLights = Newtonsoft.Json.JsonConvert.SerializeObject(compressedLightingSequence, Newtonsoft.Json.Formatting.Indented); System.IO.File.WriteAllText(fullPathToLightingFile, serializedLights); } else { System.Diagnostics.Debugger.Break(); // TODO: Delete the file!!! } }
static void StartLiveAnimation(string sceneName, List <VideoAnimationBinding> bindings, DateTime startTime) { CleanUpLiveFeedAnimators(); liveFeedAnimators = new List <LiveFeedAnimator>(); foreach (VideoAnimationBinding videoAnimationBinding in bindings) { string movementFile = GetFullPathToMovementFile(videoAnimationBinding.MovementFileName); VideoFeed[] videoFeeds = AllVideoFeeds.GetAll(videoAnimationBinding); LiveFeedAnimator liveFeedAnimator = LoadLiveAnimation(movementFile, videoAnimationBinding, videoFeeds); liveFeedAnimator.FrameAnimator.AnimationComplete += LiveFeedAnimator_AnimationComplete; liveFeedAnimator.FrameAnimator.Start(startTime); liveFeedAnimators.Add(liveFeedAnimator); } // TODO: Track which video feed we are running in case we abort while we are running. string fullPathToLightsFile = VideoAnimationManager.GetFullPathToLightsFile(sceneName); if (System.IO.File.Exists(fullPathToLightsFile)) { string lightsJson = System.IO.File.ReadAllText(fullPathToLightsFile); LightingSequence lightingSequence = JsonConvert.DeserializeObject <LightingSequence>(lightsJson); //log.Clear(); foreach (Light light in lightingSequence.Lights) { FrameAnimator frameAnimator = new FrameAnimator(light.SequenceData.Count); frameAnimator.Data = light; frameAnimator.AnimationComplete += FrameAnimator_AnimationComplete; frameAnimator.RenderFrame += FrameAnimator_RenderLights; frameAnimator.Start(startTime); lightAnimators.Add(frameAnimator); } } existingAnimationIsRunning = true; }
LightingSequence LoadLightingSequence(string sceneName, int totalFrameCount) { string fullPathToLightsFile = VideoAnimationManager.GetFullPathToLightsFile(sceneName); if (System.IO.File.Exists(fullPathToLightsFile)) { string lightsJson = System.IO.File.ReadAllText(fullPathToLightsFile); LightingSequence lightingSequence = JsonConvert.DeserializeObject <LightingSequence>(lightsJson); LightingSequence decompressedLightingSequence = lightingSequence.Decompress(); AddCenterLightIfNeeded(totalFrameCount, decompressedLightingSequence); return(decompressedLightingSequence); } else { LightingSequence lightingSequence = new LightingSequence(); lightingSequence.Lights.Add(NewLight(BluetoothLights.Left_ID, totalFrameCount)); lightingSequence.Lights.Add(NewLight(BluetoothLights.Center_ID, totalFrameCount)); lightingSequence.Lights.Add(NewLight(BluetoothLights.Right_ID, totalFrameCount)); return(lightingSequence); } }