using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace contentHierarchy
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel leftPanel;
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Panel buttonPanel;
private System.Windows.Forms.Button redButton;
private System.Windows.Forms.Button greenButton;
private System.Windows.Forms.Button blueButton;
private System.Windows.Forms.Panel fillPanel;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.leftPanel = new System.Windows.Forms.Panel();
this.buttonPanel = new System.Windows.Forms.Panel();
this.blueButton = new System.Windows.Forms.Button();
this.greenButton = new System.Windows.Forms.Button();
this.redButton = new System.Windows.Forms.Button();
this.bottomPanel = new System.Windows.Forms.Panel();
this.fillPanel = new System.Windows.Forms.Panel();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.leftPanel.SuspendLayout();
this.buttonPanel.SuspendLayout();
this.bottomPanel.SuspendLayout();
this.SuspendLayout();
//
// leftPanel
//
this.leftPanel.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(192)),
((System.Byte)(255)), ((System.Byte)(255)));
this.leftPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonPanel});
this.leftPanel.Dock = System.Windows.Forms.DockStyle.Left;
this.leftPanel.Name = "leftPanel";
this.leftPanel.Size = new System.Drawing.Size(104, 277);
this.leftPanel.TabIndex = 0;
//
// buttonPanel
//
this.buttonPanel.Anchor = (System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right);
this.buttonPanel.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(255)),
((System.Byte)(255)), ((System.Byte)(192)));
this.buttonPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
this.blueButton,
this.greenButton,
this.redButton});
this.buttonPanel.Location = new System.Drawing.Point(8, 82);
this.buttonPanel.Name = "buttonPanel";
this.buttonPanel.Size = new System.Drawing.Size(88, 104);
this.buttonPanel.TabIndex = 0;
//
// blueButton
//
this.blueButton.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.blueButton.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(192)),
((System.Byte)(192)), ((System.Byte)(255)));
this.blueButton.Location = new System.Drawing.Point(8, 76);
this.blueButton.Name = "blueButton";
this.blueButton.TabIndex = 2;
this.blueButton.Text = "Blue";
//
// greenButton
//
this.greenButton.Anchor = (System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right);
this.greenButton.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(192)),
((System.Byte)(255)), ((System.Byte)(192)));
this.greenButton.Location = new System.Drawing.Point(8, 42);
this.greenButton.Name = "greenButton";
this.greenButton.TabIndex = 1;
this.greenButton.Text = "green";
//
// redButton
//
this.redButton.Anchor = ((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.redButton.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(255)),
((System.Byte)(192)), ((System.Byte)(192)));
this.redButton.Location = new System.Drawing.Point(8, 8);
this.redButton.Name = "redButton";
this.redButton.TabIndex = 0;
this.redButton.Text = "Red";
//
// bottomPanel
//
this.bottomPanel.BackColor =
System.Drawing.Color.FromArgb(((System.Byte)(255)),
((System.Byte)(192)), ((System.Byte)(255)));
this.bottomPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
this.fillPanel,
this.leftPanel});
this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.bottomPanel.Name = "bottomPanel";
this.bottomPanel.Size = new System.Drawing.Size(292, 277);
this.bottomPanel.TabIndex = 1;
//
// fillPanel
//
this.fillPanel.Anchor =
(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.fillPanel.AutoScroll = true;
this.fillPanel.AutoScrollMargin = new System.Drawing.Size(20, 20);
this.fillPanel.AutoScrollMinSize = new System.Drawing.Size(500, 500);
this.fillPanel.BackColor = System.Drawing.Color.White;
this.fillPanel.Location = new System.Drawing.Point(104, 0);
this.fillPanel.Name = "fillPanel";
this.fillPanel.Size = new System.Drawing.Size(188, 256);
this.fillPanel.TabIndex = 1;
this.fillPanel.MouseUp +=
new System.Windows.Forms.MouseEventHandler(this.onMouseUp);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 255);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(292, 22);
this.statusBar1.TabIndex = 2;
this.statusBar1.Text =
"scroll and click in white panel to see point values";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 277);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.statusBar1,
this.bottomPanel});
this.Name = "Form1";
this.Text = "Content Hierarchy";
this.leftPanel.ResumeLayout(false);
this.buttonPanel.ResumeLayout(false);
this.bottomPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void onMouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point scrollPoint, actualPt, drawnPt;
scrollPoint = fillPanel.AutoScrollPosition;
if (e.Button == MouseButtons.Left) {
actualPt = new Point(e.X - scrollPoint.X, e.Y - scrollPoint.Y);
drawnPt = new Point(actualPt.X + scrollPoint.X,
actualPt.Y + scrollPoint.Y);
Graphics g = fillPanel.CreateGraphics();
g.FillRectangle(Brushes.Black, drawnPt.X, drawnPt.Y, 5, 5);
g.Dispose();
MessageBox.Show(" X = " + e.X.ToString() + " Y = " + e.Y.ToString()
+ "\n" +
" AutoScrollPosition " + fillPanel.AutoScrollPosition.ToString()
+ "\n" +
" actual point " + actualPt.ToString() + "\n" +
" drawn point " + drawnPt.ToString());
}
}
}
}