I use C #, wpf and mvvm.
In my datagrid, each row has a ListBox in the last cell with documents associated with this row, which I call the period.
The user can add documents to each period.
I want to display a file type icon (16x16) and the name of the document for each document.
The file type icon gives me a little headache.
I am not sure that I have to save every type of document file, for example .DOC in the database, because the day can have 10 periods, each of which has 2 .DOC files, so I save 20 icons in the database, which are 19 times redundant ...
Most of the things that my user will attach are Office file types such as .xls, .doc, .pdf, images, zip / rar, which I think.
Another, but technically more advanced, will be to save a unique file type icon as a base-64 encoded string in an XML file with a file type extension as a key / value pair.
xml is loaded once in the dictionary once upon application launch
<FileTypes>
<Extension ext="doc" base64string="ff5598sdfusd98fjs9df98sd9f" />
<Extension ext="docx" base64string="ff5498sdfusd98fjs9df98sd9f" />
<Extension ext="xls" base64string="ff9548sdfdsfdfusd98fjs9df98sd9f" />
<Extension ext="xlsx" base64string="ff98sfdfddfusd98fjs9df98sd9f" />
<Extension ext="pdf" base64string="ff98fdfdsdfusd98fjs9df98sd9f" />
<Extension ext="zip" base64string="ff98dfdfsdfusd98fjs9df98sd9f" />
<Extension ext="rar" base64string="fffdf98sdfusd98fjs9df98sd9f" />
</FileTypes>
Each time a document exits the database, I check the file extension in the file name and retrieve the dictionary to get the base64 string for the file. I could still somehow implement the caching mechanism for a string like base64, so I don't decrypt them every time I get a .doc file ...
Maybe yours is completely different / best? idea, please let me know or make suggestions about the advantages / disadvantages of saving the database / xml :)