TAILIEUCHUNG - Manning Windows Forms Programming (phần 5)

Tham khảo tài liệu 'manning windows forms programming (phần 5)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Create some class variables continued Action Result 2 Within the MainForm class add a protected album variable _album. protected PhotoAlbum _album 3 Add a protected boolean called _bAlbumChanged to track when an album is modified. protected bool _bAlbumChanged false Note This will be useful when deciding whether to save an existing album before loading a new one or closing the application. If no changes have occurred then we will know to not save the album. 4 Create an empty album at the end of the MainForm constructor. public MainForm . album new PhotoAlbum These variables are required to implement all of our new menu items in this chapter. With these in place it is time to do just that. Mul tiple file selection Now that we have an album in our MainForm class albeit an empty one we can add photos to it. In previous chapters we allowed the user to read in a single photo first using a button and later with a menu item. In our new structure this has been replaced by the ability to add multiple photos to the album or remove the current photo from the album. Since this code builds on our original Load handler it is a good place to begin. As you would expect we will provide Click handlers for both the Add and Remove items. The Add menu should allow one or more photos to be selected and added to the album while the Remove menu should delete the currently displayed photo from the album. The Add menu will use the Multiselect property of the OpenFileDialog class and is where our catchy section title comes from. Adding images to an album In chapter 3 the Click handler for the Load menu permitted a single file to be selected using the OpenFileDialog class. This made sense when only a single image was managed by the application. In this chapter the idea of an album permits multiple images to be present at the same time. As a result our user should also be able to load multiple images at once. This is again done using the OpenFileDialog class so the code for this .

TỪ KHÓA LIÊN QUAN