1. Trang chủ
  2. » Công Nghệ Thông Tin

Windows Style Guide pps

4 86 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 4
Dung lượng 32,46 KB

Nội dung

Menu Guidelines and Style If you look at most Windows applications, you'll notice that some items on the menu strip tend to appear repeatedly in the same place, and the contents of these items are often predictable. For example, the File menu is typically the first item on the menu strip, and on this menu, you typically find commands for creating a new document, opening an existing document, saving the document, printing the document, and exiting the application. The term document means the data that the application manipulates. In Microsoft Excel, it would be a spreadsheet; in the Bell Ringers application that you created in Chapter 20, it could be a new member. The order in which these commands appear tends to be the same across applications; for example, the Exit command is invariably the last command on the File menu. There might be other application-specific commands on the File menu as well. An application often has an Edit menu containing commands such as Cut, Paste, Clear, and Find. There are usually some additional application-specific menus on the menu strip, but again, convention dictates that the final menu is the Help menu, which contains access to help as well as “about” information, which contains copyright and licensing details for the application. In a well-designed application, most menus are predictable and help ensure the application becomes easy to learn and use. TIP Microsoft publishes a full set of guidelines for user interfaces, including menu design, on the Microsoft Web site at http://msdn.microsoft.com/ui . 1. Ensure that the Active User box is checked and then click Create User. The message “Complete. Your account has been successfully created.” appears in a new page. 2. Click Continue. The Create User page reappears enabling you to add further users. Click Back to return to the Security page. The number of existing users is now set to 1. NOTE You can use the Manage users link on this page to change the e-mail addresses of users and add descriptions, and remove existing users. You can enable users to change their passwords, and recover their passwords if they forget them, by adding the ChangePassword and PasswordRecovery controls to the login page of the Web site. For more information, see the topic “Walkthough: Creating a Web Site with Membership and User Login” in the Microsoft Visual Studio 2005 Documentation. 3. In the Access Rules section, click “Create access rules.” The Add New Access Rule page appears. You use this page to specify which users can access which folders in the Web site. 4. Under “Select a directory for this rule,” ensure that the Northwind folder is selected by clicking it. Under “Rule applies to,” ensure “user” is selected and type John. Under “Permission,” click Allow. Click OK. This rule grants John access to the Web site. The Security screen reappears. 5. In the Access Rules section, click “Create access rules” again. In the Add New Access Rule page, under “Select a directory for this rule,” ensure that the Northwind folder is selected. Under “Rule applies to,” click Anonymous users. Under “Permission,” ensure Deny is selected. Click OK. This rule ensures that users who have not logged in will not be able to access the Web site. The Security screen reappears. 6. Close Internet Explorer displaying the ASP.NET Web Site Administration Tool and return to Visual Studio 2005. 7. Click the Refresh button in the Solution Explorer toolbar. The database file ASPNETDB.MDF appears in the App_Data folder, and the file Web.config appears in the project folder. Double-click Web.config to display it in the Code and Text Editor window. This file was created by the ASP.NET Web Site Administration Tool and should look like this: <?xml version="1.0" encoding="utf-8"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <authorization> <allow users="John" /> <deny users="?" /> </authorization> <authentication mode="Forms" /> </system.web> </configuration> The <authorization> element specifies the users that are granted and denied access to the Web site (“?” indicates anonymous users). The mode attribute of the <authentication> element indicates that the Web site uses Forms-based authentication. 8. Modify the <authentication> element and add a <forms> child element, as follows. Make sure you add a </authentication> element: 9. <authentication mode="Forms"> 10. <forms loginUrl="LoginForm.aspx" timeout="5" 11. cookieless="AutoDetect" protection="All" /> </authentication> The <forms> element configures the parameters for Forms-based authentication. The attributes shown here specify that if an unauthenticated user attempts to gain access to any page in the Web site, the user will be redirected to the login page, LoginForm.aspx. If the user is inactive for 5 minutes, she will have to login again when next accessing a page in the Web site. In many Web sites that use Forms- based authentication, information about the user is stored in a cookie on the user's computer. However, most browsers allow the user to specify that they don't want to use cookies (cookies can be abused by malicious Web sites and are frequently considered a security risk). Specifying cookieless="AutoDetect" enables the Web site to use cookies if the user's browser has not disabled them; otherwise, the user information is passed back and forth between the Web site and the user's computer as part of each request. The user information includes the user name and the password. Obviously, you don't want this to be clearly visible to everyone. You can use the protection attribute to encrypt this information, which is what this example does. 12. On the Debug menu, click Start Without Debugging. Internet Explorer opens. The start page for the application is CustomerData.asps, but as you have not yet logged in, you are directed to the LoginForm. 13. Type in a random user name and password and then click Log In. The Login page reappears displaying the error message “Invalid User Name or Password. Please enter a valid User Name and Password.” 14. In the User Name field type John. In the Password field type Pa$$w9rd. Click Log In. The CustomerData page appears displaying the message “This form will be implemented later.” 15. Close Internet Explorer and return to Visual Studio 2005. 1. Add the following statements: 2. ContextMenuStrip formMenu = new ContextMenuStrip(); formMenu.Items.AddRange(formMenuItemList); This code creates a new ContextMenuStrip and adds the array containing the Save Member and Clear menu items. 3. Associate the pop-up menu with the form by adding the following statements: this.ContextMenuStrip = formMenu; this.ContextMenuStrip.Enabled = false; The context menu should be disabled initially as the user cannot input any member data until she clicks New on the File menu. 4. Locate the newClick method. Add the following statement that enables the formMenu to the end of the method: this.ContextMenuStrip.Enabled = true; 5. Compile and run the project. Create a new member and input some values. If you right-click anywhere on the form (apart from the First Name and Last Name text boxes), the pop-up menu appears. If you click Clear, the form resets back to its default values. If you click Save Member, the details you have entered are saved to the file Members.txt. 6. Close the form when you have finished.  . Menu Guidelines and Style If you look at most Windows applications, you'll notice that some items on the menu strip. help ensure the application becomes easy to learn and use. TIP Microsoft publishes a full set of guidelines for user interfaces, including menu design, on the Microsoft Web site at http://msdn.microsoft.com/ui .

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