Adapted main page for futur data integration
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user