Windows CE – building a transparent picturebox

Surprise!  PictureBox in Windows CE doesn’t support transparency.

Diving into yet another old forgotten corner of the .NET compact framework.

And just in case the mention of Compact Framework hasn’t scared you to death, today’s code will be in Visual Basic .NET

 

Imports System.Drawing.Imaging
Imports System.ComponentModel

Public Class TransparentPictureBox
    Inherits PictureBox

    Private _transparentColor As Color = Color.White
    Public Property TransparentColor() As Color
        Get
            Return _transparentColor
        End Get
        Set(ByVal value As Color)
            _transparentColor = value
        End Set
    End Property

    Protected Overloads Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

        If Not Me.Image Is Nothing Then
            Dim pictureBounds As New Rectangle(0, 0, Me.Width, Me.Height)
            Dim imageBounds As New Rectangle(0, 0, Me.Image.Width, Me.Image.Height)
            Dim attributes As New ImageAttributes()
            ' set color to be set to transparent - if you don't paint the background below, then these pixels
            ' will appear black
            attributes.SetColorKey(Me.TransparentColor, Me.TransparentColor)
            e.Graphics.DrawImage(Me.Image, pictureBounds, imageBounds.X, imageBounds.Y, imageBounds.Width, imageBounds.Height, GraphicsUnit.Pixel, attributes)
        End If

    End Sub

    Protected Overloads Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
        ' paint background color
        Dim brush As SolidBrush
        brush = New SolidBrush(Me.Parent.BackColor)
        e.Graphics.FillRectangle(brush, Me.ClientRectangle)
    End Sub

End Class

XP vs. Scrum

This question comes up a lot when people have heard both buzzwords and have trouble working out which one is better for them.

One good chart I found is this one:

http://jamesshore.com/Blog/Scrum-XP-Practices-Cross-Reference.html

My attempt to answer this question:

XP is

  • Agile methodology driven by developers
  • with many prescribed engineering practices

Scrum is

  • Agile methodology driven by management
  • Simpler framework where engineering isn’t prescribed
  • Trust team to do what they need to do
  • Can evolve overtime and take on many XP practices incrementally

VirtualBox – actually quite nice

I actually learn of VirtualBox via Twitter.

That’s one of the things I realize from Twitter – people talk about things they like.  One person says it…  Then a couple of months later you hear another one that has something nice to say.  Then you hear from a third guy.

Word of Mouth advertising.  It works.

What is VirtualBox – why do I need this?

VirtualBox is Sun/Oracle’s virtualization host. 

 

  • It is free for personal use.
  • It can host x64 (better than Virtual PC)
  • It can understand both VMDK and VHD formats (beats Virtual PC or VMWare)
  • It is faster than Virtual PC
  • You can create new VM with VirtualBox (beats VMWare Player)

 

 

How does it compare with other offerings?

Here’s a totally unscientific chart based on my understanding:

  Free x64 client OS Create VM Virtual HD Neeed Speeed
Virtual PC Yes No Yes VHD Sluggish
Virtual Box Yes Yes Yes VHD
VMDK
No
VMWare Workstation No Yes Yes VMDK No
VMWare Player Yes Yes No VMDK No
Hyper-V No
(Win Server x64)
Yes Yes VHD No
Boot to VHD Yes (Win7) Yes No VHD Fastest

 

Anyway, VirtualBox and Boot to VHD are my two picks.

Always blog it if you had to write anything down

Martin said something recently in an email that really echoed with what I think.

Always blog it if you had to do it… it serves as both a reminder to yourself and helps others..

It reminded me why I started ranting on a blog.  If anything, my own goals for starting a blog was never a noble crusade to help other people.  I did it primarily to help myself find something that I’ve found… and then add my own additional comments.  But hey – it’s public enough, and if it helps anybody out there that’s nice - I’m not complaining.

 

Thanks Martin, for the reminder to blog more.  There’s always words, always drafts sitting in my Windows Live Writer….  one day I’ll get through all this and hit the publish all button.