Permalink
Browse files

Added test for Form TransparencyKey and Opacity

svn path=/trunk/winforms/; revision=55264
  • Loading branch information...
1 parent f736991 commit 649a021d8d2dc2bdc914c03689aaa239c29335fd @joncham joncham committed Jan 9, 2006
Showing with 90 additions and 0 deletions.
  1. +11 −0 transparency/Makefile
  2. +79 −0 transparency/swf-transparency.cs
View
@@ -0,0 +1,11 @@
+all: mono
+
+mono: swf-transparency.cs
+ mcs -debug swf-transparency.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
+
+dotnet: swf-transparency.cs
+ csc swf-transparency.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
+
+clean:
+ rm swf-transparency.exe -r -f
+ rm -f swf-transparency.exe.mdb
@@ -0,0 +1,79 @@
+using System;
+using System.Drawing;
+using System.Globalization;
+using System.Windows.Forms;
+using System.Threading;
+using System.Runtime.InteropServices;
+
+namespace transparency
+{
+ public class MainForm : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Button button1;
+ static int i = 0;
+
+ public MainForm()
+ {
+ InitializeComponent();
+
+ }
+
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(168, 96);
+ this.button1.Name = "button1";
+ this.button1.TabIndex = 0;
+ this.button1.Text = "Click me";
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // MainForm
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(292, 266);
+ this.Controls.Add(this.button1);
+ this.Name = "MainForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "My Form";
+ this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainForm_Paint);
+ this.ResumeLayout(false);
+
+ }
+
+ [STAThread]
+ static void Main()
+ {
+ Application.Run(new MainForm());
+ }
+
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ i++;
+ if (i == 1)
+ this.Opacity = 0.75;
+ else if (i ==2 )
+ this.TransparencyKey = System.Drawing.Color.Red;
+ else if (i ==3 )
+ this.TransparencyKey = System.Drawing.Color.Green;
+ else if (i ==4 )
+ this.TransparencyKey = System.Drawing.Color.Blue;
+ else if (i ==5 )
+ this.TransparencyKey = System.Drawing.Color.Empty;
+ else if (i ==6 )
+ this.Opacity = 1;
+
+ if (i >= 6)
+ i = 0;
+ }
+
+ private void MainForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
+ e.Graphics.FillRectangle(Brushes.Red, 0,0,50,50);
+ e.Graphics.FillRectangle(Brushes.Green, 0,50,50,50);
+ e.Graphics.FillRectangle(Brushes.Blue, 0,100,50,50);
+ }
+ }
+}

0 comments on commit 649a021

Please sign in to comment.