ThinkGeo.com    |     Documentation    |     Premium Support

GeoFont, GeoColor et al

Hi Guys,


Just been asked a series of questions:-


1.  Why is there no constructor for a GeoFont that takes a .NET Font?


2.  Why is there no easy way to convert from a GeoFont to a Font?


3.  Why is there no easy methoid to convert a .NET Fonstyle to a DrawingFontStyle?


4.  Why is there not a constructor for a GeoColor that takes a .NET color?


5.  Why is there not a property a Color property in GeoColor? 


etc. etc. etc.


This developer is probably kind of 'picky' but just sort of commented if they want to do their own thing they might at least make it easy to convert to and from the similar classes/objects in the .NET framework?


He and I might be missing something but..., ducks to avoid incomming flak...


John



John, 
  
   I can help answer this.  The main reason is that we wanted to create a set of classes with no dependencies on the GDI+ namespace.  Our entire drawing classes can be extended to use various type of drawing system such as GDI+, GDI, PocketPC GDI+, WPF,  PDF, KML etc, and to have any dependencies in our drawing system to GDI+ was something we had to stay away from.  We chose to model our geographic drawing system on GDI+ because it is established and we felt it was a good minimum set of functionality we knew other drawing systems would offer.   
  
   Inside of the GdiPlusGeoCanvas we convert GeoFont to a GDI+ Font and the same for all the other types, this gives us a high level of isolation.  This approach has served us well for things like PDF and also we have ported the entire core namespace to Silverlight which has no access to GDI+.  We though this was necessary when we started this project because it seems like every few years Microsoft invents a new drawing engine. 
  
   What we could do is to expose all of these in a static conversion helper class.  The Api would be something like “Font GdiPlusConverter.ToFont(GeoFont) “ and “GeoFont GdiPlusConverter.ToGeoFont(Font)”.  We could do this for all of the various classes.  In this way you would have access to it and we can isolate the dependency into it’s appropriate class. 
  
 One other quick point is that we wanted to make our GeoCanvas a real geographic oriented drawing system.  We wanted to abstract away screen points and allow you to work with features.  This is why we tacked Geo on everything.  If we ever decide to create your own GeoCanvas you will really thank us for this. :-)  One of our primary goals with the entire framework was to make it extensible so that whatever people can dream up we can accommodate.   
  
   Another idea would be to expose these methods on the GdiPlusGeoCanvas and then allow them to be overridden.  In this way you could override how a GeoFont gets converted to a Font etc during rendering. 
  
   Sorry for making things inconvenient for you.  We strive to make the API and product easy to use and extend.  If there is anything that can make your life easier then let us know.  When we built the framework we knew intuition would only take us so far.  What will really make this great is customer feedback. 
  
 David










Hi David,


Thanks for that.


Please don’t get me wrong, I kind of appreciate why you guys did it and don’t have a problem with that, it is all how it should be to get a solid and extendable product from your side.


I think my colleague was just questioning the fact most programmers who use the product are going to, at some stage, end up having to write some little conversion functions to allow the user to pick a font using the framework font dialog, a colour (quaint UK spelling) and so on a so forth.


May be if we had a user area on the site people could contribute converters to a conversion class as and when they get written, it would save you guys having to do the work. I can see a C# font converter oozing out of my colleagues fingers as we speak!


Regards


John







John, 
  
   That is a great idea!  Don’t get me wrong, we do love to write code here and a bunch of these handy functions we already have hidden behind internal and private keywords.  We would love to share them with you any way we can.  I’m glad you brought up the font dialog, this is just the kinds of things you work with building applications that we in the isolated framework development team seldom use.  This is where our intuition failed us, and it is such a logical and ration thing I feel somewhat stupid for not thinking of that before.  Anymore of these obvious things you run across let me know, we will take action on them. 
  
   I really like the idea of a place people can post code snippets, enhanced classes they had written etc.  “The Code Project” or “Planet Source Code” are the first things that come to mind as I really like their layout.  That might take a bit of work to pull off though, I tend to think big!  What would be a good start is to create a new forum for the 3.x products and have it specializing in code.  We can place all of our little helper classes, new specialized classes etc there.  We have been posting to the Developers Blog but we could move them to our new code outpost. 
  
 What do you think? 
  
 David











Hi David,


What we are doing here is some work on converting a layer properties dialog from our previous system to ThinkGeo and kind of stumbled across all of this stuff when trying to set the properties after the user has selected a bunch of colours, fonts, widths and stuff…


You kind of, semi intuitively, think ok I’ve got the .NET color there just should be a GeoColor.Color property that you can set/get, same thing with a GeoFont...  Must be all this confusion with extraverted intuition, introverted intuition, intelligence and intellisense whatever they are!


I’ll see if we can post the source to the conversion stuff we ended up writing once we are done with it, there’s more casting going on here at the moment than in a fly-fishing competition.  It will need converting from C# for the VB guys.


Regards


John








John, 
  
   Whenever you want to post it let me know.  I have been working on my end to get a place to share code and extensions.  Thanks for your insight on this. 
  
 David