1 00:00:00,570 --> 00:00:01,640 Hello and welcome. 2 00:00:01,680 --> 00:00:11,750 In this lecture we are going to be writing some code for the Load event handler method. 3 00:00:11,760 --> 00:00:14,930 So switch to your design mode. 4 00:00:14,970 --> 00:00:21,030 Just click on the form design make sure you've got the form selected. 5 00:00:21,030 --> 00:00:25,930 You can tell by the name of the form and click on this here. 6 00:00:26,070 --> 00:00:30,600 This little thing that looks like a thunder lightning bolt. 7 00:00:30,600 --> 00:00:33,460 We need to scroll down to a point. 8 00:00:33,700 --> 00:00:41,270 Oh this is what we're looking for because what we're looking for this is the Load event right. 9 00:00:41,310 --> 00:00:43,210 So when the page loads. 10 00:00:43,230 --> 00:00:49,770 So with this is what we want to generate could force we just double click on it and it will create a 11 00:00:49,770 --> 00:00:51,290 stop a stop. 12 00:00:51,300 --> 00:00:53,130 Basically is an empty method. 13 00:00:53,190 --> 00:00:59,310 So this is an method is created is empty because we've not written the code that will go in between 14 00:00:59,310 --> 00:01:02,220 the curly braces. 15 00:01:02,910 --> 00:01:04,040 What I'm going to do. 16 00:01:04,050 --> 00:01:15,720 I am going to write the code added on and explain it to the highlighted code is what I have chosen added 17 00:01:15,720 --> 00:01:15,990 on. 18 00:01:16,560 --> 00:01:22,350 So I'm just going to explain it to make sure when you write your code make sure the curly braces match 19 00:01:22,350 --> 00:01:30,950 up if not reduced you to complain and it will not compile your code so you can see you know the. 20 00:01:30,990 --> 00:01:32,370 My curly braces. 21 00:01:32,460 --> 00:01:35,690 They all match up. 22 00:01:36,840 --> 00:01:40,690 So let's start with the first line of the code which is this one here. 23 00:01:41,560 --> 00:01:50,170 Basically any time you see square brackets know that that is referencing an array referring to an array. 24 00:01:50,190 --> 00:02:00,930 So what this line of code is basically this code is going to put a list of all the fine finally all 25 00:02:00,930 --> 00:02:08,010 the found names in the picks directly remember we created the directory for our images and call it picks. 26 00:02:08,010 --> 00:02:18,600 So it will put or put a list of all the file names in the picks directory to the images variable. 27 00:02:18,600 --> 00:02:19,340 OK. 28 00:02:19,410 --> 00:02:25,810 So this is a variable image is created a variable here called images. 29 00:02:26,010 --> 00:02:27,320 We've set it to this. 30 00:02:27,330 --> 00:02:28,540 So what it will do. 31 00:02:28,830 --> 00:02:35,520 It will get all the pictures all the images from this directory picks and dump it and store it inside 32 00:02:35,520 --> 00:02:36,970 this image. 33 00:02:37,080 --> 00:02:44,580 Images variable on line 41 here have introduced a for each a four which is a kind of loop. 34 00:02:44,580 --> 00:02:45,840 So it will loop true. 35 00:02:45,840 --> 00:02:57,750 Here is going to this image here which is the it will loop through that image and it will each time 36 00:02:57,750 --> 00:02:58,570 we loops through. 37 00:02:58,620 --> 00:03:03,900 It will create an instance of that image. 38 00:03:03,900 --> 00:03:09,980 So here is looking for each a string basically is a text a string of text. 39 00:03:10,050 --> 00:03:16,840 So it is looking for each text you know in the image is text in the image in images. 40 00:03:16,860 --> 00:03:19,530 This image is is this variable here. 41 00:03:19,530 --> 00:03:26,580 So that's what this string is looking for the text in the image in this image is variable. 42 00:03:27,030 --> 00:03:28,920 Line 4 2 3. 43 00:03:28,920 --> 00:03:34,020 This line here. 44 00:03:34,020 --> 00:03:45,840 What that highlighted line does it creates a new bit map picture and then adds it to the beachy images 45 00:03:46,080 --> 00:03:48,780 array. 46 00:03:49,310 --> 00:03:57,830 Remember we created an array earlier on in our previous lecture which is this peaky images array. 47 00:03:57,860 --> 00:04:00,710 All right. 48 00:04:00,710 --> 00:04:03,540 I've also introduced a for loop here. 49 00:04:03,560 --> 00:04:09,650 This line here is a for loop a for loop basically line inside the palace parentheses 50 00:04:12,140 --> 00:04:13,280 past it. 51 00:04:13,280 --> 00:04:21,200 There is a data type of integer which is a number a loop basically will go through each return item 52 00:04:21,500 --> 00:04:24,290 and count to what it is doing here. 53 00:04:24,290 --> 00:04:31,160 I've given it a variable of I and I have set the initial value to zero. 54 00:04:31,160 --> 00:04:33,050 So this is the value of the counter. 55 00:04:33,560 --> 00:04:35,720 So to start counting from zero. 56 00:04:36,140 --> 00:04:38,860 And here I'm calling the same variable here. 57 00:04:38,870 --> 00:04:50,780 I'm saying as long as this variable if it's less than 50 I wanted to keep increasing by 1 plus plus 58 00:04:50,780 --> 00:04:54,230 men increased by wants me to keep increasing the variable. 59 00:04:54,230 --> 00:05:02,690 So what that will do it will look in the directory for the images and it will check as long as the images 60 00:05:03,560 --> 00:05:04,820 are less than 50. 61 00:05:04,820 --> 00:05:09,690 It will keep adding adding images to the screen until it reaches 50. 62 00:05:09,710 --> 00:05:16,490 So this value you can experiment with and see you know what gets displayed on the screen later but basically 63 00:05:16,490 --> 00:05:17,470 that's what this county. 64 00:05:17,480 --> 00:05:29,350 It will stop when the images are above 50 here on line 48. 65 00:05:29,480 --> 00:05:34,950 So this is a class and this is a local variable. 66 00:05:35,240 --> 00:05:42,710 And I've set a new instance of that local variable and you say this is a method is going to equals to 67 00:05:42,710 --> 00:05:58,170 this Brit pick method here on line 49 I've got this local variable here MP and set it to this the percent 68 00:05:58,680 --> 00:06:01,390 actually means remainder. 69 00:06:02,130 --> 00:06:12,480 So 5 percent of 2 is 1 because you can divide 5 into 2 twice with a reminder of 1 70 00:06:15,210 --> 00:06:17,420 on line 50 here. 71 00:06:17,870 --> 00:06:20,140 The one highlighted. 72 00:06:20,150 --> 00:06:23,730 Basically what the line that code was going to do. 73 00:06:23,750 --> 00:06:33,910 He's going to get the next available random number between zero and the windows with the one next to 74 00:06:33,910 --> 00:06:44,510 it will do the same next available number and the windows height Oh don't worry about this line here. 75 00:06:44,530 --> 00:06:47,190 I've commented out so it doesn't matter anyway. 76 00:06:47,440 --> 00:06:49,390 Just get rid of it so it doesn't confuse you. 77 00:06:49,390 --> 00:06:57,280 I was just trying to test some things out so I get rid of that on here we are we've got a method here 78 00:06:57,820 --> 00:07:01,680 that adds an object to the end of the list. 79 00:07:01,780 --> 00:07:02,130 All right. 80 00:07:02,140 --> 00:07:05,860 So use this method if you want to append a list to is good. 81 00:07:06,050 --> 00:07:12,900 If I wanted to add this here will add an object to the end of this variable. 82 00:07:12,900 --> 00:07:14,560 Here is brick picks. 83 00:07:14,560 --> 00:07:22,510 Class variable so any way you're using add you are appending or adding to a list. 84 00:07:22,510 --> 00:07:24,170 So this is an array. 85 00:07:24,340 --> 00:07:30,480 So by adding the add here it will add an object to the end of that list. 86 00:07:30,700 --> 00:07:33,180 So that is it for this lecture. 87 00:07:33,180 --> 00:07:40,150 I'm gonna stop this lecture here and we will progress in the next lecture. 88 00:07:40,390 --> 00:07:41,980 Thank you so much for watching. 89 00:07:41,980 --> 00:07:42,970 Take care. 90 00:07:42,970 --> 00:07:43,660 Bye for now.