Archive for the ‘Design’ Category.

Color Image Scale with RGB Values

If you’re a designer, you’re almost certainly interested in color. And if you’re interested in color, you could hardly do better than to pick up a copy of Shigenobu Kobayashi’s Color Image Scale. Fellow designer Kevin Hale has some more of the skinny on this fantastic design resource:

This little red book from Japan is written by Shigenobu Kobayashi, Japan’s leading color psychologist. Over fifteen years ago, he and his team at the Nippon Color & Design Research Institute matched 130 basic colors and over 1,000 color combinations to key image words to help designers express any mood, life-style or taste through color palettes alone.

Kobayashi’s work is particularly awesome because he categorizes three-color combinations along a “soft-to-hard/warm-to-cool” axis and assigns zones of color that match how we respond to the combinations.

This is only a tiny sample of the color combinations Kobayashi categorizes.

ColorImageScaleImage 

The biggest frustration for me has been the fact that the colors are assigned with a “hue/tone” assignment that I’ve never seen anywhere else. Example: One color is “GY/B”, which is a "green-yellow” hue and a “bright” tone. This is understandable, since Kobayashi wrote the book in 1990… long before a world of web design geeks. But I’ve never found a good resource for translating Kobayashi’s colors into RGB values.

So I made one.

The link below is a recreation of the color guide at the beginning of “Color Image Scale”. I scanned in the pages, color corrected as best I could and found the RGB values for each color. It is obviously not a hard-and-fast guide, but I think it’s a good starting place for figuring out how to directly apply the Color Image Scale to your applications or projects. There is a “small” version that comes in at about 1100 x 900 and a larger version that is 1900×1080.

ColorScaleImageRGB 

Larger 1080p resolution version of Color Image Scale RGB values

Hope that helps anyone who has found Color Images Scale as useful as I have.

Adobe Illustrator To XAML Conversion Options

One of the things that I’ve been doing as I was working on my Florida Crime Rate data visualization was finding vector maps of the US and converting them into XAML. Pretty much everything I found that was free was in SVG format, so I would pull that into Adobe Illustrator and then export into XAML using Mike Swanson’s really awesome Adobe Illustrator to XAML export plug-in. But I wanted to take a moment and say why I’m still using this plug-in instead of the default Expression Blend Import for Illustrator.

As a case study, let’s look at an SVG file of the US counties. (You can find a link to the SVG here. Here is the file converted to XAML if you just want to download that and not mess with any of this other stuff. Special thanks to Nathan Yau of Flowing Data and @SimonRegenbogen for helping me find this.)

clip_image001[5]

The SVG is about 1.6 MB, but when I convert it to XAML, it sees a size reduction of about 20-25%.

clip_image001

You’ll notice that the Adobe Illustrator-to-XAML export is about 100 KB smaller than the Expression Blend Illustrator Import. What’s the difference?

  1. AI-to-XAML preserves path layers and grouping – In the native import version, all the paths are imported into a single Canvas. This makes it really hard to isolate paths and work with them individually. The AI export version groups into separate Canvases so that each state is it’s own canvas. Very handy.
  2. AI-to-XAML preserves some metadata – all the paths in the AI-to-XAML version have a comment preceding the path that contains some (not all) of the naming metadata from the SVG file.
  3. AI-to-XAML spaces code out better – Here is a sample of the data from the AI-to-XAML version:
  4. clip_image001[9]
    And here is the same path in the native import.

    clip_image001[7]

    You’ll notice three things: the first is the metadata (already noted). The second is that the export plug-in has spaced the paths to make them easier to read. The third is something you’ll notice if you’ve spent a lot of time working with XAML paths… the point data is spaced out in a way that makes it much more readable.  Overall a much better XAML experience.

  5. AI-to-XAML maintains less path data fidelity – The AI-to-XAML converts to 3 decimal places, while the native import converts to 4 decimal places. But this isn’t necessarily a bad thing. Here is a corner of Sacramento County zoomed in 6400%.
  6. clip_image001[11]

    Now let’s change the path data by a hundredth of a unit, from X=35.366 to X=35.376

    clip_image001[15]

    The difference is almost imperceptible… even at this level of magnification. Changing it by a thousandth of a unit is going to make almost no difference that users will be able to see.

