1) In the GUI preload all the resource icons and then on state change I change the image object to show the new icon
1a) Do this dynamically so I only load icons I need (LazyLoad)
2) Keep everything in the BO and have a bindable byte[] stream property? Then I would maybe LazyLoad the icons as I need them from the assembly into a dictionary type collection so I can just return the ones I need? I would keep the dictionary/collection of icons in the BOList parent. I saw Sergey's blog post about databinding to a byte[] property to show images in Silverlight
2a) Same idea but load all my icons up front
As long as you are talking WPF/SL and fixed set of images, my
vote be:
1.
Keep images in resource file
2.
Have a flag in BO (such as enum /int to indicate what state a BO
is in)
3.
Use IValueConverter to translate BO flag into an image from
resource file. You can also cache icons in value converter to optimize access.
This way you are keeping UI from BO and can still use standard
XAML binding to show images by binding to a flag from BO with a converter.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: Jack
[mailto:cslanet@lhotka.net]
Sent: Wednesday, January 21, 2009 9:24 AM
To: Sergey Barskiy
Subject: [CSLA .NET] Managing resource (images) /w a BO framework
As I start to tie in my UI to
my first set of CSLA BO classes I'm wondering how best to handle the set of
icons I want to show for different data states. I have a number of flags
that indicate to the user the state of their data (Invalid, Missing, Corrected,
Edited, HasAuditTrail, etc).
From a GUI perspective the users can click on the icon and 'do stuff' based on
the current state.
Anyhow its previous life the application GUI had all the icons placed on top of
each other and some logic in the visible property to hide/show them.
I'd like to be a little cleaner this time but I was wondering which way other
people were doing this type of thing. Currently I have an enum of states
for each icon set that basically each state would match an icon filename.
In the GUI I'm displaying a collection of these objects so each row can have
the same set of icons. My GUI's are Silverlight/ASP and WPF (at
somepoint)
I thought of a couple of options:
1) In the GUI preload all the resource icons and then on
state change I change the image object to show the new icon
1a) Do this dynamically so I only load icons I need (LazyLoad)
2) Keep everything in the BO and have a bindable byte[] stream property? Then I
would maybe LazyLoad the icons as I need them from the assembly into a
dictionary type collection so I can just return the ones I need? I would
keep the dictionary/collection of icons in the BOList parent. I saw
Sergey's blog post about databinding to a byte[] property to show images in
Silverlight
2a) Same idea but load all my icons up front
Any direction would be appreciated
thanks
jack
3)
Copyright (c) Marimer LLC