1 00:00:00,990 --> 00:00:10,540 In this lecture we are going to add some code that will enable drawing so going to the form designer 2 00:00:11,080 --> 00:00:11,890 which is this one. 3 00:00:11,890 --> 00:00:13,240 Select. 4 00:00:13,240 --> 00:00:16,790 Make sure you've got the picture box selected. 5 00:00:16,900 --> 00:00:23,830 You can tell because it will show the name in the property box. 6 00:00:24,070 --> 00:00:34,000 Make sure you've got this event selected and we are going to look for a property that's called mouse 7 00:00:34,270 --> 00:00:35,050 move. 8 00:00:36,100 --> 00:00:38,470 So let's see if we can find one. 9 00:00:38,470 --> 00:00:44,240 This should be one for a mouse move. 10 00:00:44,990 --> 00:00:45,500 Okay. 11 00:00:45,520 --> 00:00:53,140 So this is our mouse move event so let's double click on it and that will give us. 12 00:00:53,170 --> 00:00:59,900 It also generates the method for that is the event handler for the mouse move. 13 00:01:00,250 --> 00:01:07,080 So we're gonna write some code here that will respond to the mouse movement. 14 00:01:07,180 --> 00:01:15,280 So this method will be run when the mouse enters the picture box element. 15 00:01:15,310 --> 00:01:23,950 So anytime the mouse enters the picture box element this code will be activated to save time. 16 00:01:23,950 --> 00:01:33,010 I am going to write the code and I'll explain what the code that the first and I want to do is implement 17 00:01:33,190 --> 00:01:36,240 and if statement so we do. 18 00:01:36,250 --> 00:01:47,230 If and then we pass it the variable growing parcel into the if statement when you write in an if statement 19 00:01:47,260 --> 00:01:52,660 you need to specify where the code will execute. 20 00:01:52,660 --> 00:01:56,930 So you do that you specify to curly braces. 21 00:01:57,100 --> 00:02:00,910 So I'm just going to put a mouse in between and press enter. 22 00:02:00,970 --> 00:02:04,970 So in between the calibrate this is where I'll specify the code. 23 00:02:04,990 --> 00:02:15,630 So I'm typing graphics intelligence already picks out up and I give it an emoji. 24 00:02:16,200 --> 00:02:21,100 I'll make you a lowercase G and I'll set that to equals to 25 00:02:23,540 --> 00:02:28,200 graphics. 26 00:02:28,660 --> 00:02:30,370 There's a method attached to that. 27 00:02:30,370 --> 00:02:36,040 So if you hit press dot on your keyboard the intelligence will give you all the methods you can use 28 00:02:36,040 --> 00:02:37,660 with these graphics. 29 00:02:37,660 --> 00:02:38,920 So I will. 30 00:02:38,920 --> 00:02:42,220 There is a method called from image. 31 00:02:42,220 --> 00:02:45,880 We use that an every method should have a parent. 32 00:02:45,880 --> 00:02:48,070 This is inside the parentheses. 33 00:02:48,070 --> 00:02:59,120 I will pass it the BNP which is a variable I created for the bitmap opposite that valley. 34 00:03:00,130 --> 00:03:01,160 OK. 35 00:03:01,400 --> 00:03:05,650 Next I'm going to reference that variable 36 00:03:08,340 --> 00:03:08,900 dot. 37 00:03:09,940 --> 00:03:17,830 And I'm going to attach a method draw a clips. 38 00:03:17,840 --> 00:03:24,060 So I'm going to pick this method and I'm going to pass it inside the parentheses. 39 00:03:24,070 --> 00:03:28,720 I'm going to posit some values going to pass it the pen. 40 00:03:28,750 --> 00:03:31,550 That's the pen variable. 41 00:03:31,540 --> 00:03:34,930 We've already declared this before. 42 00:03:34,930 --> 00:03:36,310 And then from values 43 00:03:39,120 --> 00:03:44,230 e dot X I use that 44 00:03:48,140 --> 00:03:58,790 represent the x axis then e the e represents the eclipse e dot y for the y axis 45 00:04:01,640 --> 00:04:03,930 and then the position in 3 46 00:04:06,860 --> 00:04:14,570 and 1 and the semicolon to end that. 47 00:04:14,570 --> 00:04:21,150 Finally our reference of picture books the picture box 48 00:04:23,830 --> 00:04:26,720 our a method to that he'd be an image 49 00:04:33,840 --> 00:04:42,840 okay not the image I'll just attach the image the actual image I said that image to equals to the BNP 50 00:04:44,790 --> 00:04:47,690 bitmap variable. 51 00:04:49,170 --> 00:04:51,350 OK I'm happy with that. 52 00:04:51,440 --> 00:04:54,050 I've got some yellow strips so I'll save my code 53 00:04:56,900 --> 00:04:59,860 the next thing we need to do before we can draw. 54 00:04:59,870 --> 00:05:11,120 We need to activate the pen colours so we going to do that using different methods for each of the pens. 55 00:05:11,120 --> 00:05:17,480 So if you go back into the form designer notice I've created we've created a few together. 56 00:05:17,480 --> 00:05:23,840 I also added the black as well so you can add many colours as you like. 57 00:05:23,840 --> 00:05:30,020 If you want to add white whereby you just add whatever colours you need to add. 58 00:05:30,020 --> 00:05:31,280 So I've got red. 59 00:05:31,280 --> 00:05:35,850 Blue green purple lime black and white. 60 00:05:35,960 --> 00:05:39,230 So to activate the pen let's start with the red. 61 00:05:39,260 --> 00:05:46,340 So I'll double click double click on that and that should open up the code view for that. 62 00:05:46,340 --> 00:05:51,080 So that generates the event for that pen. 63 00:05:51,740 --> 00:05:54,440 So we're gonna write the code for that. 64 00:05:54,440 --> 00:05:58,640 So all we need to do because we've got a pen variable. 65 00:05:58,640 --> 00:06:04,220 So we access in the pen variable which is p dot colour. 66 00:06:07,160 --> 00:06:07,550 Okay. 67 00:06:07,550 --> 00:06:11,780 And then we say equals two colour 68 00:06:16,120 --> 00:06:19,560 dot read. 69 00:06:19,780 --> 00:06:25,950 That's basically what we'll do for that one and you do the same for all the colors. 70 00:06:26,550 --> 00:06:28,250 So you go back into the design view. 71 00:06:28,260 --> 00:06:29,160 We've done the red. 72 00:06:29,160 --> 00:06:31,430 We double click on the blue. 73 00:06:31,740 --> 00:06:32,640 We do the same. 74 00:06:32,640 --> 00:06:36,480 If you want to make things easy just copy 75 00:06:39,050 --> 00:06:45,200 copy that come here paste and just change that to blue. 76 00:06:50,710 --> 00:06:54,880 And do the same for the rest of the colors. 77 00:06:54,980 --> 00:07:01,380 We should now be able to do some basic drawing using our mouse. 78 00:07:01,490 --> 00:07:02,800 So let's check that out. 79 00:07:02,810 --> 00:07:09,000 So let's run the application would go start. 80 00:07:09,170 --> 00:07:11,260 So this is the application. 81 00:07:11,570 --> 00:07:14,050 So let's try and draw using some of the pen. 82 00:07:14,060 --> 00:07:15,860 This is this try. 83 00:07:16,070 --> 00:07:17,270 This is a red pen. 84 00:07:19,130 --> 00:07:20,540 Let's try the lime 85 00:07:23,130 --> 00:07:23,660 Oh. 86 00:07:23,690 --> 00:07:24,710 Good luck Picasso. 87 00:07:24,710 --> 00:07:26,360 Now let's try the white 88 00:07:29,780 --> 00:07:30,800 tribe purple 89 00:07:34,150 --> 00:07:34,810 a go. 90 00:07:34,860 --> 00:07:36,330 Mount Picasso drawing. 91 00:07:36,480 --> 00:07:45,380 So we are able to draw on the peach box now via the BNP variable. 92 00:07:45,600 --> 00:07:50,360 We older than we can do now we can't save the moment. 93 00:07:50,370 --> 00:07:53,490 The save option has not been activated. 94 00:07:53,490 --> 00:08:02,420 So in the next lecture I'm gonna write some code that we can use to activate saving of our drawing. 95 00:08:03,030 --> 00:08:05,250 So that's it for this lecture. 96 00:08:05,250 --> 00:08:06,870 Thanks so much for watching. 97 00:08:06,870 --> 00:08:09,440 Take care and bye for now.