Contenu connexe
Similaire à Vb.net session 11 (20)
Vb.net session 11
- 1. Accessibility and Globalization
Objectives
In this lesson, you will learn to:
• Identify the standard design guidelines for building accessibile applications
• Implement the standard accessibility options in Visual Basic .NET
• Identify the role of globalization and localization in designing world ready
applications
• Identify the factors related to globalized applications
• Create applications for multiple cultures
• Deploy application resources using satellite assemblies
• Describe the help system
• List the various files that constitute a help system
• Implement context-sensitive help
• Implement pop-up help
• Provide help for an application using tool-tips
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 1 of 38
- 2. Accessibility and Globalization
Application Accessibility
• Application Accessibility refers to the usability and approachability of an
application for a wide audience, including those with special needs.
• Applications need to be built in such a way as to make the application as
accessible as possible to people with impairments or those with reduced
abilities due to aging.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 2 of 38
- 3. Accessibility and Globalization
Design Guidelines for Accessible
Applications
• Applications can be made accessible by offering built-in options that allow all
types of users to use the applications more effectively.
• Certain guidelines to be followed for designing applications that are accessible
to a large audience are given below:
• Flexibility in Use: The user interface should be flexible and customizable so
that it accommodates a variety of user needs and preferences.
• Simple and Intuitive: The user interface should be simple and easy to
understand, regardless of the user's experience, knowledge, language
skills, or current concentration level.
• Compatibility with Accessibility Aids: Application should be compatible with
a variety of techniques or devices used by people with sensory limitations.
• Redundant Input and Output Methods: Application should provide multiple
input and output techniques.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 3 of 38
- 4. Accessibility and Globalization
Standard Accessibility Options in
VB .NET
• To make an application accessible, certain properties need to be set for the
various controls on a form.
• The table given below lists the various control properties and a description of
how these properties should be set to make the applications more accessible:
Control Property Accessibility Considerations
AccessibleName This property specifies a name for a control
by which the accessibility aids identify the
control.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 4 of 38
- 5. Accessibility and Globalization
Standard Accessibility Options in
VB .NET (Contd.)
• The list of various control properties:(Contd.)
Control Property Accessibility Considerations
AccessibleDescription This property specifies a description for a control. This
description is reported to the accessibility aids.
AccessibleRole This property specifies the use of the element in the
user interface and reports it to the accessibility aids.
TabIndex The TabIndex property helps to creates a logical
navigational path through the form.
Text The Text property provides keyboard access to all the
controls on the form.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 5 of 38
- 6. Accessibility and Globalization
Standard Accessibility Options in
VB .NET (Contd.)
• The list of various control properties:(Contd.)
Control Property Accessibility Considerations
Font Size All controls added to a form have the same font size
as the form by default.
Forecolor By setting the Forecolor property to default, you can
enable the form to use the user’s default system
settings for forecolor.
Backcolor By setting the Backcolor property to default, you can
enable the form to use the user’s default system
settings for backcolor.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 6 of 38
- 7. Accessibility and Globalization
Standard Accessibility Options in
VB .NET (Contd.)
• The list of various control properties:(Contd.)
Control Property Accessibility Considerations
BackgroundImage This property should be left blank so as to
make the text more readable.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 7 of 38
- 8. Accessibility and Globalization
Building International Applications
• The .NET Framework provides unprecedented support for the development
of world-ready applications.
• It helps you create applications that adapt to different languages, currency
formats, date/time formats, and other culture-specific information.
• When developing a world-ready application, the process should be divided
into three phases:
• Globalization
• Localizability
• Localization
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 8 of 38
- 9. Accessibility and Globalization
Globalization and Localization
• Globalization: In this step, the application's executable code is written in
such a way that makes it culture-neutral and language-neutral.
• Localizability: The purpose of this step is to test whether the application's
executable code is independent of the culture and language-specific data.
• Localization: In this step, you customize the application for specific cultures
or regions.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 9 of 38
- 10. Accessibility and Globalization
Factors Related to Globalization of
Applications
• Numerous factors need to be considered by application designers when
developing world-ready applications. These include:
• Language Issues: Language issues are the result of differences in how
languages around the world differ in display, alphabets, grammar, and
syntactical rules.
• Formatting Issues: Formatting issues are the main source of
discrepancies in applications designed for multiple languages or
cultures.
• String-related Issues: When developing a world-ready application,
differences among languages, especially those related to strings, must
be considered.
• User-Interface Issues: Various user interface issues are associated
with the designing of a world-ready application.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 10 of 38
- 11. Accessibility and Globalization
Globalizing and Localizing Windows
Forms
Working with Multiple Cultures
• For developing an application that works for multiple cultures, you need to
include support for culture-specific sorting rules, date and time formatting,
numeric and monetary conventions and symbols and character encoding.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 11 of 38
- 12. Accessibility and Globalization
Culture Codes
• The .NET Framework represents different cultures across the world using
either a two-letter code that specifies the language or a two-letter language
code followed by a dash and another two-letter-code that specifies the
region.
• Some culture codes and their descriptions are:
• En: Specifies English language, no region
• en-CA: Specifies English language, Canada
• fr-FR: Specifies French language, France
• De: Specifies German language, no region
• Zh-CN: Specifies Chinese language, China region
• de-DE: Specifies German language, Germany region
• Culture codes that only specify a language are called neutral cultures,
whereas culture codes that specify a language as well as the region are
called specific cultures.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 12 of 38
- 13. Accessibility and Globalization
Retrieving and Setting the Current
Culture and Current UI Culture
• The Current Culture and Current UI Culture values determine what resources
are loaded for an application and how information like currency, numbers,
and dates is formatted.
• The CultureInfo class holds the information about a culture and how it should
interact with your application.
• You can set the culture of an application programmatically by setting the
CurrentThread.CurrentCulture property to a new instance of the CultureInfo
class.
• The current UI culture can be set in the same way as the current culture.
• The CurrentUICulture can be retrieved by accessing the
CultureInfo.CurrentUICulture property
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 13 of 38
- 14. Accessibility and Globalization
Culture-specific Formatting
• The CultureInfo class has three members. These formatting members are:
• DateTimeFormat: Contains information about how dates and times are
formatted.
• NumberFormat: Contains information about how numbers and currency
are formatted.
• TextInfo: Contains information about how text is formatted.
• The properties of the above members can be changed for specific culture
formatting needs.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 14 of 38
- 15. Accessibility and Globalization
Unicode Support
• Different character sets needed to be used for representing data from
different cultures.
• Unicode provides a standard encoding scheme for characters of different
languages all over the world.
• Unicode assigns a unique numeric value, called a code point, to each
character used in the written languages of the world.
• Characters are represented in the .NET Framework using Unicode UTF-16
(Unicode Transformation Format, 16-bit encoding form) character encoding.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 15 of 38
- 16. Accessibility and Globalization
Convert Existing Encodings
• The .NET Framework allows you to convert data from other formats to
Unicode data.
• This can be done using the Encoding class.
• The Encoding class is found in the System.Text namespace and cannot be
directly instantiated.
• An instance of this class can be obtained by using the Shared method,
Encoding.GetEncoding.
• To convert an existing encoding to Unicode, you can use the
Encoding.Convert method.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 16 of 38
- 17. Accessibility and Globalization
Implementing Right-to-Left Display
• Some languages such as Arabic have scripts that read from right-to-left
instead of left-to-right.
• In order to enable implementation of a right-to-left user interface, the
RightToLeft property of a form must be set to Yes.
• The RightToLeft property can be set to one of three values viz. Yes, No and
Inherit, where No is the default value.
• When a form’s RightToLeft property is set to Yes, formatting of each control
on the form becomes a mirror image of itself.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 17 of 38
- 18. Accessibility and Globalization
Validating Non-Latin User input
• When developing an application for different cultures, you might need to
incorporate techniques for validating non-Latin input into your application.
• The Char structure exposes some validation methods that can be used to
determine the category of a non-Latin alphabet input in the same way as a
Latin alphabet input.
• The Char.IsDigit, Char.IsLetter, and other methods return appropriate
values no matter what input character set is used.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 18 of 38
- 19. Accessibility and Globalization
Culture-specific Classes and Methods
• Different cultures use different conventions for displaying currency, dates,
time, numbers and other information.
• Classes that automatically format information according to the culture
setting are called culture-specific classes.
• The System.Globalization namespace contains classes that can be used to
modify the display of culture-specific values, namely, DateTimeFormatInfo,
Calendar, and NumberFormatInfo.
• Some culture-specific methods like, IFormattable.ToString,
Console.Writeline, String.Format, MonthName and WeekDayName are also
available.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 19 of 38
- 20. Accessibility and Globalization
Globalizing Windows Forms
• Globalization is the identification of all localizable resources in the application
and their separation from the executable code so that the localizable resources
can be modified easily.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 20 of 38
- 21. Accessibility and Globalization
Localizing Windows Forms
• Localization is the process of customizing an application for a given culture.
• A form can be localized by setting its Localizable property to True.
• Text property allows the application to automatically display the date in a
format corresponding to the current culture settings.
• For each language or culture the application needs to support, a user interface
needs to be created.
• Different user interfaces can be created for different cultures by changing the
Language property of the form.
• Other elements like form layouts, display formats for dates and times,
currency, numbers, and graphics with local content, can also be localized.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 21 of 38
- 22. Accessibility and Globalization
Application Resources
• A resource is any non-executable data that is logically deployed with an
application.
• A resource might be displayed in an application as error messages or as part
of the user interface.
• Examples of resources include strings displayed in the user interface based
on the culture settings of the system or a set of images.
• Packaging your localizable data in a resource file allows you to change the
data without recompiling your entire application.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 22 of 38
- 23. Accessibility and Globalization
Resource Assemblies
• Resource assemblies are assemblies that contain only resources.
• By placing all of your resources into a resource-only assembly, you can
update the assembly as and when you need without having to recompile
your application.
• When creating an application for multiple cultures, different sets of resources
are required to be created for different cultures.
• Satellite assemblies are resource assemblies that include separate resources
for different cultures.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 23 of 38
- 24. Accessibility and Globalization
Creating Resource-only Assemblies
• To create a resource-only assembly, the following steps need to be
performed:
1. Create a new Visual Basic project with the Empty Project template.
2. From the Project menu, choose Add Existing Item to add your
resource files to your project.
3. In Solution Explorer, right-click your project and choose
Properties. The property pages open.
4. In the Output Type drop-down menu, change the output type of
your project to Class Library. This will cause your assembly to be
compiled as a .dll file.
5. From the Build menu, choose Build <your project> where <your
project> is the name of your project. The resources you added to
the project, are compiled into the assembly.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 24 of 38
- 25. Accessibility and Globalization
Creating Satellite Assemblies
• To create satellite assemblies, the following steps need to be followed:
1. Create alternate versions of your resource files specific to locales
where your application will be run.
2. Name your resource files correctly for their specific culture. Names
for resource files for satellite assemblies must contain the culture
code separated by periods between the base name and the
extension. The base name and extension must be the same as the
resource file for the invariant culture.
3. From the Project menu, use Add Existing Item to add these files to
your application.
4. From the Build menu, choose Build Solution to build your solution.
5. Culture-specific resource files are automatically compiled into
satellite assemblies and placed in an appropriate directory
structure.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 25 of 38
- 26. Accessibility and Globalization
Retrieving Resources at Runtime
• At run-time, the ResourceManager class can be used to retrieve resources
from an assembly.
• An instance of the ResourceManager can be created by specifying two
parameters in its constructor: the base name of the embedded resource file
and the assembly in which the file is found.
• The base name of a resource file is the name of the namespace that contains
the file and the filename without any extensions.
• The assembly parameter refers to the assembly in which the resource file is
located.
• To retrieve a string, the ResourceManager.GetString method can be used.
• The GetString method requires you to specify the name of the string
resource you want to retrieve as a parameter.
• Images and other objects can also be retrieved from a resource file by using
the ResourceManager.GetObject method.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 26 of 38
- 27. Accessibility and Globalization
Introducing Help System
• While using an application, a user might need help on performing an
operation or require information about a button or a dialog box.
• To assist the user while using the application, provide a help system with the
application.
• Help system can be created using HTML Help Workshop.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 27 of 38
- 28. Accessibility and Globalization
Help Files
• A help system is made up of several different help files and components that
are created using HTML Help Workshop.
• Some of the files that make up a help system are:
• HTML Files
• Graphics and Multimedia Files
• Help Project Files
• Contents Files
• Index Files
• The HTML Help Workshop allows you create a help system with standard
features of any help system like:
• Table of Contents
• Index
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 28 of 38
- 29. Accessibility and Globalization
Building a Help System
• To build a help system, the following steps need to be performed:
1. Create a Project File
2. Create HTML Topic Pages
3. Create an Index
4. Create a Table of Contents
5. Compile the Help Project
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 29 of 38
- 30. Accessibility and Globalization
Implementing Help
• The user should be able to access the help system by pressing the F1 key.
• A help system can be associated with your Windows application with the help
of the HelpProvider control.
• The HelpProvider control needs to be linked with a help file.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 30 of 38
- 31. Accessibility and Globalization
Providing Context Sensitive Help
• Context-sensitive help assists users by providing help based on a specific
dialog box or control in a program.
• To add context-sensitivity to the application, the various controls in the form
need to be linked with the Help file.
• To add context-sensitive help to a control, the following properties need to
be set for the control:
• Set the ShowHelp on <HelpProvider control> to True.
• Set the HelpKeyword on <HelpProvider control> to an appropriate
keyword for retrieving help.
• Set the HelpNavigator property.
• To implement context-sensitive help, the following steps need to be
performed:
1. Link your application with a help file.
2. Add context sensitive help to various form elements.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 31 of 38
- 32. Accessibility and Globalization
Understanding Pop-up Help
Displaying Pop-up Help
• Pop-up help can be provided in an application through the Help button, also
called the What’s This button.
• The Help button is displayed when the Maximize and Minimize buttons are
not there on the title bar.
• To display Help button on the title bar of a form, the following steps need to
be performed:
1. Set the MinimizeBox and MaximizeBox properties of the form to
False.
2. Set the HelpButton property of the form to True.
• To associate pop-up help with different controls on the form set the
HelpString on <HelpProvider Control> property of the controls to a string
that specifies the help text for the control.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 32 of 38
- 33. Accessibility and Globalization
Understanding Tool-tips
• A tool tip is a brief message for individual controls on a form.
• Tool tips are generally used for displaying help for toolbar icons.
• They can be displayed by using the Tooltip control present in the Toolbox.
• The user can access a tool tip by pointing at the control for which the tool tip
has been created.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 33 of 38
- 34. Accessibility and Globalization
Displaying Tool-tips
• To display a tool tip, you need to add a ToolTip control to the form and enter
the text in the ToolTipText property of the control for which the tool tip is to
be displayed.
• The ToolTipText property can be used to set the tool tip for a StatusBarPanel
control, a ToolBarButton control, and a selected tab.
• The following code is to set a tool tip text for a ToolBarButton control
programmatically:
ToolbarButton1.ToolTipText="Add a record"
• The SetToolTip() method of the ToolTip control is used to set the tool tip text
for a control.
• Some of the important properties of the ToolTip control are:
• Active
• AutomaticDelay
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 34 of 38
- 35. Accessibility and Globalization
Displaying Tool-tips (Contd.)
• There are three properties of the ToolTip control that have values based on
the value of the AutomaticDelay property:
• AutoPopDelay: This property is used to set the time period for which the
tool tip is displayed on the screen when the mouse pointer is stationary
in a tool tip region.
• InitialDelay: This property is used to set the time period for which the
mouse pointer should be stationary in the tool tip region before the tool
tip appears.
• ReshowDelay: This property is used to set the time taken by the
subsequent instances of the tool tip to appear when the mouse pointer
is moved from one tool tip region to another.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 35 of 38
- 36. Accessibility and Globalization
Summary
In this lesson, you learned that:
• Applications need to be made accessible so that they can be used by a wide
range of audience, including those with special needs.
• You need to follow a set of guidelines for developing accessible applications.
• The .NET Framework provides support for the development of world-ready
applications. It helps you create applications that adapt to different
languages, currency formats, date/time formats, and other culture-specific
information.
• When developing a world-ready application, the process should be divided
into three phases: globalization, localizability, and localization.
• While globalizing an application, you should strive to code the application in
such a way that allows it to work equally well for all cultures your application
supports.
• During the localizability phase, you test whether the application's executable
code has been properly separated from its resources.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 36 of 38
- 37. Accessibility and Globalization
Summary (Contd.)
• During localization an application is customized for specific cultures or
regions.
• Unicode provides a standard encoding scheme for characters of different
languages all over the world and hence helps in creating application for
multiple cultures and having a multilingual user interface.
• A resource is any non-executable data that is logically deployed with an
application.
• Visual Studio.NET allows the creation of three types of help systems:
• HTML Help
• Pop-up Help
• Tool Tips
• The HelpProvider control is used to associate a Help file with an application.
• The Help file to be associated with the HelpProvider control is specified using
the HelpNamespace property of the HelpProvider control.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 37 of 38
- 38. Accessibility and Globalization
Summary (Contd.)
• The HelpKeyword property under the Misc category of a control is used to set
the keyword for retrieving Helphelp from the Help file specified in the
HelpNamespace property.
©NIIT Enhancing and Distributing Applications Lesson 1A / Slide 38 of 38