Thursday, April 21, 2011

Typewriters

I am a person who loves the internet, who loves computers, but I cannot make myself commit to the possibility of an entirely digital media.

If you were to know me well in life, you would know I have around six typewriters. These typewriters are important to me; I enjoy their complexity, which are not as technical as the computers, but have more actual parts(not counting the various components that make up any basic IC). They are close to the paper, they demand thought before you type, you need to have some idea of what you want to say.

The total time that I spend on my typewriters is only so great due to the fact that my school does not allow computers of any kind outside of the study hall, making it very difficult to write anything personal on my free time. Other than that, typewriters carry this kind of ethereal aura which, while indescribable, is like that same special pen, which convinces you that you can write anything with it.

Besides, I thought I might make some code for you to use, which emulates the permenant nature of the typewriter.

I apologize for the atrocious formatting and utter non-readability of the code, but it should work and may be embedded into any application(in the unlikely chance you make something with this) without attribution, unless of course you feel like it.

namespace Typewriter
{
public partial class Typewriter : UserControl
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(150, 150);
this.textBox1.TabIndex = 0;
this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox1);
this.Name = "Typewriter";
this.ResumeLayout(false);
this.PerformLayout();
}

private System.Windows.Forms.TextBox textBox1;
public Typewriter()
{
InitializeComponent();
}

private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Back && e.KeyCode != Keys.Delete)
{
if (e.Shift)
{
textBox1.Text += (char)e.KeyValue;
}
else
{
System.Char t = (System.Char)e.KeyValue;
this.textBox1.Text += System.Char.ToLower(t);
}
}
}

}
}

No comments:

Post a Comment