diff --git a/STM32 Flash Loader/MainForm.Designer.cs b/STM32 Flash Loader/MainForm.Designer.cs index fc0aa4f..492528f 100644 --- a/STM32 Flash Loader/MainForm.Designer.cs +++ b/STM32 Flash Loader/MainForm.Designer.cs @@ -165,11 +165,10 @@ private void InitializeComponent() this.bWrite.Location = new System.Drawing.Point(9, 48); this.bWrite.Name = "bWrite"; this.bWrite.Size = new System.Drawing.Size(273, 23); - this.bWrite.TabIndex = 1; + this.bWrite.TabIndex = 0; this.bWrite.Text = "Write Firmware && Jump"; this.ttToolTip.SetToolTip(this.bWrite, "Uploads the firmware and jumps to it."); this.bWrite.UseVisualStyleBackColor = true; - this.bWrite.EnabledChanged += new System.EventHandler(this.bWrite_EnabledChanged); this.bWrite.Click += new System.EventHandler(this.bWrite_Click); // // pbProgress @@ -187,7 +186,7 @@ private void InitializeComponent() this.groupBox4.Location = new System.Drawing.Point(12, 128); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(293, 50); - this.groupBox4.TabIndex = 4; + this.groupBox4.TabIndex = 2; this.groupBox4.TabStop = false; this.groupBox4.Text = "Options"; // @@ -199,7 +198,7 @@ private void InitializeComponent() this.cbxFlash.Location = new System.Drawing.Point(194, 22); this.cbxFlash.Name = "cbxFlash"; this.cbxFlash.Size = new System.Drawing.Size(91, 17); - this.cbxFlash.TabIndex = 2; + this.cbxFlash.TabIndex = 1; this.cbxFlash.Text = "Flash Memory"; this.ttToolTip.SetToolTip(this.cbxFlash, "Writing to flash memory?"); this.cbxFlash.UseVisualStyleBackColor = true; @@ -209,7 +208,7 @@ private void InitializeComponent() this.tbAddress.Location = new System.Drawing.Point(66, 20); this.tbAddress.Name = "tbAddress"; this.tbAddress.Size = new System.Drawing.Size(112, 20); - this.tbAddress.TabIndex = 1; + this.tbAddress.TabIndex = 0; this.tbAddress.Text = "0x08000000"; this.tbAddress.Leave += new System.EventHandler(this.tbAddress_Leave); // @@ -228,7 +227,7 @@ private void InitializeComponent() this.bOpenFile.Location = new System.Drawing.Point(194, 16); this.bOpenFile.Name = "bOpenFile"; this.bOpenFile.Size = new System.Drawing.Size(88, 23); - this.bOpenFile.TabIndex = 2; + this.bOpenFile.TabIndex = 1; this.bOpenFile.Text = "Open File"; this.ttToolTip.SetToolTip(this.bOpenFile, "Open firmware file"); this.bOpenFile.UseVisualStyleBackColor = true; @@ -240,7 +239,7 @@ private void InitializeComponent() this.tbFileName.Location = new System.Drawing.Point(63, 18); this.tbFileName.Name = "tbFileName"; this.tbFileName.Size = new System.Drawing.Size(115, 20); - this.tbFileName.TabIndex = 3; + this.tbFileName.TabIndex = 0; this.ttToolTip.SetToolTip(this.tbFileName, "File Name"); // // label1 diff --git a/STM32 Flash Loader/MainForm.cs b/STM32 Flash Loader/MainForm.cs index c283dc7..ee90f0f 100644 --- a/STM32 Flash Loader/MainForm.cs +++ b/STM32 Flash Loader/MainForm.cs @@ -92,6 +92,8 @@ private async void bWrite_Click(object sender, EventArgs e) bin = new byte[s.Length]; /* read file contents */ await s.ReadAsync(bin, 0, bin.Length); + /* close file */ + s.Close(); /* error during read? */ } catch (Exception) { /* set message */ @@ -140,8 +142,11 @@ await stb.WriteMemory(address, bin, 0, bin.Length, p, } finally { /* close port */ stb.Close(); + /* re-enable button */ bWrite.Enabled = true; + /* set focus */ + bWrite.Focus(); } } @@ -167,16 +172,6 @@ private void cbBauds_SelectedIndexChanged(object sender, EventArgs e) baudRate = uint.Parse((string)cbBauds.SelectedItem); } - /* set focus if button was enabled */ - private void bWrite_EnabledChanged(object sender, EventArgs e) - { - /* button was enabled?*/ - if (bWrite.Enabled) { - /* set focus */ - bWrite.Focus(); - } - } - /* parse address */ private void tbAddress_Leave(object sender, EventArgs e) { @@ -240,7 +235,8 @@ private void UpdateStatus(bool ding, string text) private void cbPorts_KeyDown(object sender, KeyEventArgs e) { - cbPorts.DroppedDown = true; + + //cbPorts.DroppedDown = true; } } }