Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Project housekeeping #288

Merged
merged 6 commits into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion windows/QMK Toolbox/AboutBox.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Created by Jack Humbert on 9/1/17.
// Copyright © 2017 Jack Humbert. This code is licensed under MIT license (see LICENSE.md for details).

using System;
using System.Reflection;
using System.Windows.Forms;

Expand Down
6 changes: 3 additions & 3 deletions windows/QMK Toolbox/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<userSettings>

Expand Down Expand Up @@ -41,8 +41,8 @@
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="RJCP.SerialPortStream" publicKeyToken="5f5e7b70c6a74deb" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
8 changes: 1 addition & 7 deletions windows/QMK Toolbox/BetterComboBox.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms;

namespace QMK_Toolbox
{
Expand Down Expand Up @@ -34,7 +29,6 @@ protected override void OnKeyDown(KeyEventArgs e)
return;
}

int selectionIndex = Items.IndexOf(Text);
int hoverIndex = SelectedIndex;

Items.RemoveAt(hoverIndex);
Expand Down
7 changes: 1 addition & 6 deletions windows/QMK Toolbox/BindableToolStripMenuItem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Forms;

namespace QMK_Toolbox
Expand Down
22 changes: 6 additions & 16 deletions windows/QMK Toolbox/ComboBoxPlaceholder.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QMK_Toolbox
Expand All @@ -16,9 +10,9 @@ public class ComboBoxPlaceholder : ComboBox
private const uint CB_SETCUEBANNER = 0x1703;

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessage(HandleRef hWnd, uint msg, IntPtr wParam, String lParam);
private static extern IntPtr SendMessage(HandleRef hWnd, uint msg, IntPtr wParam, string lParam);

private string _placeholderText = String.Empty;
private string _placeholderText = string.Empty;

/// <summary>
/// Gets or sets the text the <see cref="ComboBox"/> will display as a cue to the user.
Expand All @@ -34,7 +28,7 @@ public string PlaceholderText
{
if (value == null)
{
value = String.Empty;
value = string.Empty;
}

if (!_placeholderText.Equals(value, StringComparison.CurrentCulture))
Expand All @@ -54,11 +48,7 @@ public string PlaceholderText
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnPlaceholderTextChanged(EventArgs e)
{
EventHandler handler = PlaceholderTextChanged;
if (handler != null)
{
handler(this, e);
}
PlaceholderTextChanged?.Invoke(this, e);
}

protected override void OnHandleCreated(EventArgs e)
Expand All @@ -69,9 +59,9 @@ protected override void OnHandleCreated(EventArgs e)

private void UpdatePlaceholderText()
{
if (this.IsHandleCreated)
if (IsHandleCreated)
{
SendMessage(new HandleRef(this, this.Handle), CB_SETCUEBANNER, IntPtr.Zero, _placeholderText);
SendMessage(new HandleRef(this, Handle), CB_SETCUEBANNER, IntPtr.Zero, _placeholderText);
}
}
}
Expand Down
16 changes: 6 additions & 10 deletions windows/QMK Toolbox/Flashing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using QMK_Toolbox.Helpers;
Expand Down Expand Up @@ -95,10 +91,10 @@ private void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
_printer.PrintResponse(e.Data, MessageType.Info);
}

private void ProcessOutput(Object streamReader)
private void ProcessOutput(object streamReader)
{
StreamReader _stream = (StreamReader)streamReader;
var output = "";
string output;

while (!_stream.EndOfStream)
{
Expand Down Expand Up @@ -151,9 +147,9 @@ public void Flash(string mcu, string file)
if (Usb.CanFlash(Chipset.Halfkay))
FlashHalfkay(mcu, file);
if (Usb.CanFlash(Chipset.Stm32Dfu))
FlashStm32Dfu(mcu, file);
FlashStm32Dfu(file);
if (Usb.CanFlash(Chipset.Apm32Dfu))
FlashApm32Dfu(mcu, file);
FlashApm32Dfu(file);
if (Usb.CanFlash(Chipset.Kiibohd))
FlashKiibohd(file);
if (Usb.CanFlash(Chipset.LufaMs))
Expand Down Expand Up @@ -286,7 +282,7 @@ private void SetHandednessAtmelDfu(string mcu, bool rightHand, bool erase)

private void ResetHalfkay(string mcu) => RunProcess("teensy_loader_cli.exe", $"-mmcu={mcu} -bv");

private void FlashStm32Dfu(string mcu, string file)
private void FlashStm32Dfu(string file)
{
if (Path.GetExtension(file)?.ToLower() == ".bin") {
RunProcess("dfu-util.exe", $"-a 0 -d 0483:DF11 -s 0x08000000:leave -D \"{file}\"");
Expand All @@ -304,7 +300,7 @@ private void FlashStm32Duino(string file)
}
}

private void FlashApm32Dfu(string mcu, string file)
private void FlashApm32Dfu(string file)
{
if (Path.GetExtension(file)?.ToLower() == ".bin") {
RunProcess("dfu-util.exe", $"-a 0 -d 314B:0106 -s 0x08000000:leave -D \"{file}\"");
Expand Down
4 changes: 2 additions & 2 deletions windows/QMK Toolbox/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura />
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura/>
</Weavers>
111 changes: 111 additions & 0 deletions windows/QMK Toolbox/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
34 changes: 26 additions & 8 deletions windows/QMK Toolbox/Info.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
// Created by Jack Humbert on 9/1/17.
// Copyright © 2017 Jack Humbert. This code is licensed under MIT license (see LICENSE.md for details).

using Newtonsoft.Json;

namespace QMK_Toolbox
{
[JsonObject(MemberSerialization.OptIn)]
internal class Info
{
public string Keyboard;
public string Keymap;
public string Subproject;
public string VendorId;
public string ProductId;
public string DeviceVer;
public string ChipBase;
public string Mcu;
[JsonProperty]
public string Keyboard { get; set; }

[JsonProperty]
public string Keymap { get; set; }

[JsonProperty]
public string Subproject { get; set; }

[JsonProperty]
public string VendorId { get; set; }

[JsonProperty]
public string ProductId { get; set; }

[JsonProperty]
public string DeviceVer { get; set; }

[JsonProperty]
public string ChipBase { get; set; }

[JsonProperty]
public string Mcu { get; set; }
}
}
Loading