65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
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 int Refresh()
|
|
{
|
|
LiveDriverDataLogs.Add(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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|