Prepared view to be wired to the old projects
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Test_Merge
|
||||
{
|
||||
Settings settingsForm = new Settings();
|
||||
settingsForm.ShowDialog();
|
||||
MessageBox.Show(settingsForm.GrandPrixUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
Test_Merge/Settings.Designer.cs
generated
90
Test_Merge/Settings.Designer.cs
generated
@@ -42,6 +42,7 @@
|
||||
this.btnAddDriver = new System.Windows.Forms.Button();
|
||||
this.tbxDriverName = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.btnRefresh = new System.Windows.Forms.Button();
|
||||
this.pbxMain = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.pbxDriverZone = new System.Windows.Forms.PictureBox();
|
||||
@@ -50,9 +51,9 @@
|
||||
this.lsbPresets = new System.Windows.Forms.ListBox();
|
||||
this.textBox5 = new System.Windows.Forms.TextBox();
|
||||
this.btnSavePreset = new System.Windows.Forms.Button();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.lblWindowsRemaining = new System.Windows.Forms.Label();
|
||||
this.lblZonePointsRemaning = new System.Windows.Forms.Label();
|
||||
this.lblWindowPointsRemaining = new System.Windows.Forms.Label();
|
||||
this.btnCreateWindow = new System.Windows.Forms.Button();
|
||||
this.btnCreatZone = new System.Windows.Forms.Button();
|
||||
this.gpbxInfos.SuspendLayout();
|
||||
@@ -107,6 +108,7 @@
|
||||
this.tbxGpYear.Name = "tbxGpYear";
|
||||
this.tbxGpYear.Size = new System.Drawing.Size(247, 29);
|
||||
this.tbxGpYear.TabIndex = 6;
|
||||
this.tbxGpYear.TextChanged += new System.EventHandler(this.tbxGpYear_TextChanged);
|
||||
//
|
||||
// tbxGpName
|
||||
//
|
||||
@@ -115,6 +117,7 @@
|
||||
this.tbxGpName.Name = "tbxGpName";
|
||||
this.tbxGpName.Size = new System.Drawing.Size(247, 29);
|
||||
this.tbxGpName.TabIndex = 5;
|
||||
this.tbxGpName.TextChanged += new System.EventHandler(this.tbxGpName_TextChanged);
|
||||
//
|
||||
// tbxGpUrl
|
||||
//
|
||||
@@ -123,6 +126,7 @@
|
||||
this.tbxGpUrl.Name = "tbxGpUrl";
|
||||
this.tbxGpUrl.Size = new System.Drawing.Size(247, 29);
|
||||
this.tbxGpUrl.TabIndex = 4;
|
||||
this.tbxGpUrl.TextChanged += new System.EventHandler(this.tbxGpUrl_TextChanged);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
@@ -162,7 +166,7 @@
|
||||
this.lsbDrivers.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
|
||||
this.lsbDrivers.FormattingEnabled = true;
|
||||
this.lsbDrivers.ItemHeight = 23;
|
||||
this.lsbDrivers.Location = new System.Drawing.Point(10, 108);
|
||||
this.lsbDrivers.Location = new System.Drawing.Point(10, 109);
|
||||
this.lsbDrivers.Name = "lsbDrivers";
|
||||
this.lsbDrivers.Size = new System.Drawing.Size(243, 257);
|
||||
this.lsbDrivers.TabIndex = 10;
|
||||
@@ -170,33 +174,36 @@
|
||||
// btnRemoveDriver
|
||||
//
|
||||
this.btnRemoveDriver.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnRemoveDriver.Location = new System.Drawing.Point(132, 23);
|
||||
this.btnRemoveDriver.Location = new System.Drawing.Point(132, 24);
|
||||
this.btnRemoveDriver.Name = "btnRemoveDriver";
|
||||
this.btnRemoveDriver.Size = new System.Drawing.Size(121, 44);
|
||||
this.btnRemoveDriver.TabIndex = 9;
|
||||
this.btnRemoveDriver.Text = "Remove";
|
||||
this.btnRemoveDriver.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveDriver.Click += new System.EventHandler(this.btnRemoveDriver_Click);
|
||||
//
|
||||
// btnAddDriver
|
||||
//
|
||||
this.btnAddDriver.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnAddDriver.Location = new System.Drawing.Point(10, 23);
|
||||
this.btnAddDriver.Location = new System.Drawing.Point(10, 24);
|
||||
this.btnAddDriver.Name = "btnAddDriver";
|
||||
this.btnAddDriver.Size = new System.Drawing.Size(116, 44);
|
||||
this.btnAddDriver.TabIndex = 8;
|
||||
this.btnAddDriver.Text = "Add";
|
||||
this.btnAddDriver.UseVisualStyleBackColor = true;
|
||||
this.btnAddDriver.Click += new System.EventHandler(this.btnAddDriver_Click);
|
||||
//
|
||||
// tbxDriverName
|
||||
//
|
||||
this.tbxDriverName.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.tbxDriverName.Location = new System.Drawing.Point(10, 73);
|
||||
this.tbxDriverName.Location = new System.Drawing.Point(10, 74);
|
||||
this.tbxDriverName.Name = "tbxDriverName";
|
||||
this.tbxDriverName.Size = new System.Drawing.Size(243, 29);
|
||||
this.tbxDriverName.TabIndex = 7;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.btnRefresh);
|
||||
this.groupBox2.Controls.Add(this.pbxMain);
|
||||
this.groupBox2.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
|
||||
this.groupBox2.Location = new System.Drawing.Point(283, 55);
|
||||
@@ -206,6 +213,15 @@
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Preview";
|
||||
//
|
||||
// btnRefresh
|
||||
//
|
||||
this.btnRefresh.Location = new System.Drawing.Point(6, 23);
|
||||
this.btnRefresh.Name = "btnRefresh";
|
||||
this.btnRefresh.Size = new System.Drawing.Size(101, 33);
|
||||
this.btnRefresh.TabIndex = 1;
|
||||
this.btnRefresh.Text = "Refresh";
|
||||
this.btnRefresh.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pbxMain
|
||||
//
|
||||
this.pbxMain.Location = new System.Drawing.Point(6, 23);
|
||||
@@ -214,6 +230,7 @@
|
||||
this.pbxMain.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pbxMain.TabIndex = 0;
|
||||
this.pbxMain.TabStop = false;
|
||||
this.pbxMain.Click += new System.EventHandler(this.pbxMain_Click);
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
@@ -234,6 +251,7 @@
|
||||
this.pbxDriverZone.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pbxDriverZone.TabIndex = 0;
|
||||
this.pbxDriverZone.TabStop = false;
|
||||
this.pbxDriverZone.Click += new System.EventHandler(this.pbxDriverZone_Click);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
@@ -241,9 +259,9 @@
|
||||
this.groupBox4.Controls.Add(this.lsbPresets);
|
||||
this.groupBox4.Controls.Add(this.textBox5);
|
||||
this.groupBox4.Controls.Add(this.btnSavePreset);
|
||||
this.groupBox4.Controls.Add(this.label7);
|
||||
this.groupBox4.Controls.Add(this.label5);
|
||||
this.groupBox4.Controls.Add(this.label6);
|
||||
this.groupBox4.Controls.Add(this.lblWindowsRemaining);
|
||||
this.groupBox4.Controls.Add(this.lblZonePointsRemaning);
|
||||
this.groupBox4.Controls.Add(this.lblWindowPointsRemaining);
|
||||
this.groupBox4.Controls.Add(this.btnCreateWindow);
|
||||
this.groupBox4.Controls.Add(this.btnCreatZone);
|
||||
this.groupBox4.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
|
||||
@@ -271,7 +289,6 @@
|
||||
this.lsbPresets.Name = "lsbPresets";
|
||||
this.lsbPresets.Size = new System.Drawing.Size(197, 257);
|
||||
this.lsbPresets.TabIndex = 8;
|
||||
this.lsbPresets.SelectedIndexChanged += new System.EventHandler(this.lsbPresets_SelectedIndexChanged);
|
||||
//
|
||||
// textBox5
|
||||
//
|
||||
@@ -290,32 +307,32 @@
|
||||
this.btnSavePreset.Text = "Save as new preset";
|
||||
this.btnSavePreset.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label7
|
||||
// lblWindowsRemaining
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(6, 184);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(183, 23);
|
||||
this.label7.TabIndex = 6;
|
||||
this.label7.Text = "7 windows remaining";
|
||||
this.lblWindowsRemaining.AutoSize = true;
|
||||
this.lblWindowsRemaining.Location = new System.Drawing.Point(6, 184);
|
||||
this.lblWindowsRemaining.Name = "lblWindowsRemaining";
|
||||
this.lblWindowsRemaining.Size = new System.Drawing.Size(183, 23);
|
||||
this.lblWindowsRemaining.TabIndex = 6;
|
||||
this.lblWindowsRemaining.Text = "7 windows remaining";
|
||||
//
|
||||
// label5
|
||||
// lblZonePointsRemaning
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(6, 85);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(163, 23);
|
||||
this.label5.TabIndex = 5;
|
||||
this.label5.Text = "0 points remaining";
|
||||
this.lblZonePointsRemaning.AutoSize = true;
|
||||
this.lblZonePointsRemaning.Location = new System.Drawing.Point(6, 85);
|
||||
this.lblZonePointsRemaning.Name = "lblZonePointsRemaning";
|
||||
this.lblZonePointsRemaning.Size = new System.Drawing.Size(163, 23);
|
||||
this.lblZonePointsRemaning.TabIndex = 5;
|
||||
this.lblZonePointsRemaning.Text = "0 points remaining";
|
||||
//
|
||||
// label6
|
||||
// lblWindowPointsRemaining
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(6, 161);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(163, 23);
|
||||
this.label6.TabIndex = 4;
|
||||
this.label6.Text = "0 points remaining";
|
||||
this.lblWindowPointsRemaining.AutoSize = true;
|
||||
this.lblWindowPointsRemaining.Location = new System.Drawing.Point(6, 161);
|
||||
this.lblWindowPointsRemaining.Name = "lblWindowPointsRemaining";
|
||||
this.lblWindowPointsRemaining.Size = new System.Drawing.Size(163, 23);
|
||||
this.lblWindowPointsRemaining.TabIndex = 4;
|
||||
this.lblWindowPointsRemaining.Text = "0 points remaining";
|
||||
//
|
||||
// btnCreateWindow
|
||||
//
|
||||
@@ -325,6 +342,7 @@
|
||||
this.btnCreateWindow.TabIndex = 2;
|
||||
this.btnCreateWindow.Text = "Create new Window";
|
||||
this.btnCreateWindow.UseVisualStyleBackColor = true;
|
||||
this.btnCreateWindow.Click += new System.EventHandler(this.btnCreateWindow_Click);
|
||||
//
|
||||
// btnCreatZone
|
||||
//
|
||||
@@ -334,6 +352,7 @@
|
||||
this.btnCreatZone.TabIndex = 1;
|
||||
this.btnCreatZone.Text = "Create main zone";
|
||||
this.btnCreatZone.UseVisualStyleBackColor = true;
|
||||
this.btnCreatZone.Click += new System.EventHandler(this.btnCreatZone_Click);
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
@@ -391,9 +410,10 @@
|
||||
private System.Windows.Forms.ListBox lsbPresets;
|
||||
private System.Windows.Forms.TextBox textBox5;
|
||||
private System.Windows.Forms.Button btnSavePreset;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label lblWindowsRemaining;
|
||||
private System.Windows.Forms.Label lblZonePointsRemaning;
|
||||
private System.Windows.Forms.Label lblWindowPointsRemaining;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.Button btnRefresh;
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,249 @@ namespace Test_Merge
|
||||
{
|
||||
public partial class Settings : Form
|
||||
{
|
||||
public const int EXPECTED_WINDOWS_AMOUNT = 7;
|
||||
|
||||
private string _grandPrixUrl = "";
|
||||
private string _grandPrixName = "";
|
||||
private int _grandPrixYear = 2000;
|
||||
private List<string> _driverList = new List<string>();
|
||||
|
||||
private bool CreatingZone = false;
|
||||
private Point ZoneP1;
|
||||
private Point ZoneP2;
|
||||
|
||||
private bool CreatingWindow = false;
|
||||
private Point WindowP1;
|
||||
private Point WindowP2;
|
||||
|
||||
List<Rectangle> WindowsToAdd = new List<Rectangle>();
|
||||
|
||||
public string GrandPrixUrl { get => _grandPrixUrl; private set => _grandPrixUrl = value; }
|
||||
public string GrandPrixName { get => _grandPrixName; private set => _grandPrixName = value; }
|
||||
public int GrandPrixYear { get => _grandPrixYear; private set => _grandPrixYear = value; }
|
||||
public List<string> DriverList { get => _driverList; private set => _driverList = value; }
|
||||
|
||||
public Settings()
|
||||
{
|
||||
InitializeComponent();
|
||||
Load();
|
||||
}
|
||||
private void Load()
|
||||
{
|
||||
RefreshUI();
|
||||
}
|
||||
private void RefreshUI()
|
||||
{
|
||||
lsbDrivers.DataSource = null;
|
||||
lsbDrivers.DataSource = DriverList;
|
||||
|
||||
if (CreatingZone)
|
||||
{
|
||||
if (ZoneP1 == new Point(-1, -1))
|
||||
{
|
||||
lblZonePointsRemaning.Text = "2 points Remaining";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblZonePointsRemaning.Text = "1 point Remaining";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lblZonePointsRemaning.Text = "";
|
||||
}
|
||||
|
||||
if (CreatingWindow)
|
||||
{
|
||||
if (WindowP1 == new Point(-1, -1))
|
||||
{
|
||||
lblWindowPointsRemaining.Text = "2 points Remaining";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblWindowPointsRemaining.Text = "1 point Remaining";
|
||||
}
|
||||
lblWindowPointsRemaining.Text = EXPECTED_WINDOWS_AMOUNT - WindowsToAdd.Count() + " Windows remaining";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblWindowPointsRemaining.Text = "";
|
||||
lblWindowsRemaining.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void lsbPresets_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void tbxGpUrl_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
GrandPrixUrl = tbxGpUrl.Text;
|
||||
}
|
||||
|
||||
private void tbxGpName_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
GrandPrixName = tbxGpName.Text;
|
||||
}
|
||||
|
||||
private void tbxGpYear_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int year;
|
||||
try
|
||||
{
|
||||
year = Convert.ToInt32(tbxGpYear.Text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
year = 1545;
|
||||
}
|
||||
GrandPrixYear = year;
|
||||
}
|
||||
|
||||
private void btnAddDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
string newDriver = tbxDriverName.Text;
|
||||
DriverList.Add(newDriver);
|
||||
RefreshUI();
|
||||
}
|
||||
|
||||
private void btnRemoveDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lsbDrivers.SelectedIndex >= 0)
|
||||
{
|
||||
DriverList.RemoveAt(lsbDrivers.SelectedIndex);
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
private void SwitchZoneCreation()
|
||||
{
|
||||
if (CreatingZone)
|
||||
{
|
||||
CreatingZone = false;
|
||||
lblZonePointsRemaning.Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
CreatingZone = true;
|
||||
if (CreatingWindow)
|
||||
SwitchWindowCreation();
|
||||
|
||||
ZoneP1 = new Point(-1, -1);
|
||||
ZoneP2 = new Point(-1, -1);
|
||||
|
||||
lblZonePointsRemaning.Text = "2 Points left";
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
private void SwitchWindowCreation()
|
||||
{
|
||||
if (CreatingWindow)
|
||||
{
|
||||
CreatingWindow = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreatingWindow = true;
|
||||
|
||||
if (CreatingZone)
|
||||
SwitchZoneCreation();
|
||||
|
||||
WindowP1 = new Point(-1, -1);
|
||||
WindowP2 = new Point(-1, -1);
|
||||
|
||||
WindowsToAdd = new List<Rectangle>();
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
private void btnCreatZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchZoneCreation();
|
||||
}
|
||||
private void btnCreateWindow_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchWindowCreation();
|
||||
}
|
||||
private void pbxMain_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CreatingZone && pbxMain.Image != null)
|
||||
{
|
||||
Point coordinates = pbxMain.PointToClient(new Point(MousePosition.X, MousePosition.Y));
|
||||
|
||||
float xOffset = (float)pbxMain.Image.Width / (float)pbxMain.Width;
|
||||
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));
|
||||
|
||||
if (ZoneP1 == new Point(-1, -1))
|
||||
{
|
||||
ZoneP1 = newPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
ZoneP2 = newPoint;
|
||||
//CreateNewZone();
|
||||
SwitchZoneCreation();
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void pbxDriverZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CreatingWindow && pbxDriverZone.Image != null)
|
||||
{
|
||||
Point coordinates = pbxDriverZone.PointToClient(new Point(MousePosition.X, MousePosition.Y));
|
||||
|
||||
float xOffset = (float)pbxDriverZone.Image.Width / (float)pbxDriverZone.Width;
|
||||
float yOffset = (float)pbxDriverZone.Image.Height / (float)pbxDriverZone.Height;
|
||||
|
||||
Point newPoint = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
|
||||
|
||||
if (WindowP1 == new Point(-1, -1))
|
||||
{
|
||||
WindowP1 = newPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowP2 = newPoint;
|
||||
WindowsToAdd.Add(createAbsoluteRectangle(WindowP1,WindowP2));
|
||||
|
||||
if (WindowsToAdd.Count < EXPECTED_WINDOWS_AMOUNT)
|
||||
{
|
||||
WindowP1 = new Point(-1, -1);
|
||||
WindowP2 = new Point(-1, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//CreateWindows();
|
||||
}
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
}
|
||||
private Rectangle createAbsoluteRectangle(Point p1, Point p2)
|
||||
{
|
||||
Point newP1 = new Point();
|
||||
Point newP2 = new Point();
|
||||
|
||||
if (p1.X < p2.X)
|
||||
{
|
||||
newP1.X = p1.X;
|
||||
newP2.X = p2.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
newP1.X = p2.X;
|
||||
newP2.X = p1.X;
|
||||
}
|
||||
|
||||
if (p1.Y < p2.Y)
|
||||
{
|
||||
newP1.Y = p1.Y;
|
||||
newP2.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
newP1.Y = p2.Y;
|
||||
newP2.Y = p1.Y;
|
||||
}
|
||||
return new Rectangle(newP1.X, newP1.Y,newP2.X-newP1.X,newP2.Y -newP2.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user