1 minute read

Let's assume that you have a paint application.  A user can draw, modify pictures, save it, retrieve it back and even share it.  Now with such an application, you would want to enhance the user experience by allowing him customize the user-interface.  So user changes the background color, fonts, etc and closes the application.

Next day, he opens the application and he expects that his settings are saved.  You would definitely use IsolatedStorage to save his data in a local XML file.  And then, apply the colors, fonts to the UI.  Here's where you need a Color Reflector that converts a color (in a String format) to a Color (as in Enum)

So, here you go for the ColorReflector

[sourcecode language='c#']

using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;

namespace OptimaX.WP7.Formatters
{
public class ColorReflector
{
public static Color FromKnownColor(string colorName)
{
Line lne = (Line)XamlReader.Load(" ");
return (Color)lne.Fill.GetValue(SolidColorBrush.ColorProperty);
}
}
}

[/sourcecode]

What is OptimaX.WP7?  That is my own-framework with all utilities/tools for Windows Phone 7