Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            if (Trigger == PresetTriggerType.None)
            {
                return(string.Empty);
            }

            return($"On {Trigger.GetDescription()} of {DisplayProcesses(IncludedProcesses)}{(ExcludedProcesses.Any() ? ", excluding " + DisplayProcesses(ExcludedProcesses) : string.Empty)}{(Conditions > 0 ? ", only in " + string.Join(", ", Utils.GetDescriptions<PresetConditionType>((int)Conditions)) : string.Empty)}");
        }