1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| using System;
using System.Xml.Serialization;
using System.Windows.Media;
using System.Collections;
namespace Toto
{
[XmlRoot("thumbnailsCache")]
[XmlInclude(typeof(ImageSource))]
public class ThumbnailsCache
{
ArrayList cacheList;
/// <summary>
/// Constructeur par défaut
/// </summary>
public ThumbnailsCache()
{
cacheList = new ArrayList();
}
/// <summary>
/// Ajout d'un Thumbnail à liste
/// </summary>
/// <param name="th">La Thumbnail</param>
/// <returns></returns>
public int AddThumb(Thumbnail th)
{
return cacheList.Add(th);
}
/// <summary>
/// Tableau[] permettant la sérialisation, il est la "copie" de ArrayList cacheList;
/// </summary>
[XmlElement("thumbnail")]
public Thumbnail[] Thumbnails
{
get
{
Thumbnail[] thumbs = new Thumbnail[cacheList.Count];
cacheList.CopyTo(thumbs);
return thumbs;
}
set
{
if (value == null) return;
Thumbnail[] thumbs = (Thumbnail[])value;
cacheList.Clear();
foreach (Thumbnail th in thumbs)
cacheList.Add(th);
}
}
}
/// <summary>
/// Classé utilisé pour le cache des icones
/// </summary>
public class Thumbnail
{
/// <summary>
/// Le chemin du fichier
/// </summary>
[XmlAttribute("path")]
public String path;
/// <summary>
/// Image du document ImageSource
/// </summary>
[XmlElement("icon")]
public ImageSource image;
/// <summary>
/// Constructeur par défaut
/// </summary>
public Thumbnail() { }
/// <summary>
/// Constructeur
/// </summary>
/// <param name="_path">Le chemin</param>
/// <param name="_img">L'image</param>
public Thumbnail(String _path, ImageSource _img)
{
path = _path;
image = _img;
}
}
} |
Partager