# DriverNameWindow.cs ``` cs /// Author : Maxime Rohmer /// Date : 08/05/2023 /// File : DriverNameWindow /// Brief : Window containing infos about the name of the driver /// Version : 0.1 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; namespace Test_Merge { public class DriverNameWindow : Window { public static Random rnd = new Random(); public DriverNameWindow(Bitmap image, Rectangle bounds, bool generateEngine = true) : base(image, bounds,generateEngine) { Name = "Name"; } /// /// Decodes using OCR wich driver name is in the image /// /// /// The driver name in string public override async Task DecodePng(List DriverList) { string result = ""; result = await GetStringFromPng(WindowImage, Engine); if (!IsADriver(DriverList, result)) { //I put everything in uppercase to try to lower the chances of bad answers result = FindClosestMatch(DriverList.ConvertAll(d => d.ToUpper()), result.ToUpper()); } return result; } /// /// Verifies that the name found in the OCR is a valid name /// /// /// /// If ye or no the driver exists private static bool IsADriver(List driverList, string potentialDriver) { bool result = false; //I cant use drivers.Contains because it has missmatched cases and all foreach (string name in driverList) { if (name.ToUpper() == potentialDriver.ToUpper()) result = true; } return result; } } } ```