Permalink
Browse files

- Added more test code

svn path=/trunk/winforms/; revision=44707
  • Loading branch information...
1 parent 1e49da5 commit 4fe31ae3c0a007611bd262687c51ca519b549aeb Peter Dennis Bartok committed May 18, 2005
Showing with 51 additions and 2 deletions.
  1. +51 −2 clipboard/clipboard.cs
View
@@ -2,16 +2,29 @@
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
+using System.Xml;
namespace System.Windows.Forms {
public class clipboard : Form {
+ static Image image;
+
+ protected override void OnPaint(PaintEventArgs e) {
+ base.OnPaint (e);
+ if (image != null) {
+ e.Graphics.DrawImage(image, 0, 0);
+ }
+Console.WriteLine("Got PaintEVENT");
+
+ }
+
public clipboard ()
{
this.Width = 400;
this.Height = 400;
- Clipboard.SetDataObject("blah", true);
+
+
}
public static void PrintFormatInfo(DataFormats.Format f) {
@@ -26,6 +39,28 @@ public clipboard ()
Console.WriteLine("");
}
+ public static void PrintClipboardContents() {
+ IDataObject data;
+ string[] formats;
+
+ data = Clipboard.GetDataObject();
+ if (data == null) {
+ Console.WriteLine("Clipboard is empty");
+ return;
+ }
+
+ Console.WriteLine("Clipboard contains data in the following formats:");
+ formats = data.GetFormats(false);
+
+ for (int i = 0; i < formats.Length; i++) {
+ Console.WriteLine(" => {0}", formats[i]);
+ }
+
+ for (int i = 0; i < formats.Length; i++) {
+ Console.WriteLine(" {0} = >{1}<", formats[i], data.GetData(formats[i], false));
+ }
+ }
+
public static void Main ()
{
PrintFormatInfo(DataFormats.GetFormat(DataFormats.Bitmap));
@@ -78,8 +113,22 @@ public static void Main ()
clipboard clip = new clipboard ();
+ PrintClipboardContents();
+
+ IDataObject data;
+
+ data = Clipboard.GetDataObject();
+
+ if (data != null && data.GetDataPresent(DataFormats.Bitmap)) {
+ image = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
+ }
+
+ Bitmap i = new Bitmap("test.bmp");
+ string s = "bummerä";
+
+ Clipboard.SetDataObject(s);
+
Application.Run (clip);
}
}
}
-

0 comments on commit 4fe31ae

Please sign in to comment.