2.1 Hello World! I'm creating a separate form for a picture in C#. I have a new project and I've created a menu open that is going to create a new instance of a form Use the open file dialog to get a picture, and then display it full-size in the form . The first thing I need to do this at windows form, And I'm going to name that FormPicture. And in form picture I'm going to add a picture box. And then, for the properties of the picture box I'm going to select for the location 0 0, And for the size mode I'm going to pick zoom. Then for the form, I'm going to go to the events and pick the resize event. Under resize, when we resize the form, I want to make the picture box fill the form. So picturebox1 dot width equals this dot width. Minus 20, that's just sort of a fudge factor to take care of the edges of the form that aren't really usable. And I'm going to do the same thing with the height, minus 40 because the top has the title and takes up a little more space. Now, I'm going to create a function to return the picture box. And I want to return it so that my main form can make changes to that picture box, like putting the picture in it, and things like that. So I'm going to make this public PictureBox as the return type, and then my code is simply going to say return picture box 1. Let's go back to my form, and for the open event, I'm going to paste this and then explain it. So the first thing we need to do is set the filter so that we can pick any sort of picture we want with that. And then we show the open file dialog, modal, and if they pick cancel the file name will be a null string. So it's not a null string, I create a new instance of that form and then I say pic, a picture box pic, equals form dot get picture box, that's that function that we just wrote. and then the text of the form is the file name, and I can now refer to pic, and I am directly accessing If you want that is by reference, that is returned, And so I load the file name and I did that twice didn't I? We don't need that twice. Right? And then I say the width of the form is equal to the picture... So let's run it so you can see what happens. OK. Here's my program running and I can click open. Alright, I have a picture here that I'm going to open. And you can see what happens here the form is initially about the size of the picture, and if I make the form bigger, that zoom mode makes the picture grow. So we can use this to make thumbnails and enlarge it Let's see how small we can make it. We can make it smaller and have all kinds of fun with that. Woops! OK. And let's do that again, I'm going to open, uh... I have an animated gift over here. And, again I can make that bigger, and you can see gifts are pixilated, They're not vector based, let's make it a little smaller. Alright, that's all kinds of fun. And if I close this whole form, it closes all of those pictures also. And that's it!