using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MorseWindows
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtText;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtMorse;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.txtText = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtMorse = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtText
//
this.txtText.Location = new System.Drawing.Point(24, 48);
this.txtText.MaxLength = 0;
this.txtText.Multiline = true;
this.txtText.Name = "txtText";
this.txtText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtText.Size = new System.Drawing.Size(528, 72);
this.txtText.TabIndex = 0;
this.txtText.Text = "";
this.txtText.TextChanged += new System.EventHandler(this.txtText_TextChanged);
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.TabIndex = 1;
this.label1.Text = "Geef tekst";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(24, 168);
this.label2.Name = "label2";
this.label2.TabIndex = 2;
this.label2.Text = "Morse";
//
// txtMorse
//
this.txtMorse.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.txtMorse.Location = new System.Drawing.Point(24, 192);
this.txtMorse.MaxLength = 0;
this.txtMorse.Multiline = true;
this.txtMorse.Name = "txtMorse";
this.txtMorse.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtMorse.Size = new System.Drawing.Size(528, 128);
this.txtMorse.TabIndex = 3;
this.txtMorse.Text = "";
this.txtMorse.TextChanged += new System.EventHandler(this.txtMorse_TextChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(576, 349);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.txtMorse,
this.label2,
this.label1,
this.txtText});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Opacity = 0.89999997615814209;
this.Text = "Morse";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void txtText_TextChanged(object sender, System.EventArgs e)
{
if(ActiveControl.Name == "txtText")
txtMorse.Text=TextToMorse(txtText.Text);
else txtText.Text = MorseToText(txtMorse.Text);
}
public string TextToMorse(string sText)
{
string s2="";
sText = sText.ToLower();
int l=sText.Length;
for(int i=0;i<l;i++)
{
switch(sText[i])
{
case 'a': s2+=".-"; break;
case 'b': s2+="-..."; break;
case 'c': s2+="-.-."; break;
case 'd': s2+="-.."; break;
case 'e': s2+="."; break;
case 'f': s2+="..-."; break;
case 'g': s2+="--."; break;
case 'h': s2+="...."; break;
case 'i': s2+=".."; break;
case 'j': s2+=".---"; break;
case 'k': s2+="-.-"; break;
case 'l': s2+=".-.."; break;
case 'm': s2+="--"; break;
case 'n': s2+="-."; break;
case 'o': s2+="---"; break;
case 'p': s2+=".--."; break;
case 'q': s2+="--.-"; break;
case 'r': s2+=".-."; break;
case 's': s2+="..."; break;
case 't': s2+="-"; break;
case 'u': s2+="..-"; break;
case 'v': s2+="...-"; break;
case 'w': s2+=".--"; break;
case 'x': s2+="-..-"; break;
case 'y': s2+="-.--"; break;
case 'z': s2+="--.."; break;
case '0': s2+="-----"; break;
case '1': s2+=".----"; break;
case '2': s2+="..---"; break;
case '3': s2+="...--"; break;
case '4': s2+="....-"; break;
case '5': s2+="....."; break;
case '6': s2+="-...."; break;
case '7': s2+="--..."; break;
case '8': s2+="---.."; break;
case '9': s2+="----."; break;
}
if((s2!="")&&(s2!=" "))s2+=" ";
}
return s2;
}
private void txtMorse_TextChanged(object sender, System.EventArgs e)
{
if(ActiveControl.Name == "txtText")
txtMorse.Text=TextToMorse(txtText.Text);
else txtText.Text = MorseToText(txtMorse.Text);
}
public char c_Morse2Char(string s_morse)
{
char c=(char)0;
switch(s_morse)
{
case ".-": c = 'a';break;
case "-...": c = 'b';break;
case "-.-.": c = 'c';break;
case "-..": c = 'd';break;
case ".": c = 'e';break;
case "..-.": c = 'f';break;
case "--.": c = 'g';break;
case "....": c = 'h';break;
case "..": c = 'i';break;
case ".---": c = 'j';break;
case "-.-": c = 'k';break;
case ".-..": c = 'l';break;
case "--": c = 'm';break;
case "-.": c = 'n';break;
case "---": c = 'o';break;
case ".--.": c = 'p';break;
case "--.-": c = 'q';break;
case ".-.": c = 'r';break;
case "...": c = 's';break;
case "-": c = 't';break;
case "..-": c = 'u';break;
case "...-": c = 'v';break;
case ".--": c = 'w';break;
case "-..-": c = 'x';break;
case "-.--": c = 'y';break;
case "--..": c = 'z';break;
case "-----": c = '0';break;
case ".----": c = '1';break;
case "..---": c = '2';break;
case "...--": c = '3';break;
case "....-": c = '4';break;
case ".....": c = '5';break;
case