I’ve just tested your framework and it works fine! Super!
Regarding fingerposition-visualisation via ellipses:
It seems that
el.IsHitTestVisible = false;
really doesn’t work.
But you can skip the fill of the ellipse and just use the stroke.
It isn’t elegant and doesn’t solve the general problem, but it works
In _processing_FingerNew(...) I also get an exception.
Like Calvin already said, maybe FingerMoved is called before FingerNew.
So my current solution looks like this:
public partial class Window1 : Window
{
...
Hashtable ellipseHash;
public Window1()
{
...
_processing.FingerMoved += new TouchLibEvents.TuioMoveFingerHandler(_processing_FingerMoved);
_processing.FingerRemoved += new TouchLibEvents.TuioRemoveFingerHandler(_processing_FingerRemoved);
...
}
void _processing_FingerRemoved(object sender, TouchLibEvents.TuioRemoveFingerEventArgs obj)
{
mTCanvas1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Input, (Action)delegate()
{
this.mTCanvas1.Children.Remove((UIElement)this.ellipseHash[obj.Id]);
this.ellipseHash.Remove(obj.Id);
});
}
void _processing_FingerMoved(object sender, TouchLibEvents.TuioMoveFingerEventArgs obj)
{
mTCanvas1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Input, (Action)delegate()
{
if(!ellipseHash.ContainsKey(obj.Finger.Id)) {
Ellipse el = new Ellipse();
el.Width = 20;
el.Height = 20;
el.Fill = null;
el.Stroke = Brushes.Black;
el.StrokeThickness = 3;
this.mTCanvas1.Children.Add(el);
this.ellipseHash.Add(obj.Finger.Id, el);
MTCanvas.SetZIndex(el, 26);
}
MTCanvas.SetLeft((UIElement)ellipseHash[obj.Finger.Id], obj.Finger.position.X * SystemParameters.PrimaryScreenWidth);
MTCanvas.SetTop((UIElement)ellipseHash[obj.Finger.Id], obj.Finger.position.Y * SystemParameters.PrimaryScreenHeight);
});
}
...
}