Click here to Skip to main content
15,903,362 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: How to load only needed images? Pin
Eslam Afifi12-Mar-09 12:27
Eslam Afifi12-Mar-09 12:27 
GeneralRe: How to load only needed images? Pin
S.a.n.4.e.s12-Mar-09 19:18
S.a.n.4.e.s12-Mar-09 19:18 
GeneralRe: How to load only needed images? [modified] Pin
Eslam Afifi13-Mar-09 2:53
Eslam Afifi13-Mar-09 2:53 
AnswerRe: How to load only needed images? Pin
Luc Pattyn12-Mar-09 13:29
sitebuilderLuc Pattyn12-Mar-09 13:29 
GeneralRe: How to load only needed images? Pin
S.a.n.4.e.s12-Mar-09 20:30
S.a.n.4.e.s12-Mar-09 20:30 
GeneralRe: How to load only needed images? Pin
Luc Pattyn13-Mar-09 2:14
sitebuilderLuc Pattyn13-Mar-09 2:14 
GeneralRe: How to load only needed images? Pin
Luc Pattyn13-Mar-09 2:19
sitebuilderLuc Pattyn13-Mar-09 2:19 
GeneralRe: How to load only needed images? [modified] Pin
S.a.n.4.e.s14-Mar-09 0:10
S.a.n.4.e.s14-Mar-09 0:10 
<blockquote class="FQ"><div class="FQA">Luc Pattyn wrote:</div> S.a.n.4.e.s wrote:
i assume that all the images are cached on load



not sure what you mean.</blockquote>

I mean, that all the collection of images, binded to ListView, are loading on startup. I use a single thread, don't use network or database, i simple get *.jpg files from some directory on one of my disks.

There's my code.
XAML:
<pre>
<usercontrol.resources>
<objectdataprovider x:name="PhotosODP" x:key="MyPhotos" objecttype="{x:Type l:PhotoList}" xmlns:x="#unknown" />
<l:uritoimageconverter x:key="LocalUriToImageConverter" xmlns:x="#unknown" xmlns:l="#unknown" />
<DataTemplate DataType="{x:Type l:Photo}">
<Grid VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
<Border Background="#FF562100" Padding="4" BorderThickness="1">
<StackPanel Width="{Binding ElementName=Zoomer, Path=Value}" Margin="5" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
<Image Source="{Binding Source, Converter={StaticResource LocalUriToImageConverter}}" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"/>
<Label Foreground="White" Content="{Binding FileName}" />
</StackPanel>
</Border>
</Grid>
</DataTemplate>
</usercontrol.resources>
</pre>

And C# class, that makes a collection:
<pre>
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Media.Imaging;

namespace Components
{
public class Photo
{
public Photo(string path)
{
_source = path;
_name = path.Substring(path.LastIndexOf("\\") + 1);
}

public override string ToString()
{
return Source;
}

private string _source;
public string Source { get { return _source; } }
//my
private string _name;
public string FileName { get { return _name; } }
//



}

public class PhotoList : ObservableCollection<photo>
{
public PhotoList() { }

public PhotoList(string path) : this(new DirectoryInfo(path)) { }

public PhotoList(DirectoryInfo directory)
{
_directory = directory;
Update();
}

public string Path
{
set
{
_directory = new DirectoryInfo(value);
Update();
}
get { return _directory.FullName; }
}

public DirectoryInfo Directory
{
set
{
_directory = value;
Update();
}
get { return _directory; }
}

private void Update()
{
foreach (FileInfo f in _directory.GetFiles("*.jpg"))
{
Add(new Photo(f.FullName));
}
}

DirectoryInfo _directory;
}

}
</photo></pre>
And an event of an app, on which load of images starts:
<pre>
private void UserControl_Initialized(object sender, EventArgs e)
{
photos = (PhotoList)(this.Resources["MyPhotos"] as ObjectDataProvider).Data;
photos.Path = path;
}
</pre>

modified on Saturday, March 14, 2009 6:57 AM
QuestionStoring Signature in sql server database Pin
vsaratkar12-Mar-09 5:45
vsaratkar12-Mar-09 5:45 
AnswerRe: Storing Signature in sql server database Pin
Eslam Afifi12-Mar-09 13:00
Eslam Afifi12-Mar-09 13:00 
GeneralRe: Storing Signature in sql server database Pin
vsaratkar13-Mar-09 2:13
vsaratkar13-Mar-09 2:13 
GeneralRe: Storing Signature in sql server database Pin
Eslam Afifi13-Mar-09 2:58
Eslam Afifi13-Mar-09 2:58 
GeneralRe: Storing Signature in sql server database Pin
AndyTexas22-Jun-09 6:08
AndyTexas22-Jun-09 6:08 
GeneralRe: Storing Signature in sql server database Pin
Eslam Afifi22-Jun-09 12:24
Eslam Afifi22-Jun-09 12:24 
QuestionWPF Tween Library Pin
emptythetill12-Mar-09 1:56
emptythetill12-Mar-09 1:56 
AnswerRe: WPF Tween Library Pin
Pete O'Hanlon12-Mar-09 2:25
mvePete O'Hanlon12-Mar-09 2:25 
GeneralRe: WPF Tween Library Pin
emptythetill13-Mar-09 2:50
emptythetill13-Mar-09 2:50 
QuestionWorking with 3D models created in Blender Pin
Etienne_12312-Mar-09 0:11
Etienne_12312-Mar-09 0:11 
AnswerRe: Working with 3D models created in Blender Pin
Pete O'Hanlon12-Mar-09 0:27
mvePete O'Hanlon12-Mar-09 0:27 
QuestionWPF: How to make resizing custom datagrid column? [modified] Pin
MichalDawn11-Mar-09 22:58
MichalDawn11-Mar-09 22:58 
AnswerRe: WPF: How to make resizing custom datagrid column? Pin
ABitSmart11-Mar-09 23:40
ABitSmart11-Mar-09 23:40 
GeneralRe: WPF: How to make resizing custom datagrid column? Pin
MichalDawn11-Mar-09 23:51
MichalDawn11-Mar-09 23:51 
GeneralRe: WPF: How to make resizing custom datagrid column? Pin
ABitSmart11-Mar-09 23:53
ABitSmart11-Mar-09 23:53 
GeneralRe: WPF: How to make resizing custom datagrid column? [modified] Pin
MichalDawn12-Mar-09 0:02
MichalDawn12-Mar-09 0:02 
QuestionHow to render pixels of a bitmap correctly? Pin
Andy@11-Mar-09 5:03
Andy@11-Mar-09 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.