IsolatedStorage to save window position (
Window.Left) of my WPF application using this kind of approach.
Now I want to save, always in the IsolatedStorage, a
Brush. It can be a
SolidColorBrush or a
LinearGradientBrush based on user choice.
SolidColorBrush I can just save the 3 values of RGB Color, but how treat a
I think it's possible to serialize a
Brush object, but I'm really stuck.
Now my question is: It's possible to save Brush in an
I chose to use
IsolatedStorage because my application needs to be a single exe, without installation ( it's distribuited to client with a custom software distribution program), usually executed from the desktop. The application give to user with right credentials informations about Active Directory Users.
Any other solution provided to save user customizations is welcome!
Brush and other semi-native drawing object are not serializable. So you will not be able to store them in any persistent or out-of-process storage.
Since it looks like you have limited set of objects it should be easy to get all properties and store them by hand. Creating serializable helper/wrapper classes that can be stored in a Stream and act as factory for corresponding type may be an option.
First, I wouldn't use IsolatedStorage, but user-scoped settings to store this kind of information. Second, if you can't serialize the brush, you could save whatever information the user enters in order to choose or create the brush: if they just choose a brush from existing resources, save those resources' keys, if they can enter rgb values to choose a color, save the rgb values, and whatever they do to define a LinearGradientBrush, just save their input values.