working initial release

This commit is contained in:
Manuel Kamper 2024-11-16 16:00:35 +01:00
parent 951e6da8cd
commit 0e2e4f2bf3
14 changed files with 812 additions and 92 deletions

43
PicoKeys/ActionMethods.cs Normal file
View File

@ -0,0 +1,43 @@
using AudioSwitcher.AudioApi.CoreAudio;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace PicoKeys
{
public class ActionMethods
{
public void DoNothing()
{
//DO NOTHING METHOD FOR NO ACTION
}
public void ToggleMicrophone()
{
using (var audio = new CoreAudioController())
{
audio.DefaultCaptureDevice.ToggleMute();
}
}
public void ToggleSpeaker()
{
using (var audio = new CoreAudioController())
{
audio.DefaultPlaybackDevice.ToggleMute();
}
}
public void LaunchProgram(string path)
{
if (File.Exists(path))
{
Process.Start(path);
}
else
{
MessageBox.Show("The program specified for this button was not found!\n\n" + path, "Launcher Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

20
PicoKeys/ActionObject.cs Normal file
View File

@ -0,0 +1,20 @@
namespace PicoKeys
{
public class ActionObject
{
public string ButtonName { get; set; }
public string ButtonText { get; set; }
public bool ShowStatusOverlay { get; set; }
public string Actiontype { get; set; }
public string Parameter { get; set; }
public ActionObject(string ButtonName, string ButtonText)
{
this.ButtonName = ButtonName;
this.ButtonText = ButtonText;
ShowStatusOverlay = true;
Actiontype = "None";
Parameter = "";
}
}
}

25
PicoKeys/ActionType.cs Normal file
View File

@ -0,0 +1,25 @@
namespace PicoKeys
{
public class ActionType
{
public string Name { get; set; }
public string Method { get; set; }
public bool Dummy { get; set; }
public bool HasParameter { get; set; }
public ActionType(string Name)
{
this.Name = Name;
Method = "DoNothing";
Dummy = true;
}
public ActionType(string Name, string Method, bool HasParameter = false)
{
this.Name = Name;
this.Method = Method;
Dummy = false;
this.HasParameter = HasParameter;
}
}
}

155
PicoKeys/Actions.Designer.cs generated Normal file
View File

@ -0,0 +1,155 @@
namespace PicoKeys
{
partial class Actions
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Actions));
this.label1 = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.textBoxButtonName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxActionType = new System.Windows.Forms.ComboBox();
this.checkBoxStatusOverlay = new System.Windows.Forms.CheckBox();
this.labelParameter = new System.Windows.Forms.Label();
this.textBoxParameter = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Button Name:";
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(157, 183);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 1;
this.buttonSave.Text = "save";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// textBoxButtonName
//
this.textBoxButtonName.Location = new System.Drawing.Point(15, 25);
this.textBoxButtonName.MaxLength = 20;
this.textBoxButtonName.Name = "textBoxButtonName";
this.textBoxButtonName.Size = new System.Drawing.Size(217, 20);
this.textBoxButtonName.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 58);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(74, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Button Action:";
//
// comboBoxActionType
//
this.comboBoxActionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxActionType.FormattingEnabled = true;
this.comboBoxActionType.Location = new System.Drawing.Point(15, 74);
this.comboBoxActionType.Name = "comboBoxActionType";
this.comboBoxActionType.Size = new System.Drawing.Size(217, 21);
this.comboBoxActionType.TabIndex = 4;
this.comboBoxActionType.SelectedIndexChanged += new System.EventHandler(this.ComboBoxActionType_SelectedIndexChanged);
//
// checkBoxStatusOverlay
//
this.checkBoxStatusOverlay.AutoSize = true;
this.checkBoxStatusOverlay.Checked = true;
this.checkBoxStatusOverlay.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxStatusOverlay.Location = new System.Drawing.Point(15, 160);
this.checkBoxStatusOverlay.Name = "checkBoxStatusOverlay";
this.checkBoxStatusOverlay.Size = new System.Drawing.Size(198, 17);
this.checkBoxStatusOverlay.TabIndex = 5;
this.checkBoxStatusOverlay.Text = "Show Status Overlay when triggered";
this.checkBoxStatusOverlay.UseVisualStyleBackColor = true;
//
// labelParameter
//
this.labelParameter.AutoSize = true;
this.labelParameter.Location = new System.Drawing.Point(12, 108);
this.labelParameter.Name = "labelParameter";
this.labelParameter.Size = new System.Drawing.Size(58, 13);
this.labelParameter.TabIndex = 6;
this.labelParameter.Text = "Parameter:";
this.labelParameter.Visible = false;
//
// textBoxParameter
//
this.textBoxParameter.Location = new System.Drawing.Point(15, 124);
this.textBoxParameter.MaxLength = 230;
this.textBoxParameter.Name = "textBoxParameter";
this.textBoxParameter.Size = new System.Drawing.Size(217, 20);
this.textBoxParameter.TabIndex = 7;
this.textBoxParameter.Visible = false;
//
// Actions
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(244, 222);
this.Controls.Add(this.textBoxParameter);
this.Controls.Add(this.labelParameter);
this.Controls.Add(this.checkBoxStatusOverlay);
this.Controls.Add(this.comboBoxActionType);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBoxButtonName);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Actions";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Actions - PicoKeys";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button buttonSave;
private System.Windows.Forms.TextBox textBoxButtonName;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxActionType;
private System.Windows.Forms.CheckBox checkBoxStatusOverlay;
private System.Windows.Forms.Label labelParameter;
private System.Windows.Forms.TextBox textBoxParameter;
}
}

57
PicoKeys/Actions.cs Normal file
View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace PicoKeys
{
public partial class Actions : Form
{
public ActionObject a;
private List<ActionType> actionTypes = new List<ActionType>();
public Actions(List<ActionType> actionTypes, ActionObject a)
{
InitializeComponent();
this.a = a;
this.actionTypes = actionTypes;
textBoxButtonName.Text = a.ButtonText;
checkBoxStatusOverlay.Checked = a.ShowStatusOverlay;
var bs = new BindingSource
{
DataSource = actionTypes
};
comboBoxActionType.DataSource = bs.DataSource;
comboBoxActionType.DisplayMember = "Name";
comboBoxActionType.ValueMember = "Name";
comboBoxActionType.SelectedIndex = comboBoxActionType.FindStringExact(a.Actiontype);
textBoxParameter.Text = a.Parameter;
}
private void ButtonSave_Click(object sender, EventArgs e)
{
a.ButtonText = textBoxButtonName.Text;
a.ShowStatusOverlay = checkBoxStatusOverlay.Checked;
a.Actiontype = comboBoxActionType.Text;
a.Parameter = textBoxParameter.Text;
DialogResult = DialogResult.OK;
Close();
}
private void ComboBoxActionType_SelectedIndexChanged(object sender, EventArgs e)
{
//if actiontype HasParameter, show textbox for parameter, otherwise hide it
ActionType at = actionTypes.Single(s => s.Name == (comboBoxActionType.SelectedItem as dynamic).Name);
if (at.HasParameter)
{
labelParameter.Visible = true;
textBoxParameter.Visible = true;
}
else
{
labelParameter.Visible = false;
textBoxParameter.Visible = false;
}
}
}
}

232
PicoKeys/Actions.resx Normal file
View File

@ -0,0 +1,232 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAAAAAAAEAIADhGAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAEAAAABAAgGAAAAXHKoZgAAGKhJ
REFUeNrt3W2MHdd93/Hv/8x92L37xOdHSaYlW4pMx26rpG7dxEGLBG7TwkBgGGgTNHaLwO2Lxg7aRkib
oE6LPthNgdjxi7Zo3hU10hoO2gBJnFRtkhp9SFoopmXZoiyJkkiKEh+W3F3u7r13Zs6/L87c3Utau1yS
u7xPvw88XFrc5f9y7pzfnDl35hwQERERERERERERERERERERERERERERERERERERERERERERERERERER
EREREREREREREREREREREREREREREREREZEtmXaBjLuPf/wzG78/971LtJbrHHhzirxZ4ndoAb7Nn33l
V/75yO+boMNDZHIpAEQmWE27QMZdiJvnuSwHc4d08psDDlRfM1KPv7/X37tA6AI3gOvAugJAZETZZvOu
A6eADwBPANNAcVsA9JJjEfg68IcKAJERU2blxu+7Lah3DDdvAA8DH6q2edKZPvb9aFZ9PV99PQu8MU77
RmMAMvbyer6xfe1nzrN2pEW0sk7q+h+rgmABOAwc7dsOVdsJYB+p1zBWFAAy9sqs2Nh+4ieP27t+59Xg
ITYc753hffu/wXPwAtw3hwlcASAyCjxsbuVUzdaPzNXcvE7q4kcg3+anS6BdfU8ct32jMQAZe2abd/tY
yIJZyAyrAzXf+iToAAbRoRzHxq8AkMkIgP4b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gA7siA
jD28ZBCRXVGr2uqOLkDupgdgqMcgMuwCdzH6sNMzegksA5eAQ0Ad6GhfiwyNJpBXbXS5arO7FgBt4DvA
7wDPk7oYhfa5yNCoVY3+QtVW27sZAOtVw78EtEhdjKh9LjI0qrWIWQMWqza7awFQAFerTUTGhAb1RBQA
IiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi
IiIiIiIiInKL/w8ktZc+W3SbNAAAAABJRU5ErkJggg==
</value>
</data>
</root>

View File

@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PicoKeys.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<userSettings>
<PicoKeys.Properties.Settings>
<setting name="startMinimized" serializeAs="String">
<value>False</value>
</setting>
</PicoKeys.Properties.Settings>
</userSettings>
</configuration> </configuration>

34
PicoKeys/JsonHelper.cs Normal file
View File

@ -0,0 +1,34 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace PicoKeys
{
internal class JsonHelper
{
public static List<string> InvalidJsonElements;
public static IList<T> DeserializeToList<T>(string jsonString)
{
InvalidJsonElements = null;
var array = JArray.Parse(jsonString);
IList<T> objectsList = new List<T>();
foreach (var item in array)
{
try
{
// CorrectElements
objectsList.Add(item.ToObject<T>());
}
catch (Exception ex)
{
InvalidJsonElements = InvalidJsonElements ?? new List<string>();
InvalidJsonElements.Add(item.ToString());
}
}
return objectsList;
}
}
}

View File

@ -47,9 +47,10 @@
this.button10 = new System.Windows.Forms.Button(); this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBoxActions = new System.Windows.Forms.GroupBox();
this.checkBoxMinimized = new System.Windows.Forms.CheckBox();
this.contextMenuStripTrayIcon.SuspendLayout(); this.contextMenuStripTrayIcon.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBoxActions.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// contextMenuStripTrayIcon // contextMenuStripTrayIcon
@ -79,9 +80,9 @@
this.checkBoxAutostart.AutoSize = true; this.checkBoxAutostart.AutoSize = true;
this.checkBoxAutostart.Location = new System.Drawing.Point(12, 12); this.checkBoxAutostart.Location = new System.Drawing.Point(12, 12);
this.checkBoxAutostart.Name = "checkBoxAutostart"; this.checkBoxAutostart.Name = "checkBoxAutostart";
this.checkBoxAutostart.Size = new System.Drawing.Size(145, 17); this.checkBoxAutostart.Size = new System.Drawing.Size(142, 17);
this.checkBoxAutostart.TabIndex = 1; this.checkBoxAutostart.TabIndex = 1;
this.checkBoxAutostart.Text = "Autostart on System Boot"; this.checkBoxAutostart.Text = "Autostart on system boot";
this.checkBoxAutostart.UseVisualStyleBackColor = true; this.checkBoxAutostart.UseVisualStyleBackColor = true;
this.checkBoxAutostart.CheckedChanged += new System.EventHandler(this.CheckBoxAutostart_CheckedChanged); this.checkBoxAutostart.CheckedChanged += new System.EventHandler(this.CheckBoxAutostart_CheckedChanged);
// //
@ -213,34 +214,46 @@
this.button12.UseVisualStyleBackColor = true; this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.ButtonAction_Click); this.button12.Click += new System.EventHandler(this.ButtonAction_Click);
// //
// groupBox1 // groupBoxActions
// //
this.groupBox1.Controls.Add(this.button1); this.groupBoxActions.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.button12); this.groupBoxActions.Controls.Add(this.button12);
this.groupBox1.Controls.Add(this.label1); this.groupBoxActions.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.button11); this.groupBoxActions.Controls.Add(this.button11);
this.groupBox1.Controls.Add(this.button2); this.groupBoxActions.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button10); this.groupBoxActions.Controls.Add(this.button10);
this.groupBox1.Controls.Add(this.button3); this.groupBoxActions.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button9); this.groupBoxActions.Controls.Add(this.button9);
this.groupBox1.Controls.Add(this.button4); this.groupBoxActions.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button8); this.groupBoxActions.Controls.Add(this.button8);
this.groupBox1.Controls.Add(this.button5); this.groupBoxActions.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button7); this.groupBoxActions.Controls.Add(this.button7);
this.groupBox1.Controls.Add(this.button6); this.groupBoxActions.Controls.Add(this.button6);
this.groupBox1.Location = new System.Drawing.Point(12, 35); this.groupBoxActions.Location = new System.Drawing.Point(12, 35);
this.groupBox1.Name = "groupBox1"; this.groupBoxActions.Name = "groupBoxActions";
this.groupBox1.Size = new System.Drawing.Size(331, 246); this.groupBoxActions.Size = new System.Drawing.Size(331, 246);
this.groupBox1.TabIndex = 15; this.groupBoxActions.TabIndex = 15;
this.groupBox1.TabStop = false; this.groupBoxActions.TabStop = false;
this.groupBox1.Text = "Button Actions"; this.groupBoxActions.Text = "Button Actions";
//
// checkBoxMinimized
//
this.checkBoxMinimized.AutoSize = true;
this.checkBoxMinimized.Location = new System.Drawing.Point(175, 12);
this.checkBoxMinimized.Name = "checkBoxMinimized";
this.checkBoxMinimized.Size = new System.Drawing.Size(168, 17);
this.checkBoxMinimized.TabIndex = 16;
this.checkBoxMinimized.Text = "Start minimized (in system tray)";
this.checkBoxMinimized.UseVisualStyleBackColor = true;
this.checkBoxMinimized.CheckedChanged += new System.EventHandler(this.CheckBoxMinimized_CheckedChanged);
// //
// Main // Main
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(356, 295); this.ClientSize = new System.Drawing.Size(356, 295);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.checkBoxMinimized);
this.Controls.Add(this.groupBoxActions);
this.Controls.Add(this.checkBoxAutostart); this.Controls.Add(this.checkBoxAutostart);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -250,10 +263,11 @@
this.Text = "PicoKeys v1.0 | © 2024 kmpr.at"; this.Text = "PicoKeys v1.0 | © 2024 kmpr.at";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
this.Load += new System.EventHandler(this.Main_Load); this.Load += new System.EventHandler(this.Main_Load);
this.Shown += new System.EventHandler(this.Main_Shown);
this.Resize += new System.EventHandler(this.Main_Resize); this.Resize += new System.EventHandler(this.Main_Resize);
this.contextMenuStripTrayIcon.ResumeLayout(false); this.contextMenuStripTrayIcon.ResumeLayout(false);
this.groupBox1.ResumeLayout(false); this.groupBoxActions.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBoxActions.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -278,7 +292,8 @@
private System.Windows.Forms.Button button10; private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button11; private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12; private System.Windows.Forms.Button button12;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBoxActions;
private System.Windows.Forms.CheckBox checkBoxMinimized;
} }
} }

