Utilities Needed:
Visual C# 2005 (The beta might work with it)
Step 1:
Start up C#. If you can't find the program don't worry. Go into the install directory where you installed it to (C:\Program Files\Visual Studio 8\). Go into the folder called Common7. Then go into IDE. Look for a file with an icon of a green box with C# in it and a blue arrow under it. Right click it and pick Send to Desktop. You now have a desktop shortcut to get there. So close the folder and load up C#. It may take a bit so I'll wait ... Ok it's done! Now onto step 2!
Step 2:
Go to File -> New Project. Select Windows Application and change the name to "Text Editor" or whatever you want it called. Now wait until a window is displayed inside the editor with the title Form1.
Step 3:
If the toolbox is not displayed, go to View -> Toolbox. No from the toolbox, click the plus on the All Windows Forms. Go down and drag a menustrip anywhere onto the form. To add menu items, click the menustrip anywhere and click in the box that says Type Here. Type File and press enter. You have just created a Menu Object. Notice how it expands as if you clicked it on a real menu? If it didn't do this click the File menu object. No below the File menu object type New and press enter. Type Open... and press enter. Type Save and press enter. Type Save As... and press enter. Type Exit and press enter. Now where it says Type Here under the File Menu object and below all of them Sub Objects you just typed, press the little arrow on the right of it and pick separator. Create another. Drag one onto Save and it will be placed above it. No drag the other on onto Exit to place it below Save As... so now the order should be: New, Open..., Separator, Save, Save As..., Separator, Exit.
Step 4:
You may want to go to File -> Save Project so your work is preserved. We will now add an Edit menu. So next to File add Edit. Below Edit add Undo, Cut, Copy, Paste, Font..., Font Color..., and Select All. Create 3 separators and put them in this order: Undo, Separator, Cut, Copy, Paste, Separator, Font..., Font Color..., Separator, Select All.
Step 5:
We will now add a TextBox control to the Form. To do this, drag a text box from the Toolbox onto the form. If there is no properties box showing, right click on the TextBox and click Properties. Now change the name to "t" without the "" (duh!). Change the Dock to Fill. Its the center button when you click the dropdown arrow. Change Multiline to true. Notice how the textbox takes the shape of the form. Changed the Dock to Fill does this but changing Multiline to True lets it expand on the Y axis. One last thing: click the Form caption, change the Text property from Form1 to "Text Editor". Now lets begin coding!
Step 6:
Double click on the File -> New in your form. Enter this code in between the { and the }:
Code: Select all
DialogResult res;
res = MessageBox.Show("Do you wish to clear the textbox and lose unsaved changes?", "Powered by PlasmaGhost", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.Yes) { t.Clear(); cFile = ""; }
Code: Select all
OpenFileDialog o = new OpenFileDialog();
o.Filter = "Text Files (*.txt)|*.txt";
o.Multiselect = false;
o.Title = "Powered by PlasmaGhost";
o.ShowDialog();
try
{
o.OpenFile();
System.IO.StreamReader sr;
sr = System.IO.File.OpenText(o.FileName);
t.Text = sr.ReadToEnd();
cFile = o.FileName;
}
catch { }
Code: Select all
private String cFile = "";
Code: Select all
if (cFile == "")
{
SaveFileDialog s = new SaveFileDialog();
s.Filter = "Text Files (*.txt)|*.txt";
s.Title = "Powered by PlasmaGhost";
s.ShowDialog();
try
{
System.IO.StreamWriter sw;
sw = System.IO.File.CreateText(s.FileName);
sw.Write(t.Text);
sw.Flush();
cFile = s.FileName;
}
catch { }
}
else
{
try
{
System.IO.StreamWriter sw;
sw = System.IO.File.CreateText(cFile);
sw.Write(t.Text);
sw.Flush();
}
catch { }
}
Code: Select all
SaveFileDialog s = new SaveFileDialog();
s.Filter = "Text Files (*.txt)|*.txt";
s.Title = "Powered by PlasmaGhost";
s.ShowDialog();
try
{
System.IO.StreamWriter sw;
sw = System.IO.File.CreateText(s.FileName);
sw.Write(t.Text);
sw.Flush();
cFile = s.FileName;
}
catch { }
Code: Select all
Close();
Step 7:
Double click on Undo and add this code between the brackets:
Code: Select all
t.Undo();
Code: Select all
t.Cut();
Code: Select all
t.Copy();
Code: Select all
t.Paste();
Code: Select all
FontDialog f = new FontDialog();
f.AllowScriptChange = false;
f.AllowVerticalFonts = false;
f.ShowColor = false;
f.ShowEffects = true;
f.ShowDialog();
t.Font = f.Font;
Code: Select all
ColorDialog c = new ColorDialog();
c.AnyColor = true;
c.AllowFullOpen = true;
c.FullOpen = true;
c.ShowDialog();
t.ForeColor = c.Color;
Code: Select all
t.SelectAll();
Note: I made this without the Visual C# 2005 open, so there may be errors. If there are, please notify me in this topic and I will fix them ASAP.
~PlasmaGhost