Adapted main page for futur data integration

This commit is contained in:
2023-05-23 09:10:46 +02:00
parent 195108bcde
commit 89c7e15a70
5 changed files with 330 additions and 241 deletions

64
Test_Merge/DataWrapper.cs Normal file
View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
namespace Test_Merge
{
internal class DataWrapper
{
private Reader Reader;
private SqliteStorage Storage;
List<List<DriverData>> LiveDriverDataLogs = new List<List<DriverData>>();
public DataWrapper(string configFile,Bitmap screenshot)
{
Reader = new Reader(configFile,screenshot, true);
Storage = Reader.Storage;
}
public async Task<int> Refresh()
{
LiveDriverDataLogs.Add(await Reader.Decode(Reader.MainZones, Reader.Drivers));
if (LiveDriverDataLogs.Count > 0)
return 0;
return 1;
}
public void ChangeImage(Bitmap image)
{
Reader.ChangeImage(image);
}
public void DisplayLiveRanking(Panel pnl)
{
if(LiveDriverDataLogs.Count > 0)
{
pnl.Controls.Clear();
//Gets the last item that should be the most recent data
List<DriverData> liveData = LiveDriverDataLogs[LiveDriverDataLogs.Count - 1];
Button[] buttons = new Button[liveData.Count];
Size buttonDimensions = new Size(pnl.Width,pnl.Height/liveData.Count);
for (int driverCount = 0; driverCount < liveData.Count; driverCount++)
{
Button newButton = new Button();
newButton.Size = buttonDimensions;
newButton.Location = new Point(0,driverCount * buttonDimensions.Height);
newButton.Text = liveData[driverCount].Name;
newButton.Name = liveData[driverCount].Name;
buttons[driverCount] = newButton;
}
foreach(Button button in buttons)
{
pnl.Controls.Add(button);
}
}
}
}
}

View File

