Code Search for Developers
 
 
  

PenCalibration.cs from MASE: Agile Software Engineering at Krugle


Show PenCalibration.cs syntax highlighted

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using TrackerDllLib;

namespace New_Study_Project
{
	public class PenCalibration : System.Windows.Forms.Form , TrackerDllLib.ITrackerCallback
	{
		/* creating variables */

		private System.Windows.Forms.Button ExitButton;
		private System.Windows.Forms.Label showCoordinates;
		private System.Windows.Forms.Button topLeft;
		private System.Windows.Forms.Button topRight;
		private System.Windows.Forms.Button bottomLeft;
		private System.Windows.Forms.Button bottomRight;
		private System.Windows.Forms.Button saveData;
		private TrackerDllLib.Tracker3d tracker;

		private double irX, irY, irZ;

		private System.Double[] pointTopLeft, pointTopRight, pointBottomRight, pointBottomLeft;
		private Point pixelTopLeft, pixelTopRight, pixelBottomRight, pixelBottomLeft;

		/* end of creating variables */

		public PenCalibration()
		{
			InitializeComponent();
			
			this.pointTopLeft = new System.Double[3];
			this.pointTopLeft[0] = 0.0;
			this.pointTopLeft[1] = 0.0;
			this.pointTopLeft[2] = 0.0;

			this.pointTopRight = new System.Double[3];
			this.pointTopRight[0] = 0.0;
			this.pointTopRight[1] = 0.0;
			this.pointTopRight[2] = 0.0;

			this.pointBottomLeft = new System.Double[3];
			this.pointBottomLeft[0] = 0.0;
			this.pointBottomLeft[1] = 0.0;
			this.pointBottomLeft[2] = 0.0;

			this.pointBottomRight = new System.Double[3];
			this.pointBottomRight[0] = 0.0;
			this.pointBottomRight[1] = 0.0;
			this.pointBottomRight[2] = 0.0;

			tracker = new TrackerDllLib.RemoteTracker3D().GetRemoteTracker("192.168.20.140");
			tracker.Start();
			tracker.SetCallBack(this);
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				tracker.Stop();
				tracker = null;
			}
			base.Dispose( disposing );
		}


