- vistaspeechapidemo.zip
- $RECYCLE.BIN
- S-1-5-21-3149242879-1001066200-2049084313-1000
- Program Files
- WinZip
- Speech
- Speechpad.exe
- Speechpad
- Speechpad
- System Volume Information
- Textpad.exe
- Textpad
- Textpad
- vistaspeechapisource.zip
- RECYCLER
- S-1-5-21-2096264109-2128229809-11937967-11762
- bin
- Release
- Properties
- Speechpad.sln
- Release
- SRChatterbox
- SRChatterbox
- AIML Files
- bin
- Debug
- Properties
- Textpad.sln
- Release
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Speechpad
{
public partial class TextDocument : Form
{
public TextDocument()
{
InitializeComponent();
}
#region Document File Operations
private void SaveAs(string fileName)
{
try
{
saveFileDialog1.FileName = fileName;
DialogResult dr = saveFileDialog1.ShowDialog();
if (dr == DialogResult.Cancel)
{
return;
}
string saveFileName = saveFileDialog1.FileName;
Save(saveFileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void SaveAs()
{
string fileName = this.Text;
SaveAs(fileName);
}
internal void Save()
{
string fileName = this.Text;
Save(fileName);
}
private void Save(string fileName)
{
string text = this.richTextBox1.Text;
Save(fileName, text);
}
private void Save(string fileName, string text)
{
try
{
using (StreamWriter sw = new StreamWriter(fileName, false))
{
sw.Write(text);
sw.Flush();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void CloseDocument()
{
Dispose();
}
internal void Paste()
{
try
{
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Text))
{
InsertText(data.GetData(DataFormats.Text).ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
internal void InsertText(string text)
{
RichTextBox theBox = richTextBox1;
theBox.SelectedText = text;
}
internal void Copy()
{
try
{
RichTextBox theBox = richTextBox1;
Clipboard.Clear();
Clipboard.SetDataObject(theBox.SelectedText);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
internal void Cut()
{
Copy();
Delete();
}
internal void Delete()
{
richTextBox1.SelectedText = string.Empty;
}
#endregion
#region Main Menu Handlers
private void saveMenuItem_Click(object sender, EventArgs e)
{
Save();
}
private void saveAsMenuItem_Click(object sender, EventArgs e)
{
SaveAs();
}
private void closeMenuItem_Click(object sender, EventArgs e)
{
CloseDocument();
}
#endregion
#region Popup Menu Handlers
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
Copy();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
Cut();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
Paste();
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
Delete();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
James is a program writer for a respectable software company. He is also a Microsoft MVP.