View File

@ -1,15 +1,12 @@
using AudioSwitcher.AudioApi.CoreAudio; using Microsoft.Win32;
using Microsoft.Win32; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace PicoKeys namespace PicoKeys
@ -38,7 +35,10 @@ namespace PicoKeys
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
private NotifyIcon trayIcon; private NotifyIcon TrayIcon;
private List<ActionObject> actionObjects;
private List<ActionType> actionTypes;
private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{ {
@ -50,46 +50,40 @@ namespace PicoKeys
switch (vkCode) switch (vkCode)
{ {
case 0x7C: // F13 case 0x7C: // F13
using (var audio = new CoreAudioController()) Trigger(button1);
{
audio.DefaultPlaybackDevice.ToggleMute();
}
break; break;
case 0x7D: // F14 case 0x7D: // F14
using (var audio = new CoreAudioController()) Trigger(button2);
{
audio.DefaultCaptureDevice.ToggleMute();
}
break; break;
case 0x7E: // F15 case 0x7E: // F15
Trigger(button3);
break; break;
case 0x7F: // F16 case 0x7F: // F16
Trigger(button4);
break; break;
case 0x80: // F17 case 0x80: // F17
Trigger(button5);
break; break;
case 0x81: // F18 case 0x81: // F18
Trigger(button6);
break; break;
case 0x82: // F19 case 0x82: // F19
Trigger(button7);
break; break;
case 0x83: // F20 case 0x83: // F20
Trigger(button8);
break; break;
case 0x84: // F21 case 0x84: // F21
Trigger(button9);
break; break;
case 0x85: // F22 case 0x85: // F22
Trigger(button10);
break; break;
case 0x86: // F23 case 0x86: // F23
Trigger(button11);
break; break;
case 0x87: // F24 case 0x87: // F24
Trigger(button12);
break; break;
} }
} }
@ -97,21 +91,84 @@ namespace PicoKeys
return CallNextHookEx(_hookID, nCode, wParam, lParam); return CallNextHookEx(_hookID, nCode, wParam, lParam);
} }
private bool overrideAutostartChecked = false;
public Main() public Main()
{ {
InitializeComponent(); InitializeComponent();
trayIcon = new NotifyIcon(); checkBoxMinimized.Checked = Properties.Settings.Default.startMinimized;
trayIcon.Icon = Properties.Resources.icons8_keyboard_96; RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
trayIcon.Text = "MagicKeys"; if (rk.GetValue("PicoKeys") != null)
trayIcon.Visible = false; {
trayIcon.DoubleClick += new EventHandler(TrayIcon_DoubleClick); overrideAutostartChecked = true;
trayIcon.ContextMenuStrip = contextMenuStripTrayIcon; checkBoxAutostart.Checked = true;
}
TrayIcon = new NotifyIcon
{
Icon = Properties.Resources.icons8_keyboard_96,
Text = "PicoKeys",
Visible = false
};
TrayIcon.DoubleClick += new EventHandler(TrayIcon_DoubleClick);
TrayIcon.ContextMenuStrip = contextMenuStripTrayIcon;
actionObjects = new List<ActionObject>();
actionTypes = new List<ActionType>();
} }
private void Main_Load(object sender, EventArgs e) private void Main_Load(object sender, EventArgs e)
{ {
_proc = HookCallback; _proc = HookCallback;
_hookID = SetHook(_proc); _hookID = SetHook(_proc);
//load default actiontypes
actionTypes.Add(new ActionType("None"));
actionTypes.Add(new ActionType("Mute Mic", "ToggleMicrophone"));
actionTypes.Add(new ActionType("Mute Sound", "ToggleSpeaker"));
actionTypes.Add(new ActionType("Launch Program", "LaunchProgram", true));
//load stored actions
if (!File.Exists("actions.mk0"))
{
//no stored actions (initial start), so lets generate them for each button
foreach (Control b in groupBoxActions.Controls)
{
if (b is Button)
{
ActionObject a = new ActionObject(b.Name, b.Text);
actionObjects.Add(a);
}
}
//save into file
using (StreamWriter file = File.CreateText("actions.mk0"))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, actionObjects);
}
//clear list
actionObjects.Clear();
}
//load actions from file into list
using (StreamReader file = File.OpenText("actions.mk0"))
{
actionObjects = (List<ActionObject>)JsonHelper.DeserializeToList<ActionObject>(file.ReadToEnd());
}
//load button texts from actionobjects
foreach (Control b in groupBoxActions.Controls)
{
if (b is Button)
{
ActionObject a = actionObjects.Single(s => s.ButtonName == b.Name);
b.Text = a.ButtonText;
}
}
}
private void Main_Shown(object sender, EventArgs e)
{
if (checkBoxMinimized.Checked)
{
WindowState = FormWindowState.Minimized;
}
} }
private void Main_FormClosing(object sender, FormClosingEventArgs e) private void Main_FormClosing(object sender, FormClosingEventArgs e)
@ -131,11 +188,10 @@ namespace PicoKeys
private void Main_Resize(object sender, EventArgs e) private void Main_Resize(object sender, EventArgs e)
{ {
if (this.WindowState == FormWindowState.Minimized) if (WindowState == FormWindowState.Minimized)
{ {
this.Hide(); Hide();
trayIcon.Visible = true; TrayIcon.Visible = true;
trayIcon.ShowBalloonTip(1000, "MagicKeys", "Minimized to tray", ToolTipIcon.Info);
} }
} }
@ -143,7 +199,7 @@ namespace PicoKeys
{ {
this.Show(); this.Show();
this.WindowState = FormWindowState.Normal; this.WindowState = FormWindowState.Normal;
trayIcon.Visible = false; TrayIcon.Visible = false;
} }
private void ExitToolStripMenuItem_Click(object sender, EventArgs e) private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
@ -155,17 +211,61 @@ namespace PicoKeys
{ {
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (overrideAutostartChecked)
overrideAutostartChecked = false;
else
{
if (checkBoxAutostart.Checked) if (checkBoxAutostart.Checked)
rk.SetValue("PicoKeys", Application.ExecutablePath); rk.SetValue("PicoKeys", Application.ExecutablePath);
else else
rk.DeleteValue("PicoKeys", false); rk.DeleteValue("PicoKeys", false);
} }
}
private void ButtonAction_Click(object sender, EventArgs e) private void ButtonAction_Click(object sender, EventArgs e)
{ {
Button b = sender as Button; Button b = sender as Button;
MessageBox.Show(b.Name); ActionObject a = actionObjects.Single(s => s.ButtonName == b.Name);
Actions actions = new Actions(actionTypes, a);
DialogResult dr = actions.ShowDialog();
if (dr == DialogResult.OK)
{
b.Text = a.ButtonText;
//also overwrite the actions settings file
using (StreamWriter file = File.CreateText("actions.mk0"))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, actionObjects);
}
}
}
private void Trigger(Button button)
{
ActionObject a = actionObjects.Single(s => s.ButtonName == button.Name);
ActionType at = actionTypes.Single(s => s.Name == a.Actiontype);
Type t = typeof(ActionMethods);
MethodInfo mi = t.GetMethod(at.Method);
ActionMethods am = new ActionMethods();
if (at.HasParameter)
{
mi.Invoke(am, new[] { a.Parameter });
}
else
{
mi.Invoke(am, null);
}
//if a.ShowStatusOverlay, then display balloontip too
if (a.ShowStatusOverlay)
{
TrayIcon.ShowBalloonTip(2000, "PicoKeys", "Triggered: " + a.ButtonText, ToolTipIcon.None);
}
}
private void CheckBoxMinimized_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.startMinimized = checkBoxMinimized.Checked;
Properties.Settings.Default.Save();
} }
} }
} }

