Skip to content

Commit

Permalink
update colors, better scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhumbert committed Sep 1, 2017
1 parent 22cc2b5 commit bfba798
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
25 changes: 13 additions & 12 deletions windows/QMK Toolbox/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 18 additions & 17 deletions windows/QMK Toolbox/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ private void Form1_Load(object sender, EventArgs e) {
backgroundWorker1.RunWorkerAsync();


richTextBox1.VisibleChanged += (sender1, e1) =>
{
if (richTextBox1.Visible) {
richTextBox1.SelectionStart = richTextBox1.TextLength;
richTextBox1.ScrollToCaret();
}
};
//richTextBox1.VisibleChanged += (sender1, e1) =>
//{
// if (richTextBox1.Visible) {
// richTextBox1.SelectionStart = richTextBox1.TextLength;
// richTextBox1.ScrollToCaret();
// }
//};

string dfuPath = Application.LocalUserAppDataPath + "\\dfu-programmer.exe";
ExtractResource("QMK_Toolbox.dfu-programmer.exe", dfuPath);
Expand Down Expand Up @@ -111,7 +111,7 @@ private void Form1_Load(object sender, EventArgs e) {
foreach (var device in collection) {
var match = Regex.Match(device.GetPropertyValue("DeviceID").ToString(), @".*VID_03EB.*");
if (match.Success) {
Print("*** Device connected: " + device.GetPropertyValue("Name") + "\n", true, Color.Yellow);
Print("*** DFU Device connected: " + device.GetPropertyValue("Name") + "\n", true, Color.Yellow);
} else {
//Print("*** Device connected: " + device.GetPropertyValue("Name") + "\n", true);
}
Expand Down Expand Up @@ -139,22 +139,22 @@ private bool Connect() {

_device.MonitorDeviceEvents = true;
_isAttached = true;
Print("*** HID device available\n", true, Color.Yellow);
Print("*** HID device available: " + string.Format("0x{0:X4}", VendorId) + ":" + string.Format("0x{0:X4}", ProductId) + "\n", true, Color.DeepSkyBlue);
} else {
Print("*** No HID device available\n", true, Color.Yellow);
Print("*** No HID device available\n", true, Color.DeepSkyBlue);
_isAttached = false;
}
return _isAttached;
}

private void DeviceAttachedHandler() {
Print("*** HID device attached\n", true, Color.Yellow);
Print("*** HID device attached: " + string.Format("0x{0:X4}", VendorId) + ":" + string.Format("0x{0:X4}", ProductId) + "\n", true, Color.DeepSkyBlue);
_isAttached = true;
_device.ReadReport(OnReport);
}

private void DeviceRemovedHandler() {
Print("*** HID device detached\n", true, Color.Yellow);
Print("*** HID device detached: " + string.Format("0x{0:X4}", VendorId) + ":" + string.Format("0x{0:X4}", ProductId) + "\n", true, Color.DeepSkyBlue);
_isAttached = false;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ private void FlashButton_Click(object sender, EventArgs e) {
if (targetBox.Text == "") {
Print("*** Please select an MCU\n", true, Color.Red);
} else if (hexFile == "") {
Print("*** Please select a file\n", true, Color.Red);
Print("*** Please select a .hex file\n", true, Color.Red);
RunDFU("reset");
} else {
if (mcuIsAvailable()) {
Expand All @@ -210,7 +210,8 @@ private void Print(string str, bool bold = false, Color? color = null) {
if (bold)
richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Bold);
richTextBox1.SelectionColor = color ?? Color.White;
richTextBox1.AppendText(str);
richTextBox1.SelectionStart = richTextBox1.TextLength;
richTextBox1.SelectedText = str;
} else {
this.Invoke(new Action<string, bool, Color?>(Print), new object[] { str, bold, color });
}
Expand All @@ -235,7 +236,7 @@ private bool mcuIsAvailable() {
output += process.StandardError.ReadToEnd();
process.WaitForExit();
if (output.Contains("no device present")) {
Print("*** No device present\n", true, Color.Red);
Print("*** No \""+ targetBox.Text + "\" DFU device connected\n", true, Color.Red);
return false;
} else {
return true;
Expand Down Expand Up @@ -263,7 +264,7 @@ private void DeviceInsertedEvent(object sender, EventArrivedEventArgs e) {
// Detects Atmel Vendor ID
var match = Regex.Match(instance.GetPropertyValue("DeviceID").ToString(), @".*VID_03EB.*");
if (match.Success) {
Print("*** Device inserted: " + instance.GetPropertyValue("Name") + "\n", true, Color.Yellow);
Print("*** DFU device connected: " + instance.GetPropertyValue("Name") + "\n", true, Color.Yellow);
if (checkBox1.Checked) {
FlashButton_Click(sender, e);
}
Expand All @@ -281,7 +282,7 @@ private void DeviceRemovedEvent(object sender, EventArrivedEventArgs e) {
// Detects Atmel Vendor ID
var match = Regex.Match(instance.GetPropertyValue("DeviceID").ToString(), @".*VID_03EB.*");
if (match.Success) {
Print("*** Device removed: " + instance.GetPropertyValue("Name") + "\n", true, Color.Yellow);
Print("*** DFU Device disconnected: " + instance.GetPropertyValue("Name") + "\n", true, Color.Yellow);
}
}

Expand Down

0 comments on commit bfba798

Please sign in to comment.