Ejemplo n.º 1
0
 private void UpdateEvent(ILightEvent @event, EffectsEngine.EffectFrame frame)
 {
     StartEvent(@event);
     @event.UpdateLights(frame);
 }
Ejemplo n.º 2
0
        private void Update()
        {
            //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed
            if ((Global.Configuration.time_based_dimming_enabled &&
                 Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)))
            {
                return;
            }

            UpdateProcess();

            string process_name = System.IO.Path.GetFileName(processMonitor.ProcessPath).ToLowerInvariant();

            EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame();



            //TODO: Move these IdleEffects to an event
            //this.UpdateIdleEffects(newFrame);

            ILightEvent profile     = null;
            ILightEvent tempProfile = null;
            bool        preview     = false;

            //Global.logger.LogLine(process_name);
            if (!Global.Configuration.excluded_programs.Contains(process_name))
            {
                //TODO: GetProfile that checks based on event type
                if (((tempProfile = GetProfileFromProcess(process_name)) != null) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled)
                {
                    profile = tempProfile;
                }
                else if ((tempProfile = GetProfileFromProcess(previewModeProfileKey)) != null) //Don't check for it being Enabled as a preview should always end-up with the previewed profile regardless of it being disabled
                {
                    profile = tempProfile;
                    preview = true;
                }
                else if (Global.Configuration.allow_wrappers_in_background && Global.net_listener != null && Global.net_listener.IsWrapperConnected && ((tempProfile = GetProfileFromProcess(Global.net_listener.WrappedProcess)) != null) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.Config.ProcessNames.Contains(process_name) && tempProfile.IsEnabled)
                {
                    profile = tempProfile;
                }
            }

            profile = profile ?? DesktopProfile;

            timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval;

            //Check if any keybinds have been triggered
            if (profile is Application)
            {
                foreach (var prof in (profile as Application).Profiles)
                {
                    if (prof.TriggerKeybind.IsPressed() && !(profile as Application).Profile.ProfileName.Equals(prof.ProfileName))
                    {
                        (profile as Application).SwitchToProfile(prof);
                        break;
                    }
                }
            }

            if (profile is Desktop.Desktop && !profile.IsEnabled && Global.Configuration.ShowDefaultLightingOnDisabled)
            {
                Global.dev_manager.Shutdown();
                Global.effengine.PushFrame(newFrame);
                return;
            }
            else
            {
                Global.dev_manager.InitializeOnce();
            }


            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var underlay in Underlays)
                {
                    ILightEvent @event = Events[underlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }
            }

            //Need to do another check in case Desktop is disabled or the selected preview is disabled
            if (profile.IsEnabled)
            {
                profile.UpdateLights(newFrame);
            }

            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var overlay in Overlays)
                {
                    ILightEvent @event = Events[overlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }

                //Add overlays
                TimedListObject[] overlay_events = overlays.ToArray();
                foreach (TimedListObject evnt in overlay_events)
                {
                    if ((evnt.item as LightEvent).IsEnabled)
                    {
                        (evnt.item as LightEvent).UpdateLights(newFrame);
                    }
                }

                UpdateIdleEffects(newFrame);
            }

            Global.effengine.PushFrame(newFrame);
        }
Ejemplo n.º 3
0
        private void Update()
        {
            PreUpdate?.Invoke(this, null);

            //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed
            if ((Global.Configuration.time_based_dimming_enabled &&
                 Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)))
            {
                return;
            }

            string raw_process_name = Path.GetFileName(processMonitor.ProcessPath);

            UpdateProcess();
            EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame();



            //TODO: Move these IdleEffects to an event
            //this.UpdateIdleEffects(newFrame);

            ILightEvent profile = GetCurrentProfile(out bool preview);

            timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval;

            if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name))
            {
                Global.dev_manager.Shutdown();
                Global.effengine.PushFrame(newFrame);
                return;
            }
            else
            {
                Global.dev_manager.InitializeOnce();
            }


            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var underlay in Underlays)
                {
                    ILightEvent @event = Events[underlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }
            }

            //Need to do another check in case Desktop is disabled or the selected preview is disabled
            if (profile.IsEnabled)
            {
                profile.UpdateLights(newFrame);
            }

            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var overlay in Overlays)
                {
                    ILightEvent @event = Events[overlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }

                //Add overlays
                TimedListObject[] overlay_events = overlays.ToArray();
                foreach (TimedListObject evnt in overlay_events)
                {
                    if ((evnt.item as LightEvent).IsEnabled)
                    {
                        (evnt.item as LightEvent).UpdateLights(newFrame);
                    }
                }

                UpdateIdleEffects(newFrame);
            }

            Global.effengine.PushFrame(newFrame);

            PostUpdate?.Invoke(this, null);
        }