diff --git a/Test_Merge/ConfigurationTool.cs b/Test_Merge/ConfigurationTool.cs index acdd023..4d51bb2 100644 --- a/Test_Merge/ConfigurationTool.cs +++ b/Test_Merge/ConfigurationTool.cs @@ -27,14 +27,25 @@ namespace Test_Merge MainZone = new Zone(fullImage, mainZoneDimensions,"Main"); AutoCalibrate(); } + /// + /// Resets the main zone + /// public void ResetMainZone() { MainZone.ResetZones(); } + /// + /// Reset the windows + /// public void ResetWindows() { MainZone.ResetWindows(); } + /// + /// Save the current config in a JSON file stored in /Presets/ + /// + /// A list of all the drivers in the GP. IMPORTANT, they need to ALL be mentionned or the program wont be able to detect the missing ones and will F up everything + /// The name the config should have public void SaveToJson(List drivers, string configName) { string JSON = ""; @@ -77,6 +88,11 @@ namespace Test_Merge File.WriteAllText(path, JSON); } + /// + /// Adds a window in the windows list + /// Be carefull of the order. It cant be random or it will crash. The programm expect the first to be position, second Gap to leader etc... + /// + /// The bounds of the window public void AddWindows(List rectangles) { foreach (Zone driverZone in MainZone.Zones) @@ -127,6 +143,9 @@ namespace Test_Merge } } } + /// + /// This will automatically create all the driver zones at the correct places if the main zone has been weel positionned + /// public void AutoCalibrate() { List detectedText = new List(); diff --git a/Test_Merge/DriverDrsWindow.cs b/Test_Merge/DriverDrsWindow.cs index 5d9cecd..ba06736 100644 --- a/Test_Merge/DriverDrsWindow.cs +++ b/Test_Merge/DriverDrsWindow.cs @@ -23,6 +23,10 @@ namespace Test_Merge { Name = "DRS"; } + /// + /// Method that will decode the content of the window + /// + /// public override async Task DecodePng() { bool result = false; @@ -35,6 +39,10 @@ namespace Test_Merge return result; } + /// + /// Method that will get the green pixel proportion in the image, this can be used to determin if the DRS has been actuated + /// + /// The number of clearely green pixels private unsafe int GetGreenPixels() { int tot = 0; @@ -69,6 +77,10 @@ namespace Test_Merge return tot; } + /// + /// This method is used to lock on where exactly the DRS window is + /// + /// Returns a rectangle containing the DRS public Rectangle GetBox() { var tessImage = Pix.LoadFromMemory(ImageToByte(WindowImage)); diff --git a/Test_Merge/DriverPositionWindow.cs b/Test_Merge/DriverPositionWindow.cs index 4202a8a..fb2379f 100644 --- a/Test_Merge/DriverPositionWindow.cs +++ b/Test_Merge/DriverPositionWindow.cs @@ -1,4 +1,10 @@ -using System; +/// Author : Maxime Rohmer +/// Date : 08/05/2023 +/// File : DriverPosition.cs +/// Brief : Window containing infos about the position of a driver. +/// Version : 0.1 + +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Test_Merge/F1TVEmulator.cs b/Test_Merge/F1TVEmulator.cs index 8883e46..fc1677c 100644 --- a/Test_Merge/F1TVEmulator.cs +++ b/Test_Merge/F1TVEmulator.cs @@ -39,6 +39,9 @@ namespace Test_Merge GrandPrixUrl = grandPrixUrl; Ready = false; } + /// + /// Will start the python programm that runs the Cookie Recovering + /// private void StartCookieRecovering() { string scriptPath = PYTHON_COOKIE_RETRIEVAL_FILENAME; @@ -51,6 +54,13 @@ namespace Test_Merge string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); } + /// + /// Method that will recover the needed cookies in the DB + /// + /// The host of the wanted cookie ex: ./formula1.com + /// The name of the wanted cookie ex: login + /// returns the value of the cookie if it has been found + /// public string GetCookie(string host, string name) { StartCookieRecovering(); @@ -88,6 +98,10 @@ namespace Test_Merge return value; } + /// + /// Starts the headless browser + /// + /// Error code 1xx public async Task Start() { Ready = false; @@ -248,6 +262,11 @@ namespace Test_Merge Ready = true; return 0; } + /// + /// Takes a screenshot of what the headless browser is displaying + /// + /// Optional ! The name of the picture so it can be saved + /// Returns the screenshot in the bitmap format public Bitmap Screenshot(string name = "TEST") { Bitmap result = new Bitmap(4242, 6969); @@ -273,11 +292,17 @@ namespace Test_Merge } return result; } + /// + /// Stops the Emulation. Note: if you plan to start it again please use ResetDriver() instead + /// public void Stop() { Ready = false; Driver.Dispose(); } + /// + /// Resets the emulation + /// public void ResetDriver() { Ready = false; diff --git a/Test_Merge/Settings.Designer.cs b/Test_Merge/Settings.Designer.cs index b3ed9e8..efd0f5e 100644 --- a/Test_Merge/Settings.Designer.cs +++ b/Test_Merge/Settings.Designer.cs @@ -218,7 +218,7 @@ // // btnResetDriver // - this.btnResetDriver.Location = new System.Drawing.Point(113, 22); + this.btnResetDriver.Location = new System.Drawing.Point(855, 17); this.btnResetDriver.Name = "btnResetDriver"; this.btnResetDriver.Size = new System.Drawing.Size(101, 33); this.btnResetDriver.TabIndex = 2; diff --git a/Test_Merge/Settings.cs b/Test_Merge/Settings.cs index 59c5085..c33f930 100644 --- a/Test_Merge/Settings.cs +++ b/Test_Merge/Settings.cs @@ -16,6 +16,7 @@ namespace Test_Merge private string _grandPrixUrl = ""; private string _grandPrixName = ""; private int _grandPrixYear = 2000; + private string _selectedConfigFile; private List _driverList = new List(); private F1TVEmulator Emulator = null; @@ -35,6 +36,7 @@ namespace Test_Merge public string GrandPrixName { get => _grandPrixName; private set => _grandPrixName = value; } public int GrandPrixYear { get => _grandPrixYear; private set => _grandPrixYear = value; } public List DriverList { get => _driverList; private set => _driverList = value; } + public string SelectedConfigFile { get => _selectedConfigFile;private set => _selectedConfigFile = value; } public Settings() { @@ -398,11 +400,14 @@ namespace Test_Merge { try { - Reader reader = new Reader(lsbPresets.Items[lsbPresets.SelectedIndex].ToString(), (Bitmap)pbxMain.Image,false); + string fileName = lsbPresets.Items[lsbPresets.SelectedIndex].ToString(); + Reader reader = new Reader(fileName, (Bitmap)pbxMain.Image,false); //MainZones #0 is the big main zone containing driver zones Config = new ConfigurationTool((Bitmap)pbxMain.Image, reader.MainZones[0].Bounds); Config.MainZone = reader.MainZones[0]; DriverList = reader.Drivers; + + SelectedConfigFile = fileName; } catch (Exception ex) {