public bool TriggerActive(PresetTriggerContext context) { var active = Conditions == PresetConditionType.None || (Conditions.HasFlag(PresetConditionType.SDR) ? !context.IsHDRActive : true) && (Conditions.HasFlag(PresetConditionType.HDR) ? context.IsHDRActive : true) && (Conditions.HasFlag(PresetConditionType.GsyncDisabled) ? !context.IsGsyncActive : true) && (Conditions.HasFlag(PresetConditionType.GsyncEnabled) ? context.IsGsyncActive : true); var allProcesses = IncludedProcesses.Contains("*"); if (Trigger == PresetTriggerType.ProcessSwitch) { active = active && (allProcesses || (context.ChangedProcesses?.Any() ?? false)); if (active) { var included = allProcesses || context.ChangedProcesses.Any(cp => IncludedProcesses.Any(ip => cp.ProcessName.NormEquals(ip))); var excluded = context.ChangedProcesses.Any(cp => ExcludedProcesses.Any(ep => cp.ProcessName.NormEquals(ep))); var screenSizeCheck = (!Conditions.HasFlag(PresetConditionType.FullScreen) && !context.ForegroundProcessIsFullScreen) || (context.ForegroundProcess != null && context.ForegroundProcessIsFullScreen && (allProcesses || IncludedProcesses.Any(ip => context.ForegroundProcess.ProcessName.NormEquals(ip)))); var notificationsDisabledCheck = !Conditions.HasFlag(PresetConditionType.NotificationsDisabled) || context.IsNotificationDisabled; active = included && !excluded && screenSizeCheck && notificationsDisabledCheck; } } return(active); }
public void ExcludeProcess(int originSourceUniqueId) { if (!IncludedProcesses.Contains(originSourceUniqueId)) { throw new InvalidOperationException("The originSourceIdentity was not present in the list, therefore it could not be removed"); } IncludedProcesses.Remove(originSourceUniqueId); }
public void IncludeProcess(int originUniqueId) { ValidateProcessId(originUniqueId); IncludedProcesses.Add(originUniqueId); }
internal void SetProcess(int selectedOriginIdentity) { ValidateProcessId(selectedOriginIdentity); this.IncludedProcesses.Clear(); IncludedProcesses.Add(selectedOriginIdentity); }