<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

// WFOV Imports
using TIS.Imaging;

// NFOV Imports
using FlyCapture2Managed;
using FlyCapture2Managed.Gui;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;

namespace RCCM.UI
{
    /// <summary>
    /// The main window of the program from which all hardware initialization and termination is directed
    /// </summary>
    public partial class RCCMMainForm : Form
    {
        /// <summary>
        /// The main object representing the RCCM containing references to all hardware
        /// </summary>
        protected RCCMSystem rccm;
        /// <summary>
        /// Flag for indicating if NFOV1 form is open
        /// </summary>
        protected bool nfov1Open;
        /// <summary>
        /// Flag for indicating if NFOV2 form is open
        /// </summary>
        protected bool nfov2Open;
        /// <summary>
        /// Flag for indicating if WFOV1 form is open
        /// </summary>
        protected bool wfov1Open;
        /// <summary>
        /// Flag for indicating if WFOV2 form is open
        /// </summary>
        protected bool wfov2Open;
        /// <summary>
        /// Timer for replotting certain panel graphic
        /// </summary>
        protected Timer panelRepaintTimer;
        /// <summary>
        /// List of measurement objects. Observable so controls can update when other forms update them
        /// </summary>
        protected ObservableCollection<MeasurementSequence> cracks;
        /// <summary>
        /// Object for managing test result plotting
        /// </summary>
        protected TestResults test;
        /// <summary>
        /// Object for managing panel graphic drawing
        /// </summary>
        protected PanelView view;
        /// <summary>
        /// Resource manager for loading ActiveX object for Trio controller
        /// </summary>
        protected ComponentResourceManager resources;
        /// <summary>
        /// ActiveX control for trio controller
        /// </summary>
        protected AxTrioPCLib.AxTrioPC triopc;
        /// <summary>
        /// Holds sleep setting of computer before starting program so it can be reverted on exit
        /// </summary>
        protected uint fPreviousExecutionState;
        /// <summary>
        /// Flag to indicate if user is jogging an actuator
        /// </summary>
        protected bool jogging;

