示例#1
0
 private void AddCenterLightIfNeeded(int totalFrameCount, LightingSequence decompressedLightingSequence)
 {
     if (!HasLight(decompressedLightingSequence.Lights, BluetoothLights.Center_ID))
     {
         decompressedLightingSequence.Lights.Add(NewLight(BluetoothLights.Center_ID, totalFrameCount));
     }
 }
示例#2
0
        public LightingSequence Compress()
        {
            LightingSequence result = new LightingSequence();

            foreach (Light light in Lights)
            {
                result.Lights.Add(light.Compress());
            }
            return(result);
        }
示例#3
0
 bool HasAnyLightingChanges(LightingSequence lightingSequence)
 {
     foreach (Light light in lightingSequence.Lights)
     {
         foreach (LightSequenceData lightSequenceData in light.SequenceData)
         {
             if (lightSequenceData.Lightness > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#4
0
        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!!!
            }
        }
示例#5
0
        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;
        }
示例#6
0
        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);
            }
        }