/// <summary>Gets the current application.</summary> /// <param name="preview">Boolean indicating whether the application is selected because it is previewing (true) or because the process is open (false).</param> public ILightEvent GetCurrentProfile(out bool preview) { string process_name = Path.GetFileName(processMonitor.ProcessPath).ToLower(); string process_title = processMonitor.GetActiveWindowsProcessTitle(); ILightEvent profile = null; ILightEvent tempProfile = null; preview = false; //TODO: GetProfile that checks based on event type if ((((tempProfile = GetProfileFromProcessName(process_name)) != null) || ((tempProfile = GetProfileFromProcessTitle(process_title)) != null)) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled) { profile = tempProfile; } else if ((tempProfile = GetProfileFromProcessName(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 = GetProfileFromProcessName(Global.net_listener.WrappedProcess)) != null) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled) { profile = tempProfile; } profile = profile ?? DesktopProfile; return(profile); }
/// <summary>KeyDown handler that checks the current application's profiles for keybinds. /// In the case of multiple profiles matching the keybind, it will pick the next one as specified in the Application.Profile order.</summary> public void CheckProfileKeybinds(object sender, SharpDX.RawInput.KeyboardInputEventArgs e) { ILightEvent profile = GetCurrentProfile(); // Check profile is valid and do not switch profiles if the user is trying to enter a keybind if (profile is Application && Controls.Control_Keybind._ActiveKeybind == null) { // Find all profiles that have their keybinds pressed List <ApplicationProfile> possibleProfiles = new List <ApplicationProfile>(); foreach (var prof in (profile as Application).Profiles) { if (prof.TriggerKeybind.IsPressed()) { possibleProfiles.Add(prof); } } // If atleast one profile has it's key pressed if (possibleProfiles.Count > 0) { // The target profile is the NEXT valid profile after the currently selected one (or the first valid one if the currently selected one doesn't share this keybind) int trg = (possibleProfiles.IndexOf((profile as Application).Profile) + 1) % possibleProfiles.Count; (profile as Application).SwitchToProfile(possibleProfiles[trg]); } } }
public bool RegisterEvent(ILightEvent @event) { string key = @event.Config.ID; if (string.IsNullOrWhiteSpace(key) || Events.ContainsKey(key)) { return(false); } Events.Add(key, @event); if (@event.Config.ProcessNames != null) { foreach (string exe in @event.Config.ProcessNames) { if (!exe.Equals(key)) { EventProcesses.Add(exe.ToLower(), key); } } } if (@event.Config.ProcessTitles != null) { foreach (string titleRx in @event.Config.ProcessTitles) { EventTitles.Add(titleRx, key); } } if (!String.IsNullOrWhiteSpace(@event.Config.AppID)) { EventAppIDs.Add(@event.Config.AppID, key); } if (@event is Application) { if (!Global.Configuration.ProfileOrder.Contains(key)) { Global.Configuration.ProfileOrder.Add(key); } } this.InsertLightEvent(@event); if (Initialized) { @event.Initialize(); } return(true); }
private void LightEvent_PropertyChanged(object sender, PropertyChangedExEventArgs e) { ILightEvent lightEvent = (ILightEvent)sender; if (e.PropertyName.Equals(nameof(LightEventConfig.Type))) { LightEventType old = (LightEventType)e.OldValue; LightEventType newVal = (LightEventType)e.NewValue; if (!old.Equals(newVal)) { InsertLightEvent(lightEvent, old); } } }
private bool StartEvent(ILightEvent @event) { UpdatedEvents.Add(@event); // Skip if event was already started if (StartedEvents.Contains(@event)) { return(false); } StartedEvents.Add(@event); @event.OnStart(); return(true); }
private bool InsertLightEvent(ILightEvent lightEvent, LightEventType?old = null) { LightEventType type = lightEvent.Config.Type ?? LightEventType.Normal; lightEvent.Config.Type = type; if (old == null) { lightEvent.Config.PropertyChanged += LightEvent_PropertyChanged; } else { var oldEvents = GetEventTable((LightEventType)old); oldEvents.Remove(lightEvent.Config.ID); } var events = GetEventTable(type); events.Add(lightEvent.Config.ID); return(true); }
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); }
private void Update() { PreUpdate?.Invoke(this, null); UpdatedEvents.Clear(); //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))) { StopUnUpdatedEvents(); 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 the current foreground process is excluded from Aurora, disable the lighting manager if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name)) { StopUnUpdatedEvents(); 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))) { UpdateEvent(@event, newFrame); } } } //Need to do another check in case Desktop is disabled or the selected preview is disabled if (profile.IsEnabled) { UpdateEvent(profile, newFrame); } if (Global.Configuration.OverlaysInPreview || !preview) { // Update any overlays registered in the Overlays array. This includes applications with type set to Overlay and things such as skype overlay foreach (var overlay in Overlays) { ILightEvent @event = Events[overlay]; if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames))) { UpdateEvent(@event, newFrame); } } // Update any overlays that are timer-based (e.g. the volume overlay that appears for a few seconds at a time) TimedListObject[] overlay_events = overlays.ToArray(); foreach (TimedListObject evnt in overlay_events) { if ((evnt.item as LightEvent).IsEnabled) { UpdateEvent((evnt.item as LightEvent), newFrame); } } // Update any applications that have overlay layers if that application is open var events = GetOverlayActiveProfiles().ToList(); //Add the Light event that we're previewing to be rendered as an overlay if (preview && Global.Configuration.OverlaysInPreview && !events.Contains(profile)) { events.Add(profile); } foreach (var @event in events) { @event.UpdateOverlayLights(newFrame); } UpdateIdleEffects(newFrame); } Global.effengine.PushFrame(newFrame); StopUnUpdatedEvents(); PostUpdate?.Invoke(this, null); }
private void UpdateEvent(ILightEvent @event, EffectsEngine.EffectFrame frame) { StartEvent(@event); @event.UpdateLights(frame); }
private void Update() { PreUpdate?.Invoke(this, null); UpdatedEvents.Clear(); //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))) { StopUnUpdatedEvents(); 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 the current foreground process is excluded from Aurora, disable the lighting manager if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name)) { StopUnUpdatedEvents(); Global.dev_manager.Shutdown(); Global.effengine.PushFrame(newFrame); return; } else { Global.dev_manager.InitializeOnce(); } //Need to do another check in case Desktop is disabled or the selected preview is disabled if (profile.IsEnabled) { UpdateEvent(profile, newFrame); } // Overlay layers if (!preview || Global.Configuration.OverlaysInPreview) { foreach (var @event in GetOverlayActiveProfiles()) { @event.UpdateOverlayLights(newFrame); } //Add the Light event that we're previewing to be rendered as an overlay (assuming it's not already active) if (preview && Global.Configuration.OverlaysInPreview && !GetOverlayActiveProfiles().Contains(profile)) { profile.UpdateOverlayLights(newFrame); } UpdateIdleEffects(newFrame); } Global.effengine.PushFrame(newFrame); StopUnUpdatedEvents(); PostUpdate?.Invoke(this, null); }
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); }