This project is read-only.

Telling which marker is on screen

Aug 26, 2009 at 12:50 PM


I'm trying to tweak the sample to work out when a marker is on screen and display different message boxes depending on the marker that appears onscreen, later this will call actual code rather than the test messages. I've got a messagebox working with but I can't figure out how to tell which Marker is onscreen at that time to put in a select statement. I thought Marker.Equals might work but it doesn't appear to. Any ideas?



Aug 26, 2009 at 7:13 PM

You may use something like

Marker firstVisibleMarker = null;
foreach(Marker m in touchlessMgr.Markers)
    if (m.CurrentData.Present)
        firstVisibleMarker = m;

or, using Linq code a litte bit shorter:

Marker firstVisibleMarker = touchlessMgr.Markers.FirstOrDefault(m => m.CurrentData.Present);

Maybe you would also use theforeach variant, adding an "int countVisibleMarkers" and removing the break statement. Then you can call your code only if exactly one marker is detected.

 I think using the Marker.Changed event (or, with my Patch, TouchlessMgr.MarkerChanged) and checking if a marker just became present (Marker.CurrentData.Present && !Marker.PreviousData.Present)is thebest-fitting solution here...