Author Archive

Blog Migration

In search of a bit more flexibility, I have decided to move my existing blog at dotnet.org.za to www.rohland.co.za. For lack of a better name, I ended up with the obvious pretentious default :P

I am very grateful for the service made available via the dotnet.org.za portal. A year ago it allowed me to get up and running with my blog relatively quickly. To the administrators of the portal – thank you!

In terms of moving forward, I was not sure what the correct procedure for moving my existing blog away from dotnet.org.za was, so I ended up implementing a simple script to redirect to my new domain. Hopefully, I will be able to organise a mechanism whereby future posts here reflect in the dotnet.org.za main feed. If not, then I guess that is the penalty for moving my blog.

Hopefully you subscribe to the RSS feed available here, or at the very least, check back periodically for new content. Please let me know if spot any issues.

If you have landed here after clicking a link related to one of my older blog posts, simply use the search feature available in the side bar to locate the content you were originally hoping to review.

Cheers,
Rohland

Powerpoint with some Deep Zoom shine

I thought I would give the Microsoft Office Labs team a plug after using one of their Office add-ins in a presentation I delivered last week. It had been a while since I last put together a Powerpoint presentation and I wanted to find out if there were any new funky ways of delivering presentation content.

If you cast your mind back to Tech-Ed Africa 2008, you might remember a few demos of Deep Zoom, a technology that allows you to “infinitely” zoom and pan through a large collection of high-res images. The demos were impressive but sadly, I haven’t really seen the technology applied in the wild. So, I decided to look into any advancements in the Deep Zoom toolset that would allow me to put together a presentation relatively simply. It was at this point I stumbled across PPTPlex, a plug-in for Microsoft Powerpoint. It allows you to add some cool Deep Zoom type features to your presentation. Strictly speaking, its not as robust as a true Deep Zoom compilation, but it does allow you to put together a neat presentation without too much work.

Overall, I thought the plug-in was pretty cool and had an extremely low learning curb. I successfully delivered my presentation using the plug-in without any issues. I did have one or two gripes about the plug-in though, the main being that I could not find a way to publish my presentation (I had to have Powerpoint open to present it). Also, you cannot animate any of your presentation elements through PPTPlex – I can understand why this is missing (it would be pretty complex to implement) but it is just something you need to bear in mind.

So, if you’re bored of compiling presentations using the defacto Powerpoint toolset then I would definately recommend looking into PPTPlex. Have fun…

Test mail send routine without mail server

I picked up a blog post about this tip from one of my RSS feeds. Amr ElGarhy posted a valuable article on how to write emails to a local directory rather than sending them through a mail server. This saves a lot of time in dev.

Essentially, replace your existing mail configuration with the config below:

<system.net>

<mailSettings>

   <smtp deliveryMethod=”SpecifiedPickupDirectory“>

    <specifiedPickupDirectory pickupDirectoryLocation=”c:\tmp” />

   </smtp>

</mailSettings>

</system.net>


When you send a mail using the built in .NET classes, a *.eml file will be created in the directory you specify. You can then view the email by simply opening the file.

Enable remote desktop remotely

So, this morning I needed to remote into one of our work stations at the office but lo and behold, remote desktop was disabled (ARGGH!). This meant one of three things, either I drive to the office to get it done, forget about the work until Monday or try update the setting remotely. Suffice to say, I attempted option 3 first.

It turned out to be really easy, there are already one or two articles on the web that explain how to do this, but for the folks who don’t know (and for my future reference) I thought posting it here would be useful.

Step 1 – Download PsExec (an awesome utility from SysInternals)

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

Step 2 – Run PsExec as follows:

psexec \\REMOTE_PC_NAME _HERE cmd

This will open a command line session on the machine you are attempting to enable RD on. Any of the commands you execute below will be executed on the remote machine.

Step 3 – Ensure the firewall on the remote machine lets you in

netsh firewall set service remotedesktop enable
netsh firewall set service remoteadmin enable

Step 4 – Update the terminal server registry key which controls remote desktop capability

REG ADD “HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server” /f /v fDenyTSConnections /t REG_DWORD /d 0

That’s it! You should be good to go.

Custom tooltips and Microsoft’s chart control

Posted on: (1 Comment

I have been meaning to blog about this topic for a while now because I am interested to find out if anyone else has picked up performance issues when using the Microsoft Chart Controls and the “MapAreaAttributes” property to create custom tooltips.

Before going into the mechanics of creating a custom tooltip as suggested by the documentation provided with the charting framework, I thought I would simply outline how you would create an instance of the default styled tooltip:

1 series.Points.DataBind(data,“X”,“Y”,“Tooltip=MyTooltipProperty”);

 

The code above illustrates the databinding capabilities of the charting control. The data array is made up of a list of objects that are of type Point which is a simple class I created:

    1     public class Point

    2     {

    3         public double X {get;set;}

    4         public double Y { get; set; }

    5 

    6         public string MyTooltipProperty { get; set; }

    7 

    8         public Point()

    9         {

   10             this.MyTooltipProperty = “Hello!”;

   11         }

   12     }

 

From the above it is obvious that each data point’s tooltip will look like something like this:

Normal tooltip

 

 

 

 

 

 

 

The tooltip is simply rendered using the relevant browser’s default implementation for elements.

Custom Tooltips:

You may be aware of the charting framework’s capability for creating rich HTML tooltips using the MapAreaAttributes property. As illustrated in an example provided with the framework you could create an HTML tooltip using code similar to that shown below:

series.Points[j].MapAreaAttributes = “onmouseover=\”DisplayToolTip(‘<strong>Hello From an HTML tooltip</strong>’);\” onmouseout=\”HideTooltip();\”"

 

The DisplayTooltip method referenced is a JavaScript method which essentially displays an absolutely positioned element which tracks your mouse position. The method is fired as you hover over the data point area (which is defined by an image area map). The parameter passed to the method is injected into the element as HTML. As you mouse out of the area (the relevant data point) the Hidetooltip method fires and hides the element displaying the custom tooltip. Using this methodology your tooltip could look something like this:

 HTML tooltip

 

 

 

 

 

This looks promising because it illustrates the capability to extend our tooltips to include images, links etc. however, there is a caveat. I picked up an issue when you have a chart with a large number of data points, or a number of charts on a single page that utilise this feature. I started noticing that page loads took longer than usual. I put together a test page that rendered 40 instances of the same chart as shown above using the default tooltip. With tracing turned on the page took roughly 270ms to render:

 Default performance

 

 

 

 

 

 

 

 

 

By implementing one extra line of code to implement my rich HTML tooltip using the MapAreaAttributes property as outlined earlier, the page took almost 5 seconds to render!

 Poor performance

 

 

 

 

 

 

 

 

 

It turns out anyone who dares to use the MapAreaAttributes property is severely penalised! Clearly we can’t put a page into production that takes 5 seconds just to render our charts, so we either need to revert to our dull looking tooltips or look for other ways to achieve rich HTML tooltip functionality.

Now, we know that setting the tooltip property doesn’t seem to have any performance impact but that it doesn’t result in a pretty looking tooltip either, but what if we could use the tooltip property to store the HTML tooltip markup. I know what your thinking:

Ugly tooltip

 

 

 

 

 

Yuck. That will certainly have your users scratching their heads. So, what next? So far we know that using the example as provided by the charting documentation has an adverse affect on rendering times so that’s not ideal. Default tooltip styles work without performance issues but don’t allow us to render rich tooltips. Injecting HTML into the default tooltip property means our users need to slap on their XHTML goggles.

Well, there is an option available which I will outline here.  Essentially, it relies on the ability to interpret the default tooltip property and project it into a custom tooltip that we control. If we look at the HTML rendered by the chart control, you will notice an associated image map that looks something like this:

Image map

 

 

 

 

 

 

 

 

 

As you can see, our HTML tooltip detail is sitting inside the title property, encoded of course. If we leave the mark-up untouched and hover over any element on the chart, the default tooltip is rendered with unparsed HTML. Thankfully, we can access this image map using JavaScript to rebuild the image map with mouseover/out events to render our custom tooltip. While this is exactly what setting the MapAreaAttributes property is supposed to do, modifying the rendered HTML to do the same thing bypasses the performance issue noted. I have provided the JavaScript method below which rebuilds the image map. All that is required, from a server side scripting point of view, is the registration of a start-up script to process any chart you wish to load with custom tooltips.

    1 RebuildImageMap: function(id) {

    2     // Fetch the image and grab the imagemap ID

    3     var map = $(“#” + id).attr(“usemap”);

    4 

    5     // If the map ID is null, then perhaps there

    6     // were no datapoints. Don’t bother

    7     // processing an empty set

    8     if (map == null)

    9         return;

   10 

   11     // Fetch the map element using jQuery and

   12     // return the raw HTML element

   13     var areaMap = $(map)[0];

   14     if (areaMap == null) {

   15         return;

   16     }

   17 

   18     // Create an empty array to store our new elements

   19     var elementArray = [];

   20 

   21     // Iterate over existing map elements and create a new

   22     // set with our mouseover/out events

   23     for (var i = 0; i < areaMap.areas.length; i++) {

   24         var oldAreaElement = areaMap.areas[i];

   25         var element = document.createElement(“AREA”);

   26         element.shape = oldAreaElement.shape;

   27         element.coords = oldAreaElement.coords;

   28        

   29         element.tooltip = oldAreaElement.title;

   30         element.onmouseover =

   31             function() { DisplayTooltip(this.tooltip); };

   32         element.onmouseout =

   33             function() { HideTooltip(); };

   34         element.href = oldAreaElement.href;

   35         elementArray[elementArray.length] = element;

   36     }

   37     // Get rid of the old map elements

   38     areaMap.innerHTML = ;

   39 

   40     // Add our new elements back in

   41     for (var i = 0; i < elementArray.length; i++) {

   42         areaMap.appendChild(elementArray[i]);

   43     }

   44 

   45 }

 

The code above utilises jQuery which is useful, but not required to get the job done. If you are going to use another framework, just note that the map attribute (which contains the map’s ID) is prefixed with a #. You may want to get rid of that. The code above is a modified
snippet of an existing class. The DisplayTooltip method simply takes the tooltip HTML and loads it into a custom hidden element on the page. It then displays the element and tracks the mouse position so the element moves as the user’s cursor does. The HideTooltip method simply hides the tooltip and resets the HTML content. Using this technique, our HTML tooltip is rendered correctly without using the MapAreaAttributes  property.

 HTML tooltip

 

 

 

 

 

 

So far I have tested this method of rendering custom tooltips in Firefox, IE 7/8 and Chrome. Its a pity that this was required in the first place. I am really not sure why setting the MapAreaAttributes  property has such a huge impact on rendering times. If anyone could shed light on the matter, please feel free to post the detail! For now, the implementation above will suffice. Since the image map processing is performed on the client side, there is no effect on the server side processing time.

Hope this helps someone out there.