Compare commits

..

3 Commits

Author SHA1 Message Date
Maxluli 23de653bde Still not working well but a lot more does 2023-04-27 11:18:53 +02:00
Maxluli d1eb1720a2 End of the day push. Does not compile 2023-04-26 16:52:51 +02:00
Maxluli 3291a3c18b Updated README 2023-04-26 15:59:39 +02:00
12 changed files with 347 additions and 36 deletions
+8 -1
View File
@@ -1,3 +1,10 @@
# Work in progress # Work in progress
Nothing to say for now # How to run it on your machine
you will need to take a couple of folders and files in the /bin/debug or /bin/release folder
You need to take the recoverCookiesCSV.py in ./Test_Merge and put it in the /bin/... folder
Same for the all geckodriver-v0.xx.x-win32 folder
You also have to change the TESS_DATA_FOLDER constant in the Windows.cs file. A small one is included in the project files
+129
View File
@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tesseract;
namespace Test_Merge
{
public class ConfigurationTool
{
public Zone MainZone;
public const int NUMBER_OF_DRIVERS = 20;
public const int NUMBER_OF_ZONES = 9;
public ConfigurationTool(Bitmap fullImage,Rectangle mainZoneDimensions)
{
MainZone = new Zone(fullImage,mainZoneDimensions);
AutoCalibrate();
}
public void AddWindows(List<Rectangle> rectangles)
{
foreach (Zone driverZone in MainZone.Zones)
{
Bitmap zoneImage = driverZone.ZoneImage;
for (int i = 1; i <= rectangles.Count; i++)
{
switch (i)
{
case 1:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverPositionWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 2:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverGapToLeaderWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 3:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverLapTimeWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 4:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverDrsWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 5:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverTyresWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 6:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverNameWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 7:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 8:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i]));
break;
case 9:
//First zone should be the driver's Position
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i]));
break;
}
}
}
}
public void AutoCalibrate()
{
List<Rectangle> detectedText = new List<Rectangle>();
List<Zone> zones = new List<Zone>();
TesseractEngine engine = new TesseractEngine(Window.TESS_DATA_FOLDER.FullName, "eng", EngineMode.Default);
Image image = MainZone.ZoneImage;
var tessImage = Pix.LoadFromMemory(Window.ImageToByte(image));
Page page = engine.Process(tessImage);
using (var iter = page.GetIterator())
{
iter.Begin();
do
{
Rect boundingBox;
if (iter.TryGetBoundingBox(PageIteratorLevel.Word, out boundingBox))
{
//var text = iter.GetText(PageIteratorLevel.Word).ToUpper();
//We remove all the rectangles that are definitely too big
if (boundingBox.Height < image.Height / NUMBER_OF_DRIVERS)
{
//Now we add a filter to only get the boxes in the right because they are much more reliable in size
if (boundingBox.X1 > image.Width / 2)
{
//Now we check if an other square box has been found roughly in the same y axis
bool match = false;
//The tolerance is roughly half the size that a window will be
int tolerance = (image.Height / NUMBER_OF_DRIVERS) / 2;
foreach (Rectangle rect in detectedText)
{
if (rect.Y > boundingBox.Y1 - tolerance && rect.Y < boundingBox.Y1 + tolerance)
{
//There already is a rectangle in this line
match = true;
}
}
//if nothing matched we can add it
if (!match)
detectedText.Add(new Rectangle(boundingBox.X1, boundingBox.Y1, boundingBox.Width, boundingBox.Height));
}
}
}
} while (iter.Next(PageIteratorLevel.Word));
}
foreach (Rectangle Rectangle in detectedText)
{
Rectangle windowRectangle;
Size windowSize = new Size(image.Width, image.Height / NUMBER_OF_DRIVERS);
Point windowLocation = new Point(0, (Rectangle.Y + Rectangle.Height / 2) - windowSize.Height / 2);
windowRectangle = new Rectangle(windowLocation, windowSize);
//We add the driver zones
MainZone.AddZone(new Zone(MainZone.ZoneImage, windowRectangle));
}
}
}
}
+5 -5
View File
@@ -53,9 +53,9 @@ namespace Test_Merge
//Position //Position
result += "Position : " + Position + Environment.NewLine; result += "Position : " + Position + Environment.NewLine;
//Gap //Gap
result += "Gap to leader : " + Reader.ConvertMsToTime(GapToLeader) + Environment.NewLine; result += "Gap to leader : " + OCRDecoder.ConvertMsToTime(GapToLeader) + Environment.NewLine;
//LapTime //LapTime
result += "Lap time : " + Reader.ConvertMsToTime(LapTime) + Environment.NewLine; result += "Lap time : " + OCRDecoder.ConvertMsToTime(LapTime) + Environment.NewLine;
//DRS //DRS
result += "DRS : " + DRS + Environment.NewLine; result += "DRS : " + DRS + Environment.NewLine;
//Tyres //Tyres
@@ -63,11 +63,11 @@ namespace Test_Merge
//Name //Name
result += "Driver name : " + Name + Environment.NewLine; result += "Driver name : " + Name + Environment.NewLine;
//Sector 1 //Sector 1
result += "Sector 1 : " + Reader.ConvertMsToTime(Sector1) + Environment.NewLine; result += "Sector 1 : " + OCRDecoder.ConvertMsToTime(Sector1) + Environment.NewLine;
//Sector 1 //Sector 1
result += "Sector 2 : " + Reader.ConvertMsToTime(Sector2) + Environment.NewLine; result += "Sector 2 : " + OCRDecoder.ConvertMsToTime(Sector2) + Environment.NewLine;
//Sector 1 //Sector 1
result += "Sector 3 : " + Reader.ConvertMsToTime(Sector3) + Environment.NewLine; result += "Sector 3 : " + OCRDecoder.ConvertMsToTime(Sector3) + Environment.NewLine;
return result; return result;
} }
+3
View File
@@ -1,8 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tesseract;
namespace Test_Merge namespace Test_Merge
{ {
+10
View File
@@ -148,6 +148,8 @@ namespace Test_Merge
actions.SendKeys(OpenQA.Selenium.Keys.Space).Perform(); actions.SendKeys(OpenQA.Selenium.Keys.Space).Perform();
Thread.Sleep(1000); Thread.Sleep(1000);
//Clicks on the settings Icon //Clicks on the settings Icon
try
{
IWebElement settingsButton = Driver.FindElement(By.ClassName("bmpui-ui-settingstogglebutton")); IWebElement settingsButton = Driver.FindElement(By.ClassName("bmpui-ui-settingstogglebutton"));
settingsButton.Click(); settingsButton.Click();
IWebElement selectElement = Driver.FindElement(By.ClassName("bmpui-ui-videoqualityselectbox")); IWebElement selectElement = Driver.FindElement(By.ClassName("bmpui-ui-videoqualityselectbox"));
@@ -155,6 +157,14 @@ namespace Test_Merge
IWebElement selectOption = selectElement.FindElement(By.CssSelector("option[value^='1080_']")); IWebElement selectOption = selectElement.FindElement(By.CssSelector("option[value^='1080_']"));
selectOption.Click(); selectOption.Click();
}
catch
{
//Sometimes it can crash because it could not get the options to show up in time. When it happens just retry
Driver.Dispose();
return 105;
}
//Makes the feed fullscreen //Makes the feed fullscreen
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10)); WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
IWebElement fullScreenButton = Driver.FindElement(By.ClassName("bmpui-ui-fullscreentogglebutton")); IWebElement fullScreenButton = Driver.FindElement(By.ClassName("bmpui-ui-fullscreentogglebutton"));
+3 -3
View File
@@ -143,9 +143,9 @@ namespace Test_Merge
newDriverZone.AddWindow(new DriverDrsWindow(zoneImg, new Rectangle(driverDrsPosition, driverDrsArea))); newDriverZone.AddWindow(new DriverDrsWindow(zoneImg, new Rectangle(driverDrsPosition, driverDrsArea)));
newDriverZone.AddWindow(new DriverTyresWindow(zoneImg, new Rectangle(driverTyresPosition, driverTyresArea))); newDriverZone.AddWindow(new DriverTyresWindow(zoneImg, new Rectangle(driverTyresPosition, driverTyresArea)));
newDriverZone.AddWindow(new DriverNameWindow(zoneImg, new Rectangle(driverNamePosition, driverNameArea))); newDriverZone.AddWindow(new DriverNameWindow(zoneImg, new Rectangle(driverNamePosition, driverNameArea)));
newDriverZone.AddWindow(new DriverSector1Window(zoneImg, new Rectangle(driverSector1Position, driverSector1Area))); newDriverZone.AddWindow(new DriverSectorWindow(zoneImg, new Rectangle(driverSector1Position, driverSector1Area)));
newDriverZone.AddWindow(new DriverSector2Window(zoneImg, new Rectangle(driverSector2Position, driverSector2Area))); newDriverZone.AddWindow(new DriverSectorWindow(zoneImg, new Rectangle(driverSector2Position, driverSector2Area)));
newDriverZone.AddWindow(new DriverSector3Window(zoneImg, new Rectangle(driverSector3Position, driverSector3Area))); newDriverZone.AddWindow(new DriverSectorWindow(zoneImg, new Rectangle(driverSector3Position, driverSector3Area)));
MainZone.AddZone(newDriverZone); MainZone.AddZone(newDriverZone);
}//); }//);
+1
View File
@@ -371,6 +371,7 @@
this.Name = "Settings"; this.Name = "Settings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Settings"; this.Text = "Settings";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Settings_FormClosing);
this.gpbxInfos.ResumeLayout(false); this.gpbxInfos.ResumeLayout(false);
this.gpbxInfos.PerformLayout(); this.gpbxInfos.PerformLayout();
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
+64 -15
View File
@@ -12,14 +12,13 @@ namespace Test_Merge
{ {
public partial class Settings : Form public partial class Settings : Form
{ {
public const int EXPECTED_WINDOWS_AMOUNT = 7;
private string _grandPrixUrl = ""; private string _grandPrixUrl = "";
private string _grandPrixName = ""; private string _grandPrixName = "";
private int _grandPrixYear = 2000; private int _grandPrixYear = 2000;
private List<string> _driverList = new List<string>(); private List<string> _driverList = new List<string>();
private F1TVEmulator Emulator = null; private F1TVEmulator Emulator = null;
private ConfigurationTool Config = null;
private bool CreatingZone = false; private bool CreatingZone = false;
private Point ZoneP1; private Point ZoneP1;
@@ -76,15 +75,32 @@ namespace Test_Merge
{ {
lblWindowPointsRemaining.Text = "1 point Remaining"; lblWindowPointsRemaining.Text = "1 point Remaining";
} }
lblWindowPointsRemaining.Text = EXPECTED_WINDOWS_AMOUNT - WindowsToAdd.Count() + " Windows remaining"; lblWindowPointsRemaining.Text = ConfigurationTool.NUMBER_OF_ZONES - WindowsToAdd.Count() + " Windows remaining";
} }
else else
{ {
lblWindowPointsRemaining.Text = ""; lblWindowPointsRemaining.Text = "";
lblWindowsRemaining.Text = ""; lblWindowsRemaining.Text = "";
} }
if (Config != null)
{
pbxMain.Image = Config.MainZone.Draw();
pbxDriverZone.Image = Config.MainZone.Zones[0].ZoneImage;
}
}
private void CreateNewZone(Point p1, Point p2)
{
Rectangle dimensions = CreateAbsoluteRectangle(p1, p2);
Config = new ConfigurationTool((Bitmap)pbxMain.Image, dimensions);
RefreshUI();
}
private void CreateWindows(List<Rectangle> dimensions)
{
if (Config != null)
{
Config.AddWindows(dimensions);
}
} }
private void tbxGpUrl_TextChanged(object sender, EventArgs e) private void tbxGpUrl_TextChanged(object sender, EventArgs e)
{ {
GrandPrixUrl = tbxGpUrl.Text; GrandPrixUrl = tbxGpUrl.Text;
@@ -137,6 +153,12 @@ namespace Test_Merge
if (CreatingWindow) if (CreatingWindow)
SwitchWindowCreation(); SwitchWindowCreation();
if (Emulator != null && Emulator.Ready)
{
Config = null;
pbxMain.Image = Emulator.Screenshot();
}
ZoneP1 = new Point(-1, -1); ZoneP1 = new Point(-1, -1);
ZoneP2 = new Point(-1, -1); ZoneP2 = new Point(-1, -1);
@@ -177,12 +199,15 @@ namespace Test_Merge
if (CreatingZone && pbxMain.Image != null) if (CreatingZone && pbxMain.Image != null)
{ {
Point coordinates = pbxMain.PointToClient(new Point(MousePosition.X, MousePosition.Y)); Point coordinates = pbxMain.PointToClient(new Point(MousePosition.X, MousePosition.Y));
float xOffset = (float)pbxMain.Image.Width / (float)pbxMain.Width; float xOffset = (float)pbxMain.Image.Width / (float)pbxMain.Width;
float yOffset = (float)pbxMain.Image.Height / (float)pbxMain.Height; float yOffset = (float)pbxMain.Image.Height / (float)pbxMain.Height;
Point newPoint = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset)); Point newPoint = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
//Point newPoint = new Point(coordinates.X - pbxMain.Left, coordinates.Y - pbxMain.Top);
//newPoint = new Point(Convert.ToInt32((float)newPoint.X * xOffset),Convert.ToInt32((float)newPoint.Y * yOffset));
MessageBox.Show("Coordinates" + Environment.NewLine + "Old : " + coordinates.ToString() + Environment.NewLine + "New : " + newPoint.ToString());
if (ZoneP1 == new Point(-1, -1)) if (ZoneP1 == new Point(-1, -1))
{ {
ZoneP1 = newPoint; ZoneP1 = newPoint;
@@ -190,7 +215,20 @@ namespace Test_Merge
else else
{ {
ZoneP2 = newPoint; ZoneP2 = newPoint;
//CreateNewZone();
/*
//Correction
if(ZoneP1.Y > ZoneP2.Y)
{
ZoneP1 = new Point(ZoneP1.X,ZoneP1.Y + pbxMain.Top);
}
else
{
ZoneP2 = new Point(ZoneP2.X, ZoneP2.Y - pbxMain.Top);
}
*/
CreateNewZone(ZoneP1, ZoneP2);
SwitchZoneCreation(); SwitchZoneCreation();
} }
RefreshUI(); RefreshUI();
@@ -215,22 +253,22 @@ namespace Test_Merge
else else
{ {
WindowP2 = newPoint; WindowP2 = newPoint;
WindowsToAdd.Add(createAbsoluteRectangle(WindowP1,WindowP2)); WindowsToAdd.Add(CreateAbsoluteRectangle(WindowP1, WindowP2));
if (WindowsToAdd.Count < EXPECTED_WINDOWS_AMOUNT) if (WindowsToAdd.Count < ConfigurationTool.NUMBER_OF_ZONES)
{ {
WindowP1 = new Point(-1, -1); WindowP1 = new Point(-1, -1);
WindowP2 = new Point(-1, -1); WindowP2 = new Point(-1, -1);
} }
else else
{ {
//CreateWindows(); CreateWindows(WindowsToAdd);
} }
} }
RefreshUI(); RefreshUI();
} }
} }
private Rectangle createAbsoluteRectangle(Point p1, Point p2) private Rectangle CreateAbsoluteRectangle(Point p1, Point p2)
{ {
Point newP1 = new Point(); Point newP1 = new Point();
Point newP2 = new Point(); Point newP2 = new Point();
@@ -256,13 +294,13 @@ namespace Test_Merge
newP1.Y = p2.Y; newP1.Y = p2.Y;
newP2.Y = p1.Y; newP2.Y = p1.Y;
} }
return new Rectangle(newP1.X, newP1.Y,newP2.X-newP1.X,newP2.Y -newP2.Y); return new Rectangle(newP1.X, newP1.Y, newP2.X - newP1.X, newP2.Y - newP1.Y);
} }
private async void btnRefresh_Click(object sender, EventArgs e) private async void btnRefresh_Click(object sender, EventArgs e)
{ {
btnRefresh.Enabled = false; btnRefresh.Enabled = false;
if (Emulator == null) if (Emulator == null || Emulator.GrandPrixUrl != tbxGpUrl.Text)
{ {
Emulator = new F1TVEmulator(tbxGpUrl.Text); Emulator = new F1TVEmulator(tbxGpUrl.Text);
} }
@@ -283,10 +321,13 @@ namespace Test_Merge
message = "Error " + errorCode + " Could not navigate on the F1TV site. Make sure the correct URL has been given and that you logged from chrome. It can take a few minutes to update"; message = "Error " + errorCode + " Could not navigate on the F1TV site. Make sure the correct URL has been given and that you logged from chrome. It can take a few minutes to update";
break; break;
case 103: case 103:
message = "Error "+errorCode+" The url is not a valid url"; message = "Error " + errorCode + " The url is not a valid url";
break; break;
case 104: case 104:
message = "Error "+errorCode+" The url is not a valid url"; message = "Error " + errorCode + " The url is not a valid url";
break;
case 105:
message = "Error " + errorCode + " There has been an error trying to emulate button presses. Please try again";
break; break;
default: default:
message = "Could not start the emulator Error " + errorCode; message = "Could not start the emulator Error " + errorCode;
@@ -305,5 +346,13 @@ namespace Test_Merge
} }
btnRefresh.Enabled = true; btnRefresh.Enabled = true;
} }
private void Settings_FormClosing(object sender, FormClosingEventArgs e)
{
if (Emulator != null)
{
Emulator.Stop();
}
}
} }
} }
Binary file not shown.
+8
View File
@@ -86,7 +86,15 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ConfigurationTool.cs" />
<Compile Include="DriverData.cs" /> <Compile Include="DriverData.cs" />
<Compile Include="DriverDrsWindow.cs" />
<Compile Include="DriverGapToLeaderWindow.cs" />
<Compile Include="DriverLapTimeWindow.cs" />
<Compile Include="DriverNameWindow.cs" />
<Compile Include="DriverPositionWindow.cs" />
<Compile Include="DriverSectorWindow.cs" />
<Compile Include="DriverTyresWindow.cs" />
<Compile Include="F1TVEmulator.cs" /> <Compile Include="F1TVEmulator.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
+12
View File
@@ -293,5 +293,17 @@ namespace Test_Merge
return d[string1.Length, string2.Length]; return d[string1.Length, string2.Length];
} }
public virtual string ToJSON()
{
string result = "";
result += "\"" + Name + "\"" + ":{" + Environment.NewLine;
result += "\t" + "\"x\":" + Bounds.X + "," + Environment.NewLine;
result += "\t" + "\"y\":" + Bounds.Y + "," + Environment.NewLine;
result += "\t" + "\"width\":" + Bounds.Width + Environment.NewLine;
result += "}";
return result;
}
} }
} }
+98 -6
View File
@@ -79,6 +79,7 @@ namespace Test_Merge
/// <returns>A driver data object that contains all the infos about a driver</returns> /// <returns>A driver data object that contains all the infos about a driver</returns>
public virtual async Task<DriverData> Decode(List<string> driverList) public virtual async Task<DriverData> Decode(List<string> driverList)
{ {
int sectorCount = 0;
DriverData result = new DriverData(); DriverData result = new DriverData();
Parallel.ForEach(Windows, async w => Parallel.ForEach(Windows, async w =>
{ {
@@ -93,16 +94,107 @@ namespace Test_Merge
result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng(); result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
if (w is DriverPositionWindow) if (w is DriverPositionWindow)
result.Position = (int)await (w as DriverPositionWindow).DecodePng(); result.Position = (int)await (w as DriverPositionWindow).DecodePng();
if (w is DriverSector1Window) if (w is DriverSectorWindow)
result.Sector1 = (int)await (w as DriverSector1Window).DecodePng(); {
if (w is DriverSector2Window) sectorCount++;
result.Sector2 = (int)await (w as DriverSector2Window).DecodePng(); if (sectorCount == 1)
if (w is DriverSector3Window) result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng();
result.Sector3 = (int)await (w as DriverSector3Window).DecodePng(); if (sectorCount == 2)
result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng();
if (sectorCount == 3)
result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng();
}
if (w is DriverTyresWindow) if (w is DriverTyresWindow)
result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng(); result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng();
}); });
return result; return result;
} }
public virtual Bitmap Draw()
{
Image img = Image;
Graphics g = Graphics.FromImage(img);
foreach (Zone z in Zones)
{
Rectangle newBounds = new Rectangle(z.Bounds.X,z.Bounds.Y + Bounds.Y,z.Bounds.Width,z.Bounds.Height);
g.DrawRectangle(Pens.Red, newBounds);
}
foreach (Window w in Windows)
{
g.DrawRectangle(Pens.Blue, w.Bounds);
}
return (Bitmap)img;
}
public virtual string ToJSON()
{
string result = "";
result += "\"" + "Zone" + "\":{" + Environment.NewLine;
result += "\t" + "\"x\":" + Bounds.X + "," + Environment.NewLine;
result += "\t" + "\"y\":" + Bounds.Y + "," + Environment.NewLine;
result += "\t" + "\"width\":" + Bounds.Width + "," + Environment.NewLine;
result += "\t" + "\"height\":" + Bounds.Height;
if (Windows.Count != 0)
{
result += "," + Environment.NewLine;
result += "\t" + "\"Windows\":[" + Environment.NewLine;
result += "\t\t{" + Environment.NewLine;
int Wcount = 0;
foreach (Window w in Windows)
{
result += "\t\t" + w.ToJSON();
Wcount++;
if (Wcount != Windows.Count)
result += ",";
}
result += "\t\t}" + Environment.NewLine;
result += "\t" + "]" + Environment.NewLine;
}
else
{
result += Environment.NewLine;
}
if (Zones.Count != 0)
{
result += "," + Environment.NewLine;
result += "\t" + "\"Zones\":[" + Environment.NewLine;
result += "\t\t{" + Environment.NewLine;
int Zcount = 0;
//foreach (Zone z in Zones)
//{
result += "\t\t" + Zones[0].ToJSON();
Zcount++;
if (Zcount != Zones.Count)
//result += ",";
//}
result += "\t\t}" + Environment.NewLine;
result += "\t" + "]" + Environment.NewLine;
}
else
{
result += Environment.NewLine;
}
result += "}";
return result;
}
/// <summary>
/// Checks if the given Rectangle fits in the current zone
/// </summary>
/// <param name="InputRectangle">The Rectangle you want to check the fittment</param>
/// <returns></returns>
protected bool Fits(Rectangle inputRectangle)
{
if (inputRectangle.X + inputRectangle.Width > Bounds.Width || inputRectangle.Y + inputRectangle.Height > Bounds.Height || inputRectangle.X < 0 || inputRectangle.Y < 0)
{
return false;
}
else
{
return true;
}
}
} }
} }