Cleaned the Settings.cs and added some responsiveness

This commit is contained in:
2023-05-22 14:00:15 +02:00
parent 66906cb54e
commit af8db571f3
3 changed files with 271 additions and 289 deletions

View File

@@ -33,7 +33,8 @@ namespace Test_Merge
}
private async void btnSettings_Click(object sender, EventArgs e)
{
Emulator.Stop();
if(Emulator != null)
Emulator.Stop();
Settings settingsForm = new Settings();
settingsForm.ShowDialog();
//MessageBox.Show(settingsForm.GrandPrixUrl + Environment.NewLine + settingsForm.GrandPrixName + Environment.NewLine + settingsForm.GrandPrixYear);

View File

@@ -30,52 +30,48 @@
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.gpbxInfos = new System.Windows.Forms.GroupBox();
this.tbxGpYear = new System.Windows.Forms.TextBox();
this.tbxGpName = new System.Windows.Forms.TextBox();
this.gpbxRaceSettings = new System.Windows.Forms.GroupBox();
this.tbxGpUrl = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.gpbxDriverList = new System.Windows.Forms.GroupBox();
this.lsbDrivers = new System.Windows.Forms.ListBox();
this.btnRemoveDriver = new System.Windows.Forms.Button();
this.btnAddDriver = new System.Windows.Forms.Button();
this.tbxDriverName = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.gpbxPreview = new System.Windows.Forms.GroupBox();
this.lblWindowsRemaining = new System.Windows.Forms.Label();
this.btnResetDriver = new System.Windows.Forms.Button();
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();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.lblWindowPointsRemaining = new System.Windows.Forms.Label();
this.lblZonePointsRemaning = new System.Windows.Forms.Label();
this.btnCreateWindow = new System.Windows.Forms.Button();
this.pbxPreview = new System.Windows.Forms.PictureBox();
this.btnCreatZone = new System.Windows.Forms.Button();
this.gpbxWindowPreview = new System.Windows.Forms.GroupBox();
this.pbxWindowPreview = new System.Windows.Forms.PictureBox();
this.btnLoadPreset = new System.Windows.Forms.Button();
this.label8 = new System.Windows.Forms.Label();
this.lsbPresets = new System.Windows.Forms.ListBox();
this.tbxPresetName = new System.Windows.Forms.TextBox();
this.btnSavePreset = new System.Windows.Forms.Button();
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();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxMain)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxDriverZone)).BeginInit();
this.groupBox4.SuspendLayout();
this.gpbxPresets = new System.Windows.Forms.GroupBox();
this.btnDeletePreset = new System.Windows.Forms.Button();
this.gpbxRaceSettings.SuspendLayout();
this.gpbxDriverList.SuspendLayout();
this.gpbxPreview.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxPreview)).BeginInit();
this.gpbxWindowPreview.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxWindowPreview)).BeginInit();
this.gpbxPresets.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(593, 16);
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(132, 36);
this.label1.Size = new System.Drawing.Size(260, 36);
this.label1.TabIndex = 0;
this.label1.Text = "Setttings";
this.label1.Text = "Configuration tool";
//
// label2
//
@@ -87,96 +83,57 @@
this.label2.TabIndex = 1;
this.label2.Text = "Grand Prix URL";
//
// gpbxInfos
// gpbxRaceSettings
//
this.gpbxInfos.Controls.Add(this.tbxGpYear);
this.gpbxInfos.Controls.Add(this.tbxGpName);
this.gpbxInfos.Controls.Add(this.tbxGpUrl);
this.gpbxInfos.Controls.Add(this.label4);
this.gpbxInfos.Controls.Add(this.label3);
this.gpbxInfos.Controls.Add(this.label2);
this.gpbxInfos.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.gpbxInfos.Location = new System.Drawing.Point(18, 55);
this.gpbxInfos.Name = "gpbxInfos";
this.gpbxInfos.Size = new System.Drawing.Size(259, 226);
this.gpbxInfos.TabIndex = 2;
this.gpbxInfos.TabStop = false;
this.gpbxInfos.Text = "RaceSettings";
//
// tbxGpYear
//
this.tbxGpYear.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxGpYear.Location = new System.Drawing.Point(6, 187);
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
//
this.tbxGpName.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxGpName.Location = new System.Drawing.Point(6, 117);
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);
this.gpbxRaceSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.gpbxRaceSettings.Controls.Add(this.tbxGpUrl);
this.gpbxRaceSettings.Controls.Add(this.label2);
this.gpbxRaceSettings.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.gpbxRaceSettings.Location = new System.Drawing.Point(715, 2);
this.gpbxRaceSettings.Name = "gpbxRaceSettings";
this.gpbxRaceSettings.Size = new System.Drawing.Size(521, 70);
this.gpbxRaceSettings.TabIndex = 2;
this.gpbxRaceSettings.TabStop = false;
this.gpbxRaceSettings.Text = "RaceSettings";
//
// tbxGpUrl
//
this.tbxGpUrl.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxGpUrl.Location = new System.Drawing.Point(6, 53);
this.tbxGpUrl.Location = new System.Drawing.Point(144, 24);
this.tbxGpUrl.Name = "tbxGpUrl";
this.tbxGpUrl.Size = new System.Drawing.Size(247, 29);
this.tbxGpUrl.Size = new System.Drawing.Size(367, 29);
this.tbxGpUrl.TabIndex = 4;
this.tbxGpUrl.TextChanged += new System.EventHandler(this.tbxGpUrl_TextChanged);
//
// label4
// gpbxDriverList
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(6, 161);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(45, 23);
this.label4.TabIndex = 3;
this.label4.Text = "Year";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(6, 91);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(59, 23);
this.label3.TabIndex = 2;
this.label3.Text = "Name";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lsbDrivers);
this.groupBox1.Controls.Add(this.btnRemoveDriver);
this.groupBox1.Controls.Add(this.btnAddDriver);
this.groupBox1.Controls.Add(this.tbxDriverName);
this.groupBox1.Location = new System.Drawing.Point(18, 287);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(259, 376);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DriverList";
this.gpbxDriverList.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.gpbxDriverList.Controls.Add(this.lsbDrivers);
this.gpbxDriverList.Controls.Add(this.btnRemoveDriver);
this.gpbxDriverList.Controls.Add(this.btnAddDriver);
this.gpbxDriverList.Controls.Add(this.tbxDriverName);
this.gpbxDriverList.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.gpbxDriverList.Location = new System.Drawing.Point(976, 55);
this.gpbxDriverList.Name = "gpbxDriverList";
this.gpbxDriverList.Size = new System.Drawing.Size(259, 269);
this.gpbxDriverList.TabIndex = 3;
this.gpbxDriverList.TabStop = false;
this.gpbxDriverList.Text = "DriverList";
//
// lsbDrivers
//
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, 109);
this.lsbDrivers.Location = new System.Drawing.Point(10, 23);
this.lsbDrivers.Name = "lsbDrivers";
this.lsbDrivers.Size = new System.Drawing.Size(243, 257);
this.lsbDrivers.Size = new System.Drawing.Size(243, 142);
this.lsbDrivers.TabIndex = 10;
//
// 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, 24);
this.btnRemoveDriver.Location = new System.Drawing.Point(132, 175);
this.btnRemoveDriver.Name = "btnRemoveDriver";
this.btnRemoveDriver.Size = new System.Drawing.Size(121, 44);
this.btnRemoveDriver.TabIndex = 9;
@@ -187,7 +144,7 @@
// 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, 24);
this.btnAddDriver.Location = new System.Drawing.Point(10, 175);
this.btnAddDriver.Name = "btnAddDriver";
this.btnAddDriver.Size = new System.Drawing.Size(116, 44);
this.btnAddDriver.TabIndex = 8;
@@ -198,218 +155,227 @@
// 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, 74);
this.tbxDriverName.Location = new System.Drawing.Point(10, 225);
this.tbxDriverName.Name = "tbxDriverName";
this.tbxDriverName.Size = new System.Drawing.Size(243, 29);
this.tbxDriverName.TabIndex = 7;
//
// groupBox2
// gpbxPreview
//
this.groupBox2.Controls.Add(this.btnResetDriver);
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);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(968, 608);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Preview";
this.gpbxPreview.Controls.Add(this.lblWindowsRemaining);
this.gpbxPreview.Controls.Add(this.btnResetDriver);
this.gpbxPreview.Controls.Add(this.btnRefresh);
this.gpbxPreview.Controls.Add(this.lblWindowPointsRemaining);
this.gpbxPreview.Controls.Add(this.lblZonePointsRemaning);
this.gpbxPreview.Controls.Add(this.btnCreateWindow);
this.gpbxPreview.Controls.Add(this.pbxPreview);
this.gpbxPreview.Controls.Add(this.btnCreatZone);
this.gpbxPreview.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.gpbxPreview.Location = new System.Drawing.Point(2, 55);
this.gpbxPreview.Name = "gpbxPreview";
this.gpbxPreview.Size = new System.Drawing.Size(968, 608);
this.gpbxPreview.TabIndex = 4;
this.gpbxPreview.TabStop = false;
this.gpbxPreview.Text = "Preview";
//
// lblWindowsRemaining
//
this.lblWindowsRemaining.AutoSize = true;
this.lblWindowsRemaining.Location = new System.Drawing.Point(218, 85);
this.lblWindowsRemaining.Name = "lblWindowsRemaining";
this.lblWindowsRemaining.Size = new System.Drawing.Size(183, 23);
this.lblWindowsRemaining.TabIndex = 6;
this.lblWindowsRemaining.Text = "7 windows remaining";
//
// btnResetDriver
//
this.btnResetDriver.Location = new System.Drawing.Point(855, 17);
this.btnResetDriver.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnResetDriver.Location = new System.Drawing.Point(745, 23);
this.btnResetDriver.Name = "btnResetDriver";
this.btnResetDriver.Size = new System.Drawing.Size(101, 33);
this.btnResetDriver.Size = new System.Drawing.Size(211, 33);
this.btnResetDriver.TabIndex = 2;
this.btnResetDriver.Text = "Reset";
this.btnResetDriver.Text = "Reset the emulator";
this.btnResetDriver.UseVisualStyleBackColor = true;
this.btnResetDriver.Click += new System.EventHandler(this.btnResetDriver_Click);
//
// btnRefresh
//
this.btnRefresh.Location = new System.Drawing.Point(6, 23);
this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnRefresh.Location = new System.Drawing.Point(546, 23);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(101, 33);
this.btnRefresh.Size = new System.Drawing.Size(193, 33);
this.btnRefresh.TabIndex = 1;
this.btnRefresh.Text = "Refresh";
this.btnRefresh.Text = "Get a newer image";
this.btnRefresh.UseVisualStyleBackColor = true;
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
//
// pbxMain
// lblWindowPointsRemaining
//
this.pbxMain.Location = new System.Drawing.Point(6, 62);
this.pbxMain.Name = "pbxMain";
this.pbxMain.Size = new System.Drawing.Size(950, 535);
this.pbxMain.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbxMain.TabIndex = 0;
this.pbxMain.TabStop = false;
this.pbxMain.Click += new System.EventHandler(this.pbxMain_Click);
this.pbxMain.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbxMain_MouseClick);
this.lblWindowPointsRemaining.AutoSize = true;
this.lblWindowPointsRemaining.Location = new System.Drawing.Point(218, 62);
this.lblWindowPointsRemaining.Name = "lblWindowPointsRemaining";
this.lblWindowPointsRemaining.Size = new System.Drawing.Size(163, 23);
this.lblWindowPointsRemaining.TabIndex = 4;
this.lblWindowPointsRemaining.Text = "0 points remaining";
//
// groupBox3
// lblZonePointsRemaning
//
this.groupBox3.Controls.Add(this.pbxDriverZone);
this.groupBox3.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.groupBox3.Location = new System.Drawing.Point(18, 669);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(1452, 83);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "DriverZonePreview";
this.lblZonePointsRemaning.AutoSize = true;
this.lblZonePointsRemaning.Location = new System.Drawing.Point(22, 62);
this.lblZonePointsRemaning.Name = "lblZonePointsRemaning";
this.lblZonePointsRemaning.Size = new System.Drawing.Size(163, 23);
this.lblZonePointsRemaning.TabIndex = 5;
this.lblZonePointsRemaning.Text = "0 points remaining";
//
// pbxDriverZone
// btnCreateWindow
//
this.pbxDriverZone.Location = new System.Drawing.Point(10, 27);
this.pbxDriverZone.Name = "pbxDriverZone";
this.pbxDriverZone.Size = new System.Drawing.Size(1436, 50);
this.pbxDriverZone.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbxDriverZone.TabIndex = 0;
this.pbxDriverZone.TabStop = false;
this.pbxDriverZone.Click += new System.EventHandler(this.pbxDriverZone_Click);
this.pbxDriverZone.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbxDriverZone_MouseClick);
this.btnCreateWindow.Location = new System.Drawing.Point(213, 23);
this.btnCreateWindow.Name = "btnCreateWindow";
this.btnCreateWindow.Size = new System.Drawing.Size(201, 33);
this.btnCreateWindow.TabIndex = 2;
this.btnCreateWindow.Text = "Create the windows";
this.btnCreateWindow.UseVisualStyleBackColor = true;
this.btnCreateWindow.Click += new System.EventHandler(this.btnCreateWindow_Click);
//
// groupBox4
// pbxPreview
//
this.groupBox4.Controls.Add(this.btnLoadPreset);
this.groupBox4.Controls.Add(this.label8);
this.groupBox4.Controls.Add(this.lsbPresets);
this.groupBox4.Controls.Add(this.tbxPresetName);
this.groupBox4.Controls.Add(this.btnSavePreset);
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);
this.groupBox4.Location = new System.Drawing.Point(1257, 55);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(213, 608);
this.groupBox4.TabIndex = 6;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Calibration settings";
this.pbxPreview.Location = new System.Drawing.Point(10, 62);
this.pbxPreview.Name = "pbxPreview";
this.pbxPreview.Size = new System.Drawing.Size(950, 540);
this.pbxPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbxPreview.TabIndex = 0;
this.pbxPreview.TabStop = false;
this.pbxPreview.Click += new System.EventHandler(this.pbxMain_Click);
this.pbxPreview.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbxMain_MouseClick);
//
// btnCreatZone
//
this.btnCreatZone.Location = new System.Drawing.Point(6, 23);
this.btnCreatZone.Name = "btnCreatZone";
this.btnCreatZone.Size = new System.Drawing.Size(201, 33);
this.btnCreatZone.TabIndex = 1;
this.btnCreatZone.Text = "Create the main zone";
this.btnCreatZone.UseVisualStyleBackColor = true;
this.btnCreatZone.Click += new System.EventHandler(this.btnCreatZone_Click);
//
// gpbxWindowPreview
//
this.gpbxWindowPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.gpbxWindowPreview.Controls.Add(this.pbxWindowPreview);
this.gpbxWindowPreview.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.gpbxWindowPreview.Location = new System.Drawing.Point(8, 669);
this.gpbxWindowPreview.Name = "gpbxWindowPreview";
this.gpbxWindowPreview.Size = new System.Drawing.Size(1227, 88);
this.gpbxWindowPreview.TabIndex = 5;
this.gpbxWindowPreview.TabStop = false;
this.gpbxWindowPreview.Text = "DriverZonePreview";
//
// pbxWindowPreview
//
this.pbxWindowPreview.Location = new System.Drawing.Point(6, 30);
this.pbxWindowPreview.Name = "pbxWindowPreview";
this.pbxWindowPreview.Size = new System.Drawing.Size(1212, 50);
this.pbxWindowPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbxWindowPreview.TabIndex = 0;
this.pbxWindowPreview.TabStop = false;
this.pbxWindowPreview.Click += new System.EventHandler(this.pbxDriverZone_Click);
this.pbxWindowPreview.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbxDriverZone_MouseClick);
//
// btnLoadPreset
//
this.btnLoadPreset.Location = new System.Drawing.Point(6, 297);
this.btnLoadPreset.Location = new System.Drawing.Point(10, 194);
this.btnLoadPreset.Name = "btnLoadPreset";
this.btnLoadPreset.Size = new System.Drawing.Size(201, 40);
this.btnLoadPreset.Size = new System.Drawing.Size(243, 40);
this.btnLoadPreset.TabIndex = 10;
this.btnLoadPreset.Text = "LoadPreset";
this.btnLoadPreset.Text = "Load the preset";
this.btnLoadPreset.UseVisualStyleBackColor = true;
this.btnLoadPreset.Click += new System.EventHandler(this.btnLoadPreset_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 337);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(68, 23);
this.label8.TabIndex = 9;
this.label8.Text = "Presets";
//
// lsbPresets
//
this.lsbPresets.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.lsbPresets.FormattingEnabled = true;
this.lsbPresets.ItemHeight = 23;
this.lsbPresets.Location = new System.Drawing.Point(10, 363);
this.lsbPresets.Location = new System.Drawing.Point(10, 23);
this.lsbPresets.Name = "lsbPresets";
this.lsbPresets.Size = new System.Drawing.Size(197, 234);
this.lsbPresets.Size = new System.Drawing.Size(243, 119);
this.lsbPresets.TabIndex = 8;
this.lsbPresets.SelectedIndexChanged += new System.EventHandler(this.lsbPresets_SelectedIndexChanged);
//
// tbxPresetName
//
this.tbxPresetName.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxPresetName.Location = new System.Drawing.Point(10, 216);
this.tbxPresetName.Location = new System.Drawing.Point(10, 286);
this.tbxPresetName.Name = "tbxPresetName";
this.tbxPresetName.Size = new System.Drawing.Size(197, 29);
this.tbxPresetName.Size = new System.Drawing.Size(243, 29);
this.tbxPresetName.TabIndex = 7;
//
// btnSavePreset
//
this.btnSavePreset.Location = new System.Drawing.Point(6, 251);
this.btnSavePreset.Location = new System.Drawing.Point(10, 240);
this.btnSavePreset.Name = "btnSavePreset";
this.btnSavePreset.Size = new System.Drawing.Size(201, 40);
this.btnSavePreset.Size = new System.Drawing.Size(243, 40);
this.btnSavePreset.TabIndex = 7;
this.btnSavePreset.Text = "Save as new preset";
this.btnSavePreset.Text = "Save current preset";
this.btnSavePreset.UseVisualStyleBackColor = true;
this.btnSavePreset.Click += new System.EventHandler(this.btnSavePreset_Click);
//
// lblWindowsRemaining
// gpbxPresets
//
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";
this.gpbxPresets.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.gpbxPresets.Controls.Add(this.btnSavePreset);
this.gpbxPresets.Controls.Add(this.btnDeletePreset);
this.gpbxPresets.Controls.Add(this.tbxPresetName);
this.gpbxPresets.Controls.Add(this.btnLoadPreset);
this.gpbxPresets.Controls.Add(this.lsbPresets);
this.gpbxPresets.Font = new System.Drawing.Font("Microsoft YaHei UI", 10F);
this.gpbxPresets.Location = new System.Drawing.Point(976, 330);
this.gpbxPresets.Name = "gpbxPresets";
this.gpbxPresets.Size = new System.Drawing.Size(259, 333);
this.gpbxPresets.TabIndex = 6;
this.gpbxPresets.TabStop = false;
this.gpbxPresets.Text = "Presets";
//
// lblZonePointsRemaning
// btnDeletePreset
//
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";
//
// lblWindowPointsRemaining
//
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
//
this.btnCreateWindow.Location = new System.Drawing.Point(6, 118);
this.btnCreateWindow.Name = "btnCreateWindow";
this.btnCreateWindow.Size = new System.Drawing.Size(201, 40);
this.btnCreateWindow.TabIndex = 2;
this.btnCreateWindow.Text = "Create new Window";
this.btnCreateWindow.UseVisualStyleBackColor = true;
this.btnCreateWindow.Click += new System.EventHandler(this.btnCreateWindow_Click);
//
// btnCreatZone
//
this.btnCreatZone.Location = new System.Drawing.Point(6, 42);
this.btnCreatZone.Name = "btnCreatZone";
this.btnCreatZone.Size = new System.Drawing.Size(201, 40);
this.btnCreatZone.TabIndex = 1;
this.btnCreatZone.Text = "Create main zone";
this.btnCreatZone.UseVisualStyleBackColor = true;
this.btnCreatZone.Click += new System.EventHandler(this.btnCreatZone_Click);
this.btnDeletePreset.Location = new System.Drawing.Point(10, 148);
this.btnDeletePreset.Name = "btnDeletePreset";
this.btnDeletePreset.Size = new System.Drawing.Size(243, 40);
this.btnDeletePreset.TabIndex = 11;
this.btnDeletePreset.Text = "Delete the preset";
this.btnDeletePreset.UseVisualStyleBackColor = true;
this.btnDeletePreset.Click += new System.EventHandler(this.btnDeletePreset_Click);
//
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 19F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1478, 760);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.gpbxInfos);
this.ClientSize = new System.Drawing.Size(1244, 760);
this.Controls.Add(this.gpbxPresets);
this.Controls.Add(this.gpbxWindowPreview);
this.Controls.Add(this.gpbxPreview);
this.Controls.Add(this.gpbxDriverList);
this.Controls.Add(this.label1);
this.Controls.Add(this.gpbxRaceSettings);
this.Font = new System.Drawing.Font("Microsoft YaHei UI", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MinimumSize = new System.Drawing.Size(1262, 807);
this.Name = "Settings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Settings";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Settings_FormClosing);
this.gpbxInfos.ResumeLayout(false);
this.gpbxInfos.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbxMain)).EndInit();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbxDriverZone)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.Resize += new System.EventHandler(this.Settings_Resize);
this.gpbxRaceSettings.ResumeLayout(false);
this.gpbxRaceSettings.PerformLayout();
this.gpbxDriverList.ResumeLayout(false);
this.gpbxDriverList.PerformLayout();
this.gpbxPreview.ResumeLayout(false);
this.gpbxPreview.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxPreview)).EndInit();
this.gpbxWindowPreview.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbxWindowPreview)).EndInit();
this.gpbxPresets.ResumeLayout(false);
this.gpbxPresets.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -419,22 +385,17 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox gpbxInfos;
private System.Windows.Forms.TextBox tbxGpYear;
private System.Windows.Forms.TextBox tbxGpName;
private System.Windows.Forms.GroupBox gpbxRaceSettings;
private System.Windows.Forms.TextBox tbxGpUrl;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox gpbxDriverList;
private System.Windows.Forms.ListBox lsbDrivers;
private System.Windows.Forms.Button btnRemoveDriver;
private System.Windows.Forms.Button btnAddDriver;
private System.Windows.Forms.TextBox tbxDriverName;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PictureBox pbxMain;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.PictureBox pbxDriverZone;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox gpbxPreview;
private System.Windows.Forms.PictureBox pbxPreview;
private System.Windows.Forms.GroupBox gpbxWindowPreview;
private System.Windows.Forms.PictureBox pbxWindowPreview;
private System.Windows.Forms.Button btnCreateWindow;
private System.Windows.Forms.Button btnCreatZone;
private System.Windows.Forms.ListBox lsbPresets;
@@ -443,9 +404,10 @@
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;
private System.Windows.Forms.Button btnResetDriver;
private System.Windows.Forms.Button btnLoadPreset;
private System.Windows.Forms.GroupBox gpbxPresets;
private System.Windows.Forms.Button btnDeletePreset;
}
}

