C:\>SRCHARCH.EXE "June, 2008"

Getting System Colors In C#

| June 29th, 2008

*** READ THE COMMENTS! I have been enlightened. :) ***

Maybe it’s just me, but it took me forever to figure out how to set the background color of a control to the “window” color the user has set up in the control panel. 99% of the time this is white but since I’m one of those guys who runs with dark window colors, I was determined not to make that assumption and do things the right way.

Ways you can’t do it:

  • System.Windows.Forms.SystemInformation: You can get a wealth of information from here, including whether or not the user has chosen to always show pull-down menu access key underlines, or only when ALT is held… but no color information. Close, but no cigar.
  • Color.System.: all the other colors live here. I was hoping for a “System…” subsection under here or at least names like “ActiveBorder” intermingled with “hard coded” names (Lemon Chiffon!), but couldn’t find any.
  • Control.DefaultBackColor: So close! This appears to return the 3D face color, but regardless isn’t what I was looking for. I want a big list of all the system colors, not just a one-off.

The Way:

System colors, in C#, are called “known colors.” Once you know this it’s easy to find:

System.Drawing.Color.FromKnownColor(KnownColor.Window);

And, as you’d expect, the KnownColor enumeration contains all of the other user-definable colors (active window border, whatever).

I don’t understand the logic behind calling these colors “known colors.” If anything, Lemon Chiffon is a Known Color (well, OK maybe not to all of us, but to interior decorators at least), and the current window color is Unknown, or at least “user-defined.” But even more perplexing is why C# deviates from calling them “system colors.” In Win32 you’d call GetSysColor() (and truth be told, I almost just pinvoked that). KnownColors is a wart that detracts from the beautiful organization of C# in other places (for example, Process or System.IO.Ports).

If I were running the C# show, I would have put the system colors in with the rest of the system information.

So I’m working on this XNA game and have recently become annoyed with the amount of absolute garbage that appears in the output window. Check this out:

garbage in the output window

The top line is where I start the build, and the bottom line is the first error from the complation. But everything in between is completely useless. Specifically it looks like an echo of the command line for the C# compiler (csc) – the bulk of which is just all the CS files to compile.

That’s annoying, but what’s worse is that when you hit F4 to go to your first error the IDE takes you to this line instead. This morning, after working in c# for almost 3 years, for some reason, I just couldn’t take it anymore.

As it turns out the “magic option” is here:

Magic MSBuild Option

By default the “MSBuild Project Build Output Verbosity” setting is “Minimal,” which for me isn’t nearly minimal enough. Set it to Quiet and behold:

nice and clean output window

I am kind of terrified to see what the “Diagnostic” setting would do to my poor output window.

Enter The Chumby

| June 13th, 2008

Chumby

What the hell is that? It is a Chumby. I won’t tell you what it does, because that’s for you to decide, after looking at the site.

What I will say is that this thing is RAD. Seriously. I got one a few days ago, and it is up there at Tivo levels of awesomeness. Playing with this thing is like seeing the future.

In fact, it has inspired something big. In a closed door top-secret meeting last night, the Cuttlefish Industries board of directors unanimously approved the creation of a spin-off company: the Cuttlefish Technology Procurement Advisory Group (CTPAG), dedicated to testing products from across the globe and showcasing to the consumer only the most righteously awesome.

The Chumby has received a coveted One Star rating from the Cuttlefish Technology Procurement Advisory Group. Since this is the first product to receive such an honor, all subsequent products will be awarded stars (or, more likely, fractions of a star) based on their awesomeness relative to the Chumby.

Content!

| June 11th, 2008

I got to thinking today about how in the late 90s I wrote a lot of stuff online. Back when Y2K was still selling bomb shelters, I had a pretty regular stream of writing going – most notably at gamedev.net, but in the 7 or 8 years since, it’s kind of fallen by the wayside. But, I decided today that letting that happen was a sad thing, and have thus resolved myself towards more active participation in this here “Internet Thing.”

I will christen this re-emergence by giving a shout out to some of my favorite OTHER blogs (in no particular order):

Save this IP! More episodes of C# on Two Beers, more chords, more articles, and more awesomeness in general all coming soon.

HEAT

| June 9th, 2008

So… yeah. When people say it gets REALLY hot here during the summer… they aren’t lying. As Carly puts it: “it feels like a new, horrible planet out here.”

Holy crap I can’t believe I just blogged about the weather! I’m THAT GUY!!

Real content coming soon. Promise!