Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

Sydney Mobility

Welcome to another action packed week of mobility here in (not so) sunny Sydney!  On the back of a successful Office Developer Conference there are a series of events lined up for this week that are worth attending if you are working in the mobility area.  By mobility I mean everything from being a developer for Windows Mobile or the .NET Compact Framework, through to infrastructure management of tablet PC/UMPC environments, through to content/service provision for mobile phones.

Finding the Silicon Beach House

There as some exciting times happening at the Silicon Beach House this week.  Not only did we welcome a new resident, Ben Giles from Spoon Media, the dividing walls are set to come down (finally).  We would have had this done ages ago but the builders have been doing the finishing touches to one of the other offices downstairs.

The other announcement is that there is now an easy way to find the beach house - in case you get lost in your lunch hour!  Simply go to http://www.siliconbeachhouse.com/map (big thanks to Dave for setting that up).

Another Microsoft Move and Shake

Last night I went down to Little Bay to play a social game of hockey with Andrew which was a ball of fun - it helped that we won!  Interestingly he shared the fact that yesterday Roger Lawrence was appointed Frank's replacement as Group Manager Evangelism (hope I got the title right) in the Microsoft Australia DPE team. 

I had the privilege of co-presenting with Roger back at the 2006 TechEd on enterprise mobility.  The amount of enthusiasm he has for technology, user groups and the community in general is unbelievable and I'm sure we will continue to see fantastic things from this team going forward. 

Welcome Roger!

IceTV User Group Offer!

icetv_rgb_colour

Regular readers of my blog will recall that I posted about my awesome experience with purchasing a Dell and IceTV subscription. Well the great news is that I was so excited I emailed IceTV to see whether I could get other people as excited as I am.  The upshot is that Matt Kozzatz, General Manager for IceTV, has made an off for all .NET user group members to receive 25% off their annual subscription - you need to attend a .NET user group to find out how to take advantage of this fantastic offer.

But the goodness doesn't stop there - Matt has also offered a Free 6 month subscription as a prize for all .NET user groups!  If you attend a .NET user group you will hopefully hear about this offer via your usual mailing list or at a meeting in the coming month or so.

Vista_Guide_Screen

Advanced Graphics with .NET Compact Framework

Building managed applications for Windows Mobile devices that have a rich user interface is almost impossible if you restrict yourself to the primitive controls that ship with the .NET Compact Framework.  Luckily building your own custom controls isn't that difficult.  You typically have to override the painting of the control to render the content the way you want it.  Unfortunately if you want to do some more complex rendering you will still run into problems because the Graphics object that is exposed by the OnPaint event is a significantly reduced subset of the desktop Graphics object.  The main things it misses are the ability to transform (scale, rotate and translate) the graphics.

Lets take an example, say you have a method that draws a cross:

Private Sub DrawCross(ByVal g As Graphics, 
                               ByVal size As Integer)
    g.DrawLine(mForegroundPen, -size, -size, size, size)
    g.DrawLine(mForegroundPen, size, -size, -size, size)
End Sub

As you can see from this method it draws the cross based around the origin.  This is great but the likelihood of you wanting to draw a cross at the origin is virtually 0 since only a quarter of it would be visible.  There are a couple of options in terms of positioning the cross.  Firstly, you can modify the DrawCross method to accept a third parameter that identifies the centre of the cross:

Private Sub DrawCross(ByVal g As Graphics, _
                               ByVal centre As Point, _
                               ByVal size As Integer)
    g.DrawLine(mForegroundPen, centre.X - size, centre.Y - size, _
                                           
centre.X + size, centre.Y + size)
    g.DrawLine(mForegroundPen, centre.X + size, centre.Y - size, _
                                            centre.X - size, centre.Y + size)
End Sub

Now all of a sudden the method has become significantly less readable and you can imagine how it would get if the rendering was more complex than just a cross. The second way to do this, and my preference, is to translate the centre of the graphics canvas.  This way the DrawCross method doesn't change - it still things it's drawing at the origin - just the canvas that you are drawing on does.  A way to visualise this is to imagine a pen suspended in mid air ready to draw a cross on the canvas below it.  What we want to do is reposition the canvas underneath so that when the pen draws the cross, the cross is actually at the required position in the canvas.  When we are done, we have to remember to reset the canvas so that other drawing is done at the right place.  We can do this as follows:

Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
    MyBase.OnPaint(pe)

    Dim g As Graphics = pe.Graphics
   
g.Clear(Me.BackColor)
   
    g.TranslateTransform(Me.Width / 2, Me.Height / 2)
    DrawCross(g, 10)
    g.ResetTransform()
