473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Loading alot of images, don't want to see the load process...

Samishii23
246 100+
In my project I have a loading method for 132 PictureBoxs, and will probably load 70-90 images in those boxes based on user selection. There is no error in my loading method. But I have tried to hide all the picture boxes during load time, because I don't like how it looks as they load.

I have all 132 PB's inside panels, which are hidden at first, and are shown at the end of the method, and I also use Suspend / ResumeLayout to maybe not show them while my method is loading each Image from local folders... But the show at the end of the method seems to be done first then the loop starts, and the Layout functions don't do anything either. I have tried an IF statement within the FOR statement to show the panels at the end of the loop, doesn't work either.

Basicly, I need this: Keep the panels hidden until the image loading is done. But I haven't figured out how to do this... The show portion of the method seems to always be ran first before the loop starts despite being at the end of the method...

Any suggestions?
Mar 27 '10 #1

✓ answered by tlhintoq

Expand|Select|Wrap|Line Numbers
  1. TTree[i].BackColor = Color.Transparent;
So did you try my suggestion of making the backcolor something obvious like Blue, then change it to Transparent when you are done loading and make it .Visible = true? As a means of determining if it was becoming visible earlier than you thought? If you see blue before you are done loading then you know you are turning it visible early.

14 1572
tlhintoq
3,525 Expert 2GB
Let's see the actual routine and then maybe we can guide you as to where you went wrong.
Mar 27 '10 #2
Samishii23
246 100+
Expand|Select|Wrap|Line Numbers
  1. void Load() {
  2.     this.SuspendLayout();
  3.     for (int i = 0; i < TD.Pts.Count(); i++) {
  4.         if (TD.Pts[i] == 0) {
  5.             TIcon[i].Enabled = false;
  6.             TIcon[i].Visible = false;
  7.             }
  8.         else {
  9.             TIcon[i].Enabled = true;
  10.             TIcon[i].Visible = true;
  11.             try {
  12.                 TIcon[i].Image = gi(TD.Icon[i], 1);
  13.                 }
  14.             catch (Exception EX) {
  15.                 TIcon[i].Image = null;
  16.                 TIcon[i].BorderStyle = BorderStyle.Fixed3D;
  17.                 TIcon[i].BackColor = Color.Black;
  18.                 }
  19.             }
  20.         }
  21.  
  22.     this.ResumeLayout();
  23.  
  24.     for (int i = 0; i < 3; i++) {
  25.         TTree[i].Visible = true;
  26.         }
  27.     }
TIcon[] is the PictureBox array.
TTree[] are the Panels which the PictureBoxs are inside.

The Panels appear to get shown first before all the Images of each of PictureBox's Images are set.

gi() is just a method to get the image location based on user settings.
Mar 27 '10 #3
tlhintoq
3,525 Expert 2GB
Basicly, I need this: Keep the panels hidden until the image loading is done.
There is no image loading taking place in the code you have provided.

Where are you loading the images into your 130+ pictureboxes?
Mar 27 '10 #4
Samishii23
246 100+
This loads the images...
Expand|Select|Wrap|Line Numbers
  1. TIcon[i].Image = gi(TD.Icon[i], 1);
This is the gi() method...
Expand|Select|Wrap|Line Numbers
  1. public Bitmap gi(string f, int t) {
  2.     // TODO: Integrate MPQ / BLP file integration based on user prefrences
  3.     switch (t) {
  4.         default: return null;
  5.         case 0: return new Bitmap(Settings[19] + f + ".jpg"); // Tree BG Files
  6.         case 1: return new Bitmap(Settings[1] + f + ".png"); // Icons
  7.         }
  8.     }
Sorry. Was in a hurry to leave home at the time, forgot to include the gi().
Mar 28 '10 #5
tlhintoq
3,525 Expert 2GB
Suspendlayout is going to do nothing for you because the layout is already completed. It was *done* before the Load() event was ever raised.

You said the pictureboxes are on a Panel, and that panel is set to visible = false. Is that right?

If that is so, then where are you setting the panel visible to true when you are done? Since I can see no place where you are turning the panel to visible, I am doubting that you ever have it be not visible.
Mar 28 '10 #6
Samishii23
246 100+
Expand|Select|Wrap|Line Numbers
  1. for (int i = 0; i < 3; i++) {
  2.          TTree[i].Visible = true;
  3.          }
