<commit_before>﻿using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Windows.Forms.DataVisualization.Charting;

namespace phoenix
{
    public partial class MainDialog : Form
    {
        private IniSettings         m_AppSettings;
        private ProcessRunner       m_ProcessRunner;
        private OpenFileDialog      m_FileDialog;
        private FolderBrowserDialog m_FolderDialog;
        private bool                m_PauseMonitor = false;
        private bool                m_FirstVisibleCall = true;
        private Series              m_CpuUsageSeries;
        private Series              m_MemoryUsageSeries;
        static Mutex                m_SingleInstanceMutex;

        public MainDialog()
        {
            InitializeComponent();
            SetupTracer();

            m_AppSettings   = new IniSettings("phoenix.ini");
            m_ProcessRunner = new ProcessRunner();
            m_FileDialog    = new OpenFileDialog();
            m_FolderDialog  = new FolderBrowserDialog();

            ApplySettings();

            m_MemoryUsageSeries = memory_chart.Series[0];
            m_CpuUsageSeries    = cpu_chart.Series[0];

            notify_icon.Icon = Icon;

            process_monitor_timer.Start();

            // These are executed in a separate thread
            m_ProcessRunner.MonitorStarted += ResetWatchButtonLabel;
            m_ProcessRunner.MonitorStopped += ResetWatchButtonLabel;
            m_ProcessRunner.ProcessStarted += ResetWatchButtonLabel;
            m_ProcessRunner.ProcessStopped += ResetWatchButtonLabel;

            HotkeyManager.Register(Handle);

            ValidateAndStartMonitoring();
        }

        private void SetupTracer()
        {
            Trace.Listeners.Add(new TextboxWriterTraceListener(log_box, "PhoenixTextboxLog"));
            Trace.Listeners.Add(new TextWriterTraceListener("phoenix.log", "PhoneixFileLog"));
            Trace.Listeners["PhoneixFileLog"].TraceOutputOptions |= TraceOptions.DateTime;

            Trace.TraceInformation("Phoenix Tracer setup finished.");
        }

        private void ResetWatchButtonLabel()
        {
            watch_button.Invoke((MethodInvoker)(() =>
            {
                if (m_ProcessRunner.Monitoring)
                    watch_button.Text = "Stop Watching ( ALT+F10 )";
                else
                    watch_button.Text = "Start Watching ( ALT+F10 )";
            }));
        }

        private bool EnsureSingleInstanceMode()
        {
            if (application_to_watch.Text == string.Empty)
                return false;

            try
            {
                if (m_SingleInstanceMutex != null)
                {
                    m_SingleInstanceMutex.ReleaseMutex();
                    m_SingleInstanceMutex.Dispose();
                    m_SingleInstanceMutex = null;<commit_msg>Welcome user when Phoenix is up and running<commit_after>﻿using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Windows.Forms.DataVisualization.Charting;

namespace phoenix
{
    public partial class MainDialog : Form
    {
        private IniSettings         m_AppSettings;
        private ProcessRunner       m_ProcessRunner;
        private OpenFileDialog      m_FileDialog;
        private FolderBrowserDialog m_FolderDialog;
        private bool                m_PauseMonitor = false;
        private bool                m_FirstVisibleCall = true;
        private Series              m_CpuUsageSeries;
        private Series              m_MemoryUsageSeries;
        static Mutex                m_SingleInstanceMutex;

        public MainDialog()
        {
            InitializeComponent();
            SetupTracer();

            m_AppSettings   = new IniSettings("phoenix.ini");
            m_ProcessRunner = new ProcessRunner();
            m_FileDialog    = new OpenFileDialog();
            m_FolderDialog  = new FolderBrowserDialog();

            ApplySettings();

            m_MemoryUsageSeries = memory_chart.Series[0];
            m_CpuUsageSeries    = cpu_chart.Series[0];

            notify_icon.Icon = Icon;

            process_monitor_timer.Start();

            // These are executed in a separate thread
            m_ProcessRunner.MonitorStarted += ResetWatchButtonLabel;
            m_ProcessRunner.MonitorStopped += ResetWatchButtonLabel;
            m_ProcessRunner.ProcessStarted += ResetWatchButtonLabel;
            m_ProcessRunner.ProcessStopped += ResetWatchButtonLabel;

            HotkeyManager.Register(Handle);

            ValidateAndStartMonitoring();

            Logger.Info("Phoenix is up and running.");
        }

        private void SetupTracer()
        {
            Trace.Listeners.Add(new TextboxWriterTraceListener(log_box, "PhoenixTextboxLog"));
            Trace.Listeners.Add(new TextWriterTraceListener("phoenix.log", "PhoneixFileLog"));
            Trace.Listeners["PhoneixFileLog"].TraceOutputOptions |= TraceOptions.DateTime;
        }

        private void ResetWatchButtonLabel()
        {
            watch_button.Invoke((MethodInvoker)(() =>
            {
                if (m_ProcessRunner.Monitoring)
                    watch_button.Text = "Stop Watching ( ALT+F10 )";
                else
                    watch_button.Text = "Start Watching ( ALT+F10 )";
            }));
        }

        private bool EnsureSingleInstanceMode()
        {
            if (application_to_watch.Text == string.Empty)
                return false;

            try
            {
                if (m_SingleInstanceMutex != null)
                {
                    m_SingleInstanceMutex.ReleaseMutex();
                    m_SingleInstanceMutex.Dispose();
                    m_SingleInstanceMutex = null;
{'fraction_non_alphanumeric': 0.07332319648589289, 'fraction_numerical': 0.0020273694880892043, 'mean_word_length': 1.9062346588119783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3267909', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1429, 'n_words': 281}