		private void InitializeComponent()
		{
			this.ExitButton = new System.Windows.Forms.Button();
			this.showCoordinates = new System.Windows.Forms.Label();
			this.topLeft = new System.Windows.Forms.Button();
			this.topRight = new System.Windows.Forms.Button();
			this.bottomLeft = new System.Windows.Forms.Button();
			this.bottomRight = new System.Windows.Forms.Button();
			this.saveData = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// ExitButton
			// 
			this.ExitButton.BackColor = System.Drawing.Color.SandyBrown;
			this.ExitButton.Cursor = System.Windows.Forms.Cursors.Hand;
			this.ExitButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ExitButton.Location = new System.Drawing.Point(296, 176);
			this.ExitButton.Name = "ExitButton";
			this.ExitButton.Size = new System.Drawing.Size(200, 160);
			this.ExitButton.TabIndex = 0;
			this.ExitButton.Text = "Exit Calibration";
			this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click);
			// 
			// showCoordinates
			// 
			this.showCoordinates.BackColor = System.Drawing.Color.LightGray;
			this.showCoordinates.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.showCoordinates.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.showCoordinates.Location = new System.Drawing.Point(32, 144);
			this.showCoordinates.Name = "showCoordinates";
			this.showCoordinates.Size = new System.Drawing.Size(544, 23);
			this.showCoordinates.TabIndex = 1;
			this.showCoordinates.Text = "X: -, Y: -, Z: -";
			this.showCoordinates.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// topLeft
			// 
			this.topLeft.BackColor = System.Drawing.Color.SaddleBrown;
			this.topLeft.Cursor = System.Windows.Forms.Cursors.Cross;
			this.topLeft.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.topLeft.Location = new System.Drawing.Point(0, 0);
			this.topLeft.Name = "topLeft";
			this.topLeft.Size = new System.Drawing.Size(80, 40);
			this.topLeft.TabIndex = 2;
			this.topLeft.Text = "TopLeft";
			this.topLeft.Click += new System.EventHandler(this.topLeft_Click);
			// 
			// topRight
			// 
			this.topRight.BackColor = System.Drawing.Color.SaddleBrown;
			this.topRight.Cursor = System.Windows.Forms.Cursors.Cross;
			this.topRight.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.topRight.Location = new System.Drawing.Point(696, 0);
			this.topRight.Name = "topRight";
			this.topRight.Size = new System.Drawing.Size(80, 40);
			this.topRight.TabIndex = 3;
			this.topRight.Text = "TopRight";
			this.topRight.Click += new System.EventHandler(this.topRight_Click);
			// 
			// bottomLeft
			// 
			this.bottomLeft.BackColor = System.Drawing.Color.SaddleBrown;
			this.bottomLeft.Cursor = System.Windows.Forms.Cursors.Cross;
			this.bottomLeft.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.bottomLeft.Location = new System.Drawing.Point(0, 480);
			this.bottomLeft.Name = "bottomLeft";
			this.bottomLeft.Size = new System.Drawing.Size(80, 40);
			this.bottomLeft.TabIndex = 4;
			this.bottomLeft.Text = "BottomLeft";
			this.bottomLeft.Click += new System.EventHandler(this.bottomLeft_Click);
			// 
			// bottomRight
			// 
			this.bottomRight.BackColor = System.Drawing.Color.SaddleBrown;
			this.bottomRight.Cursor = System.Windows.Forms.Cursors.Cross;
			this.bottomRight.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.bottomRight.Location = new System.Drawing.Point(696, 480);
			this.bottomRight.Name = "bottomRight";
			this.bottomRight.Size = new System.Drawing.Size(80, 40);
			this.bottomRight.TabIndex = 5;
			this.bottomRight.Text = "BottomRight";
			this.bottomRight.Click += new System.EventHandler(this.bottomRight_Click);
			// 
			// saveData
			// 
			this.saveData.BackColor = System.Drawing.Color.ForestGreen;
			this.saveData.Cursor = System.Windows.Forms.Cursors.Hand;
			this.saveData.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.saveData.Location = new System.Drawing.Point(256, 392);
			this.saveData.Name = "saveData";
			this.saveData.Size = new System.Drawing.Size(280, 40);
			this.saveData.TabIndex = 6;
			this.saveData.Text = "Save Calibaration Data to File";
			this.saveData.Click += new System.EventHandler(this.saveData_Click);
			// 
			// PenCalibration
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.DarkGray;
			this.ClientSize = new System.Drawing.Size(776, 520);
			this.Controls.Add(this.saveData);
			this.Controls.Add(this.bottomRight);
			this.Controls.Add(this.bottomLeft);
			this.Controls.Add(this.topRight);
			this.Controls.Add(this.topLeft);
			this.Controls.Add(this.showCoordinates);
			this.Controls.Add(this.ExitButton);
			this.Cursor = System.Windows.Forms.Cursors.No;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "PenCalibration";
			this.Text = "PenCalibration";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.PenCalibration_Load);
			this.ResumeLayout(false);

		}
	

		private void PenCalibration_Load(object sender, System.EventArgs e)
		{
			this.ExitButton.Location = new Point((int) (this.Width/2-this.ExitButton.Width/2), (int) (this.Height/2-this.ExitButton.Height/2));
			this.showCoordinates.Location = new Point((int) (this.Width/2-this.showCoordinates.Width/2), (int) (this.Height/2-250));
			this.saveData.Location = new Point((int) (this.Width/2-this.saveData.Width/2), (int) (this.Height/2+250));
			this.topLeft.Location = new Point(40,40);
			this.topRight.Location = new Point(this.Width-this.topRight.Width-40, 40);
			this.bottomRight.Location = new Point(this.Width-this.bottomRight.Width-40, this.Height-this.bottomRight.Height-40);
			this.bottomLeft.Location = new Point(40, this.Height-this.bottomLeft.Height-40);

		}


		private void ExitButton_Click(object sender, System.EventArgs e)
		{
			this.Dispose();
			this.Close();
		}

		public void Callback ( System.Int32 nID , System.Double dX , System.Double dY , System.Double dZ )
		{
			this.showCoordinates.Text = "X: "+dX.ToString() + " ,  Y: " + dY.ToString() + " , Z: " + dZ.ToString();
		}

		private void saveData_Click(object sender, System.EventArgs e)
		{
			StreamWriter output;
					
			output = new StreamWriter((System.Environment.CurrentDirectory + "\\calibration.pcb"), false, System.Text.Encoding.Default);
			output.WriteLine("******************************************");
			output.WriteLine("* Calibration Data for ID Identification *");
			output.WriteLine("******************************************");
			output.WriteLine(" ");
			output.WriteLine("Date: "+System.DateTime.Today.ToShortDateString());
			output.WriteLine(" ");
			output.WriteLine(" ");
			output.WriteLine("TopLeft ~ ("+this.pixelTopLeft.X.ToString()+", "+this.pixelTopLeft.Y.ToString()+") ~ ("+this.pointTopLeft[0].ToString()+", "+this.pointTopLeft[1].ToString()+", "+this.pointTopLeft[2].ToString()+")");
			output.WriteLine(" ");
			output.WriteLine("TopRight ~ ("+this.pixelTopRight.X.ToString()+", "+this.pixelTopRight.Y.ToString()+") ~ ("+this.pointTopRight[0].ToString()+", "+this.pointTopRight[1].ToString()+", "+this.pointTopRight[2].ToString()+")");
			output.WriteLine(" ");
			output.WriteLine("BottomRight ~ ("+this.pixelBottomRight.X.ToString()+", "+this.pixelBottomRight.Y.ToString()+") ~ ("+this.pointBottomRight[0].ToString()+", "+this.pointBottomRight[1].ToString()+", "+this.pointBottomRight[2].ToString()+")");
			output.WriteLine(" ");
			output.WriteLine("BottomLeft ~ ("+this.pixelBottomLeft.X.ToString()+", "+this.pixelBottomLeft.Y.ToString()+") ~ ("+this.pointBottomLeft[0].ToString()+", "+this.pointBottomLeft[1].ToString()+", "+this.pointBottomLeft[2].ToString()+")");
			output.WriteLine(" ");
			output.Close();
					
			output = new StreamWriter((System.Environment.CurrentDirectory + "\\testCalibration.pcb"), false, System.Text.Encoding.Default);
			output.WriteLine("******************************************");
			output.WriteLine("* Calibration Data for ID Identification *");
			output.WriteLine("******************************************");
			output.WriteLine(" ");
			output.WriteLine(this.pixelTopLeft.X.ToString()+"|"+this.pixelTopLeft.Y.ToString()+"|"+this.pointTopLeft[0].ToString()+"|"+this.pointTopLeft[1].ToString()+"|"+this.pointTopLeft[2].ToString());
			output.WriteLine(this.pixelTopRight.X.ToString()+"|"+this.pixelTopRight.Y.ToString()+"|"+this.pointTopRight[0].ToString()+"|"+this.pointTopRight[1].ToString()+"|"+this.pointTopRight[2].ToString());
			output.WriteLine(this.pixelBottomRight.X.ToString()+"|"+this.pixelBottomRight.Y.ToString()+"|"+this.pointBottomRight[0].ToString()+"|"+this.pointBottomRight[1].ToString()+"|"+this.pointBottomRight[2].ToString());
			output.WriteLine(this.pixelBottomLeft.X.ToString()+"|"+this.pixelBottomLeft.Y.ToString()+"|"+this.pointBottomLeft[0].ToString()+"|"+this.pointBottomLeft[1].ToString()+"|"+this.pointBottomLeft[2].ToString());
			output.WriteLine(" ");
			output.Close();
		}

		private void topLeft_Click(object sender, System.EventArgs e)
		{
			// Get current location of IR enhanced pen
			tracker.GetLocation(0,out irX,out irY,out irZ);

			this.pointTopLeft[0] = irX;
			this.pointTopLeft[1] = irY;
			this.pointTopLeft[2] = irZ;

			
			this.pixelTopLeft = new Point(Cursor.Position.X, Cursor.Position.Y);

			this.topLeft.Text = "Finished";
			this.topLeft.Enabled = false;

		}

		private void topRight_Click(object sender, System.EventArgs e)
		{
			// Get current location of IR enhanced pen
			tracker.GetLocation(0,out irX,out irY,out irZ);

			this.pointTopRight[0] = irX;
			this.pointTopRight[1] = irY;
			this.pointTopRight[2] = irZ;

			this.pixelTopRight = new Point(Cursor.Position.X, Cursor.Position.Y);
			
			this.topRight.Text = "Finished";
			this.topRight.Enabled = false;
		}

		private void bottomLeft_Click(object sender, System.EventArgs e)
		{
			// Get current location of IR enhanced pen
			tracker.GetLocation(0,out irX,out irY,out irZ);

			this.pointBottomLeft[0] = irX;
			this.pointBottomLeft[1] = irY;
			this.pointBottomLeft[2] = irZ;

			this.pixelBottomLeft = new Point(Cursor.Position.X, Cursor.Position.Y);

			this.bottomLeft.Text = "Finished";
			this.bottomLeft.Enabled = false;

		}

		private void bottomRight_Click(object sender, System.EventArgs e)
		{
			// Get current location of IR enhanced pen
			tracker.GetLocation(0,out irX,out irY,out irZ);

			this.pointBottomRight[0] = irX;
			this.pointBottomRight[1] = irY;
			this.pointBottomRight[2] = irZ;

			this.pixelBottomRight = new Point(Cursor.Position.X, Cursor.Position.Y);
			
			this.bottomRight.Text = "Finished";
			this.bottomRight.Enabled = false;
		}


	}
}




See more files for this project here

MASE: Agile Software Engineering

The MASE project investigates methods to support the coordination and executable acceptance testing of software projects. Keywords: Agile methods, distributed teams, Extreme Programming. See http://ebe.cpsc.ucalgary.ca/ebe for more information.

Project homepage: http://sourceforge.net/projects/mase
Programming language(s): Java,XML
License: other

  ControlPoint.cs
  CustomTreeNode.cs
  CustomTreeView.cs
  Dashboard.cs
  Dashboard.resx
  EStoryForm.cs
  EStoryForm.resx
  IOSelectObject.cs
  InterfaceGrid.cs
  InterfaceObject.cs
  List.cs
  ListNode.cs
  LogFile.cs
  MenuForm.cs
  MenuForm.resx
  MoveAbleSpline.cs
  NonMoveAbleSpline.cs
  ObjectButton.cs
  Old_MoveAbleSpline.cs
  PenCalibration.cs
  PenCalibration.resx
  RNTObject.cs
  Spline.cs
  StartupScreen.cs
  StartupScreen.resx
  StorageButton.cs
  Study_Project.cs
  Study_Project.resx
  TabletUI.cs
  TabletUI.resx
  Workspace.cs
  Workspace.resx
  testCalibration.cs
  testCalibration.resx