This project is read-only.

Making the TouchManager.Markers IList not read-only?

Feb 2, 2009 at 6:00 PM
Hi guys,
I've been working on my XNA (w/touchless) game for a few weeks now, and I'm getting on quite well with it.
I'm trying to make a settings form which will allow the user to tweak all settings to do with markers and gesture recognition (something I'm adding in as part of the project).
As part of this settings form, I want the user to be able to replace the default marker if they wish.
When they have selected the area they wish to have as their marker, I want to remove the existing marker and replace it with this new one. My problem is that removing/inserting markers at specific indexes in the Markers IList wont work as it is read only.
In the Touchless demo, though, the user is able to remove specific markers.

Is there any easy way for me to do this? And if not, is there any way to set Markers.IsReadOnly to False?

If you're interested in seeing the progress of my XNA + Touchless game so far, there are a few videos up here:

I update it with progress videos every week or so.

Feb 2, 2009 at 7:11 PM
Ah, I see there is a Markers.RemoveMarker() method which the demo probably uses to modify the Markers IList. Say I wanted to add my own method to your implementation of the IList, how would I go about modifying and recompiling your touchlib.dll? Sorry for the newbie question!
Feb 3, 2009 at 11:47 PM

The most easy way to understand what is done is just downloading the source code (also containing the demo app sources) and reading what's happening.
Thats how I started, too.

Afterall, the "IList" you get is nothing more than a standard List<Marker>. You do not want to modify this list, but possibly use other methods of the TouchlessMgr class

(or if you really miss a feature, extend that class and/or ask for the feature here in the forums or using the issue tracker)



Feb 5, 2009 at 2:24 AM
Hey Johnathan,

Did Florian's advice help? He's right.
Use RemoveMarker(), The IList is a read-only copy to prevent threading problems.
The IList is a templated .NET construct that I use, I don't extend their implementation.
It's easy enough to modify the source code and link to your version of the library.
May I ask what additional functionality are you looking for?

- Mike
Feb 5, 2009 at 2:32 AM
Hi guys,
Thanks for the responses.
Mike - I managed to work out how to modify and recompile your source code. I stuck with an old build though, as I found some changes in the new builds were breaking some parts of my project. I'm sure it would be sensible in the long-term for me to upgrade my code to work with the new builds, but given the time constraints I have on this project I didn't want to complicate matters!

Basically, I added an "InsertMarkerAt" method to your TouchlessLib. This allows me to specify where in the Markers list a new marker will be added. The reason behind this is because I have two markers in my game which I allow the user to define themselves in any order. One marker is for player character movement, and the other marker is for gestures. I needed to be able to insert a marker at a specific place in the marker list as I had to ensure that the player marker was always the first one in the list (index 0) and the gesture marker was always the second one (index 1). If I simply used the addMarker() method, the last marker that the user defines would be placed second in the list.

Hope that makes sense, haha. My brain is a bit mushed after working on all of this for so long. Hopefully you'll enjoy the finished project - be sure to check out those videos Mike!
Feb 5, 2009 at 2:45 AM
Oh sigh..
I've just realised after looking at my code with a pair of fresh eyes, that I didn't need to bother adding that method at all.. I could have done it a far simpler way.

Feb 5, 2009 at 2:53 AM
I was just going to suggest that it might have been easier to modify your client-side code to remember the indices of your game's 'movement' and 'gesture' markers, instead of assuming they are 0 and 1. Either way, I'm glad you found a solution. If you'd like, you can submit a request to the feature tracker for me to add more Marker list editing functionality, although I'm not sure how useful it is to other users.

The videos are great, I just pointed them out to my family this past weekend. Your project looks like it's coming along nicely. I particularly like the video you just added with your own editable gesture recognition system and mini-language. Something similar would potentially be a useful component of the Touchless library. I'd love to see a gesture recognition system built on top of the library, or a way to map Touchless output to an existing system.

Keep up the awesome work,
- Mike

Feb 5, 2009 at 2:59 AM
Hahah yeah I just realised I could've used IndexOf() and fed in the marker I want to remove, and then remove the marker at that index. Simple as that. That's about 4 hours yesterday wasted! Oh well, you live and learn :).

Glad you liked the videos. I plan on investing at least another solid 2 weeks coding time into the project to have the majority of it done, but it's definitely something I'll continue to work upon in my spare time afterwards. I'll give you all the source code (if you're interested) to see if there's anything useful you can salvage from it once it's finished, assuming my university don't have any issues with me giving it out.
Feb 6, 2009 at 6:26 PM

Hi again,

I also had the need to "identify"/classify markers and thus used the marker name for this (or is the "Name" property an extension of my own? can't remember...)
Mike, we could extend the Marker and Manager classes with a marker ID generated on AddMarker and/or user-settable and add FindMarker(string name) and RemoveMarker(string name) etc. methods.

Another idea I am currently working on is adding some more event handlers to the marker class to allow user code to register once and recieve Marker.OnChange-Events for any marker defined or added later. Does anyone need this feature? In that case, I could make a small intermediate patch for you, until Mike may include it in its main code.

Feb 8, 2009 at 9:24 PM
Edited Feb 8, 2009 at 9:24 PM

I just added the patch mentioned above for the curious. Mike, the content is part of a bigger patchset, so you may simply decline it without checking, the changes will be part of anotherbigger patchset following later. Just had some spare time on the train...

The patch applies against SVN r28702

[edit: fixed typo]

Feb 10, 2009 at 11:31 PM
Hi Guys,
Just a little update on my touchless game if anyone's interested.
The game is really starting to take shape now!