Archive for December 2006

Drawers made from old floorboards

Just put a page up with photos from my latest woodwork project – a small chest of drawers made from some old floorboards given to me. Here’s a picture of it finished…

MSG on Google Maps

Have just done my first version of overlaying geolocation info for MSG users onto Google Maps. At the moment it’s pretty rough and ready (only on my dev server), but seems to do the basics, eg changes the ‘pin’ when a users state changes. Quick screenshot here with users having different presence states:

Another problem for me to work on is how to ‘cluster’ users, as things stand with my map, users will only be clustered if they have exactly the same latitude and longitude – which fairly quickly starts to break down – on the image above there are several pins around Milton Keynes and it’s not really obvious exactly how many users are there – or whether there are more pins hidden behind the pins you can already see.

So I’m going to look to see how we can do the clustering more sensibly (perhaps at different resolutions of Google maps), this was solved quite well in BuddySpace, so I’m going to have a look at the algorithm used there (see the tech report on it) and see if I could apply the same algorithm, or if other algorithms have been developed in the last few years.

PHP arrays & recordsets to Javascript Objects (JSON)

Whilst writing the code for our MSG-Moodle integration, I needed to write a couple of helper functions to turn PHP arrays and ADOdb recordsets into JSON objects, and thought other might find them useful, so here they are:

This one takes an associative array of objects to turn into JSON object:

/**
* @param $objects object to turn into JSON
* @param $name overall name of the JSON object
* @param $callback name of the callback function
* @return string of the JSON object
*/
function phpToJSON($objects,$name,$callback=''){
$str = '';
if ($callback != ''){
$str .= $callback.'(';
}
if ($objects){
$str .= '{"'.$name.'":[';
$okeys = array_keys($objects);
for ($i=0; $i< sizeof($okeys); $i++){
$myobj = $objects[$okeys[$i]];
$attr = get_object_vars($myobj);
$str .= '{';
$keys = array_keys($attr);
for($j=0;$j< sizeof($keys); $j++){
$str .= '"'. $keys[$j] .'":"'. $attr[$keys[$j]] .'"';
if ($j != (sizeof($keys)-1)){
$str .= ',';
}
}
$str .= '}';
if ($i != (sizeof($objects)-1)){
$str .= ',';
}
}
$str .= ']}';
}
if ($callback != ''){
$str .= ');';
}
return $str;
}

and this one takes an ADOdb recordset and turns it into JSON object:

/**
* @param $objects object to turn into JSON
* @param $name overall name of the JSON object
* @param $callback name of the callback function
* @return string of the JSON object
*/
function phpRSToJSON($rs,$name,$callback=''){
$str = '';
if ($callback != ''){
$str .= $callback.'(';
}
if ($rs){

$str .= '{"'.$name.'":[';

$i=0;
while(!$rs->EOF) {
$i++;
$str .= '{';
$keys = array_keys($rs->fields);
for($j=0;$jfields[$keys[$j]] .'"';
if ($j != (sizeof($keys)-1)){
$str .= ',';
}
}
$str .= '}';
if ($i != $rs->RecordCount()){
$str .= ',';
}
$rs->MoveNext();
}

$str .= ']}';
}
if ($callback != ''){
$str .= ');';
}
return $str;
}

Hope you find these useful, and if you spot anything wrong (or that could be done better!) – please feel free to let me know 🙂

Article on JoinIn

New article on the JISC e-Learning Focus site about the JoinIn project I was involved just before I moved over to the OpenLearn project: JoinIn project: Sharing Groups between LAMS and Moodle

left click and right click – spot the difference??

Had fun this morning figuring out how to get the context menu for MSG Alert to display the same context menu when you right or left click on it. You’d think that ought to be very easy to do (and it is when you know how) but it was totally non obvious to me – the NotifyIcon class only has click, doubleclick, mouseclick etc methods, there aren’t any methods which deal solely with left or right clicks.

I tried a variety of approaches (from the number of messages in forums etc this isn’t a new problem!!), most of which used the NotifyIcon.ContextMenu.Show() method. However when I tried this, although the menu appeared fine, a blank item appeared in the taskbar, which looked really horrible!!! In the ended I opted for the method described here. This seemed to be the only reliable way of doing it.

Whilst doing this I also ‘upgraded’ my menu from ContextMenu to a ContextMenuStrip to take advantage of being able to add icons etc etc.

MSGAlert rewritten in Visual C#

Just about finished rewriting MSGAlert in visual c# and we’re now just testing it all out. Has been fairly painless – well, once we decided to go with c# instead of c++. So now users will see a balloon tool tip in the taskbar notification area when a new message is received and should stop some of the problems/comments we had where users didn’t find the notification of a new message to be obvious enough!

Hopefully we’ll not find very many bugs or issues and I can get on with the Google maps that I was playing with before 😉

Visual C++ to Visual C#

So, after a couple of weeks messing around (and to be honest – not getting very far!!!) with Visual C++ finally decided that it was probably best to go with Visual C# .NET instead. C# is much more ‘understandable’ to me, having done Java before, and hope that should make the code much easier to develop and maintain. In fact I’ve got further in couple of days with C# than I had with 2 weeks of C++, and with each I was starting at the same level, I’d not used either before.

Have even got as far (in the recoded MSG Alert program) as connecting up to the server, sending and receiving responses, so I think the ‘hard’ bits are all done, and I just need to spend some time putting it all together 🙂