Another Microsoft Move and Shake

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 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

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

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

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

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?

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

"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!

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

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)

SQL Server Compact Edition – Getting Started

SQL Server Compact Edition – Getting Started

Here are a couple of relatively intersting “getting started” links for SQL Server Compact Edition:


VS2008 Goodness

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

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/