mirror of
https://github.com/MarkAHamann/MorseTrainer.git
synced 2026-04-21 06:13:44 +00:00
Added support for assigning prosign keys
This commit is contained in:
parent
be4980e690
commit
0659c119e3
6 changed files with 491 additions and 1 deletions
|
|
@ -49,6 +49,10 @@ namespace MorseTrainer
|
|||
Default._favorNew = true;
|
||||
Default._custom = "";
|
||||
|
||||
Default._prosignBT = '[';
|
||||
Default._prosignSK = ']';
|
||||
Default._prosignAR = '\\';
|
||||
|
||||
Default._version = CurrentVersion;
|
||||
}
|
||||
|
||||
|
|
@ -325,5 +329,56 @@ namespace MorseTrainer
|
|||
_favorNew = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Char _prosignBT;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key that will be used to enter the BT prosign
|
||||
/// </summary>
|
||||
public Char ProsignBT
|
||||
{
|
||||
get
|
||||
{
|
||||
return _prosignBT;
|
||||
}
|
||||
set
|
||||
{
|
||||
_prosignBT = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Char _prosignSK;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key that will be used to enter the SK prosign
|
||||
/// </summary>
|
||||
public Char ProsignSK
|
||||
{
|
||||
get
|
||||
{
|
||||
return _prosignSK;
|
||||
}
|
||||
set
|
||||
{
|
||||
_prosignSK = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Char _prosignAR;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key that will be used to enter the AR prosign
|
||||
/// </summary>
|
||||
public Char ProsignAR
|
||||
{
|
||||
get
|
||||
{
|
||||
return _prosignAR;
|
||||
}
|
||||
set
|
||||
{
|
||||
_prosignAR = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ namespace MorseTrainer
|
|||
_analyzer = new Analyzer(txtAnalysis);
|
||||
_builder = new WordToToneBuilder(_toneGenerator);
|
||||
_recorded = new StringBuilder();
|
||||
_dlgAssigner = new ProsignKeyAssigner();
|
||||
|
||||
// Do initialization
|
||||
FrequencyInitialize(
|
||||
|
|
@ -189,6 +190,10 @@ namespace MorseTrainer
|
|||
cmbKoch.SelectedIndex = config.KochIndex;
|
||||
chkFavorNew.Checked = config.FavorNew;
|
||||
txtCustom.Text = config.Custom;
|
||||
|
||||
_dlgAssigner.Key_BT = config.ProsignBT;
|
||||
_dlgAssigner.Key_SK = config.ProsignSK;
|
||||
_dlgAssigner.Key_AR = config.ProsignAR;
|
||||
}
|
||||
|
||||
private Config ExtractConfig()
|
||||
|
|
@ -208,6 +213,10 @@ namespace MorseTrainer
|
|||
config.FavorNew = chkFavorNew.Checked;
|
||||
config.Custom = txtCustom.Text;
|
||||
|
||||
config.ProsignBT = _dlgAssigner.Key_BT;
|
||||
config.ProsignSK = _dlgAssigner.Key_SK;
|
||||
config.ProsignAR = _dlgAssigner.Key_AR;
|
||||
|
||||
return config;
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -1226,7 +1235,7 @@ namespace MorseTrainer
|
|||
|
||||
private void mnuContextSetProsignKeys_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
_dlgAssigner.ShowDialog();
|
||||
}
|
||||
|
||||
private void mnuContextAbout_Click(object sender, EventArgs e)
|
||||
|
|
@ -1240,6 +1249,18 @@ namespace MorseTrainer
|
|||
private bool UserKey(char key)
|
||||
{
|
||||
bool processed = false;
|
||||
if (key == _dlgAssigner.Key_BT)
|
||||
{
|
||||
key = MorseInfo.PROSIGN_BT;
|
||||
}
|
||||
else if (key == _dlgAssigner.Key_SK)
|
||||
{
|
||||
key = MorseInfo.PROSIGN_SK;
|
||||
}
|
||||
else if (key == _dlgAssigner.Key_AR)
|
||||
{
|
||||
key = MorseInfo.PROSIGN_AR;
|
||||
}
|
||||
String expanded = MorseInfo.ExpandProsigns(key.ToString()).ToUpperInvariant();
|
||||
txtAnalysis.AppendText(expanded);
|
||||
_recorded.Append(expanded);
|
||||
|
|
@ -1265,6 +1286,7 @@ namespace MorseTrainer
|
|||
private Runner _runner;
|
||||
private Analyzer _analyzer;
|
||||
private StringBuilder _recorded;
|
||||
private ProsignKeyAssigner _dlgAssigner;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@
|
|||
<Compile Include="MorseCompareResults.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProsignKeyAssigner.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ProsignKeyAssigner.Designer.cs">
|
||||
<DependentUpon>ProsignKeyAssigner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Runner.cs" />
|
||||
<Compile Include="SoundPlayerAsync.cs" />
|
||||
<Compile Include="ToneGenerator.cs" />
|
||||
|
|
@ -87,6 +93,9 @@
|
|||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="ProsignKeyAssigner.resx">
|
||||
<DependentUpon>ProsignKeyAssigner.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
|
|
|||
119
MorseTrainer/ProsignKeyAssigner.Designer.cs
generated
Normal file
119
MorseTrainer/ProsignKeyAssigner.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
namespace MorseTrainer
|
||||
{
|
||||
partial class ProsignKeyAssigner
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtBT = new System.Windows.Forms.TextBox();
|
||||
this.txtSK = new System.Windows.Forms.TextBox();
|
||||
this.txtAR = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(47, 20);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "<BT>";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 47);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(48, 20);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "<SK>";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 79);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(50, 20);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "<AR>";
|
||||
//
|
||||
// txtBT
|
||||
//
|
||||
this.txtBT.Location = new System.Drawing.Point(82, 12);
|
||||
this.txtBT.Name = "txtBT";
|
||||
this.txtBT.Size = new System.Drawing.Size(56, 26);
|
||||
this.txtBT.TabIndex = 3;
|
||||
this.txtBT.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_KeyPress);
|
||||
//
|
||||
// txtSK
|
||||
//
|
||||
this.txtSK.Location = new System.Drawing.Point(82, 44);
|
||||
this.txtSK.Name = "txtSK";
|
||||
this.txtSK.Size = new System.Drawing.Size(56, 26);
|
||||
this.txtSK.TabIndex = 4;
|
||||
this.txtSK.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_KeyPress);
|
||||
//
|
||||
// txtAR
|
||||
//
|
||||
this.txtAR.Location = new System.Drawing.Point(82, 76);
|
||||
this.txtAR.Name = "txtAR";
|
||||
this.txtAR.Size = new System.Drawing.Size(56, 26);
|
||||
this.txtAR.TabIndex = 5;
|
||||
this.txtAR.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_KeyPress);
|
||||
//
|
||||
// ProsignKeyAssigner
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(171, 123);
|
||||
this.Controls.Add(this.txtAR);
|
||||
this.Controls.Add(this.txtSK);
|
||||
this.Controls.Add(this.txtBT);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.Name = "ProsignKeyAssigner";
|
||||
this.Text = "Prosign Keys";
|
||||
this.VisibleChanged += new System.EventHandler(this.ProsignKeyAssigner_VisibleChanged);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtBT;
|
||||
private System.Windows.Forms.TextBox txtSK;
|
||||
private System.Windows.Forms.TextBox txtAR;
|
||||
}
|
||||
}
|
||||
165
MorseTrainer/ProsignKeyAssigner.cs
Normal file
165
MorseTrainer/ProsignKeyAssigner.cs
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
Morse Trainer
|
||||
Copyright (C) 2016 Mark Hamann
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MorseTrainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The ProsignKeyAssigner is a dialog box that the user can use
|
||||
/// to specify keys to be used to enter prosigns.
|
||||
/// </summary>
|
||||
public partial class ProsignKeyAssigner : Form
|
||||
{
|
||||
public const Char DefaultBT = '\r';
|
||||
public const Char DefaultSK = '[';
|
||||
public const Char DefaultAR = ']';
|
||||
|
||||
/// <summary>
|
||||
/// Create a new prosign key assigner dialog box
|
||||
/// </summary>
|
||||
public ProsignKeyAssigner()
|
||||
{
|
||||
InitializeComponent();
|
||||
_keyBT = DefaultBT;
|
||||
_keySK = DefaultSK;
|
||||
_keyAR = DefaultAR;
|
||||
}
|
||||
|
||||
private Char DispToChar(String text)
|
||||
{
|
||||
Char c = '\0';
|
||||
if (text.Length > 0)
|
||||
{
|
||||
if (text == @"\r")
|
||||
{
|
||||
c = '\r';
|
||||
}
|
||||
else
|
||||
{
|
||||
c = text[0];
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
private String CharToDisp(Char c)
|
||||
{
|
||||
if (c == '\r')
|
||||
{
|
||||
return @"\r";
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key to be used to indicate the BT prosign
|
||||
/// </summary>
|
||||
public Char Key_BT
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keyBT;
|
||||
}
|
||||
set
|
||||
{
|
||||
_keyBT = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key to be used to indicate the SK prosign
|
||||
/// </summary>
|
||||
public Char Key_SK
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keySK;
|
||||
}
|
||||
set
|
||||
{
|
||||
_keySK = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key to be used to indicate the AR prosign
|
||||
/// </summary>
|
||||
public Char Key_AR
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keyAR;
|
||||
}
|
||||
set
|
||||
{
|
||||
_keyAR = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void txt_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
TextBox tb = (TextBox)sender;
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
tb.Text = @"\r";
|
||||
}
|
||||
else if (e.KeyChar >= ' ')
|
||||
{
|
||||
tb.Text = e.KeyChar.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.Text = "";
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ProsignKeyAssigner_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Visible == false)
|
||||
{
|
||||
_keyBT = DispToChar(txtBT.Text);
|
||||
_keySK = DispToChar(txtSK.Text);
|
||||
_keyAR = DispToChar(txtAR.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtBT.Text = CharToDisp(_keyBT);
|
||||
txtSK.Text = CharToDisp(_keySK);
|
||||
txtAR.Text = CharToDisp(_keyAR);
|
||||
}
|
||||
}
|
||||
|
||||
private char _keyBT;
|
||||
private char _keySK;
|
||||
private char _keyAR;
|
||||
|
||||
}
|
||||
}
|
||||
120
MorseTrainer/ProsignKeyAssigner.resx
Normal file
120
MorseTrainer/ProsignKeyAssigner.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?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>
|
||||
</root>
|
||||
Loading…
Add table
Add a link
Reference in a new issue