<commit_before>﻿using Aurora.Profiles;
using Aurora.Utils;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;

namespace Aurora.Settings.Overrides.Logic {

    /// <summary>
    /// Evaluatable that returns true/false depending on whether the given process name is running.
    /// </summary>
    [OverrideLogic("Process Running", category: OverrideLogicCategory.Misc)]
    public class BooleanProcessRunning : IEvaluatable<bool> {

        public string ProcessName { get; set; } = "";

        public BooleanProcessRunning() { }
        public BooleanProcessRunning(string processName) { ProcessName = processName; }

        public Visual GetControl() => new TextBox { MinWidth = 80 }
            .WithBinding(TextBox.TextProperty, new Binding("ProcessName") { Source = this, Mode = BindingMode.TwoWay });

        public bool Evaluate(IGameState gameState)
            => Global.LightingStateManager.RunningProcessMonitor.IsProcessRunning(ProcessName);
        object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);

        public IEvaluatable<bool> Clone() => new BooleanProcessRunning { ProcessName = ProcessName };
        IEvaluatable IEvaluatable.Clone() => Clone();
    }
}<commit_msg>Added ProcessPicker to the Running Process evaluatable.<commit_after>﻿using Aurora.Profiles;
using Aurora.Utils;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;

namespace Aurora.Settings.Overrides.Logic {

    /// <summary>
    /// Evaluatable that returns true/false depending on whether the given process name is running.
    /// </summary>
    [OverrideLogic("Process Running", category: OverrideLogicCategory.Misc)]
    public class BooleanProcessRunning : IEvaluatable<bool>, INotifyPropertyChanged {

        public string ProcessName { get; set; } = "";

        public BooleanProcessRunning() { }
        public BooleanProcessRunning(string processName) { ProcessName = processName; }

        public event PropertyChangedEventHandler PropertyChanged;

        public Visual GetControl() {
            var selectButton = new Button { Content = "Select", Padding = new System.Windows.Thickness(8, 0, 8, 0), Margin = new System.Windows.Thickness(8, 0, 0, 0) };
            DockPanel.SetDock(selectButton, Dock.Right);
            selectButton.Click += (sender, e) => {
                var wnd = new Window_ProcessSelection { ButtonLabel = "Select" };
                if (wnd.ShowDialog() == true && !string.IsNullOrWhiteSpace(wnd.ChosenExecutableName)) {
                    ProcessName = wnd.ChosenExecutableName;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProcessName)));
                }
            };

            return new DockPanel { LastChildFill = true }
                .WithChild(selectButton)
                .WithChild(new TextBox { MinWidth = 80 }
                    .WithBinding(TextBox.TextProperty, new Binding("ProcessName") { Source = this, Mode = BindingMode.TwoWay }));
        }

        public bool Evaluate(IGameState gameState)
            => Global.LightingStateManager.RunningProcessMonitor.IsProcessRunning(ProcessName);
        object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);

        public IEvaluatable<bool> Clone() => new BooleanProcessRunning { ProcessName = ProcessName };
        IEvaluatable IEvaluatable.Clone() => Clone();
    }
}
{'fraction_non_alphanumeric': 0.1009518315546582, 'fraction_numerical': 0.003461205653302567, 'mean_word_length': 3.193470374848851, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3114302', 'n_tokens_mistral': 926, 'n_tokens_neox': 883, 'n_words': 217}