From: Simon [2610] on 21 Jun 2010 13:53 Hi, Im building an application to use instead of the explorer thumbnail view. Lets say i have a folder with 2500 images, and at any given time i can show 25 images at thumbnail size on my screen. I have a control (PictureControl, PC) on which i have a picturebox to display the individual images, and a label for the name. Ive loaded all theese 2500 controls onto a FlowLayoutPanel. Now i want an event to fire when i scroll and a PC becomes visible, so that i can load the image then, and when it leaves the visible area i can unload the image. so that i use a minimal amount of memory. I thought the visiblechanged event was what i needed, but they are always visible :/ I am building this because im getting tired of waiting for windows to finish producing the thumbnails when i view a folder, and have found no way to force windows to load all the thumbnails without me scrolling down and looking at them (and even then it can seem like its stalling). Now, i have thought of an alternate way, if i can get the percentage position (or something like that) of the scroll bar, i can calculate what is and what isnt visible... but i would rather the application to tell my controls which are visible to the user and which arent. anyone got a solution for that one? ive searched the web without any luck, but perhaps im searching for the wrong things? Regards Simon.
From: Peter Duniho on 22 Jun 2010 00:34 Simon [2610] wrote: > Hi, > > Im building an application to use instead of the explorer thumbnail > view. > Lets say i have a folder with 2500 images, and at any given time i can > show 25 images at thumbnail size on my screen. I have a control > (PictureControl, PC) on which i have a picturebox to display the > individual images, and a label for the name. > Ive loaded all theese 2500 controls onto a FlowLayoutPanel. > Now i want an event to fire when i scroll and a PC becomes visible, so > that i can load the image then, and when it leaves the visible area i > can unload the image. so that i use a minimal amount of memory. > I thought the visiblechanged event was what i needed, but they are > always visible :/ As you've found, the Visible property has nothing to do with clipping. It's simply a question of whether the control is shown when it's scrolled to an unclipped position on the screen. > I am building this because im getting tired of waiting for windows to > finish producing the thumbnails when i view a folder, and have found > no way to force windows to load all the thumbnails without me > scrolling down and looking at them (and even then it can seem like its > stalling). For what it's worth, it seems to me that if you delay loading of the thumbnails until the item is visible on the screen, you would run into the same behavior Windows already has and which you don't like. > Now, i have thought of an alternate way, if i can get the percentage > position (or something like that) of the scroll bar, i can calculate > what is and what isnt visible... but i would rather the application to > tell my controls which are visible to the user and which arent. > > anyone got a solution for that one? ive searched the web without any > luck, but perhaps im searching for the wrong things? The best approach for what you're doing is to use the ListView control, which supports a "virtual mode". In that mode, you have to respond to certain events that allow you to manage a cache of items and provide just the items that are actually visible. If that doesn't provide enough control for your needs, you'll probably have to implement a custom control yourself that does the management of the thumbnails in the way you want. The ListView control is pretty flexible so if it can't do what you want, there's probably nothing else in the stock Forms controls that will. (WPF might have something similar that works differently/better-suited to your needs, but I don't know as much about that). Pete
From: Tim Roberts on 22 Jun 2010 00:50 "Simon [2610]" <djurhus(a)gmail.com> wrote: > >Im building an application to use instead of the explorer thumbnail >view. >Lets say i have a folder with 2500 images, and at any given time i can >show 25 images at thumbnail size on my screen. I have a control >(PictureControl, PC) on which i have a picturebox to display the >individual images, and a label for the name. >Ive loaded all theese 2500 controls onto a FlowLayoutPanel. >Now i want an event to fire when i scroll and a PC becomes visible, so >that i can load the image then, and when it leaves the visible area i >can unload the image. so that i use a minimal amount of memory. That's a false optimization. 2500 thumbnails at 64x64 true color totals only 30 megabytes of memory. Absolutely trivial. >I thought the visiblechanged event was what i needed, but they are >always visible :/ Really, the whole point of a FlowLayoutPanel is that you don't have to worry about when controls come and go. You might consider using a different kind of container, where you can intercept the scroll operations and update the images manually. >I am building this because im getting tired of waiting for windows to >finish producing the thumbnails when i view a folder, and have found >no way to force windows to load all the thumbnails without me >scrolling down and looking at them (and even then it can seem like its >stalling). Well, you only pay that penalty the first time, until it builds the thumbnail database. Are you sure you can build the thumbnails faster? It takes time to read a large image file. -- Tim Roberts, timr(a)probo.com Providenza & Boekelheide, Inc.
From: Simon [2610] on 22 Jun 2010 02:49 On 22 Jun., 06:34, Peter Duniho <NpOeStPe...(a)NnOwSlPiAnMk.com> wrote: > Simon [2610] wrote: > > Hi, > > > Im building an application to use instead of the explorer thumbnail > > view. > > Lets say i have a folder with 2500 images, and at any given time i can > > show 25 images at thumbnail size on my screen. I have a control > > (PictureControl, PC) on which i have a picturebox to display the > > individual images, and a label for the name. > > Ive loaded all theese 2500 controls onto a FlowLayoutPanel. > > Now i want an event to fire when i scroll and a PC becomes visible, so > > that i can load the image then, and when it leaves the visible area i > > can unload the image. so that i use a minimal amount of memory. > > I thought the visiblechanged event was what i needed, but they are > > always visible :/ > > As you've found, the Visible property has nothing to do with clipping. > It's simply a question of whether the control is shown when it's > scrolled to an unclipped position on the screen. > > > I am building this because im getting tired of waiting for windows to > > finish producing the thumbnails when i view a folder, and have found > > no way to force windows to load all the thumbnails without me > > scrolling down and looking at them (and even then it can seem like its > > stalling). > > For what it's worth, it seems to me that if you delay loading of the > thumbnails until the item is visible on the screen, you would run into > the same behavior Windows already has and which you don't like. Yes that is partially true, but what i will avoid the thumbnail generating stalling, as i have seen it in windows - sometimes for up to 30 seconds even in folders with only 300 images. Also i was thinking of loading the images in several threads and taking advantage of multicore cpu. When windows loads thumbnails it seems like it doesnt use that much cpu power. > > Now, i have thought of an alternate way, if i can get the percentage > > position (or something like that) of the scroll bar, i can calculate > > what is and what isnt visible... but i would rather the application to > > tell my controls which are visible to the user and which arent. > > > anyone got a solution for that one? ive searched the web without any > > luck, but perhaps im searching for the wrong things? > > The best approach for what you're doing is to use the ListView control, > which supports a "virtual mode". In that mode, you have to respond to > certain events that allow you to manage a cache of items and provide > just the items that are actually visible. I will probably try doing the listview control approach. will be interesting to see if it fits my needs :) - i did however continue my search yesterday, and found someone with a similar problem - he was adviced to check the controls bounds against the containers clientrectangle - i implemented this in my app, and it seems to do the trick - i narrowed the search for controls by taking the currentscrolling position dividing it by the maximum (to get the percentage used) and then finding that position in a list of PictureControls which improved the speed a lot compared to going through all of the controls (just thought id share if anyone else comes upon this thread with a similar problem). > If that doesn't provide enough control for your needs, you'll probably > have to implement a custom control yourself that does the management of > the thumbnails in the way you want. The ListView control is pretty > flexible so if it can't do what you want, there's probably nothing else > in the stock Forms controls that will. (WPF might have something > similar that works differently/better-suited to your needs, but I don't > know as much about that). Thanks for sharing your thoughts on this matter! regards Simon
From: Peter Duniho on 22 Jun 2010 02:54 Simon [2610] wrote: > [...] >> For what it's worth, it seems to me that if you delay loading of the >> thumbnails until the item is visible on the screen, you would run into >> the same behavior Windows already has and which you don't like. > > Yes that is partially true, but what i will avoid the thumbnail > generating stalling, as i have seen it in windows - sometimes for up > to 30 seconds even in folders with only 300 images. Also i was > thinking of loading the images in several threads and taking advantage > of multicore cpu. When windows loads thumbnails it seems like it > doesnt use that much cpu power. It will depend on a number of factors of course, but�there's a good possibility that your bottleneck will be the hard drive and not the CPU. Adding threads will only make that worse as they all wind up competing for the same resource. > I will probably try doing the listview control approach. will be > interesting to see if it fits my needs :) > - i did however continue my search yesterday, and found someone with a > similar problem - he was adviced to check the controls bounds against > the containers clientrectangle - i implemented this in my app, and it > seems to do the trick - i narrowed the search for controls by taking > the currentscrolling position dividing it by the maximum (to get the > percentage used) and then finding that position in a list of > PictureControls which improved the speed a lot compared to going > through all of the controls (just thought id share if anyone else > comes upon this thread with a similar problem). That seems like a reasonable approach to detecting clipping or not of controls contained in a panel. However, another thing to keep in mind is that at least some of the overhead you will experience will be related to there being thousands of windows (each control having its own window) in your main window. I.e. even if you aren't drawing anything at all, there's a non-trivial effort the OS has to engage in just to manage all of that. Anyway, good luck with your efforts. Pete
|
Next
|
Last
Pages: 1 2 Prev: Looping Through a Stucture Easy way. Next: StreamReader/Writer dealing with funny characters |