Commented the configuration methods to move on to the OCR part
This commit is contained in:
@@ -27,14 +27,25 @@ namespace Test_Merge
|
|||||||
MainZone = new Zone(fullImage, mainZoneDimensions,"Main");
|
MainZone = new Zone(fullImage, mainZoneDimensions,"Main");
|
||||||
AutoCalibrate();
|
AutoCalibrate();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the main zone
|
||||||
|
/// </summary>
|
||||||
public void ResetMainZone()
|
public void ResetMainZone()
|
||||||
{
|
{
|
||||||
MainZone.ResetZones();
|
MainZone.ResetZones();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Reset the windows
|
||||||
|
/// </summary>
|
||||||
public void ResetWindows()
|
public void ResetWindows()
|
||||||
{
|
{
|
||||||
MainZone.ResetWindows();
|
MainZone.ResetWindows();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Save the current config in a JSON file stored in /Presets/
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drivers">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</param>
|
||||||
|
/// <param name="configName">The name the config should have</param>
|
||||||
public void SaveToJson(List<string> drivers, string configName)
|
public void SaveToJson(List<string> drivers, string configName)
|
||||||
{
|
{
|
||||||
string JSON = "";
|
string JSON = "";
|
||||||
@@ -77,6 +88,11 @@ namespace Test_Merge
|
|||||||
|
|
||||||
File.WriteAllText(path, JSON);
|
File.WriteAllText(path, JSON);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 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...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rectangles">The bounds of the window</param>
|
||||||
public void AddWindows(List<Rectangle> rectangles)
|
public void AddWindows(List<Rectangle> rectangles)
|
||||||
{
|
{
|
||||||
foreach (Zone driverZone in MainZone.Zones)
|
foreach (Zone driverZone in MainZone.Zones)
|
||||||
@@ -127,6 +143,9 @@ namespace Test_Merge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// This will automatically create all the driver zones at the correct places if the main zone has been weel positionned
|
||||||
|
/// </summary>
|
||||||
public void AutoCalibrate()
|
public void AutoCalibrate()
|
||||||
{
|
{
|
||||||
List<Rectangle> detectedText = new List<Rectangle>();
|
List<Rectangle> detectedText = new List<Rectangle>();
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ namespace Test_Merge
|
|||||||
{
|
{
|
||||||
Name = "DRS";
|
Name = "DRS";
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Method that will decode the content of the window
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override async Task<object> DecodePng()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -35,6 +39,10 @@ namespace Test_Merge
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Method that will get the green pixel proportion in the image, this can be used to determin if the DRS has been actuated
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The number of clearely green pixels</returns>
|
||||||
private unsafe int GetGreenPixels()
|
private unsafe int GetGreenPixels()
|
||||||
{
|
{
|
||||||
int tot = 0;
|
int tot = 0;
|
||||||
@@ -69,6 +77,10 @@ namespace Test_Merge
|
|||||||
|
|
||||||
return tot;
|
return tot;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// This method is used to lock on where exactly the DRS window is
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns a rectangle containing the DRS</returns>
|
||||||
public Rectangle GetBox()
|
public Rectangle GetBox()
|
||||||
{
|
{
|
||||||
var tessImage = Pix.LoadFromMemory(ImageToByte(WindowImage));
|
var tessImage = Pix.LoadFromMemory(ImageToByte(WindowImage));
|
||||||
|
|||||||
@@ -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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ namespace Test_Merge
|
|||||||
GrandPrixUrl = grandPrixUrl;
|
GrandPrixUrl = grandPrixUrl;
|
||||||
Ready = false;
|
Ready = false;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Will start the python programm that runs the Cookie Recovering
|
||||||
|
/// </summary>
|
||||||
private void StartCookieRecovering()
|
private void StartCookieRecovering()
|
||||||
{
|
{
|
||||||
string scriptPath = PYTHON_COOKIE_RETRIEVAL_FILENAME;
|
string scriptPath = PYTHON_COOKIE_RETRIEVAL_FILENAME;
|
||||||
@@ -51,6 +54,13 @@ namespace Test_Merge
|
|||||||
string output = process.StandardOutput.ReadToEnd();
|
string output = process.StandardOutput.ReadToEnd();
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Method that will recover the needed cookies in the DB
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host"> The host of the wanted cookie ex: ./formula1.com</param>
|
||||||
|
/// <param name="name">The name of the wanted cookie ex: login</param>
|
||||||
|
/// <returns>returns the value of the cookie if it has been found</returns>
|
||||||
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
public string GetCookie(string host, string name)
|
public string GetCookie(string host, string name)
|
||||||
{
|
{
|
||||||
StartCookieRecovering();
|
StartCookieRecovering();
|
||||||
@@ -88,6 +98,10 @@ namespace Test_Merge
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the headless browser
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Error code 1xx</returns>
|
||||||
public async Task<int> Start()
|
public async Task<int> Start()
|
||||||
{
|
{
|
||||||
Ready = false;
|
Ready = false;
|
||||||
@@ -248,6 +262,11 @@ namespace Test_Merge
|
|||||||
Ready = true;
|
Ready = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Takes a screenshot of what the headless browser is displaying
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Optional ! The name of the picture so it can be saved</param>
|
||||||
|
/// <returns>Returns the screenshot in the bitmap format</returns>
|
||||||
public Bitmap Screenshot(string name = "TEST")
|
public Bitmap Screenshot(string name = "TEST")
|
||||||
{
|
{
|
||||||
Bitmap result = new Bitmap(4242, 6969);
|
Bitmap result = new Bitmap(4242, 6969);
|
||||||
@@ -273,11 +292,17 @@ namespace Test_Merge
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Stops the Emulation. Note: if you plan to start it again please use ResetDriver() instead
|
||||||
|
/// </summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
Ready = false;
|
Ready = false;
|
||||||
Driver.Dispose();
|
Driver.Dispose();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the emulation
|
||||||
|
/// </summary>
|
||||||
public void ResetDriver()
|
public void ResetDriver()
|
||||||
{
|
{
|
||||||
Ready = false;
|
Ready = false;
|
||||||
|
|||||||
Generated
+1
-1
@@ -218,7 +218,7 @@
|
|||||||
//
|
//
|
||||||
// btnResetDriver
|
// 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.Name = "btnResetDriver";
|
||||||
this.btnResetDriver.Size = new System.Drawing.Size(101, 33);
|
this.btnResetDriver.Size = new System.Drawing.Size(101, 33);
|
||||||
this.btnResetDriver.TabIndex = 2;
|
this.btnResetDriver.TabIndex = 2;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace Test_Merge
|
|||||||
private string _grandPrixUrl = "";
|
private string _grandPrixUrl = "";
|
||||||
private string _grandPrixName = "";
|
private string _grandPrixName = "";
|
||||||
private int _grandPrixYear = 2000;
|
private int _grandPrixYear = 2000;
|
||||||
|
private string _selectedConfigFile;
|
||||||
private List<string> _driverList = new List<string>();
|
private List<string> _driverList = new List<string>();
|
||||||
|
|
||||||
private F1TVEmulator Emulator = null;
|
private F1TVEmulator Emulator = null;
|
||||||
@@ -35,6 +36,7 @@ namespace Test_Merge
|
|||||||
public string GrandPrixName { get => _grandPrixName; private set => _grandPrixName = value; }
|
public string GrandPrixName { get => _grandPrixName; private set => _grandPrixName = value; }
|
||||||
public int GrandPrixYear { get => _grandPrixYear; private set => _grandPrixYear = value; }
|
public int GrandPrixYear { get => _grandPrixYear; private set => _grandPrixYear = value; }
|
||||||
public List<string> DriverList { get => _driverList; private set => _driverList = value; }
|
public List<string> DriverList { get => _driverList; private set => _driverList = value; }
|
||||||
|
public string SelectedConfigFile { get => _selectedConfigFile;private set => _selectedConfigFile = value; }
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
@@ -398,11 +400,14 @@ namespace Test_Merge
|
|||||||
{
|
{
|
||||||
try
|
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
|
//MainZones #0 is the big main zone containing driver zones
|
||||||
Config = new ConfigurationTool((Bitmap)pbxMain.Image, reader.MainZones[0].Bounds);
|
Config = new ConfigurationTool((Bitmap)pbxMain.Image, reader.MainZones[0].Bounds);
|
||||||
Config.MainZone = reader.MainZones[0];
|
Config.MainZone = reader.MainZones[0];
|
||||||
DriverList = reader.Drivers;
|
DriverList = reader.Drivers;
|
||||||
|
|
||||||
|
SelectedConfigFile = fileName;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user