Netframwork 2.0 (phần 16) doc

43 338 0
Netframwork 2.0 (phần 16) doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Answers 725 In the ValidationError event handler, we can save the XML file as is instead of process- ing it and add it to a queue of items that must be hand-examined. Case Scenario 2: The Merger By designing our application around the XmlDocument class, we can accomplish this quickly and easily. Each document can be loaded into an instance of the XmlDocument class. We can retrieve the nodes in question by using the XmlDocument.GetElements- ByTagName. Because these elements wrap text, we can use the XmlNode.ReplaceChild method to replace the child text elements with the text we specify. Chapter 10: Lesson Review Answers Lesson 1 1. Correct Answer: C A. Incorrect. The PrintPreviewDialog represents a print preview form but does not allow the user to add printers. B. Incorrect. The PageSetupDialog represents a page setup form but does not allow the user to add printers. C. Correct. Users can add printers from the PrintDialog. D. Incorrect. The PrintPreviewControl can be used to create customized print preview components but does not allow the user to add printers. 2. Correct Answers: A and C A. Correct. You must set the Document property to the PrintDocument you want to preview. B. Incorrect. The PrintPreviewDialog automatically generates the output for the PrintDocument component and displays it. No additional method or event is necessary to generate the previewed document. C. Correct. You must display the form to preview the document. D. Incorrect. The PrintPreviewDialog automatically generates the output for the PrintDocument component and displays it. No additional method or event is necessary to generate the previewed document. 3. Correct Answer: C A. Incorrect. Users can set the page orientation from the PageSetupDialog component. 726 Answers B. Incorrect. Users can set the paper tray from the PageSetupDialog component. C. Correct. The user can add a printer within the PrintDialog box only. D. Incorrect. Users can set the page margins from the PageSetupDialog com- ponent. Lesson 2 1. Correct Answer: B A. Incorrect. PrintPages is the event that is raised to print pages, but it cannot be called like a method. B. Correct. Set the HasMorePages property to True to raise the PrintPages event again and print multiple pages. C. Incorrect. HasMorePages is a property, not a method. D. Incorrect. The Cancel property can be set to True to cancel the current print job, but setting it to False does not automatically print additional pages. 2. Correct Answer: A A. Correct. To find the total lines on the printed page, you divide the height of the MarginBounds by the height of the Font. B. Incorrect. The GetHeight method requires a Graphics object as a parameter. C. Incorrect. GetHeight is not a member of the Graphics object. D. Incorrect. Using the height of the PageBounds will calculate the total number of lines in the page, including the excluded areas of the header and footer. 3. Correct Answer: B A. Incorrect. The BeginPrint event occurs at the beginning of a print job. B. Correct. The EndPrint event occurs after all pages have been printed, and it is the appropriate event to handle to notify the user that a print job is complete. C. Incorrect. The PrintPages event is used to send data to the printer. D. Incorrect. The QueryPageSettings event occurs before each page is printed to allow the user to use different page settings for each page. Lesson 3 1. Correct Answer: C A. Incorrect. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, 250 would correspond to a zoom of 25,000 percent. Answers 727 B. Incorrect. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, 25 would correspond to a zoom of 2,500 percent. C. Correct. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, 2.5 would correspond to a zoom of 250 percent. D. Incorrect. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, .25 would correspond to a zoom of 25 percent. 2. Correct Answer: B A. Incorrect. UseAntiAlias is a property, not a method. B. Correct. To smooth the appearance, set the UseAntiAlias property to True. C. Incorrect. UseAntiAlias is a property, not a method, and it exists in the PrintPreviewControl class, not on the Document property. D. Incorrect. UseAntiAlias exists in the PrintPreviewControl class, not on the Document property. Chapter 10: Case Scenario Answers Case Scenario 1: A Better PrintPreview Control To create a component like the one described, you would start by creating a new form that contains a PrintPreviewControl that would be used to display the document. By adding a Timer component, you can change the PrintPreviewControl.StartPage prop- erty at regular intervals to cycle through the pages. One way of implementing page skipping would be to subclass the PrintPreviewControl and add a property that indi- cated the step to take when skipping pages. Case Scenario 2: A Simple Report Tool Because the form is already the size of a piece of paper, the task is quite simplified. In the method handling the PrintPages event, you can loop through the controls on the form. For the label controls, you can use the Graphics.DrawString method to print the string in the label using the same font and location as the label itself. For image con- trols, you can likewise print the image using the Graphics.DrawImage method to draw the image at the location specified by the image control. You can print a report for each record in the database by iterating through the records in the PrintPage event handler. After a page has been printed, the method should check to see if any more records exist. If so, the e.HasMorePages property should be set to True and the next record printed. 728 Answers Chapter 11: Lesson Review Answers Lesson 1 1. Correct Answer: D A. Incorrect. Although most drag-and-drop operations begin in the Mouse- Down event on the source control, it is not required that they begin here. B. Incorrect. Although most drag-and-drop operations end with the mouse button being released, this is handled by the DragDrop event. C. Incorrect. The DragLeave event is used to execute code when data is dragged out of a control, but it is not necessary for the drag-and-drop operation. D. Correct. The DragDrop event must be handled to complete a drag-and- drop-operation. 2. Correct Answers: A, B, C, and D A. Correct. The DoDragDrop method begins the drag-and-drop operation. B. Correct. If the target control does not allow one of the specified effects, the operation will not be completed. C. Correct. If the data format is not correct, the operation cannot be completed. D. Correct. If AllowDrop is set to False, no drag-and-drop operation may occur. 3. Correct Answer: B A. Incorrect. Whereas the MouseDown event is used to initiate most drag-and- drop operations, the ItemDrag event is used to initiate a drag-and-drop operation in a TreeView control. B. Correct. Use the ItemDrag event to call the DoDragDrop method. C. Incorrect. The TreeView.DragEnter event should be used to set the effect allowed for the drag-and-drop operation, but it will not be raised if a drag- and-drop operation has not already been started. D. Incorrect. The TreeView.DragDrop event is used to complete the drag-and- drop operation. Lesson 2 1. Correct Answer: C A. Incorrect. CurrentUICulture determines the localized version of the form that is loaded but does not control data formatting. Answers 729 B. Incorrect. Culture is set by the thread, not by the form. C. Correct. The CurrentCulture setting determines the formatting methods used for application data. D. Incorrect. Culture is set by the thread, not by the form. 2. Correct Answers: C and D A. Incorrect. Because the default value for the RightToLeft property is Inherit, you only need to set the Form.RightToLeft property to True for the control text to be displayed right to left. B. Incorrect. Because the default value for the RightToLeft property is Inherit, you only need to set the Form.RightToLeft property to True for the control text to be displayed right to left. C. Correct. Setting the Form.RightToLeft property to True will cause all con- trols with a RightToLeft property value of Inherit to display text right to left. D. Correct. Setting the Form.RightToLeftLayout property to True, along with setting the Form.RightToLeft property to True, will cause the entire form to lay out in a right-to-left manner. Lesson 3 1. Correct Answers: A and C A. Correct. You must create a parent form by setting the IsMdiParent property to True. B. Incorrect. The ActiveMdiForm property is to determine which child form is active, but it is not required to create a child form. C. Correct. You create a child form by setting the MdiParent property to an appropriate parent form. D. Incorrect. It is not necessary to create a window list menu to create a child form. 2. Correct Answer: D A. Incorrect. This method is used to activate a child form, not to get a refer- ence to the active form. B. Incorrect. This method adds an owned form but does not return a refer- ence to it. C. Incorrect. This property reports whether the form is a child form but does not return a reference. 730 Answers D. Correct. The ActiveMdiChild property holds a reference to the currently active MDI form. Chapter 11: Case Scenario Answers Case Scenario 1: Still More Document Control By using an MDI application, you can enable users to view multiple child documents while containing and organizing them in a single form. The parent form can include a TreeView control to display the documents in the table of contents, and the docu- ments can be loaded as child forms when viewing is required. You can use drag-and- drop functionality to enable reordering of the table of contents in the TreeView control at run time. Case Scenario 2: Fabrikam Goes International You can create an MDI form that displays two child forms simultaneously: one for the European market and one for the U.S. market. You can ensure that market data is for- matted appropriately by setting the CurrentCulture property to an appropriate culture before creating the form. You can create localized versions of the user interface by researching what locales the application will be deployed in and creating localized strings and other resources for the user interface. You can then use these strings to create localized versions of the form. At run time, the application will retrieve the CurrentUICulture from the system and automatically display the correctly localized user interface. If desired, you can also allow the user to manually switch locales by setting the CurrentUICulture prop- erty in code. Chapter 12: Lesson Review Answers Lesson 1 1. Correct Answers: A, B, and D A. Correct. A user interface should be flexible to accommodate a variety of accessibility styles. B. Correct. Consistency allows your application to interact with the system in a predictable manner, thus enhancing accessibility. Answers 731 C. Incorrect. An accessible interface does not have to be a simple interface. Even complicated interfaces can be made accessible. D. Correct. Accessible interfaces should be compatible with accessibility aids. 2. Correct Answer: A A. Correct. Although sound can be helpful, no information should be con- veyed by sound alone. B. Incorrect. This is an accessibility best practice. C. Incorrect. This is an accessibility best practice. D. Incorrect. This is an accessibility best practice. Lesson 2 1. Correct Answers: A and C A. Correct. The PerformStep method will increment the value to whatever the Step property is set to. B. Incorrect. After the Step property is set, you must call PerformStep to advance the value. C. Correct. The Increment method advances the Value by the value indicated. D. Incorrect. The Increment method requires a value for the Value property to be advanced. It does not use the value of the Step property. 2. Correct Answers: A, B, and C A. Correct. If the next control that is navigated to after the text box does not have the CausesValidation property set to True, the Validating event on the text box will not be fired. B. Correct. To display the error icon, you must call the SetError method and set the error to an informative string. C. Correct. To cancel the error, you must call the SetError method and set the error string to an empty string. D. Incorrect. The ErrorProvider component does not have inherent validation capabilities. 3. Correct Answer: B A. Incorrect. Although you must call SetShowHelp, you must also set the Help- Navigator to Find. 732 Answers B. Correct. You must call the SetShowHelp method to set ShowHelp to True, and you must set the HelpNavigator to Find to open the search page. C. Incorrect. Whereas you must call the SetShowHelp method to set ShowHelp to True, setting the HelpNavigator to Topic will open help to a topic, not to the search page. D. Incorrect. Setting the HelpString will not have any effect when the Help- Navigator has been set. Chapter 12: Case Scenario Answers Case Scenario 1: Putting the Final Touches on the Document Management System You can use the HScrollBar or VScrollBar to build an interface that provides rapid nav- igation through the long list of files. By tying the value of the scroll bar to the location in the file list, you can allow the user to rapidly navigate to the approximate location of the desired file and then use fine adjustments to find the exact location. You can use the ProgressBar control to provide feedback for the download status. When download is complete, you can notify the user by playing a beep from System- Sounds. You can provide help for the application by creating a compiled help file (.chm) and using the HelpProvider component to connect it to your application. For more imme- diate and less in-depth help, you can use the ToolTip component to provide informa- tive tooltips for the controls on your application. The ErrorProvider component can be used to provide feedback for invalid user input. Case Scenario 2: Making the Document Management Application Accessible By using only system colors, you can support high-contrast mode. If nonsystem colors are desired for the regular application interface, the application should detect if the system is in high-contrast mode and replace nonstandard colors with system colors. No information should be conveyed by sound alone, so when file downloads are com- plete, for example, you should provide a visual cue as well as an audible cue. Access keys should be used to enable keyboard access to all important functionality in the application, and this keyboard access should be fully documented. Answers 733 System settings should be used throughout the application to support interaction with usability aids. In addition, the AccessibleDescription, AccessibleName, and AccessibleRole properties should be set to appropriate values. Chapter 13: Lesson Review Answers Lesson 1 1. Correct Answers: A and B A. Correct. The RunWorkerAsync process fires the DoWork event, which con- tains the code that is executed on a background process. B. Correct. The DoWork event handler contains the code that is executed on the background process. C. Incorrect. The ProgessChanged event is fired when the ReportsProgress method is called, but it is not required for the background process to be run. D. Incorrect. The WorkerSupportsCancellation property indicates whether the BackgroundWorker supports cancellation of the background process, but it is not required for the background process to run. 2. Correct Answers: A, B, and C A. Correct. You must set the WorkerSupportsCancellation property to True to allow the process to be cancelled. B. Correct. You must implement your own code to poll the CancellationPend- ing property and cancel the process. C. Correct. The CancelAsync method sets the CancellationPending property to True. D. Incorrect. You cannot set the CancellationPending property directly. You must instead call the CancelAsync method. 3. Correct Answers: A, B, and D A. Correct. The ReportProgress method raises the ProgressChanged event and allows you to specify a percentage of progress. B. Correct. You must handle the ProgressChanged event to implement code that is executed when progress is reported. C. Incorrect. It is unnecessary to poll the IsBusy property to report progress. D. Correct. You cannot call the ReportProgress method unless the Worker- ReportsProgress property is set to True. 734 Answers Lesson 2 1. Correct Answer: B A. Incorrect. The Invoke method is used to execute a method call synchro- nously. B. Correct. The BeginInvoke method calls the method on a separate process thread. C. Incorrect. Although commonly used to complete an asynchronous method call, EndInvoke is required to complete the call only if a method result is required. D. Incorrect. The DynamicInvoke method is used to call methods synchro- nously using late binding. 2. Correct Answers: A and B A. Correct. Thread objects are instances of the Thread class, and each thread must be individually created. B. Correct. The Thread.Start method starts the new background process. C. Incorrect. Although you can provide an Object parameter to the new thread, you can also start a thread with a method that takes no parameters. D. Incorrect. Once execution of a thread completes, the thread will stop. Call- ing Thread.Abort is required only to stop a thread that is still running. 3. Correct Answers: B and C A. Incorrect. Calls to controls from background threads are inherently unsafe and must be called through Control.Invoke. B. Correct. The InvokeRequired property can be queried from any thread to determine if it is safe to make a direct call or whether Control.Invoke must be used. C. Correct. The Control.Invoke method can be used to make safe calls to con- trols from background threads. D. Incorrect. The Control.IsAccessible property indicates if the control is acces- sible to accessibility aids and is not related to calls from background threads. [...]... 257 Dock property controls, 26 Fill setting, 40 function of, 59 overview of, 60 Properties window and, 58 setting, 60 document object model (DOM) XML DOM See XML DOM XmlNode and, 451 Document Outline window allocating controls with, 61 opening, 62 working with controls, 62 752 Document property, PrintPreviewControl, Document property, PrintPreviewControl, 510 documentation, keyboard navigation, 559 documents,... variable used to provide alternate val­ ues to expressions such as SQL statements and stored procedures parameter PrintDocument The primary component in printing A PrintDocument component represents a printed document An on-screen preview of a printed document You can preview a PrintDocument component in either a PrintPreviewDialog or a PrintPreviewControl PrintPreview setting A value that properties... method, PrintDocument, 496, 510 PrintDialog box, 490 PrintDialog component changing selected printer at runtime, 489 overview of, 487–489 review, 493, 493–495 PrintDocument component overview of, 496–498 overview of printing, 496 PageSetupDialog component, 490–492 PrintPage events, 497 PrintPreviewControl, 509 review, 506 setting Document property, 510 using PrintDialog box to print, 490 PrintDocumentEndPrint... application design is the list of documents for download Both the UI thread and the background downloading thread must access this list You should protect access to this list by using SyncLock or lock blocks where appropriate to allow access to the list by only one thread at a time A background thread should be used to download the documents When download of a particular document is com­ plete, the UI... PrintPreviewControl, Document property, PrintPreviewControl, 510 documentation, keyboard navigation, 559 documents, WebBrowser control for working with, 136 DocumentStorage table, 303 DocumentType value, Name property, 446 DoDragDrop method, 524, 525, 526 DOM (document object model) XML DOM See XML DOM XmlNode and, 451 DomainUpDown control, 114 DoubleClick, mouse events, 184 DoWork event creating background... ErrorProvider component, 573 DataSet objects, with XML data, 387–395 loading DataSet from XML stream or document, 388 loading DataSet objects with XML data, 393 loading DataSet schema from XML stream or document, 388 review, 394 saving DataSet objects as XML, 390 synchronizing DataSet with XmlDataDocument, 389 writing DataSet as XML data, 387 writing DataSet schema as XML schema, 388 XPath queries on... property, 26 case scenarios, 659–660 common properties, 51 configuring help for, 576 configuring invisible, 629 consistency of use in user interface, 64 container controls See container controls Dock property, 26 Document Outline window for working with, 62 events raised by, 181 list-based See list-based controls overview of, 51, 623 practice test, 661 review, 658–659 setting tooltips for, 570 suggested... using properties, 650 review, 653, 656-657 controls, configuring, 51–92 Anchor property, 59 at design time, 53–57 Button controls, 67–72 changing control location at design time, 54 Dock property, 60 DataAdapter objects Document Outline window, 61 exercise, 64, 92 Label controls, 72 layout tasks at design time, 55 LinkLabel controls, 73–75 overview of controls, 51 Properties window, 58 resizing controls... application In addition, with a Click-Once application, your clients do not have to be administrative users to install the application 740 Answers Case Scenario 2: Installing the Document Core By creating a setup project to install the document core, you can create a setup environ­ ment that accomplishes all of these goals Directory structures can be defined in the File System Editor, and registry keys can... 513–516 PrintPreview control, 509–510 review, 516–517 setting columns and rows, 511 setting Document property, 510 setting Start page, 512 zooming, 512 PrintPreviewControl adding methods and events to, 513 anti-aliasing, 511 lab exercise, 513–516 overview of, 509–510 review, 516–517 setting columns and rows, 511 setting Document property, 510 setting Start page, 512 zooming, 512 PrintPreviewDialog component . represents 100 percent normal size. Thus, 25 0 would correspond to a zoom of 25 ,00 0 percent. Answers 727 B. Incorrect. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, 25 . correspond to a zoom of 2, 500 percent. C. Correct. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, 2. 5 would correspond to a zoom of 25 0 percent. D. Incorrect Incorrect. In the Zoom property, a value of 1 represents 100 percent normal size. Thus, .25 would correspond to a zoom of 25 percent. 2. Correct Answer: B A. Incorrect. UseAntiAlias is a property,

Ngày đăng: 07/07/2014, 05:20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan