From 9cefb673eb43088c522752ecc9329bd35f180714 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 1 Sep 2017 01:29:32 -0400 Subject: [PATCH] working version --- windows/QMK Toolbox/Form1.Designer.cs | 36 +++++++++++++++++++++----- windows/QMK Toolbox/Form1.cs | 19 +++++++------- windows/QMK Toolbox/Form1.resx | 3 --- windows/QMK Toolbox/QMK Toolbox.csproj | 6 ++--- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/windows/QMK Toolbox/Form1.Designer.cs b/windows/QMK Toolbox/Form1.Designer.cs index 48d956cda9..f8cbb67851 100644 --- a/windows/QMK Toolbox/Form1.Designer.cs +++ b/windows/QMK Toolbox/Form1.Designer.cs @@ -33,6 +33,7 @@ private void InitializeComponent() { this.button2 = new System.Windows.Forms.Button(); this.hexFileBox = new System.Windows.Forms.ComboBox(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.button3 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // targetBox @@ -50,11 +51,12 @@ private void InitializeComponent() { this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button1.BackColor = System.Drawing.Color.Green; this.button1.FlatAppearance.BorderColor = System.Drawing.Color.DarkGreen; + this.button1.FlatAppearance.BorderSize = 0; this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.ForeColor = System.Drawing.Color.White; - this.button1.Location = new System.Drawing.Point(638, 11); + this.button1.Location = new System.Drawing.Point(633, 11); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(80, 23); + this.button1.Size = new System.Drawing.Size(54, 23); this.button1.TabIndex = 3; this.button1.Text = "Flash"; this.button1.UseVisualStyleBackColor = false; @@ -64,14 +66,15 @@ private void InitializeComponent() { // this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.checkBox1.AutoSize = true; + this.checkBox1.BackColor = System.Drawing.Color.Transparent; this.checkBox1.Enabled = false; - this.checkBox1.Location = new System.Drawing.Point(590, 14); + this.checkBox1.Location = new System.Drawing.Point(589, 14); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(47, 17); this.checkBox1.TabIndex = 4; this.checkBox1.Text = "auto"; this.toolTip1.SetToolTip(this.checkBox1, "unimplemented"); - this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.UseVisualStyleBackColor = false; // // openFileDialog1 // @@ -83,13 +86,14 @@ private void InitializeComponent() { | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.richTextBox1.Font = new System.Drawing.Font("Courier Prime", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.richTextBox1.ForeColor = System.Drawing.Color.White; this.richTextBox1.Location = new System.Drawing.Point(12, 40); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.ReadOnly = true; this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; - this.richTextBox1.Size = new System.Drawing.Size(706, 365); + this.richTextBox1.Size = new System.Drawing.Size(729, 365); this.richTextBox1.TabIndex = 5; this.richTextBox1.Text = ""; this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); @@ -119,17 +123,34 @@ private void InitializeComponent() { this.toolTip1.IsBalloon = true; this.toolTip1.ShowAlways = true; // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.button3.FlatAppearance.BorderColor = System.Drawing.Color.Maroon; + this.button3.FlatAppearance.BorderSize = 0; + this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button3.ForeColor = System.Drawing.Color.White; + this.button3.Location = new System.Drawing.Point(693, 11); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(48, 23); + this.button3.TabIndex = 7; + this.button3.Text = "Reset"; + this.button3.UseVisualStyleBackColor = false; + this.button3.Click += new System.EventHandler(this.button3_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(730, 417); + this.ClientSize = new System.Drawing.Size(753, 417); + this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.richTextBox1); - this.Controls.Add(this.checkBox1); this.Controls.Add(this.button1); this.Controls.Add(this.targetBox); this.Controls.Add(this.hexFileBox); + this.Controls.Add(this.checkBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Form1"; this.Text = "QMK Toolbox"; @@ -149,6 +170,7 @@ private void InitializeComponent() { private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.Button button2; private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.Button button3; } } diff --git a/windows/QMK Toolbox/Form1.cs b/windows/QMK Toolbox/Form1.cs index 4418566d96..1301f281aa 100644 --- a/windows/QMK Toolbox/Form1.cs +++ b/windows/QMK Toolbox/Form1.cs @@ -91,7 +91,7 @@ void ExtractResource(string resource, string path) { private void FlashButton_Click(object sender, EventArgs e) { string hexFile = hexFileBox.Text; if (hexFile == "") { - Print("*** Please select a file ***\n", true); + Print("*** Please select a file\n", true); } else { if (mcuIsAvailable()) { RunDFU("erase --force"); @@ -130,7 +130,7 @@ private bool mcuIsAvailable() { output += process.StandardError.ReadToEnd(); process.WaitForExit(); if (output.Contains("no device present")) { - Print("*** No device present ***\n", true); + Print("*** No device present\n", true); return false; } else { return true; @@ -149,18 +149,12 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e) { private void DeviceInsertedEvent(object sender, EventArrivedEventArgs e) { ManagementBaseObject instance = (ManagementBaseObject)e.NewEvent["TargetInstance"]; - Print("Thing inserted:", true); - foreach (var property in instance.Properties) { - Print(property.Name + " = " + property.Value + "\n"); - } + Print("*** Device inserted: " + instance.GetPropertyValue("DeviceID") + "\n", true); } private void DeviceRemovedEvent(object sender, EventArrivedEventArgs e) { ManagementBaseObject instance = (ManagementBaseObject)e.NewEvent["TargetInstance"]; - Print("Thing removed:", true); - foreach (var property in instance.Properties) { - Print(property.Name + " = " + property.Value + "\n"); - } + Print("*** Device removed: "+ instance.GetPropertyValue("DeviceID") + "\n", true); } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { @@ -179,5 +173,10 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { System.Threading.Thread.Sleep(2000000); } + private void button3_Click(object sender, EventArgs e) { + if (mcuIsAvailable()) { + RunDFU("reset"); + } + } } } diff --git a/windows/QMK Toolbox/Form1.resx b/windows/QMK Toolbox/Form1.resx index f4951e2fac..2e5a2b7df5 100644 --- a/windows/QMK Toolbox/Form1.resx +++ b/windows/QMK Toolbox/Form1.resx @@ -123,9 +123,6 @@ 26, 28 - - 166, 28 - diff --git a/windows/QMK Toolbox/QMK Toolbox.csproj b/windows/QMK Toolbox/QMK Toolbox.csproj index 56914950e7..2043e3b39b 100644 --- a/windows/QMK Toolbox/QMK Toolbox.csproj +++ b/windows/QMK Toolbox/QMK Toolbox.csproj @@ -12,6 +12,7 @@ v4.5.2 512 true + false publish\ true Disk @@ -22,9 +23,8 @@ false false true - 0 + 1 1.0.0.%2a - false false true true @@ -67,7 +67,7 @@ Properties\app.manifest - true + false