Most Helpful Girl
If she was leading you on like that and turned you down, she was in the wrong. It may have taken you awhile to get the courage to ask her out, but you did it! I'm proud of you for doing it, even though you didn't get the intended result. I think being shy is one of the most attractive qualities in a man, and the fact that you cared enough about this girl to ask her out should make her feel VERY special. It is hard for anyone to ask someone out. However it takes extra courage for a shy guy to do anything social let alone ask that special girl out. When he does finally muster the courage to ask, it tells me that I mean enough to him that he is willing to put himself out there.1
Most Helpful Guy
If she flirted with you you might not be wrong, but she might have something else going on right now. Who knows. Gather more information.
I feel your pain on the pining for years thing. That shit sucks. Try not to do it if at all possible. Any possible way you can convince yourself to make subtle, civilized, but intent-signalling moves earlier on when a girl catches your eye, DO it. Then the stakes don't get a chance to get so high. There, I just compressed six years of talk therapy into a paragraph for you. :)
Meantime, work on making yourself interesting - hobbies, teams, activities etc. Even if it's weird and different, like writing code instead of picking up guitar, etc.2