I am making an OOB application that is to become a picture viewer that will show all images from the local disk.
I can do this using the scripting object and i am capable of showing all the images (limited of course to the types of images that silverlight can visualize)
But the problem is that it is very slow! ( 150 images of average size takes minutes)
If you set the image source in the tiles to a "Path", the tile view control will load the images extremely fast. But when the images have to be loaded from the local drive it is not possible to use a Path (even SL5 will not show images with a local path... at least not in the beta).
So in this case i need to load the images from the drive and then set the source to loaded image:
Even though this works, it is extremely slow... because all the images must be loaded in memory.
My question now is... is there a way that i can make the RadTileView load these images "on demand", so that the image is only loaded when it is shown for the first time?
I can do this using the scripting object and i am capable of showing all the images (limited of course to the types of images that silverlight can visualize)
But the problem is that it is very slow! ( 150 images of average size takes minutes)
If you set the image source in the tiles to a "Path", the tile view control will load the images extremely fast. But when the images have to be loaded from the local drive it is not possible to use a Path (even SL5 will not show images with a local path... at least not in the beta).
So in this case i need to load the images from the drive and then set the source to loaded image:
dynamic fileSystem = AutomationFactory.CreateObject("Scripting.FileSystemObject");
var BinaryStream = AutomationFactory.CreateObject("ADODB.Stream");
BinaryStream.Type = 1;
dynamic files = fileSystem.GetFolder(string.Format(@"{0}", path)).Files;
int counter = 0;
int totalfiles = files.Count;
foreach (var file in files)
{
if (file.Type.ToLower().Contains("png") || file.Type.ToLower().Contains("jpeg"))
{
BinaryStream.Open();
BinaryStream.LoadFromFile(file.Path);
byte[] ReadBinaryFile = BinaryStream.Read();
BinaryStream.Close();
BitmapImage bmp = HelperClasses.ImageHelper.LoadImage(ReadBinaryFile);
_photosbeforesort.Add(new Photo() { Id = file.Path, Description = file.Name, Image = bmp, Author=null, CreationDate = DateTime.Parse(file.DateCreated.ToString()) });
}
}
}
Even though this works, it is extremely slow... because all the images must be loaded in memory.
My question now is... is there a way that i can make the RadTileView load these images "on demand", so that the image is only loaded when it is shown for the first time?