Permalink
Browse files

- Be verbose on the events

- Allow testing of horizontal and vertical splitter (just set the teststyle
  variable to Left, Right, Top or Bottom)

svn path=/trunk/winforms/; revision=51896
  • Loading branch information...
1 parent 1dba0ed commit 9841697e2e5dfd8616fcb6ec91bc4d97b8ff1391 Peter Dennis Bartok committed Oct 19, 2005
Showing with 67 additions and 21 deletions.
  1. +2 −5 splitter/Makefile
  2. +65 −16 splitter/swf-splitter.cs
View
@@ -1,10 +1,7 @@
-all: mono
+all: swf-splitter.exe
-mono: swf-splitter.cs
+swf-splitter.exe: swf-splitter.cs
mcs swf-splitter.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
-dotnet: swf-splitter.cs
- csc swf-splitter.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
-
clean:
rm swf-splitter.exe -r -f
View
@@ -1,34 +1,83 @@
using System;
+using System.Drawing;
using System.Windows.Forms;
+using System.Reflection;
public class SplitterTest : Form {
+ TreeView treeView1;
+ Label label;
+ Label label2;
+ Splitter splitter;
+
public SplitterTest ()
{
- TreeView treeView1 = new TreeView ();
- ListView listView1 = new ListView ();
+ DockStyle teststyle;
+
+ treeView1 = new TreeView ();
+ label = new Label ();
+ label2 = new Label ();
+
+ teststyle = DockStyle.Left;
- Splitter splitter = new Splitter ();
- splitter.Dock = DockStyle.Left;
- splitter.MinExtra = 100;
- splitter.MinSize = 75;
+ splitter = new Splitter ();
+ splitter.Dock = teststyle;
+ splitter.MinExtra = 0;
+ splitter.MinSize = 0;
+ splitter.BorderStyle = BorderStyle.Fixed3D;
+ splitter.BackColor = Color.Red;
+ splitter.SplitterMoving += new SplitterEventHandler(splithandler);
+ splitter.SplitterMoved += new SplitterEventHandler(splittermoved);
+ splitter.MouseUp += new MouseEventHandler(mouseup);
- treeView1.Dock = DockStyle.Left;
- listView1.Dock = DockStyle.Fill;
+ treeView1.Dock = teststyle;
+ treeView1.BorderStyle = BorderStyle.Fixed3D;
+ label.Dock = teststyle;
treeView1.Nodes.Add ("TreeView Node");
- listView1.Items.Add ("ListView Item");
+ label.Text = "Click to trigger resize of TreeView Node";
+ label.Click += new EventHandler(clickhandler);
- Controls.AddRange (new Control [] { listView1, splitter, treeView1});
+ label2.Dock = DockStyle.Fill;
+ label2.Text = "Filler";
- Console.WriteLine ("treeview right: " + treeView1.Right);
- Console.WriteLine ("splitter left: " + splitter.Left);
- Console.WriteLine ("splitter right: " + splitter.Right);
- Console.WriteLine ("listView left: " + listView1.Left);
+ Controls.AddRange (new Control [] { label2, label, splitter, treeView1});
+
+ this.ClientSize = new Size(500, 500);
+ this.CreateControl();
+
+ #if not
+ Console.WriteLine ("treeview right: " + treeView1.Right + "Width: " + treeView1.Width);
+ Console.WriteLine ("splitter right: " + splitter.Right + "Width: " + splitter.Width);
+ Console.WriteLine ("listView left: " + label.Left + "Width: " + label.Width);
+ Console.WriteLine ("filler left: " + label2.Left + "Width: " + label2.Width);
- Console.WriteLine("ListView child index: {0}", Controls.GetChildIndex(listView1));
- Console.WriteLine("Splitter child index: {0}", Controls.GetChildIndex(splitter));
Console.WriteLine("treeView child index: {0}", Controls.GetChildIndex(treeView1));
+ Console.WriteLine("Splitter child index: {0}", Controls.GetChildIndex(splitter));
+ Console.WriteLine("ListView child index: {0}", Controls.GetChildIndex(label));
+ Console.WriteLine("filler child index: {0}", Controls.GetChildIndex(label2));
+ #endif
+
+ }
+
+ public void splithandler(object sender, SplitterEventArgs e) {
+ Console.WriteLine("SplitterMoving: SplitPosition: {0} (Event: split: {1},{2} mouse: {3},{4})", ((Splitter)sender).SplitPosition, e.SplitX, e.SplitY, e.X, e.Y);
+
+ if (((Splitter)sender).SplitPosition==16) {
+ ((Splitter)sender).SplitPosition = 150;
+ }
+ }
+
+ public void splittermoved(object sender, SplitterEventArgs e) {
+ Console.WriteLine("SplitterMoved: SplitPosition: {0} (Event: split: {1},{2} mouse: {3},{4})", ((Splitter)sender).SplitPosition, e.SplitX, e.SplitY, e.X, e.Y);
+ }
+
+ public void mouseup(object sender, MouseEventArgs e) {
+ Console.WriteLine("Got mouseup event");
+ }
+
+ public void clickhandler(object sender, EventArgs e) {
+// splitter.SplitPosition = 150;
}
public static void Main ()

0 comments on commit 9841697

Please sign in to comment.