mirror of
https://github.com/MarkAHamann/MorseTrainer.git
synced 2026-01-27 02:24:18 +01:00
Added paper copy method. Fixed custom string bug. Added license to new file
This commit is contained in:
parent
daf15ae264
commit
ad793adfc5
|
|
@ -42,6 +42,7 @@ namespace MorseTrainer
|
|||
Default._duration = 60;
|
||||
Default._startDelay = 2;
|
||||
Default._stopDelay = 2;
|
||||
Default._paper = false;
|
||||
Default._volume = 1.0f;
|
||||
|
||||
Default._method = CharGenerator.Method.Koch;
|
||||
|
|
@ -245,6 +246,24 @@ namespace MorseTrainer
|
|||
}
|
||||
}
|
||||
|
||||
private bool _paper;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the paper value which lets the user control when to analyze
|
||||
/// </summary>
|
||||
public bool Paper
|
||||
{
|
||||
get
|
||||
{
|
||||
return _paper;
|
||||
}
|
||||
set
|
||||
{
|
||||
_paper = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private float _volume;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
76
MorseTrainer/Form1.Designer.cs
generated
76
MorseTrainer/Form1.Designer.cs
generated
|
|
@ -52,7 +52,6 @@
|
|||
this.txtAnalysis = new System.Windows.Forms.RichTextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.sliderStartDelay = new System.Windows.Forms.TrackBar();
|
||||
this.sliderStopDelay = new System.Windows.Forms.TrackBar();
|
||||
this.txtFrequency = new System.Windows.Forms.TextBox();
|
||||
|
|
@ -74,6 +73,9 @@
|
|||
this.mnuContextRestoreDefaults = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuContextSetProsignKeys = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuContextAbout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.radPaper = new System.Windows.Forms.RadioButton();
|
||||
this.radTimed = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.sliderFrequency)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.sliderWPM)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.sliderDuration)).BeginInit();
|
||||
|
|
@ -82,6 +84,7 @@
|
|||
((System.ComponentModel.ISupportInitialize)(this.sliderStopDelay)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.sliderVolume)).BeginInit();
|
||||
this.mnuStrip.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
|
|
@ -194,15 +197,6 @@
|
|||
this.label6.TabIndex = 10;
|
||||
this.label6.Text = "Start Delay";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(357, 188);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(87, 20);
|
||||
this.label7.TabIndex = 11;
|
||||
this.label7.Text = "Stop Delay";
|
||||
//
|
||||
// sliderStartDelay
|
||||
//
|
||||
this.sliderStartDelay.Location = new System.Drawing.Point(147, 185);
|
||||
|
|
@ -268,7 +262,7 @@
|
|||
// btnKoch
|
||||
//
|
||||
this.btnKoch.AutoSize = true;
|
||||
this.btnKoch.Location = new System.Drawing.Point(24, 484);
|
||||
this.btnKoch.Location = new System.Drawing.Point(8, 19);
|
||||
this.btnKoch.Name = "btnKoch";
|
||||
this.btnKoch.Size = new System.Drawing.Size(70, 24);
|
||||
this.btnKoch.TabIndex = 19;
|
||||
|
|
@ -280,7 +274,7 @@
|
|||
// btnCustom
|
||||
//
|
||||
this.btnCustom.AutoSize = true;
|
||||
this.btnCustom.Location = new System.Drawing.Point(24, 522);
|
||||
this.btnCustom.Location = new System.Drawing.Point(8, 57);
|
||||
this.btnCustom.Name = "btnCustom";
|
||||
this.btnCustom.Size = new System.Drawing.Size(89, 24);
|
||||
this.btnCustom.TabIndex = 20;
|
||||
|
|
@ -292,7 +286,7 @@
|
|||
// cmbKoch
|
||||
//
|
||||
this.cmbKoch.FormattingEnabled = true;
|
||||
this.cmbKoch.Location = new System.Drawing.Point(139, 483);
|
||||
this.cmbKoch.Location = new System.Drawing.Point(123, 18);
|
||||
this.cmbKoch.Name = "cmbKoch";
|
||||
this.cmbKoch.Size = new System.Drawing.Size(100, 28);
|
||||
this.cmbKoch.TabIndex = 21;
|
||||
|
|
@ -300,7 +294,7 @@
|
|||
//
|
||||
// txtCustom
|
||||
//
|
||||
this.txtCustom.Location = new System.Drawing.Point(139, 522);
|
||||
this.txtCustom.Location = new System.Drawing.Point(123, 57);
|
||||
this.txtCustom.Name = "txtCustom";
|
||||
this.txtCustom.Size = new System.Drawing.Size(602, 26);
|
||||
this.txtCustom.TabIndex = 22;
|
||||
|
|
@ -308,7 +302,7 @@
|
|||
// chkFavorNew
|
||||
//
|
||||
this.chkFavorNew.AutoSize = true;
|
||||
this.chkFavorNew.Location = new System.Drawing.Point(259, 484);
|
||||
this.chkFavorNew.Location = new System.Drawing.Point(243, 19);
|
||||
this.chkFavorNew.Name = "chkFavorNew";
|
||||
this.chkFavorNew.Size = new System.Drawing.Size(192, 24);
|
||||
this.chkFavorNew.TabIndex = 23;
|
||||
|
|
@ -388,22 +382,57 @@
|
|||
this.mnuContextAbout.Text = "About...";
|
||||
this.mnuContextAbout.Click += new System.EventHandler(this.mnuContextAbout_Click);
|
||||
//
|
||||
// radPaper
|
||||
//
|
||||
this.radPaper.AutoSize = true;
|
||||
this.radPaper.Location = new System.Drawing.Point(361, 216);
|
||||
this.radPaper.Name = "radPaper";
|
||||
this.radPaper.Size = new System.Drawing.Size(76, 24);
|
||||
this.radPaper.TabIndex = 29;
|
||||
this.radPaper.Text = "Paper";
|
||||
this.radPaper.UseVisualStyleBackColor = true;
|
||||
this.radPaper.Click += new System.EventHandler(this.radTimedPaper_Click);
|
||||
//
|
||||
// radTimed
|
||||
//
|
||||
this.radTimed.AutoSize = true;
|
||||
this.radTimed.Checked = true;
|
||||
this.radTimed.Location = new System.Drawing.Point(361, 186);
|
||||
this.radTimed.Name = "radTimed";
|
||||
this.radTimed.Size = new System.Drawing.Size(77, 24);
|
||||
this.radTimed.TabIndex = 30;
|
||||
this.radTimed.TabStop = true;
|
||||
this.radTimed.Text = "Timed";
|
||||
this.radTimed.UseVisualStyleBackColor = true;
|
||||
this.radTimed.Click += new System.EventHandler(this.radTimedPaper_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.chkFavorNew);
|
||||
this.groupBox1.Controls.Add(this.txtCustom);
|
||||
this.groupBox1.Controls.Add(this.cmbKoch);
|
||||
this.groupBox1.Controls.Add(this.btnCustom);
|
||||
this.groupBox1.Controls.Add(this.btnKoch);
|
||||
this.groupBox1.Location = new System.Drawing.Point(21, 471);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(735, 94);
|
||||
this.groupBox1.TabIndex = 31;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(941, 580);
|
||||
this.ContextMenuStrip = this.mnuStrip;
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.radTimed);
|
||||
this.Controls.Add(this.radPaper);
|
||||
this.Controls.Add(this.txtVolume);
|
||||
this.Controls.Add(this.txtStopDelay);
|
||||
this.Controls.Add(this.txtStartDelay);
|
||||
this.Controls.Add(this.sliderVolume);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.chkFavorNew);
|
||||
this.Controls.Add(this.txtCustom);
|
||||
this.Controls.Add(this.cmbKoch);
|
||||
this.Controls.Add(this.btnCustom);
|
||||
this.Controls.Add(this.btnKoch);
|
||||
this.Controls.Add(this.btnStartStop);
|
||||
this.Controls.Add(this.txtDuration);
|
||||
this.Controls.Add(this.txtFarnsworth);
|
||||
|
|
@ -411,7 +440,6 @@
|
|||
this.Controls.Add(this.txtFrequency);
|
||||
this.Controls.Add(this.sliderStopDelay);
|
||||
this.Controls.Add(this.sliderStartDelay);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.txtAnalysis);
|
||||
|
|
@ -436,6 +464,8 @@
|
|||
((System.ComponentModel.ISupportInitialize)(this.sliderStopDelay)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.sliderVolume)).EndInit();
|
||||
this.mnuStrip.ResumeLayout(false);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
@ -454,7 +484,6 @@
|
|||
private System.Windows.Forms.RichTextBox txtAnalysis;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.TrackBar sliderStartDelay;
|
||||
private System.Windows.Forms.TrackBar sliderStopDelay;
|
||||
private System.Windows.Forms.TextBox txtFrequency;
|
||||
|
|
@ -476,6 +505,9 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuContextRestoreDefaults;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuContextSetProsignKeys;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuContextAbout;
|
||||
private System.Windows.Forms.RadioButton radPaper;
|
||||
private System.Windows.Forms.RadioButton radTimed;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,15 @@ namespace MorseTrainer
|
|||
StopDelaySlider = config.StopDelay;
|
||||
StopDelayText = config.StopDelay;
|
||||
|
||||
if (config.Paper)
|
||||
{
|
||||
radPaper.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
radTimed.Checked = true;
|
||||
}
|
||||
|
||||
Volume = config.Volume;
|
||||
VolumeSlider = config.Volume;
|
||||
VolumeText = config.Volume;
|
||||
|
|
@ -206,6 +215,7 @@ namespace MorseTrainer
|
|||
|
||||
config.StartDelay = (UInt16)sliderStartDelay.Value;
|
||||
config.StopDelay = (UInt16)sliderStopDelay.Value;
|
||||
config.Paper = radPaper.Checked;
|
||||
config.Volume = (float)sliderVolume.Value / 10.0f;
|
||||
|
||||
config.GenerationMethod = btnKoch.Checked ? CharGenerator.Method.Koch : CharGenerator.Method.Custom;
|
||||
|
|
@ -230,9 +240,13 @@ namespace MorseTrainer
|
|||
btnStartStop.Enabled = false;
|
||||
_runner.RequestStop();
|
||||
}
|
||||
//else if (_runner.IsListenMode && _runner.IsPaper)
|
||||
//{
|
||||
//}
|
||||
else
|
||||
{
|
||||
_recorded.Clear();
|
||||
_charGenerator.Custom = txtCustom.Text.ToUpperInvariant();
|
||||
String word = _charGenerator.CreateRandomString();
|
||||
_builder.StartBuildAsync(word, new AsyncCallback(FirstWaveReadyCallback));
|
||||
btnStartStop.Text = "Stop";
|
||||
|
|
@ -303,6 +317,17 @@ namespace MorseTrainer
|
|||
|
||||
private void _runner_StopDelayEnter(object sender, EventArgs e)
|
||||
{
|
||||
if (_runner.IsPaper)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler(_runner_StopDelayEnter), sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStartStop.Text = "Copied";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _runner_StopDelayExit(object sender, EventArgs e)
|
||||
|
|
@ -333,6 +358,12 @@ namespace MorseTrainer
|
|||
btnStartStop.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void radTimedPaper_Click(object sender, EventArgs e)
|
||||
{
|
||||
_runner.IsPaper = radPaper.Checked;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Analysis
|
||||
|
|
@ -1336,5 +1367,6 @@ namespace MorseTrainer
|
|||
private ProsignKeyAssigner _dlgAssigner;
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,22 @@
|
|||
using System;
|
||||
/*
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,13 @@ namespace MorseTrainer
|
|||
// send is done, but finishing up the rest of the word
|
||||
SendFinished,
|
||||
|
||||
// send is
|
||||
// send is finished and counting down to end
|
||||
StopDelay,
|
||||
|
||||
// send is finished and waiting for user to indicate the manual input is
|
||||
// complete
|
||||
PaperDelay,
|
||||
|
||||
// stop requested
|
||||
StopRequest
|
||||
}
|
||||
|
|
@ -102,6 +106,35 @@ namespace MorseTrainer
|
|||
_timer.Elapsed += _timer_Elapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the paper option. When true, the user must call
|
||||
/// PaperCopyComplete to start analysis. When false, the timer
|
||||
/// is used.
|
||||
/// </summary>
|
||||
public bool IsPaper
|
||||
{
|
||||
get
|
||||
{
|
||||
return _paper;
|
||||
}
|
||||
set
|
||||
{
|
||||
_paper = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call PaperCopyComplete when in IsPaper mode and the user is ready
|
||||
/// to have the input analyzed
|
||||
/// </summary>
|
||||
public void PaperCopyComplete()
|
||||
{
|
||||
if (_state == State.PaperDelay)
|
||||
{
|
||||
StateExit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the runner is idle (false) or in one of the running states (true)
|
||||
/// </summary>
|
||||
|
|
@ -122,7 +155,8 @@ namespace MorseTrainer
|
|||
get
|
||||
{
|
||||
return _state == State.Sending ||
|
||||
_state == State.SendFinished ||
|
||||
_state == State.SendFinished ||
|
||||
_state == State.PaperDelay ||
|
||||
_state == State.StopDelay;
|
||||
}
|
||||
}
|
||||
|
|
@ -165,6 +199,10 @@ namespace MorseTrainer
|
|||
OnStopDelayExit();
|
||||
nextState = State.Idle;
|
||||
break;
|
||||
case State.PaperDelay:
|
||||
OnStopDelayExit();
|
||||
nextState = State.Idle;
|
||||
break;
|
||||
}
|
||||
return nextState;
|
||||
}
|
||||
|
|
@ -186,8 +224,15 @@ namespace MorseTrainer
|
|||
OnMorseEnter();
|
||||
break;
|
||||
case State.StopDelay:
|
||||
_timer.Interval = _stopDelay * 1000;
|
||||
_timer.Start();
|
||||
if (_paper)
|
||||
{
|
||||
_state = State.PaperDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer.Interval = _stopDelay * 1000;
|
||||
_timer.Start();
|
||||
}
|
||||
OnStopDelayEnter();
|
||||
break;
|
||||
}
|
||||
|
|
@ -378,6 +423,7 @@ namespace MorseTrainer
|
|||
private int _startDelay;
|
||||
private int _sendDuration;
|
||||
private int _stopDelay;
|
||||
private bool _paper;
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false; // To detect redundant calls
|
||||
|
|
|
|||
Loading…
Reference in a new issue