void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { float normalizedX = this.X / (float)controlHeight; float normalizedY = this.Y / (float)controlWidth; CurrentNormalizedPosition = new Point3DNormalized(normalizedX, normalizedY, 0); }
void tmr_Tick(object sender, EventArgs e) { Frame frame = Controller.Frame(); var hands = frame.Hands; var hand = hands[0]; var fingers = hand.Fingers; if (controller == null || !controller.IsConnected) { StopDrawing(this, EventArgs.Empty); } else { if ((hands[0].IsRight) && (fingers[FINGER_ID] != Finger.Invalid) && (fingers[FINGER_ID].IsExtended)) { var normailizedPos = frame.InteractionBox.NormalizePoint(fingers[FINGER_ID].StabilizedTipPosition, false); CurrentNormalizedPosition = new Point3DNormalized(normailizedPos.x, 1 - normailizedPos.y, 1 - normailizedPos.z); StartDrawing(this, EventArgs.Empty); } if (!this.controller.HasFocus) { StopDrawing(this, EventArgs.Empty); } } }
void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) { Vector3d pos = Device.Position; CurrentNormalizedPosition = new Point3DNormalized( (pos.X - MIN_X) / (MAX_X - MIN_X), (pos.Y - MIN_Y) / (MAX_Y - MIN_Y), (pos.Z - MIN_Z) / (MAX_Z - MIN_Z) ); Debug.WriteLine("X {0} Y {1} Z {2}", pos.X, pos.Y, pos.Z); var buttonIsPressed = Device.IsButtonPressed; if (!WasDrawing && buttonIsPressed) { StartDrawing(this, EventArgs.Empty); } if (WasDrawing && !buttonIsPressed) { StopDrawing(this, EventArgs.Empty); } WasDrawing = buttonIsPressed; }
void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { float normalizedX = this.X / (float)controlWidth; float normalizedY = this.Y / (float)controlHeight; if (oldx == X && oldy == Y) { if (watch.IsRunning) { if (watch.ElapsedMilliseconds == WAITITME) { StopDrawing(this, EventArgs.Empty); watch.Stop(); watch.Reset(); } } else { watch.Start(); } } else { if (watch.IsRunning) { watch.Stop(); watch.Reset(); } } oldx = X; oldy = Y; CurrentNormalizedPosition = new Point3DNormalized(normalizedX, normalizedY, 0); }
void tmr_Tick(object sender, EventArgs e) { Frame frame = Controller.Frame(); if (controller == null || !controller.IsConnected) { StopDrawing(this, EventArgs.Empty); } else { var hands = frame.Hands; var hand = hands[0]; var fingers = hand.Fingers; if ((fingers[FINGER_ID] != Finger.Invalid) && (fingers[FINGER_ID].IsExtended)) { var normailizedPos = frame.InteractionBox.NormalizePoint(fingers[FINGER_ID].StabilizedTipPosition, false); CurrentNormalizedPosition = new Point3DNormalized(normailizedPos.x, 1 - normailizedPos.y, 1 - normailizedPos.z); /* try{*/ StartDrawing(this, EventArgs.Empty); /* } * catch (Exception exc) * { * MessageBox.Show(exc.Message); * }*/ } if (fingers.IsEmpty) { try { StopDrawing(this, EventArgs.Empty); } catch (Exception exc) { MessageBox.Show(exc.Message); } } } }