Hey Tech thats not a nice position to be in and I hope the legal problems you can work out, just keep fighting.
Theres alot of simularity about your story and how things played out with me and my Ex GF. She had a history of mental problems (manic depression) a very difficult childhood and had a string of failed relationships and a 6yo child. Im pretty niave but i did fall for in love with her, like you id describe myself the opposite of a player, reserved and also im in IT. We didnt last and it all ended when she met someone else...
You say you would often go home or leave when she would confront you or get angry, I'd do the same, I found thats probably a mistake, in my case every time I backed off things would escalate. I thought I was being calm and didnt want to upset her any more but in my case she saw it as a form of rejection, me leaving etc. You also said she told you she was "comfortable" and felt "sane" with you, the Ex told me the exact same line... Perhaps she appricated the support you were providing, money, emotional support and the encouragament. Why contact the guy for the one night stand? probably to see your reaction and how you'd deal with her, I suspect she is very insecure about everything?
I'd agree with shheadz here totally, these kind of women literally suck the life out of every man they get involved with, when you fall for someone its so hard to remain objective you see things so one sided. Try stepping back and thinking, actions tend to be much more genuine than any kind word she ever told you. As for why would she do this to you after everything you did for her? Who knows its probably just the way she is and always will be. Dont waste time on trying to make sense out of it, you'll probably get a few answers blaming her bad past etc, but really now thats her issues to deal with and not yours.
Best of luck with the court case, remember to keep fighting and don't stoop down to her levels in this, when its all over with and it will be, move forward and dont ever look back.