View File

@ -42,6 +42,9 @@
<Reference Include="AudioSwitcher.AudioApi.CoreAudio, Version=3.0.0.209, Culture=neutral, PublicKeyToken=fda5729e2db3a64f, processorArchitecture=MSIL"> <Reference Include="AudioSwitcher.AudioApi.CoreAudio, Version=3.0.0.209, Culture=neutral, PublicKeyToken=fda5729e2db3a64f, processorArchitecture=MSIL">
<HintPath>..\packages\AudioSwitcher.AudioApi.CoreAudio.3.0.3\lib\net48\AudioSwitcher.AudioApi.CoreAudio.dll</HintPath> <HintPath>..\packages\AudioSwitcher.AudioApi.CoreAudio.3.0.3\lib\net48\AudioSwitcher.AudioApi.CoreAudio.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -55,6 +58,16 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ActionMethods.cs" />
<Compile Include="ActionObject.cs" />
<Compile Include="Actions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Actions.Designer.cs">
<DependentUpon>Actions.cs</DependentUpon>
</Compile>
<Compile Include="ActionType.cs" />
<Compile Include="JsonHelper.cs" />
<Compile Include="Main.cs"> <Compile Include="Main.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -63,6 +76,9 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Actions.resx">
<DependentUpon>Actions.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx"> <EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon> <DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -1,30 +1,38 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Dieser Code wurde von einem Tool generiert.
// Runtime Version:4.0.30319.42000 // Laufzeitversion:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// the code is regenerated. // der Code erneut generiert wird.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace PicoKeys.Properties namespace PicoKeys.Properties {
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default public static Settings Default {
{ get {
get
{
return defaultInstance; return defaultInstance;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool startMinimized {
get {
return ((bool)(this["startMinimized"]));
}
set {
this["startMinimized"] = value;
}
}
} }
} }

View File

@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PicoKeys.Properties" GeneratedClassName="Settings">
<Profiles> <Profiles />
<Profile Name="(Default)" /> <Settings>
</Profiles> <Setting Name="startMinimized" Type="System.Boolean" Scope="User">
<Settings /> <Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile> </SettingsFile>

View File

@ -2,4 +2,5 @@
<packages> <packages>
<package id="AudioSwitcher.AudioApi" version="3.0.0" targetFramework="net48" /> <package id="AudioSwitcher.AudioApi" version="3.0.0" targetFramework="net48" />
<package id="AudioSwitcher.AudioApi.CoreAudio" version="3.0.3" targetFramework="net48" /> <package id="AudioSwitcher.AudioApi.CoreAudio" version="3.0.3" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
</packages> </packages>