private String calculateMaxDist(IRSensor first, IRSensor second, IRSensor third) { int firstX = first.RawPosition.X; int secondX = second.RawPosition.X; int thirdX = third.RawPosition.X; int firstY = first.RawPosition.Y; int secondY = second.RawPosition.Y; int thirdY = third.RawPosition.Y; g.DrawEllipse(new Pen(Color.Red), (int)(first.RawPosition.X / 4), (int)(first.RawPosition.Y / 4), first.Size + 1, first.Size + 1); g.DrawEllipse(new Pen(Color.Blue), (int)(second.RawPosition.X / 4), (int)(second.RawPosition.Y / 4), second.Size + 1, second.Size + 1); g.DrawEllipse(new Pen(Color.Yellow), (int)(third.RawPosition.X / 4), (int)(third.RawPosition.Y / 4), third.Size + 1, third.Size + 1); double firstSecondDist = Math.Sqrt(Math.Pow((firstX - secondX), 2) + (Math.Pow((firstY - secondY), 2))); double secondThirdDist = Math.Sqrt(Math.Pow((secondX - thirdX), 2) + (Math.Pow((secondY - thirdY), 2))); double firstThirdDist = Math.Sqrt(Math.Pow((firstX - thirdX), 2) + (Math.Pow((firstY - thirdY), 2))); if (firstSecondDist > secondThirdDist && firstSecondDist > firstThirdDist) return firstX.ToString() + "," + firstY.ToString() + "," + secondX.ToString() + "," + secondY.ToString(); if(secondThirdDist > firstSecondDist && secondThirdDist > firstThirdDist) return secondX.ToString() + "," + secondY.ToString() + "," + thirdX.ToString() + "," + thirdY.ToString(); //firstThirdDist is largest return firstX.ToString() + "," + firstY.ToString() + "," + thirdX.ToString() + "," + thirdY.ToString(); }
private void UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color) { chkFound.Checked = irSensor.Found; if(irSensor.Found) { lblNorm.Text = irSensor.Position.ToString() + ", " + irSensor.Size; lblRaw.Text = irSensor.RawPosition.ToString(); g.DrawEllipse(new Pen(color), (int)(irSensor.RawPosition.X / 4), (int)(irSensor.RawPosition.Y / 4), irSensor.Size+1, irSensor.Size+1); } }
private void UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color) { //chkFound.Checked = irSensor.Found; }
private void UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color) { chkFound.Checked = irSensor.Found; g.DrawEllipse(new Pen(color), (int)(pbIR.Width / 2), (int)(pbIR.Height / 2), 4, 4); if(irSensor.Found) { if (WorkStatus == 1) { buffer += "\n"; long time_elapsed = ((DateTime.Now.Ticks - msec.Ticks) / 10000);//milliseconds long time_elapsed_last = ((DateTime.Now.Ticks - msec_last.Ticks) / 10000);//milliseconds buffer += time_elapsed.ToString(); buffer += " " + (irSensor.RawPosition.X).ToString() + " " + irSensor.RawPosition.Y.ToString(); msec_last = DateTime.Now; WriteLog(0); } lblNorm.Text = irSensor.Position.ToString() + ", " + irSensor.Size; lblRaw.Text = irSensor.RawPosition.ToString(); //g.DrawEllipse(new Pen(color), (int)(irSensor.RawPosition.X / 4), (int)(irSensor.RawPosition.Y / 4), irSensor.Size+1, irSensor.Size+1); g.DrawEllipse(new Pen(color), (int)pbIR.Width - (int)(irSensor.RawPosition.X / 2), (int)(irSensor.RawPosition.Y / 2), irSensor.Size + 4, irSensor.Size + 4); //Cursor.Position = new System.Drawing.Point((int)(irSensor.RawPosition.X / 4), (int)(irSensor.RawPosition.Y / 4)); //System.Windows.Forms.MouseButtons.l } }
private String UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color) { chkFound.Checked = irSensor.Found; if(irSensor.Found) { //AsynchronousClient.Send(StateObject.workSocket, irSensor.RawPosition.X.ToString() + ','); //AsynchronousClient.Send(StateObject.workSocket, "69" + '\n'); //System.Console.WriteLine(irSensor + irSensor.RawPosition.ToString()); lblNorm.Text = irSensor.Position.ToString() + ", " + irSensor.Size; lblRaw.Text = irSensor.RawPosition.ToString(); g.DrawEllipse(new Pen(color), (int)(irSensor.RawPosition.X / 4), (int)(irSensor.RawPosition.Y / 4), irSensor.Size+1, irSensor.Size+1); return irSensor.RawPosition.X.ToString() + "," + irSensor.RawPosition.Y.ToString(); } return null; }
private String getTwoPoints(IRSensor first, IRSensor second) { g.DrawEllipse(new Pen(Color.Red), (int)(first.RawPosition.X / 4), (int)(first.RawPosition.Y / 4), first.Size + 1, first.Size + 1); g.DrawEllipse(new Pen(Color.Blue), (int)(second.RawPosition.X / 4), (int)(second.RawPosition.Y / 4), second.Size + 1, second.Size + 1); return first.RawPosition.X.ToString() + "," + first.RawPosition.Y.ToString() + "," + second.RawPosition.X.ToString() + "," + second.RawPosition.Y.ToString() + '\n'; }
void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { lock (lockObj) { WiimoteLib.ButtonState bs = args.WiimoteState.ButtonState; //extract the wiimote state IRSensor ws = args.WiimoteState.IRState.IRSensors[0]; if (ws.Found) //move cursor { PointF position = new PointF(ws.RawPosition.X, ws.RawPosition.Y); PointF warpedPos = position; warper.warp(position, ref warpedPos); SmoothingBuffer[SmoothingBufferIndex % SMOOTHING_BUFFER_SIZE] = warpedPos; SmoothingBufferIndex++; if (!lastWiiState.Found) //mouse down { SmoothingBufferIndex = 0; //resets the count if (CursorEnabled) { InputCont.MoveMouse(warpedPos); //move the mouse to x,y InputCont.LeftMouseDown(); //left click down } else if (CalibrationState.State > 0) ContinueCalibration(position); } else if (CursorEnabled) //dragging { //if (((x != lastWiiState.RawPosition.X) || (y != lastWiiState.RawPosition.Y)) && cursorControl) if (SmoothingEnabled) { PointF s = GetSmoothedCursor(SmoothingAmount); InputCont.MoveMouse(s); //move the mouse to x,y } else InputCont.MoveMouse(warpedPos); //move the mouse to x,y } } else if (lastWiiState.Found && CursorEnabled) {//mouse up InputCont.LeftMouseUp(); InputCont.MoveMouse(new PointF(0,0)); //move the mouse to x,y } if (!lastButtonState.A && bs.A) Calibrate(); lastButtonState = bs; lastWiiState = ws; if (StatusInfoChanged != null) StatusInfoChanged(this, new EventArgs<WiimoteState>(args.WiimoteState)); } }
private void UpdateIR(IRSensor irSensor, Label lblNorm, Label lblRaw, CheckBox chkFound, Color color) { chkFound.Checked = irSensor.Found; if (irSensor.Found) { lblNorm.Text = string.Concat(irSensor.Position.ToString(), ", ", irSensor.Size); lblRaw.Text = irSensor.RawPosition.ToString(); this.g.DrawEllipse(new Pen(color), irSensor.RawPosition.X / 4, irSensor.RawPosition.Y / 4, irSensor.Size + 1, irSensor.Size + 1); } }