@@ -33,41 +33,41 @@
this.pbxResult = new System.Windows.Forms.PictureBox();
this.btnStopUpdating = new System.Windows.Forms.Button();
this.btnResetEmulator = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.lsbPresets = new System.Windows.Forms.ListBox();
this.gpbxControls = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.gpbxRanking = new System.Windows.Forms.GroupBox();
this.gpbxOvertakes = new System.Windows.Forms.GroupBox();
this.pnlLiveRanking = new System.Windows.Forms.Panel();
this.gpbxDriverInfos = new System.Windows.Forms.GroupBox();
this.gpbxLapTimes = new System.Windows.Forms.GroupBox();
this.pnlGainingTime = new System.Windows.Forms.Panel();
this.pnlLosingTime = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.gpbxBattles = new System.Windows.Forms.GroupBox();
this.tbxResult = new System.Windows.Forms.TextBox();
this.gpbxOvertakes = new System.Windows.Forms.GroupBox();
this.pnlOvertakes = new System.Windows.Forms.Panel();
this.pnlBattles = new System.Windows.Forms.Panel();
this.lblCurrentDriverName = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.lblCurrentDriverLapTime = new System.Windows.Forms.Label();
this.pnlCurrentDriverLapsHistory = new System.Windows.Forms.Panel();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.lblCurrentDriverGapToLeader = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.lblCurrentDriverTyreType = new System.Windows.Forms.Label();
this.lblCurrentDriverTyreAge = new System.Windows.Forms.Label();
this.gpbxDriverInfos = new System.Windows.Forms.GroupBox();
this.lblCurrentDriverPosition = new System.Windows.Forms.Label();
this.lblCurrentDriverDRS = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.lblCurrentDriverPosition = new System.Windows.Forms.Label();
this.tbxResult = new System.Windows.Forms.TextBox();
this.lblCurrentDriverTyreAge = new System.Windows.Forms.Label();
this.lblCurrentDriverTyreType = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.lblCurrentDriverGapToLeader = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.pnlCurrentDriverLapsHistory = new System.Windows.Forms.Panel();
this.lblCurrentDriverLapTime = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.lblCurrentDriverName = new System.Windows.Forms.Label();
this.gpbxLapTimes = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.pnlLosingTime = new System.Windows.Forms.Panel();
this.pnlGainingTime = new System.Windows.Forms.Panel();
this.gpbxBattles = new System.Windows.Forms.GroupBox();
this.pnlBattles = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.pbxResult)).BeginInit();
this.gpbxControls.SuspendLayout();
this.gpbxRanking.SuspendLayout();
this.gpbxOvertakes.SuspendLayout();
this.pnlLiveRanking.SuspendLayout();
this.gpbxOvertakes.SuspendLayout();
this.gpbxDriverInfos.SuspendLayout();
this.gpbxLapTimes.SuspendLayout();
this.gpbxBattles.SuspendLayout();
@@ -122,14 +122,15 @@
this.btnResetEmulator.UseVisualStyleBackColor = true;
this.btnResetEmulator.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
// lsbPresets
//
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(6, 133);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(274, 52);
this.listBox1.TabIndex = 6;
this.lsbPresets.FormattingEnabled = true;
this.lsbPresets.ItemHeight = 16;
this.lsbPresets.Location = new System.Drawing.Point(6, 133);
this.lsbPresets.Name = "lsbPresets";
this.lsbPresets.Size = new System.Drawing.Size(274, 52);
this.lsbPresets.TabIndex = 6;
this.lsbPresets.SelectedIndexChanged += new System.EventHandler(this.lsbPresets_SelectedIndexChanged);
//
// gpbxControls
//
@@ -139,7 +140,7 @@
this.gpbxControls.Controls.Add(this.btnStopUpdating);
this.gpbxControls.Controls.Add(this.pbxResult);
this.gpbxControls.Controls.Add(this.btnStartDecoding);
this.gpbxControls.Controls.Add(this.listBox1);
this.gpbxControls.Controls.Add(this.lsbPresets);
this.gpbxControls.Controls.Add(this.btnSettings);
this.gpbxControls.Location = new System.Drawing.Point(987, 360);
this.gpbxControls.Name = "gpbxControls";
@@ -148,6 +149,14 @@
this.gpbxControls.TabStop = false;
this.gpbxControls.Text = "Controls";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(6, 105);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(274, 22);
this.textBox1.TabIndex = 8;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
@@ -157,13 +166,6 @@
this.label1.TabIndex = 7;
this.label1.Text = "Grand Prix URL";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(6, 105);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(274, 22);
this.textBox1.TabIndex = 8;
//
// gpbxRanking
//
this.gpbxRanking.Controls.Add(this.pnlLiveRanking);
@@ -174,6 +176,22 @@
this.gpbxRanking.TabStop = false;
this.gpbxRanking.Text = "Live Ranking";
//
// pnlLiveRanking
//
this.pnlLiveRanking.Controls.Add(this.tbxResult);
this.pnlLiveRanking.Location = new System.Drawing.Point(6, 21);
this.pnlLiveRanking.Name = "pnlLiveRanking";
this.pnlLiveRanking.Size = new System.Drawing.Size(341, 669);
this.pnlLiveRanking.TabIndex = 0;
//
// tbxResult
//
this.tbxResult.Location = new System.Drawing.Point(17, 12);
this.tbxResult.Multiline = true;
this.tbxResult.Name = "tbxResult";
this.tbxResult.Size = new System.Drawing.Size(307, 442);
this.tbxResult.TabIndex = 0;
//
// gpbxOvertakes
//
this.gpbxOvertakes.Controls.Add(this.pnlOvertakes);
@@ -184,13 +202,12 @@
this.gpbxOvertakes.TabStop = false;
this.gpbxOvertakes.Text = "Overtakes";
//
// pnlLiveRanking
// pnlOvertakes
//
this.pnlLiveRanking.Controls.Add(this.tbxResult);
this.pnlLiveRanking.Location = new System.Drawing.Point(6, 21);
this.pnlLiveRanking.Name = "pnlLiveRanking";
this.pnlLiveRanking.Size = new System.Drawing.Size(341, 669);
this.pnlLiveRanking.TabIndex = 0;
this.pnlOvertakes.Location = new System.Drawing.Point(6, 21);
this.pnlOvertakes.Name = "pnlOvertakes";
this.pnlOvertakes.Size = new System.Drawing.Size(275, 315);
this.pnlOvertakes.TabIndex = 2;
//
// gpbxDriverInfos
//
@@ -214,171 +231,15 @@
this.gpbxDriverInfos.TabStop = false;
this.gpbxDriverInfos.Text = "Driver infos";
//
// gpbxLapTimes
// lblCurrentDriverPosition
//
this.gpbxLapTimes.Controls.Add(this.label3);
this.gpbxLapTimes.Controls.Add(this.label2);
this.gpbxLapTimes.Controls.Add(this.pnlLosingTime);
this.gpbxLapTimes.Controls.Add(this.pnlGainingTime);
this.gpbxLapTimes.Location = new System.Drawing.Point(371, 12);
this.gpbxLapTimes.Name = "gpbxLapTimes";
this.gpbxLapTimes.Size = new System.Drawing.Size(610, 239);
this.gpbxLapTimes.TabIndex = 11;
this.gpbxLapTimes.TabStop = false;
this.gpbxLapTimes.Text = "Driver infos";
//
// pnlGainingTime
//
this.pnlGainingTime.Location = new System.Drawing.Point(6, 33);
this.pnlGainingTime.Name = "pnlGainingTime";
this.pnlGainingTime.Size = new System.Drawing.Size(290, 200);
this.pnlGainingTime.TabIndex = 0;
//
// pnlLosingTime
//
this.pnlLosingTime.Location = new System.Drawing.Point(314, 33);
this.pnlLosingTime.Name = "pnlLosingTime";
this.pnlLosingTime.Size = new System.Drawing.Size(290, 200);
this.pnlLosingTime.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 14);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(81, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Gaining time";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(311, 14);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 16);
this.label3.TabIndex = 3;
this.label3.Text = "Losing time";
//
// gpbxBattles
//
this.gpbxBattles.Controls.Add(this.pnlBattles);
this.gpbxBattles.Location = new System.Drawing.Point(371, 257);
this.gpbxBattles.Name = "gpbxBattles";
this.gpbxBattles.Size = new System.Drawing.Size(610, 198);
this.gpbxBattles.TabIndex = 11;
this.gpbxBattles.TabStop = false;
this.gpbxBattles.Text = "Battles";
//
// pnlOvertakes
//
this.pnlOvertakes.Location = new System.Drawing.Point(6, 21);
this.pnlOvertakes.Name = "pnlOvertakes";
this.pnlOvertakes.Size = new System.Drawing.Size(275, 315);
this.pnlOvertakes.TabIndex = 2;
//
// pnlBattles
//
this.pnlBattles.Location = new System.Drawing.Point(9, 21);
this.pnlBattles.Name = "pnlBattles";
this.pnlBattles.Size = new System.Drawing.Size(595, 171);
this.pnlBattles.TabIndex = 2;
//
// lblCurrentDriverName
//
this.lblCurrentDriverName.AutoSize = true;
this.lblCurrentDriverName.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCurrentDriverName.Location = new System.Drawing.Point(6, 18);
this.lblCurrentDriverName.Name = "lblCurrentDriverName";
this.lblCurrentDriverName.Size = new System.Drawing.Size(178, 36);
this.lblCurrentDriverName.TabIndex = 0;
this.lblCurrentDriverName.Text = "Driver name";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label4.Location = new System.Drawing.Point(6, 68);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(105, 27);
this.label4.TabIndex = 1;
this.label4.Text = "Lap time :";
//
// lblCurrentDriverLapTime
//
this.lblCurrentDriverLapTime.AutoSize = true;
this.lblCurrentDriverLapTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverLapTime.Location = new System.Drawing.Point(190, 69);
this.lblCurrentDriverLapTime.Name = "lblCurrentDriverLapTime";
this.lblCurrentDriverLapTime.Size = new System.Drawing.Size(94, 27);
this.lblCurrentDriverLapTime.TabIndex = 2;
this.lblCurrentDriverLapTime.Text = "0:00.000";
//
// pnlCurrentDriverLapsHistory
//
this.pnlCurrentDriverLapsHistory.Location = new System.Drawing.Point(304, 55);
this.pnlCurrentDriverLapsHistory.Name = "pnlCurrentDriverLapsHistory";
this.pnlCurrentDriverLapsHistory.Size = new System.Drawing.Size(300, 186);
this.pnlCurrentDriverLapsHistory.TabIndex = 3;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label6.Location = new System.Drawing.Point(299, 25);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(111, 27);
this.label6.TabIndex = 4;
this.label6.Text = "Last 5 laps";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label5.Location = new System.Drawing.Point(6, 113);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(153, 27);
this.label5.TabIndex = 5;
this.label5.Text = "Gap to leader :";
//
// lblCurrentDriverGapToLeader
//
this.lblCurrentDriverGapToLeader.AutoSize = true;
this.lblCurrentDriverGapToLeader.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverGapToLeader.Location = new System.Drawing.Point(190, 113);
this.lblCurrentDriverGapToLeader.Name = "lblCurrentDriverGapToLeader";
this.lblCurrentDriverGapToLeader.Size = new System.Drawing.Size(94, 27);
this.lblCurrentDriverGapToLeader.TabIndex = 6;
this.lblCurrentDriverGapToLeader.Text = "0:00.000";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label8.Location = new System.Drawing.Point(6, 157);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(58, 27);
this.label8.TabIndex = 7;
this.label8.Text = "Tyre:";
//
// lblCurrentDriverTyreType
//
this.lblCurrentDriverTyreType.AutoSize = true;
this.lblCurrentDriverTyreType.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverTyreType.Location = new System.Drawing.Point(65, 157);
this.lblCurrentDriverTyreType.Name = "lblCurrentDriverTyreType";
this.lblCurrentDriverTyreType.Size = new System.Drawing.Size(111, 27);
this.lblCurrentDriverTyreType.TabIndex = 8;
this.lblCurrentDriverTyreType.Text = "Undefined";
//
// lblCurrentDriverTyreAge
//
this.lblCurrentDriverTyreAge.AutoSize = true;
this.lblCurrentDriverTyreAge.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverTyreAge.Location = new System.Drawing.Point(190, 157);
this.lblCurrentDriverTyreAge.Name = "lblCurrentDriverTyreAge";
this.lblCurrentDriverTyreAge.Size = new System.Drawing.Size(85, 27);
this.lblCurrentDriverTyreAge.TabIndex = 9;
this.lblCurrentDriverTyreAge.Text = "10 Laps";
this.lblCurrentDriverPosition.AutoSize = true;
this.lblCurrentDriverPosition.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCurrentDriverPosition.Location = new System.Drawing.Point(216, 18);
this.lblCurrentDriverPosition.Name = "lblCurrentDriverPosition";
this.lblCurrentDriverPosition.Size = new System.Drawing.Size(43, 36);
this.lblCurrentDriverPosition.TabIndex = 12;
this.lblCurrentDriverPosition.Text = "-1";
//
// lblCurrentDriverDRS
//
@@ -400,23 +261,164 @@
this.label11.TabIndex = 10;
this.label11.Text = "DRS";
//
// lblCurrentDriverPosition
// lblCurrentDriverTyreAge
//
this.lblCurrentDriverPosition.AutoSize = true;
this.lblCurrentDriverPosition.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCurrentDriverPosition.Location = new System.Drawing.Point(216, 18);
this.lblCurrentDriverPosition.Name = "lblCurrentDriverPosition";
this.lblCurrentDriverPosition.Size = new System.Drawing.Size(43, 36);
this.lblCurrentDriverPosition.TabIndex = 12;
this.lblCurrentDriverPosition.Text = "-1";
this.lblCurrentDriverTyreAge.AutoSize = true;
this.lblCurrentDriverTyreAge.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverTyreAge.Location = new System.Drawing.Point(190, 157);
this.lblCurrentDriverTyreAge.Name = "lblCurrentDriverTyreAge";
this.lblCurrentDriverTyreAge.Size = new System.Drawing.Size(85, 27);
this.lblCurrentDriverTyreAge.TabIndex = 9;
this.lblCurrentDriverTyreAge.Text = "10 Laps";
//
// tbxResult
// lblCurrentDriverTyreType
//
this.tbxResult.Location = new System.Drawing.Point(17, 12);
this.tbxResult.Multiline = true;
this.tbxResult.Name = "tbxResult";
this.tbxResult.Size = new System.Drawing.Size(307, 442);
this.tbxResult.TabIndex = 0;
this.lblCurrentDriverTyreType.AutoSize = true;
this.lblCurrentDriverTyreType.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverTyreType.Location = new System.Drawing.Point(65, 157);
this.lblCurrentDriverTyreType.Name = "lblCurrentDriverTyreType";
this.lblCurrentDriverTyreType.Size = new System.Drawing.Size(111, 27);
this.lblCurrentDriverTyreType.TabIndex = 8;
this.lblCurrentDriverTyreType.Text = "Undefined";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label8.Location = new System.Drawing.Point(6, 157);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(58, 27);
this.label8.TabIndex = 7;
this.label8.Text = "Tyre:";
//
// lblCurrentDriverGapToLeader
//
this.lblCurrentDriverGapToLeader.AutoSize = true;
this.lblCurrentDriverGapToLeader.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverGapToLeader.Location = new System.Drawing.Point(190, 113);
this.lblCurrentDriverGapToLeader.Name = "lblCurrentDriverGapToLeader";
this.lblCurrentDriverGapToLeader.Size = new System.Drawing.Size(94, 27);
this.lblCurrentDriverGapToLeader.TabIndex = 6;
this.lblCurrentDriverGapToLeader.Text = "0:00.000";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label5.Location = new System.Drawing.Point(6, 113);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(153, 27);
this.label5.TabIndex = 5;
this.label5.Text = "Gap to leader :";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label6.Location = new System.Drawing.Point(299, 25);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(111, 27);
this.label6.TabIndex = 4;
this.label6.Text = "Last 5 laps";
//
// pnlCurrentDriverLapsHistory
//
this.pnlCurrentDriverLapsHistory.Location = new System.Drawing.Point(304, 55);
this.pnlCurrentDriverLapsHistory.Name = "pnlCurrentDriverLapsHistory";
this.pnlCurrentDriverLapsHistory.Size = new System.Drawing.Size(300, 186);
this.pnlCurrentDriverLapsHistory.TabIndex = 3;
//
// lblCurrentDriverLapTime
//
this.lblCurrentDriverLapTime.AutoSize = true;
this.lblCurrentDriverLapTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.lblCurrentDriverLapTime.Location = new System.Drawing.Point(190, 69);
this.lblCurrentDriverLapTime.Name = "lblCurrentDriverLapTime";
this.lblCurrentDriverLapTime.Size = new System.Drawing.Size(94, 27);
this.lblCurrentDriverLapTime.TabIndex = 2;
this.lblCurrentDriverLapTime.Text = "0:00.000";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.label4.Location = new System.Drawing.Point(6, 68);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(105, 27);
this.label4.TabIndex = 1;
this.label4.Text = "Lap time :";
//
// lblCurrentDriverName
//
this.lblCurrentDriverName.AutoSize = true;
this.lblCurrentDriverName.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCurrentDriverName.Location = new System.Drawing.Point(6, 18);
this.lblCurrentDriverName.Name = "lblCurrentDriverName";
this.lblCurrentDriverName.Size = new System.Drawing.Size(178, 36);
this.lblCurrentDriverName.TabIndex = 0;
this.lblCurrentDriverName.Text = "Driver name";
//
// gpbxLapTimes
//
this.gpbxLapTimes.Controls.Add(this.label3);
this.gpbxLapTimes.Controls.Add(this.label2);
this.gpbxLapTimes.Controls.Add(this.pnlLosingTime);
this.gpbxLapTimes.Controls.Add(this.pnlGainingTime);
this.gpbxLapTimes.Location = new System.Drawing.Point(371, 12);
this.gpbxLapTimes.Name = "gpbxLapTimes";
this.gpbxLapTimes.Size = new System.Drawing.Size(610, 239);
this.gpbxLapTimes.TabIndex = 11;
this.gpbxLapTimes.TabStop = false;
this.gpbxLapTimes.Text = "Driver infos";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(311, 14);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 16);
this.label3.TabIndex = 3;
this.label3.Text = "Losing time";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 14);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(81, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Gaining time";
//
// pnlLosingTime
//
this.pnlLosingTime.Location = new System.Drawing.Point(314, 33);
this.pnlLosingTime.Name = "pnlLosingTime";
this.pnlLosingTime.Size = new System.Drawing.Size(290, 200);
this.pnlLosingTime.TabIndex = 1;
//
// pnlGainingTime
//
this.pnlGainingTime.Location = new System.Drawing.Point(6, 33);
this.pnlGainingTime.Name = "pnlGainingTime";
this.pnlGainingTime.Size = new System.Drawing.Size(290, 200);
this.pnlGainingTime.TabIndex = 0;
//
// gpbxBattles
//
this.gpbxBattles.Controls.Add(this.pnlBattles);
this.gpbxBattles.Location = new System.Drawing.Point(371, 257);
this.gpbxBattles.Name = "gpbxBattles";
this.gpbxBattles.Size = new System.Drawing.Size(610, 198);
this.gpbxBattles.TabIndex = 11;
this.gpbxBattles.TabStop = false;
this.gpbxBattles.Text = "Battles";
//
// pnlBattles
//
this.pnlBattles.Location = new System.Drawing.Point(9, 21);
this.pnlBattles.Name = "pnlBattles";
this.pnlBattles.Size = new System.Drawing.Size(595, 171);
this.pnlBattles.TabIndex = 2;
//
// Form1
//
@@ -437,9 +439,9 @@
this.gpbxControls.ResumeLayout(false);
this.gpbxControls.PerformLayout();
this.gpbxRanking.ResumeLayout(false);
this.gpbxOvertakes.ResumeLayout(false);
this.pnlLiveRanking.ResumeLayout(false);
this.pnlLiveRanking.PerformLayout();
this.gpbxOvertakes.ResumeLayout(false);
this.gpbxDriverInfos.ResumeLayout(false);
this.gpbxDriverInfos.PerformLayout();
this.gpbxLapTimes.ResumeLayout(false);
@@ -456,7 +458,7 @@
private System.Windows.Forms.PictureBox pbxResult;
private System.Windows.Forms.Button btnStopUpdating;
private System.Windows.Forms.Button btnResetEmulator;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox lsbPresets;
private System.Windows.Forms.GroupBox gpbxControls;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;

View File

@@ -15,8 +15,9 @@ namespace Test_Merge
{
public partial class Form1 : Form
{
Reader Reader = null;
F1TVEmulator Emulator = null;
//private Reader Reader = null;
private F1TVEmulator Emulator = null;
private DataWrapper Wrapper = null;
private bool cancelRequested = false;
private SemaphoreSlim semaphore = new SemaphoreSlim(1);
@@ -29,7 +30,11 @@ namespace Test_Merge
}
public async void RefreshUI()
{
if (Directory.Exists(ConfigurationTool.CONFIGS_FOLDER_NAME))
{
lsbPresets.DataSource = null;
lsbPresets.DataSource = Directory.GetFiles(ConfigurationTool.CONFIGS_FOLDER_NAME);
}
}
private async void btnSettings_Click(object sender, EventArgs e)
{
@@ -61,12 +66,16 @@ namespace Test_Merge
//Those are the default values but they will need to be changed later when the configuration has been done
ConfigFile = "./Presets/Clean_4K_2023.json";
GpUrl = "https://f1tv.formula1.com/detail/1000006688/2023-azerbaijan-grand-prix?action=play";
textBox1.Text = GpUrl;
RefreshUI();
}
private async void btnUpdate_Click(object sender, EventArgs e)
{
cancelRequested = false;
if (Emulator != null && Reader != null)
if (Emulator != null && Wrapper != null)
{
// Disable UI controls to prevent re-entrancy
btnStartDecoding.Enabled = false;
@@ -86,14 +95,15 @@ namespace Test_Merge
Bitmap screen = Emulator.Screenshot();
screen.Save("HopefullyDataScreenshot.png");
Reader.ChangeImage(screen);
string result = await Reader.Decode(Reader.MainZones, Reader.Drivers);
Wrapper.ChangeImage(screen);
int errorCode = await Wrapper.Refresh();
sw.Stop();
// Task completed
Invoke((MethodInvoker)delegate
{
DisplayResults(result, sw, screen);
DisplayResults(errorCode,sw, screen);
});
});
}
@@ -115,19 +125,16 @@ namespace Test_Merge
Emulator.Stop();
}
}
private void DisplayResults(string result, Stopwatch sw, Bitmap screen)
private void DisplayResults(int errorCode,Stopwatch sw, Bitmap screen)
{
if (result == "")
if (errorCode != 0)
{
cancelRequested = true;
MessageBox.Show("An error has occured while trying to recover data from live feed. This can happen sometimes. I would advise you to restart a few times. If the problem persists check your configuration.");
}
else
{
tbxResult.Text = "";
tbxResult.Text = "Decoding done in :" + sw.ElapsedMilliseconds + "ms" + Environment.NewLine;
tbxResult.Text += result;
pbxResult.Image = screen;
Wrapper.DisplayLiveRanking(pnlLiveRanking);
}
}
@@ -150,7 +157,7 @@ namespace Test_Merge
Emulator.ResetDriver();
Emulator = null;
Reader = null;
Wrapper = null;
Emulator = new F1TVEmulator(GpUrl);
errorCode = await Emulator.Start();
@@ -164,11 +171,23 @@ namespace Test_Merge
}
else
{
Reader = new Reader(ConfigFile, Emulator.Screenshot(), true);
Wrapper = new DataWrapper(ConfigFile, Emulator.Screenshot());
btnResetEmulator.Enabled = true;
btnSettings.Enabled = true;
btnStartDecoding.Enabled = true;
}
}
private void lsbPresets_SelectedIndexChanged(object sender, EventArgs e)
{
if (lsbPresets.SelectedIndex >= 0)
ConfigFile = lsbPresets.Items[lsbPresets.SelectedIndex].ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (tbxResult.Text != "")
GpUrl = textBox1.Text;
}
}
}

View File

@@ -224,7 +224,7 @@ namespace Test_Merge
/// </summary>
/// <param name="idImage">The id of the image we are working with</param>
/// <returns>a string representation of all the returns</returns>
public async Task<string> Decode(List<Zone> mainZones, List<string> drivers)
public async Task<List<DriverData>> Decode(List<Zone> mainZones, List<string> drivers)
{
string result = "";
List<DriverData> mainResults = new List<DriverData>();
@@ -284,6 +284,7 @@ namespace Test_Merge
}
//Display
/*
int nullDrivers = 0;
foreach (DriverData driver in mainResults)
{
@@ -302,6 +303,8 @@ namespace Test_Merge
{
return result;
}
*/
return mainResults;
}
public void ChangeImage(Bitmap Image)

View File

@@ -104,6 +104,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigurationTool.cs" />
<Compile Include="DataWrapper.cs" />
<Compile Include="DriverData.cs" />
<Compile Include="DriverDrsWindow.cs" />
<Compile Include="DriverGapToLeaderWindow.cs" />