public virtual void Add(SkeletonPoint position, KinectSensor sensor, Object format) { Entry newEntry = new Entry {Position = position.ToVector3(), Time = DateTime.Now}; Entries.Add(newEntry); // Drawing if (DisplayCanvas != null) { newEntry.DisplayEllipse = new Ellipse { Width = 4, Height = 4, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, StrokeThickness = 2.0, Stroke = new SolidColorBrush(DisplayColor), StrokeLineJoin = PenLineJoin.Round }; Vector2 vector2 = Tools.Convert(sensor.CoordinateMapper, position, format); float x = (float)(vector2.X * DisplayCanvas.ActualWidth); float y = (float)(vector2.Y * DisplayCanvas.ActualHeight); Canvas.SetLeft(newEntry.DisplayEllipse, x - newEntry.DisplayEllipse.Width / 2); Canvas.SetTop(newEntry.DisplayEllipse, y - newEntry.DisplayEllipse.Height / 2); DisplayCanvas.Children.Add(newEntry.DisplayEllipse); } // Remove too old positions if (Entries.Count > WindowSize) { Entry entryToRemove = Entries[0]; if (DisplayCanvas != null) { DisplayCanvas.Children.Remove(entryToRemove.DisplayEllipse); } Entries.Remove(entryToRemove); } // Look for gestures LookForGesture(); }
public virtual void Add(Vector position, SkeletonEngine engine) { Entry newEntry = new Entry {Position = position.ToVector3(), Time = DateTime.Now}; Entries.Add(newEntry); if (displayCanvas != null) { newEntry.DisplayEllipse = new Ellipse { Width = 4, Height = 4, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, StrokeThickness = 2.0, Stroke = new SolidColorBrush(displayColor), StrokeLineJoin = PenLineJoin.Round }; float x, y; engine.SkeletonToDepthImage(position, out x, out y); x = (float)(x * displayCanvas.ActualWidth); y = (float)(y * displayCanvas.ActualHeight); Canvas.SetLeft(newEntry.DisplayEllipse, x - newEntry.DisplayEllipse.Width / 2); Canvas.SetTop(newEntry.DisplayEllipse, y - newEntry.DisplayEllipse.Height / 2); displayCanvas.Children.Add(newEntry.DisplayEllipse); } if (Entries.Count > WindowSize) { Entry entryToRemove = Entries[0]; if (displayCanvas != null) { displayCanvas.Children.Remove(entryToRemove.DisplayEllipse); } Entries.Remove(entryToRemove); } LookForGesture(); }