Wednesday, February 23, 2011

VB.NET -- Checkerboard in PictureBox

    Private Sub CheckerBoard()
 
        Dim rect As New Rectangle
 
        ' create a Graphics object to draw into it
        Dim pbox As Graphics = PictureBox1.CreateGraphics
        mSquWidth = PictureBox1.Width / CDbl(mCols)
        mSquHeight = PictureBox1.Height / CDbl(mRows)
        rect.Width = mSquWidth
        rect.Height = mSquHeight
 
        Dim r, c
        For r = 0 To mRows - 1
            For c = 0 To mCols - 1
                If ((r + c) Mod 2) = 0 Then
                    ' create a Graphics object to draw into it
                    pbox.FillRectangle(Brushes.Azure, rect)
                    pbox.DrawRectangle(Pens.Pink, rect)
                Else
                    pbox.FillRectangle(Brushes.BlueViolet, rect)
                    pbox.DrawRectangle(Pens.Red, rect)
                End If
                rect.X = c * mSquWidth
                rect.Y = r * mSquHeight
                ' create a Graphics object to draw into it
                pbox.FillRectangle(Brushes.BlueViolet, rect)
                pbox.DrawRectangle(Pens.Red, rect)
            Next
        Next
 
    End Sub
 

Tuesday, February 22, 2011

All She Wrote

Maybe I'll get a little time to review the books I've been reading lately.
  • The Edge of Physics by Anil Ananthaswamy
  • Self Comes to Mind by Antonio Damasio
  • A Walk in the Woods by Bill Bryson
  • Switch by Dan Health
  • Getting Organized in the Google Era by Douglas Merrill, James Martin
  • Spark by John J. Ratey
  • Matterhorn by Karl Marlantes
  • 101 Theory Drive by Terry McDermott
  • Sleight of Mind by Stephen L. Macknik, Susan Martinez

Real Estate and Financials

Interesting, stocks making new highs are REIT, Insurance Companies and other financials including RE, CBL, AIZ, MAC and UDR.  Insurance companies have to invest their reserves somewhere safe.

Something Old, Something New

The chunky 4GL math library creates console applications with very little GUI grace. The solution to the quagmire came in the form of .NET wrapper around the console application. All the niceties of a modern GUI with the number crunching under the hood.

Being that the 4GL is strictly single threaded, a few tricks were needed in order to accommodate the inter process communication. Since the wrapper had no way to directly initial a dialog, the 4GL had to instigate the handshake.

Initially I established a channel using a network socket, low level stuff.  I found it more responsive and robust to cheat a little.  I set off a system file watcher thread from the .NET wrapper and created event handlers for the various types of files it discovered.

Phil Windley

Phil Windley does a great service in promoting technology and ideas via the IT Conversations web site. Find out more about him:

Phil Windley
IT Conversations

Go!

IT Conversations had guest Rob Pike describe the reasoning behind the Go programming language.

audio clip

Monday, February 21, 2011

Umbraco or Bust

When Install the Umbraco CMS via WebMatrix I had to change my security setting to "SQL Server and Windows Authentication mode".

What's IT Cool

What is IT cool?  IT cool is Dependency Injection, Silverlight, HTML5, Singletons, Fluent Interface, Test Driven Development, Refactoring, jQuery, Ruby on Rails, and we haven’t even reached the acronyms, MVC, MVVM, WCF, WPF, ORM,...

Of course, you need the right mix of languages.  Start with an interpreted scripting base like Perl or  now a days Ruby, then throw in the compiled language C#, Java or whatnot.  And don’t forget the web languages; JavaScript and PHP.

Sunday, February 13, 2011

Color Palette

The color palette was a little tricky, when using the Forms.ColorDiaplog control and custom colors.  The custom color list must be integer, but you can't use the color.toargb.  The work around is

dim intColor = Microsoft.VisualBasic.RGB(color.R, color.G,color.B).ToString 

for each color in the custom list.  I'm not sure if the list is fixed at 16 colors, but when I assign custom color to a list of 50 colors the dialog only displays 16 custom color.  In addition, the return color list is only 16 colors.

It helps to read up a bit on the Windows Color Model.

Another pitfall was attempting to turn the custom color integer list back into windows colors.  You will be tempted to use the obvious

c = Color.FromArgb(intarr(idx))
routine, but no, you must use

c = System.Drawing.
ColorTranslator.FromOle(intarr(idx))