2using System.Collections.Generic;
3using System.ComponentModel;
8using System.Windows.Forms;
9using System.Runtime.InteropServices;
23 public partial class Form1 : Form
25 private int WM_COPYDATA = 0x004A;
29 InitializeComponent();
31 public Form1(String title)
33 InitializeComponent();
42 [MarshalAs(UnmanagedType.LPStr)]
46 [
System.Security.Permissions.PermissionSet(
System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")]
47 protected override void WndProc(ref Message m)
49 if (m.Msg == WM_COPYDATA)
52 Type mytype = mystr.GetType();
55 if (text.ToLower().Trim().Equals(
"@CopyToClipboard".ToLower()))
59 else if (text.ToLower().Trim().StartsWith(
"@SaveAs".ToLower()))
61 String fileName = text.Split()[1];
64 else if (text.ToLower().Trim().Equals(
"@Terminate".ToLower()))
70 this.richTextBox1.Text += DateTime.Now.ToString(
"HH:mm:ss tt") +
": " + text + Environment.NewLine;
71 this.richTextBox1.SelectionStart = this.richTextBox1.Text.Length;
72 this.richTextBox1.ScrollToCaret();
78 private void CopyToClipboard()
80 if (this.richTextBox1.Text !=
null &&
this.richTextBox1.Text !=
"")
81 Clipboard.SetText(this.richTextBox1.Text);
84 private void SaveAs(String fileName)
86 this.richTextBox1.SaveFile(fileName, RichTextBoxStreamType.PlainText);
89 private void button1_Click(
object sender, EventArgs e)
94 private void button2_Click(
object sender, EventArgs e)
96 SaveFileDialog sfd =
new SaveFileDialog();
97 sfd.Filter =
"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
98 if (sfd.ShowDialog() == DialogResult.OK)