        /// <summary>
        /// Create the main form and initialize all hardware
        /// </summary>
        /// <param name="plugins">List of plugins that were found on startup</param>
        public RCCMMainForm(ICollection<IRCCMPlugin> plugins)
        {
            // Need to load the ActiveX state or something, I'm not actually sure
            this.resources = new ComponentResourceManager(typeof(RCCMMainForm));
            // Create Trio controller ActiveX control and initialize
            this.triopc = new AxTrioPCLib.AxTrioPC();
            ((ISupportInitialize)(this.triopc)).BeginInit();
            this.Controls.Add(this.triopc);
            this.triopc.Name = "AxTrioPC1";
            this.triopc.Visible = false;
            this.triopc.OcxState = ((AxHost.State)(resources.GetObject("AxTrioPC1.OcxState")));
            ((ISupportInitialize)(this.triopc)).EndInit();

            InitializeComponent();

            this.rccm = new RCCMSystem(this.triopc);
            this.cracks = new ObservableCollection<MeasurementSequence>();
            this.test = new TestResults(this.rccm, this.cracks, this.chartCracks, this.chartCycles, this.textCycle, this.textPressure, this.listCrackSelection);
            this.view = new PanelView(this.rccm);

            // Apply certain settings to controls
            this.applyUISettings();
            
            // Create timer for redrawing panel graphics
            this.panelRepaintTimer = new Timer();
            this.panelRepaintTimer.Enabled = true;
            this.panelRepaintTimer.Interval = (int)Program.Settings.json["repaint period"];
            this.panelRepaintTimer.Tick += new EventHandler(refreshPanelView);

            // Add toolstrip item for each plugin
            if (plugins != null)
            {
                foreach (IRCCMPlugin plugin in plugins)
                {
                    ToolStripMenuItem pluginItem = new ToolStripMenuItem(plugin.Name);
                    this.pluginsToolStripMenuItem.DropDownItems.Add(pluginItem);
                    pluginItem.Click += delegate (object sender, EventArgs e)
                    {
                        this.PluginToolStripClick(plugin);
                    };
                }
            }

            this.jogging = false;

            // Set new state to prevent system sleep
            this.fPreviousExecutionState = NativeMethods.SetThreadExecutionState(
                NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
            if (this.fPreviousExecutionState == 0)
            {
                Console.WriteLine("SetThreadExecutionState failed. Do something here...");
            }
            Show();
        }
        
        /// <summary>
        /// Load form and initialize things dependent on UI visibility
        /// </summary>
        private void RCCMMainForm_Load(object sender, EventArgs e)
        {
            this.view.SetTransform(this.panelView.CreateGraphics());
            this.panelRepaintTimer.Start();
            // Prevent radio buttons from accepting arrow key input
            foreach (Control c in this.groupBoxStageSelect.Controls)
            {<commit_msg>add splash screen, git broke on my computer<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TIS.Imaging;
using FlyCapture2Managed;
using FlyCapture2Managed.Gui;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;

namespace RCCM.UI
{
    /// <summary>
    /// The main window of the program from which all hardware initialization and termination is directed
    /// </summary>
    public partial class RCCMMainForm : Form
    {
        /// <summary>
        /// The main object representing the RCCM containing references to all hardware
        /// </summary>
        protected RCCMSystem rccm;
        /// <summary>
        /// Flag for indicating if NFOV1 form is open
        /// </summary>
        protected bool nfov1Open;
        /// <summary>
        /// Flag for indicating if NFOV2 form is open
        /// </summary>
        protected bool nfov2Open;
        /// <summary>
        /// Flag for indicating if WFOV1 form is open
        /// </summary>
        protected bool wfov1Open;
        /// <summary>
        /// Flag for indicating if WFOV2 form is open
        /// </summary>
        protected bool wfov2Open;
        /// <summary>
        /// Timer for replotting certain panel graphic
        /// </summary>
        protected Timer panelRepaintTimer;
        /// <summary>
        /// List of measurement objects. Observable so controls can update when other forms update them
        /// </summary>
        protected ObservableCollection<MeasurementSequence> cracks;
        /// <summary>
        /// Object for managing test result plotting
        /// </summary>
        protected TestResults test;
        /// <summary>
        /// Object for managing panel graphic drawing
        /// </summary>
        protected PanelView view;
        /// <summary>
        /// Resource manager for loading ActiveX object for Trio controller
        /// </summary>
        protected ComponentResourceManager resources;
        /// <summary>
        /// ActiveX control for trio controller
        /// </summary>
        protected AxTrioPCLib.AxTrioPC triopc;
        /// <summary>
        /// Holds sleep setting of computer before starting program so it can be reverted on exit
        /// </summary>
        protected uint fPreviousExecutionState;
        /// <summary>
        /// Flag to indicate if user is jogging an actuator
        /// </summary>
        protected bool jogging;

        /// <summary>
        /// Create the main form and initialize all hardware
        /// </summary>
        /// <param name="plugins">List of plugins that were found on startup</param>
        public RCCMMainForm(ICollection<IRCCMPlugin> plugins)
        {
            // Show splash screen
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            RCCMSplashScreen splash = new RCCMSplashScreen();
            splash.Show();
            stopwatch.Start();
            
            // Need to load the ActiveX state or something, I'm not actually sure
            this.resources = new ComponentResourceManager(typeof(RCCMMainForm));
            // Create Trio controller ActiveX control and initialize
            this.triopc = new AxTrioPCLib.AxTrioPC();
            ((ISupportInitialize)(this.triopc)).BeginInit();
            this.Controls.Add(this.triopc);
            this.triopc.Name = "AxTrioPC1";
            this.triopc.Visible = false;
            this.triopc.OcxState = ((AxHost.State)(resources.GetObject("AxTrioPC1.OcxState")));
            ((ISupportInitialize)(this.triopc)).EndInit();

            InitializeComponent();

            this.rccm = new RCCMSystem(this.triopc);
            this.cracks = new ObservableCollection<MeasurementSequence>();
            this.test = new TestResults(this.rccm, this.cracks, this.chartCracks, this.chartCycles, this.textCycle, this.textPressure, this.listCrackSelection);
            this.view = new PanelView(this.rccm);

            // Apply certain settings to controls
            this.applyUISettings();
            
            // Create timer for redrawing panel graphics
            this.panelRepaintTimer = new Timer();
            this.panelRepaintTimer.Enabled = true;
            this.panelRepaintTimer.Interval = (int)Program.Settings.json["repaint period"];
            this.panelRepaintTimer.Tick += new EventHandler(refreshPanelView);

            // Add toolstrip item for each plugin
            if (plugins != null)
            {
                foreach (IRCCMPlugin plugin in plugins)
                {
                    ToolStripMenuItem pluginItem = new ToolStripMenuItem(plugin.Name);
                    this.pluginsToolStripMenuItem.DropDownItems.Add(pluginItem);
                    pluginItem.Click += delegate (object sender, EventArgs e)
                    {
                        this.PluginToolStripClick(plugin);
                    };
                }
            }

            this.jogging = false;

            // Set new state to prevent system sleep
            this.fPreviousExecutionState = NativeMethods.SetThreadExecutionState(
                NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
            if (this.fPreviousExecutionState == 0)
            {
                Console.WriteLine("SetThreadExecutionState failed. Do something here...");
            }
            
            stopwatch.Stop();
            System.Threading.Thread.Sleep((int)Math.Max(2000 - stopwatch.ElapsedMilliseconds, 0));
            splash.Close();
            
            Show();
        }
        
        /// <summary>
        /// Load form and initialize things dependent on UI visibility
        /// </summary>
        private void RCCMMainForm_Load(object sender, EventArgs e)
        {
            this.view.SetTransform(this.panelView.CreateGraphics());
            this.panelRepaintTimer.Start();
            // Prevent radio buttons from accepting arrow key input
            foreach (Control c in this.groupBoxStageSelect.Controls)
            {
{'fraction_non_alphanumeric': 0.09447444952222683, 'fraction_numerical': 0.002575820523473203, 'mean_word_length': 1.8870232669704965, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, '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': '885067', 'n_tokens_mistral': 3006, 'n_tokens_neox': 2931, 'n_words': 849}