Conclusion: I’m going to continue using Mike Swanson’s Adobe Illustrator to XAML Export plug-in because it is awesome. If you don’t have or can’t afford Adobe Illustrator, the default import isn’t bad, but it is missing a good deal of potentially valuable functionality.

How To Wrap Text in a Silverlight 3 ComboBox

Download ComboBox TextWrapping Tutorial Project

Sometimes you just want stuff to work the way you want it to work. I want a property on the Silverlight ComboBox that says “WrapText”. But alas there is not one, so I have to do it myself.

So your ComboBox looks like this:

and you want it to look like this:

clip_image001[13]

Let’s make that happen.

First, we need to make sure that the DataTemplate is going to act in such a way that it is compatible to having the data inside it wrap.

So… right-click on your ComboBox and go to: “Edit Additional Templates –> Edit Generated Items (Item Template) –> Edit Current”

clip_image001[5]

If that option isn’t available, go to “Create Empty” The DataTemplate in my sample looks like this:

clip_image001[7]

Hopefully, you have the binding information available for your data. If not, check out this post on creating sample data for the purpose of styling things. Make sure all the Widths and Heights (but especially the Widths) are set to “Auto”.

clip_image001[9]

And make sure your TextBox or TextBlock has TextWrapping=”Wrap”

clip_image001[11]

So now your ComboBox wraps in the main section… which is awesome, but you still have this happen when you open up the DropDown (PopUp)

clip_image001[15]

If you want that to wrap as well, the solution isn’t hard so we’ll deal with it here instead of giving it another post.

First,change the HorizontalContentAlignment on the ComboBox to be “Stretch”.

clip_image001[17]

Next, right click on the ComboBox and go to “Edit Additional Templates –> Edit Generated Item Container (ItemContainerStyle) –> Edit a Copy…”

clip_image001[19]

What is happening is that the ItemContainerStyle element is requesting all the space in the world from it’s parent and since the parent with the ultimate authority is a PopUp, it sees no reason to constrict the ItemContainerStyle with irritating constraints, so the text element finds no reason to start wrapping. So, we’re going to tell the ItemContainerStyle that it can only request a certain amount of space. In this particular case, we’re going to set MaxWidth=”200”

clip_image001[21]

And we get this:

finalcomboboxwrapping

And we’re happy.

Or at least I hope we’re happy. If you’re not happy, mention your problem in the comments and I’ll try to get back to you with any tweaks or updates you need.

Flex Anchored Layout in Silverlight

When I started using Silverlight, I was moving over from Flex, and the first thing I noticed was: Where is my anchored positioning?

In some cases using a table (Grid) for a layout is not ideal, and if your moving over from Flex like I did, you may want to have something you’re familiar with. This post walks though how to simulate anchored layout in Sliverlight, using a single cell and applying alignment and margin properties to its elements.

The following example, built in Silverlight, illustrates the types of anchored positioning:

Example screen normal size

Example screen normal size

Example screen stretched

Example screen stretched

Here is the XAML for the layout of the screen above.

XAML for screen

XAML for screen

One Cell, Many Possibilities

As you can see from the screenshots above, as the page is stretched, the elements stretch and retain their positions also. Normally this type of layout in Silverlight would require a Grid with 3 columns and 3 rows, and you would have to add the definitions for them as well as set the column and row properties for each element inside the Grid. To simplify how the page is layed out, only a single cell is needed, and instead the HorizonalAlignment, VerticalAlignment, and Margins are adjusted. A nice side effect of this type of layout, is the XAML used is significantly reduced. I’ll go through each element in turn and explain how it’s layout is simulated from Flex. On the left side of each explanation is the constraints as would be defined in Flex.