End Sub

As you can see it is clear from here what is going on - we are moving to the centre of the control, drawing the cross with size 10 and then resetting the canvas (just in case other methods are added).

Going back to the original discussion around the .NET Compact Framework you will notice that the TranslateTransform method doesn't exist on the Graphics object.  I'm guessing that part of the reason for this is the lack of support from the underlying rendering engine but here's quite a simple way to get around this issue (be warned though, calculations involved in doing these operations can quickly become CPU intensive which can make your application slow and consume battery power!).  You need to create a wrapper graphics class that is capable of doing the layout changes you want:

Public Class TranformGraphics
    Private mGraphics As Graphics
    Private mMatrix As TMatrix

    Public Sub New(ByVal g As Graphics)
        Me.mGraphics = g
    End Sub

    Public Sub DrawLine(ByVal pen As Pen, ByVal x1 As Integer, _
                                                        ByVal y1 As Integer, _
                                                        ByVal x2 As Integer, _
                                                        ByVal y2 As Integer) 
        Me.mGraphics.DrawLine(pen, ConvertedX(x1, y1), _
                                                ConvertedY(x1, y1), _
                                                ConvertedX(x2, y2), _
                                                ConvertedY(x2, y2))
    End Sub

    Private Function ConvertedX(ByVal x As Integer, _
                                           ByVal y As Integer) As Integer
        If Me.mMatrix Is Nothing Then Return x
        Return CInt(mMatrix.R1C1 * x + mMatrix.R1C2 * y + mMatrix.DX)
    End Function

    Private Function ConvertedY(ByVal x As Integer, _
                                           ByVal y As Integer) As Integer
        If Me.mMatrix Is Nothing Then Return y
        Return CInt(mMatrix.R2C1 * x + mMatrix.R2C2 * y + mMatrix.DY)
    End Function

    Public Sub ResetTransform()
        mMatrix = Nothing
    End Sub

    Public Sub TranslateTransform(ByVal dx As Single, ByVal dy As Single)
        Dim trans As New TMatrix(1, 0, 0, 1, dx, dy)
        If mMatrix Is Nothing Then
            mMatrix = trans
        Else
            mMatrix = mMatrix.Multiply(trans)
        End If
    End Sub
End Class

I've left the implementation of TMatrix to your imagination but the important method that you need to get right is the matrix multiplication:

Public Function Multiply(ByVal M1 As TMatrix) As TMatrix
    Dim M2 As TMatrix = Me

    Return New TMatrix(M2.R1C1 * M1.R1C1 + M2.R1C2 * M1.R2C1, _
                        M2.R1C1 * M1.R1C2 + M2.R1C2 * M1.R2C2, _
                        M2.R2C1 * M1.R1C1 + M2.R2C2 * M1.R2C1, _
                        M2.R2C1 * M1.R1C2 + M2.R2C2 * M1.R2C2, _
                        M2.R1C1 * M1.DX + M2.R1C2 * M1.DY + M2.DX, _
                        M2.R2C1 * M1.DX + M2.R2C2 * M1.DY + M2.DY)
End Function