These are the panels. When the program is initialized, the three panels are initilized, and never shown to the user. This is done within the main program load, and within the first SuspendLayout call. So I know they are hidden before the PictureBox load.

The PB's are within the Panels Controls. Easier to show 3 panels then 132 individual PB's. I hope thats how it came off my earlier comments, sorry if it didn't
Mar 28 '10 #7
tlhintoq
3,525 Expert 2GB
Why not just set their visible property to false in the designer? That why you know it is done before any of your code runs.

Here's another good test: In the designer set the panel back color to something odd - like blue. If the panel really is not visible then it won't matter. Just before you set the visible to true, set the color back back to .Control

If at any time you see a blue panel, then you know it is being set to visible earlier than you thought.
Mar 28 '10 #8
Samishii23
246 100+
I don't use the designer anymore. I'll run a test project though, and see what happens.
Mar 29 '10 #9
tlhintoq
3,525 Expert 2GB
OK. Wherever you actually created the panel for the first time... Did you set it to .Visible = false?

The simple idea here is that if you are seeing the pictureboxes load images then you haven't made them not visible.
Mar 29 '10 #10
Samishii23
246 100+
OK. Wherever you actually created the panel for the first time... Did you set it to .Visible = false?
Of course tlhintoq. I mentioned this above. Though it appears I have been vague yet again. Sorry.

This is my panel loop:
Expand|Select|Wrap|Line Numbers
  1. TTree[i] = new Panel();
  2. TTree[i].Size = new Size(s2i(Settings[10]), s2i(Settings[9]));
  3. TTree[i].Name = "Tree." + i2s(i);
  4. TTree[i].BackColor = Color.Transparent;
  5. TTree[i].BorderStyle = BorderStyle.None;
  6. TTree[i].BackgroundImageLayout = ImageLayout.Center;
  7. TTree[i].Visible = false;
  8. TTree[i].Location = new Point(s2i(TreeX[i]),s2i(Settings[7]));
  9. this.Controls.Add(TTree[i]);
s2i() is just a string to int32 converter.
Mar 29 '10 #11
tlhintoq
3,525 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. TTree[i].BackColor = Color.Transparent;
So did you try my suggestion of making the backcolor something obvious like Blue, then change it to Transparent when you are done loading and make it .Visible = true? As a means of determining if it was becoming visible earlier than you thought? If you see blue before you are done loading then you know you are turning it visible early.
Mar 29 '10 #12
Samishii23
246 100+
I did as you suggested.

I changed the .BGColor to something noticable.

The result was different then I would have thought. When I changed the BGColor to anything but Transparent, the method run as I would have thought originally. All the PB's were loaded then displayed. Load time was probably a second rather then 2-3 for when you would watch each PB load individually.

It seems that when the BGColor is transparent it causes that Visibility issue... Seems weird. But now I know this. I'll just keep the Panels a solid color. Thank you for your help.
Mar 29 '10 #13
tlhintoq
3,525 Expert 2GB
That's because in reality the panels aren't really transparent. They exactly clone the data below them to mimic being transparent. And do to that, they have to be visible. Color.Transparent in the .NET framework is a lie.

It also explains the reduction in processing time. When it was transparant and having to mimic the contents below it had to constantly re-process every time a new PB load occured. When it stopped having to do all that hidden processing it stopped taking so long.
Mar 29 '10 #14
Samishii23
246 100+
So thats what Transparency does... Huh, interesting. Well thanks for the insight. :)
Mar 29 '10 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Matthew | last post by:
I am not the most talented programmer to grace the earth by a long shot. But I've got a gripe I need to air about the .NET implementaion of Visual Basic. I can live with alot of the major changes...
0
by: Mark McKay | last post by:
I will be starting a contract with a film production company soon, and will be writing code to process large images representing frames of movies (unknown file format at this time). I'd also like...
4
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
2
by: Jean Pierre Daviau | last post by:
When I have something like this in a js file. listeImg = new Array(); listeImg = new Image(w,h); listeImg.src = "centre1.jpg"; etc Are the images loaded after the page is loaded? In the same...
27
by: Chris Tomlinson | last post by:
Hi, is there any way to specify the sequence in which images load on a web page? More specifically, here is what we need to achieve: Image1 starts loading first and the browser does not...
0
by: speedcoder | last post by:
hi all, i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and...
10
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without...
1
by: sirjaybishop | last post by:
Hi I have an issue in some browsers when linking to style sheets or images in some browsers using a DOM script after I have submitted a form. I am trying to make the form submission process...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.