public frmCalibration(bool useThis,int left,int top) { [color=red]this.Location = new Point(left, top); Rectangle rect = new Rectangle(); Screen[] allScreens = Screen.AllScreens; int x = left; int y = top; int width = 0; int height = 0; if (Screen.AllScreens.Length > 1 && !useThis) { foreach (Screen screen in allScreens) { if (screen.Bounds.X < x) x = screen.Bounds.X; if (screen.Bounds.Y < y) y = screen.Bounds.Y; if (screen.Bounds.Right > width) width = screen.Bounds.Right; if (screen.Bounds.Bottom > height) height = screen.Bounds.Bottom; } rect = new Rectangle(x, y, width, height); } else { rect = Screen.GetBounds(new Point(left+1,top+1)); }[/color] InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.Left = rect.Left; this.Top = rect.Top; this.Size = new Size(rect.Width, rect.Height); this.Text = "Calibration - Working area:" + Screen.GetWorkingArea(this).ToString() + " || Real area: " + Screen.GetBounds(this).ToString(); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnKeyPress); screenHeight = rect.Height; screenWidth = rect.Width; bCalibration = new Bitmap(screenWidth, screenHeight, PixelFormat.Format24bppRgb); gCalibration = Graphics.FromImage(bCalibration); pbCalibrate.Left = 0; pbCalibrate.Top = 0; pbCalibrate.Size = new Size(rect.Width, rect.Height); gCalibration.Clear(Color.White); BeginInvoke((MethodInvoker)delegate() { pbCalibrate.Image = bCalibration; }); }
public frmMain() { CheckForIllegalCrossThreadCalls = false; screenWidth = Screen.GetBounds(this).Width; screenHeight = Screen.GetBounds(this).Height; screenTop = Screen.GetBounds(this).Top; screenLeft = Screen.GetBounds(this).Left; if (Screen.AllScreens.Length > 1) { Screen[] allScreens = Screen.AllScreens; foreach (Screen screen in allScreens) { if (screen.Bounds.Right > screenWidth) screenWidth = screen.Bounds.Right; if (screen.Bounds.Bottom > screenHeight) screenHeight = screen.Bounds.Bottom; if (screen.Bounds.Top < screenTop) screenTop = screen.Bounds.Top; if (screen.Bounds.Left < screenLeft) screenLeft = screen.Bounds.Left; } } InitializeComponent(); CanCalibrate = true; }
private void btnCalibrate_Click(object sender, EventArgs e) { if (CanCalibrate) { if (cf == null) { if (rdoBtnCurrent.Checked) { cf = new frmCalibration(true, Screen.GetBounds(this).Left, Screen.GetBounds(this).Top); } else { cf = new frmCalibration(false,0,0); } cf.Show(); } if (cf.IsDisposed) { if (rdoBtnCurrent.Checked) { cf = new frmCalibration(true, Screen.GetBounds(this).Left, Screen.GetBounds(this).Top); } else { cf = new frmCalibration(false,0,0); } cf.Show(); } calibrationState = 1; doCalibration(); } } private void Screens_CheckedChanged(object sender, EventArgs e) { screenWidth = Screen.GetBounds(this).Width; screenHeight = Screen.GetBounds(this).Height; screenTop = Screen.GetBounds(this).Top; screenLeft = Screen.GetBounds(this).Left; if (Screen.AllScreens.Length > 1 && !rdoBtnCurrent.Checked) { Screen[] allScreens = Screen.AllScreens; foreach (Screen screen in allScreens) { if (screen.Bounds.Right > screenWidth) screenWidth = screen.Bounds.Right; if (screen.Bounds.Bottom > screenHeight) screenHeight = screen.Bounds.Bottom; if (screen.Bounds.Top < screenTop) screenTop = screen.Bounds.Top; if (screen.Bounds.Left < screenLeft) screenLeft = screen.Bounds.Left; } } }
public void doCalibration(){ if (cf == null) return; int x = screenLeft; int y = screenTop; int size = 25; Pen p = new Pen(Color.Red); int crossX = 0; int crossY = 0; switch (calibrationState) { case 1: crossX = (int)(screenWidth * calibrationMargin); crossY = (int)(screenHeight * calibrationMargin); x += (int)(screenWidth * calibrationMargin); y += (int)(screenHeight * calibrationMargin); cf.showCalibration(crossX, crossY, size, p); dstX[calibrationState - 1] = x; dstY[calibrationState - 1] = y; break; case 2: crossX = screenWidth - (int)(screenWidth * calibrationMargin); crossY = (int)(screenHeight * calibrationMargin); x += screenWidth - (int)(screenWidth * calibrationMargin); y += (int)(screenHeight * calibrationMargin); cf.showCalibration(crossX, crossY, size, p); dstX[calibrationState - 1] = x; dstY[calibrationState - 1] = y; break; case 3: crossX = (int)(screenWidth * calibrationMargin); crossY = screenHeight - (int)(screenHeight * calibrationMargin); x += (int)(screenWidth * calibrationMargin); y += screenHeight -(int)(screenHeight * calibrationMargin); cf.showCalibration(crossX, crossY, size, p); dstX[calibrationState - 1] = x; dstY[calibrationState - 1] = y; break; case 4: crossX = screenWidth - (int)(screenWidth * calibrationMargin); crossY = screenHeight - (int)(screenHeight * calibrationMargin); x += screenWidth - (int)(screenWidth * calibrationMargin); y += screenHeight -(int)(screenHeight * calibrationMargin); cf.showCalibration(crossX, crossY, size, p); dstX[calibrationState - 1] = x; dstY[calibrationState - 1] = y; break;
Two: Three selling major points of this project are simplicity, portability, and low-cost; the original project really only require a Wiimote and a <$6 LED pen that is assembled relatively easily. Meets all the points. Microcontrollers, additional peripherals, corded controllers, things in the off-hand--all these infringe on the selling points. Three: People are stupid. Granted, if they can get this project to work, they're undoubtedly on the upper half of the bell curve, but you cannot give people too many things to do and expect them to do it all correctly.