There might be an easier way to do this with existing classes, so if you come across something please let me know.  Now back to our code - instead of using the Graphics.TranslateTransform (which doesn't exist for the .NET CF), we can now use our newly created TransformGraphics.TranslateTransform:

Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
    MyBase.OnPaint(pe)

    Dim g As new TransformGraphics(pe.Graphics)
   
g.Clear(Me.BackColor)
   
    g.TranslateTransform(Me.Width / 2, Me.Height / 2)
    DrawCross(g, 10)
    g.ResetTransform()
End Sub

Private Sub DrawCross(ByVal g As TransformGraphics, 
                               ByVal size As Integer)
    g.DrawLine(mForegroundPen, -size, -size, size, size)
    g.DrawLine(mForegroundPen, size, -size, -size, size)
End Sub

Note we have still had to modify the DrawCross method so that it accepts a TransformGraphics but overall we haven't really affected the readability of the code.  Please feel free to comment on how you get around the challenges of complex rendering using the .NET Compact Framework!

Australian DPE Team Welcomes (back) a new Member

Yesterday I caught up with Finula Crowe who is currently the Wave 2008 Community Launch Leed for Microsoft. She had some awesome news which is that she is rejoining DPE as Audience Marketing Manager.  In Fin's own words her "passion for Developer, Architect and extended Influencer communities is no secret". There will of course be a transition period over the coming weeks but I expect we will start to see her influence in the way that DPE interacts with the community.

I've always been a big proponent of the way that Microsoft supports the community.  From what I can see the communities surrounding .NET and more recently specific technologies such as SQL Server, Sharepoint and SBS are all very active.  Whilst most of these are now organised and supported by the community itself, it is encouraging to see that Microsoft still believes that they are important.

As the number of user groups and other communities grow the engagement model for DPE has had to evolve. Unfortunately in recent times this has resulted in a number of groups feeling un-loved or under valued.  Hopefully over the coming months we will start to see a new model emerge that will once again provide the much needed support for the user groups in a way that it can scale with the number of groups.

Don't forget to "Ride the Wave" early next year with the launch of Windows Server 2008, SQL Server 2008 and of course Visual Studio 2008.

VB guys can be Zealots too

This morning I heard some devastating news - Bill McCarthy, author of the @Head blog, has been evicted from a community discussion alias for being inflammatory and using derogatory language.  As a courtesy to the VB community Bill has posted his thoughts about VB being the n*gg*r of Microsoft's programming languages

Whilst I can understand that this post could be taken as being culturally insensitive I think this is an over the top reaction, essentially trying to cover up a real issue that the VB community have been fighting for years.  Regardless of what Microsoft says, VB is not given the same level of respect as C#.  This is not to say that the VB product team doesn't do a fantastic job of both innovating with both language and IDE features, because as a long time VB zealot I'm still yet to be convinced to join the dark side... But honestly how many times do you see a framework, best practice guidance or SDK come out that has been done in VB first?

As a plea to Microsoft - please reconsider Bill's involvement with the discussion alias.  His contribution to the alias and the VB.NET community as a whole is too valuable to be lost.

Rockin' End User Experience

Since I moved to Sydney last month I've been without my Media Center setup that I was used to having.  When I got back from Perth a week and a half ago I decided that enough was enough, and went online and purchased a mid-range Dell machine, complete with TV tuner, decent monitor and speakers.  Last week the delivery arrived almost a week earlier than they had initially quoted.  After unpacking all the bits and plugging everything in I had a working Media Center computer - no additional setup required!!!

The only problem came when I went through the setup process for Media Center.  While it could pick up all the TV channels there was of course no Electronic Program Guide for Australia.  I decided to give IceTV a go.  After registering on their website I proceeded to follow their particularly detailed instructions for Vista - this required me to re-scan for the TV channels but other than that it was an incredibly simple process.  Now I'm sitting comfortable knowing that all my favourite shows will be recorded.

Big thumbs up to both Dell and IceTV for just a simple end user experience - I wish that more companies would think about the end user.

What do Victorian .NET SIG attendees and Ben Cousins have in Common?

A: They're both "users" in the eyes of the government....

Ok, so not a great joke but I had to post about this as it is a true sign that political correctness has gone a step too far.  When Victoria .NET was established, the Melbourne .NET User Group and the Australian Developers .NETwork combined and came in under their banner.  For better or worse it was done to help the user groups function, providing venue and funds for them do continue to operate.  However, they decided to change the name to Victoria .NET Dev SIG.  Apparently one of the reasons it wasn't called a "user group" was that it has connotations relating to drug using - go figure huh!

I mentioned this earlier today to a friend of mine and his response was

... so the attendees now wear protective helmets and badges that say they are "special" ...

"Ride the Wave" - Early Event Notification

Microsoft Australia has announced the dates for the "Ride the Wave" (omg not another dreadful marketing slogan) tour.  As most people will be aware Microsoft will be concurrently launching Visual Studio 2008, SQL Server 2008 and Windows Server 2008 early next year.  To support this this tour will visit the following capital cities:

Sydney      February 28, 2008

Melbourne   March 4, 2008

Adelaide     March 13, 2008

Perth         March 19, 2008

Brisbane     March 26, 2008

Canberra    April 2, 2008

Why some C# developers are Zealots!

Today I came across a quote that I couldn't help but blog.  For a while Brian has been running a C# developer site called CSharpZealot and he continually gives me grief about using VB.NET as my primary language.  Other than pointing out that C# is lacking good xml language integration, I tend to avoid this discussion as I find it pointless but this quote provides me with great ammunition for those C# zealots that really want an answer!

"... I think that the real reason that C# fanatics disparage VB.NET is the same reason that religious fanatics disparage other religions; because their beliefs are fundamentally groundless, and they desperately fear that they're really wrong as hell, which they are... "

Sydney Geek Coffee - Wednesdays @ 1pm

Following a growing trend of geek coffee groups Craig and I had the first Sydney geek coffee yesterday at Mecca Espresso Bar (imho some of the best coffee I've had in Sydney to date!).  Craig announced that we would be meeting here and here but we are clearly on the bleeding edge yet again, as we were the only ones to show up. Maybe Sydney just isn't ready for this idea - some other regular coffee groups include:

The next Sydney Geek Coffee will again be at 1pm next Wednesday.  However, the venue has changed to JET (map: http://www.eatability.com.au/au/sydney/jet_cafebar/map.htm)

VS2008 Goodness

Last night I presented at the Perth .NET Community of Practice monthly meeting to quite a full house.  Despite not covering some of the new designer features for WPF, WCF etc or any of the improvements in the web space it seems to have gone down reasonably well.  Well at least, Brian saw some things he liked!

As promised I will be uploading the content to this blog and the Professional Visual Studio website over the coming days.  The overview presentation (with links to some of the relevant downloads) is attached to this post and I have already posted about integrating application manifest files to handle UAC in Vista using both VS2005 and VS2008.

If you have any questions about last night's presentation or any other feature of Visual Studio 2008, please feel free to drop me an email

More Perth Events - ACS IT in the Pub

Following my recent post about Perth IT events, I was asked to help promote the following by Hemal on behalf of the ACS Young IT Committee.  If you are still a student, new to the IT profession or just figure you're young at heart then I would highly recommend attending this event. 

I will like to invite all IT/ICT professionals on behalf of ACS Young IT Committee to our quarterly community IT in the Pub Event. The details of the event are as under:

Event Name: IT in the Pub

Date :  Friday 12 October 2007

Time : Start at 6pm

Venue: Platform Bar, Shop 7 Woodside Plaza, 240 St Georges Terrace

Event Brief: Young IT in conjunction with our sponsors Egton Software Service and Ross would like to invite all ACS Young IT members and guests to "IT in the Pub" at the Platform Bar (http://www.brokenhillhotel.com.au) in Perth City on Friday 12th Oct 2007 @ 6pm.

This social event provides an opportunity for ACS young IT professionals, students and industry representatives to network with each other on a social, business and professional basis. So it’s time to get away from behind those monitors, leave those notebooks and PDA at home, and have a few drinks on us.

Free food and drinks (Beer, Wine and Soft drinks) for the first hour or until the bar tab runs out. Representatives from Ross and Egton Software Service will be present.  This is a "Bring a Friend" initiative.

Attendance is free for ACS Members and they are encouraged to invite 1 friend at no cost, with further friends at the standard $5 fee.

If you would like to attend please register at www.acs.org.au/wa and you stand a  chance to win one of the many door prizes.

Hope to see you there!

Young IT Committee

http://www.acs.org.au/youngit

Sponsored by:

http://www.rossjuliaross.com/

http://www.egtonsoftware.com/

Forget the OBH this Summer, Come visit the SBH!

That's right, despite the wall not coming down last weekend, as we initially had planned, we are going ahead with the official housewarming of the Silicon Beach House.  This will give you the opportunity to see where some of the best software development is happening here in the heart of Perth, not to mention check out the great artwork and mingle with the remaining housemates who haven't been evicted ;-)

Drop by between 4:00 pm and 7:30 pm to see our offices and share a drink with us. Marvel at the view from our balcony. Express your inner geek by sharing your opinion on the virtues of duck typing. Or just stay at home and follow what’s happening via Twitter.

BYO drinks. No RSVP necessary.

Silicon Beach House is on the 2nd floor at 90 King St, Perth.

(actually, I'm going to be there as I'm back in Perth until the 8th October - if you're interested in attending next week's Perth .NET Community of Practice meeting I'm going to be presenting on Visual Studio 2008)

Small Features are Cool Too!

This evening I was taking a look at some of the additional options in the Project Properties dialog in Visual Studio 2008 Beta 2 and noticed that there was an additional dropdown on the Resources page.  The Access Modifier dropdown with options Friend and Public (in conflict with the documentation which states there should also be a No code generation option) allows you to control the accessibility of the project resources.

image

So, how does this look in practice?  Well, assume that this TestResource string resource is defined in a project called ReferencedLibrary. Now to access this resource from within this assembly you would write:

My.Resources.TestResource

To access this resource from another assembly that references this project you would write:

ReferencedLibrary.My.Resources.TestResource

This option requires the Access Modifier property to be set to Public. Not sure if I agree with access modifiers for resources being set at a project level - think I would prefer to see this property set on  a resource by resource basis but hey, this is a small but cool improvement!

More Behavioural Change

By chance I was walking through Crows Nest on Saturday when I noticed what initially looked like a graffitied wall (I've only added the red ellipse):

behavioural change

Although my initial reaction was to keep on walking - honestly, can these guys be serious with a wall painted like that? - but then I noticed the "Driving Behavioural Change" point.  If we look at what Behavioural Intelligence is, over and above traditional Business Intelligence, it is all about instigating and supporting (aka driving) behavioural change within an organisation. 

When I returned home I thought I'd take a look at Change Drivers and sure enough their slogan is "Systems make it possible - people make it happen".  The most important asset in nearly any organisation are the people that run the business.  They are also the most complex of all assets, both financially and operationally, making them the hardest to manage.  Further, unlike machinery, you actually need to motivate them and keep them engaged in the business.  Behavioural Intelligence is more than giving employees the tools to do their job, it's about the provision of accurate and timely information.   This subsequently removes a significant portion of the mundane, often frustrating, parts of their job, allowing them to engage with the business and be proactive. In other words it invokes behavioural change.

If you take a look at the Change Drivers' website you will see an entire section devoted to Driving Change. Whilst Intilecta addresses this challenge in a different way, the site makes a number of interesting points about staff behaviour and driving change within an organisation.

Visual Studio 2008 - Are 3 Pillars Enough?

As some of you will be aware, Dave and myself have embarked on writing the sequel to [VS2005], aptly name Professional Visual Studio 2008, which should be completed early next year.  For the last month or so, while we were waiting for the contracts to be finalised, I have been going through a reviewing process of the chapters from the first edition.  With this now mostly complete it is time to turn our attention to actually writing.  Over the coming months you will see a number of posts relating to Visual Studio across on the Professional Visual Studio website.  This will include things like the table of contents, discussion points that we think the community might be interested in and even some code samples/snippets for you to download.

We have also established a Facebook group through which we are encouraging as much community feedback as possible.  As chapters are completed there will be an opportunity for anyone in this group to access the draft and submit comments/feedback.  There is also rumored to be a prize for most active reviewer! The group is currently hidden so if you want to be involved you will have to "be-friend" me and let me know you are interested in providing feedback.

The rest of this post will appear in due course across at http://www.professionalvisualstudio.com:

In preparation for the release of Visual Studio 2008 Microsoft have been doing a considerable amount of work to make sure their documentation stays in sync with the product.  From past experience the feedback has been that documentation, particularly around new features is essential if Microsoft wants to get good user adoption both prior to and following product release.  To this end there will be updated language specifications for C# and VB.NET, MSDN will be updated to include the new features and there are some additional whitepapers floating around that further discuss some of the features we can expect in Visual Studio 2008.

One such whitepaper is the "An Overview of Microsoft Visual Studio 2008" put together by Tony Goodhew.  In this document it is stated that VS2008 delivers across three primary pillars:

  • Developer Productivity
  • Application Life Cycle
  • Latest Technologies

Reading this I have to pose the question - is this enough to give Microsoft the leading edge when it comes to developer technologies and/or IDEs?  The latter part of this question is easier to answer if you contain yourself to the .NET/Microsoft world.  In this space there is almost no question that Visual Studio is definitely the best option as it closely aligned with where Microsoft sees the future developer trends going. 

Interestingly enough this seems to occasionally backfire, leaving Microsoft on the back foot playing catch up.  For example if you expand the field of vision to the web in general and look at Visual Studio in contrast to other web developer tools there are some significantly limitations.  In VS2005 there was little support for Javascript development, debugging was still a painful process and when compared to Firebug there was clearly no way Visual Studio was playing in the same space.  Back when VS2005 was released this wasn't a significant issue but with the ever growing and dynamic nature of the web, VS2005 is an overweight dinky toy playing in the world's largest super-pit.

When it comes to Application Life Cycle I can see that Microsoft has done considerable work to fix a major shortcoming of Visual Studio.  Now with Visual Studio Team System the ability to collaborate as a team and build a product from design through to deployment is a significant step forward.  Personally I think that the marketing department Microsoft has frustrated companies by breaking VSTS into numerous skus trying to "accommodate" to different types of developers (although the names end up being different, when it comes down to it all the skus are used by developer focused users). imho they should do away with the different role based skus and have standard, professional and universal editions. 

One of the biggest areas that I think isn't highlighted enough is that Visual Studio is more than just a developer IDE.  It is actually a reusable shell that has been refined and is not available to VSIP companies.  Such companies have the option to either integrate their product as an addin or actually reuse the entire shell depending on their requirements.  Of course it's a pity that Microsoft didn't think to reuse this shell for the Expression suite!

Open question: If you were defining the Primary Pillars for Visual Studio 2008, what would they be?