using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Clipboard_Simple
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
Bitmap bm;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItemCopy;
private System.Windows.Forms.MenuItem menuItemPaste;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.PictureBox pictureBox1;
/// <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()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItemCopy = new System.Windows.Forms.MenuItem();
this.menuItemPaste = new System.Windows.Forms.MenuItem();
this.textBox1 = new System.Windows.Forms.TextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemCopy,
this.menuItemPaste});
this.menuItem1.Text = "Edit";
//
// menuItemCopy
//
this.menuItemCopy.Index = 0;
this.menuItemCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
this.menuItemCopy.Text = "Copy";
this.menuItemCopy.Click += new System.EventHandler(this.menuItemCopy_Click);
//
// menuItemPaste
//
this.menuItemPaste.Index = 1;
this.menuItemPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
this.menuItemPaste.Text = "Paste";
this.menuItemPaste.Click += new System.EventHandler(this.menuItemPaste_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 136);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(192, 136);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(104, 16);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(168, 104);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 305);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.textBox1});
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItemCopy_Click(object sender, System.EventArgs e)
{
Clipboard.SetDataObject(textBox1.SelectedText, true);
}
private void menuItemPaste_Click(object sender, System.EventArgs e)
{
IDataObject data = Clipboard.GetDataObject();
// Check to see if there's some text on the clipboard...
// and if so display it in the form's text box
if (data.GetDataPresent(typeof(string)))
//textBox1.Text = (string) data.GetData(typeof(string));
textBox1.Text = (string) data.GetData(DataFormats.Text);
// Check to see if there's an image on the clipboard...
// and if so display it in the form's picturebox
if (data.GetDataPresent(DataFormats.Bitmap))
{
bm = (Bitmap)data.GetData(DataFormats.Bitmap);
pictureBox1.Image = bm;
}
}
}
}