View File

@@ -14,8 +14,6 @@ namespace Test_Merge
public partial class Settings : Form
{
private string _grandPrixUrl = "";
private string _grandPrixName = "";
private int _grandPrixYear = 2000;
private string _selectedConfigFile;
private List<string> _driverList = new List<string>();
@@ -33,11 +31,17 @@ namespace Test_Merge
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 string SelectedConfigFile { get => _selectedConfigFile; private set => _selectedConfigFile = value; }
//For the responsive content
Size oldSize = new Size();
Size oldGpbxPreviewSize = new Size();
Size oldGpbxWindowPreviewSize = new Size();
Size oldPbxPreviewSize = new Size();
Size oldPbxWindowPreviewSize = new Size();
public Settings()
{
InitializeComponent();
@@ -46,6 +50,11 @@ namespace Test_Merge
private void Load()
{
RefreshUI();
oldSize = this.Size;
oldGpbxPreviewSize = gpbxPreview.Size;
oldGpbxWindowPreviewSize = gpbxWindowPreview.Size;
oldPbxPreviewSize = pbxPreview.Size;
oldPbxWindowPreviewSize = pbxWindowPreview.Size;
}
private void RefreshUI()
{
@@ -93,15 +102,15 @@ namespace Test_Merge
}
if (Config != null)
{
pbxMain.Image = Config.MainZone.Draw();
pbxPreview.Image = Config.MainZone.Draw();
if (Config.MainZone.Zones.Count > 0)
pbxDriverZone.Image = Config.MainZone.Zones[0].Draw();
pbxWindowPreview.Image = Config.MainZone.Zones[0].Draw();
}
}
private void CreateNewZone(Point p1, Point p2)
{
Rectangle dimensions = CreateAbsoluteRectangle(p1, p2);
Config = new ConfigurationTool((Bitmap)pbxMain.Image, dimensions);
Config = new ConfigurationTool((Bitmap)pbxPreview.Image, dimensions);
RefreshUI();
}
private void CreateWindows(List<Rectangle> dimensions)
@@ -116,25 +125,6 @@ namespace Test_Merge
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;
@@ -171,7 +161,7 @@ namespace Test_Merge
if (Emulator != null && Emulator.Ready)
{
Config = null;
pbxMain.Image = Emulator.Screenshot();
pbxPreview.Image = Emulator.Screenshot();
}
ZoneP1 = new Point(-1, -1);
@@ -214,12 +204,12 @@ namespace Test_Merge
}
private void pbxMain_MouseClick(object sender, MouseEventArgs e)
{
if (CreatingZone && pbxMain.Image != null)
if (CreatingZone && pbxPreview.Image != null)
{
//Point coordinates = pbxMain.PointToClient(new Point(MousePosition.X, MousePosition.Y));
Point coordinates = e.Location;
float xOffset = (float)pbxMain.Image.Width / (float)pbxMain.Width;
float yOffset = (float)pbxMain.Image.Height / (float)pbxMain.Height;
float xOffset = (float)pbxPreview.Image.Width / (float)pbxPreview.Width;
float yOffset = (float)pbxPreview.Image.Height / (float)pbxPreview.Height;
Point newPoint = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
//MessageBox.Show("Coordinates" + Environment.NewLine + "Old : " + coordinates.ToString() + Environment.NewLine + "New : " + newPoint.ToString());
@@ -243,12 +233,12 @@ namespace Test_Merge
}
private void pbxDriverZone_MouseClick(object sender, MouseEventArgs e)
{
if (CreatingWindow && pbxDriverZone.Image != null)
if (CreatingWindow && pbxWindowPreview.Image != null)
{
Point coordinates = e.Location;
float xOffset = (float)pbxDriverZone.Image.Width / (float)pbxDriverZone.Width;
float yOffset = (float)pbxDriverZone.Image.Height / (float)pbxDriverZone.Height;
float xOffset = (float)pbxWindowPreview.Image.Width / (float)pbxWindowPreview.Width;
float yOffset = (float)pbxWindowPreview.Image.Height / (float)pbxWindowPreview.Height;
Point newPoint = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
@@ -269,7 +259,7 @@ namespace Test_Merge
else
{
WindowP1 = new Point(WindowP1.X, 0);
WindowP2 = new Point(WindowP2.X, pbxDriverZone.Image.Height);
WindowP2 = new Point(WindowP2.X, pbxWindowPreview.Image.Height);
CreateWindows(WindowsToAdd);
SwitchWindowCreation();
}
@@ -353,12 +343,12 @@ namespace Test_Merge
}
else
{
pbxMain.Image = Emulator.Screenshot();
pbxPreview.Image = Emulator.Screenshot();
}
}
else
{
pbxMain.Image = Emulator.Screenshot();
pbxPreview.Image = Emulator.Screenshot();
}
btnRefresh.Enabled = true;
}
@@ -397,14 +387,14 @@ namespace Test_Merge
private void btnLoadPreset_Click(object sender, EventArgs e)
{
//MessageBox.Show(lsbPresets.SelectedIndex.ToString());
if (lsbPresets.SelectedIndex >= 0 && pbxMain.Image != null)
if (lsbPresets.SelectedIndex >= 0 && pbxPreview.Image != null)
{
try
{
string fileName = lsbPresets.Items[lsbPresets.SelectedIndex].ToString();
Reader reader = new Reader(fileName, (Bitmap)pbxMain.Image, false);
Reader reader = new Reader(fileName, (Bitmap)pbxPreview.Image, false);
//MainZones #0 is the big main zone containing driver zones
Config = new ConfigurationTool((Bitmap)pbxMain.Image, reader.MainZones[0].Bounds);
Config = new ConfigurationTool((Bitmap)pbxPreview.Image, reader.MainZones[0].Bounds);
Config.MainZone = reader.MainZones[0];
DriverList = reader.Drivers;
SelectedConfigFile = fileName;
@@ -416,5 +406,34 @@ namespace Test_Merge
RefreshUI();
}
}
private void Settings_Resize(object sender, EventArgs e)
{
int xDiff = this.Width - oldSize.Width;
int yDiff = this.Height - oldSize.Height;
gpbxPreview.Size = new Size(oldGpbxPreviewSize.Width + xDiff,oldGpbxPreviewSize.Height + yDiff);
gpbxWindowPreview.Size = new Size(oldGpbxWindowPreviewSize.Width + xDiff,oldGpbxWindowPreviewSize.Height);
pbxPreview.Size = new Size(oldPbxPreviewSize.Width + xDiff,oldPbxPreviewSize.Height + yDiff);
pbxWindowPreview.Size = new Size(oldPbxWindowPreviewSize.Width + xDiff,oldPbxWindowPreviewSize.Height);
}
private void btnDeletePreset_Click(object sender, EventArgs e)
{
int selectedIndex = lsbPresets.SelectedIndex;
if (selectedIndex >= 0)
{
string fileName = lsbPresets.Items[selectedIndex].ToString();
if (File.Exists(fileName))
{
File.Delete(fileName);
RefreshUI();
}
else
{
MessageBox.Show("Could not delete the preset because it does not exists");
}
}
}
}
}