Header

Flex layout constraints for Header

Flex layout constraints for Header

     

The header of the page stays at the top and stretches left and right. In Flex a top, left, and right position for the Header would have been set. In Silverlight, the header of the page is anchored to the top using a VerticalAlignment of Top, and then stretches both left and right by using a HorizontalAlignment of Stretch. A fixed Height is set, and a left Margin of 100 is applied.


<Border Background=”Red” Height=”50″ VerticalAlignment=”Top” HorizontalAlignment=”Stretch” Margin=”100,0,0,0″>
<TextBlock Text=”Header” Style=”{StaticResource Number}” />
</Border>

Navigation

Flex layout constraints for Navigation

Flex layout constraints for Navigation

     

The navigation pane on the page stays vertically centered on the left. In Flex, the verticalCenter and left positions would be set for the Navigation. In Silverlight, VerticalAlignment is set to Stretch, and HorizontalAlignment is set to Left, with a fixed Height applied to the element.



<Border Background=”Green” Width=”80″ Height=”200″ VerticalAlignment=”Stretch” HorizontalAlignment=”Left”>
<TextBlock Text=”Navigation” Style=”{StaticResource Number}” />
</Border>

Body

Body layout constraints in Flex

Body layout constraints in Flex

     

The body of the page stretches in all directions while still leaving room for the other elements. In Flex, top, left, right, and bottom positions would be set. In Silverlight, a VerticalAlignment and HorizontalAlignment of Stretch is set, as well as Margins on all sides.



<Border Background=”Orange” VerticalAlignment=”Stretch” HorizontalAlignment=”Stretch” Margin=”100,80,80,80″>
<TextBlock Text=”Body” Style=”{StaticResource Number}” />
</Border>

Buttons

Flex layout constraints for Buttons

Flex layout constraints for Buttons

     

The buttons on the page are centered horizontally on the bottom. In Flex, the positions of bottom and right would be set. In Silverlight, VerticalAlignment is set to Bottom, and HorizonalAlignment is set to Center with a fixed Width and Height on the element.



<Border Background=”Blue” Width=”200″ Height=”60″ VerticalAlignment=”Bottom” HorizontalAlignment=”Stretch”>
<TextBlock Text=”Buttons” Style=”{StaticResource Number}” />
</Border>

Page

Flex layout constraints for Page

Flex layout constraints for Page

     

The page number is in the bottom right of the page. In Flex, a position on the bottom and right would be set. In Silverlight, VerticalAlignment is set to Bottom, and HorizontalAlignment is set to Right, with a fixed Width and Height applied to the element.



<Border Background=”Purple” Width=”80″ Height=”60″ VerticalAlignment=”Bottom” HorizontalAlignment=”Right”>
<TextBlock Text=”Page” Style=”{StaticResource Number}” />
</Border>

Summary

The use of the Grid layout can be simplified and simulate Flex anchored layout by only using a single cell, and applying alignments with margins. Standard absolution positioning can also be achieved within a single cell grid by applying a VerticalAlignment of Top, a HorizontalAlignment of Left, and then using left and top margins for x and y respectively. The translation from Flex anchored layout to Silverlight can be summarized by the table below:

 Description 

 Flex 

 Silverlight 

Top left position top, left VerticalAlignment=Top, HorizontalAlignment=Left
Bottom right position bottom, right VerticalAlignment=Bottom, HorizontalAlignment=Right
Center horizontally center HorizontalAlignment=Center
Center vertically verticalCenter VerticalAlignment=Center
Stretch horizontally left, right HorizontalAlignment=Stretch
Stretch vertically top, bottom VerticalAlignment=Stretch

Silverlight Color Picker

UPDATE: I’ve posted links to all my code here.

I apologize, but I don’t have the time right now to go over how I made this, but I did want to take the time to show it off.

Copy the following to paste this app into web page: