Back to description
Planning a trip to the beach, the mountains, or just a day of work in the yard? Most people want to know what the weather... more
Planning a trip to the beach, the mountains, or just a day of work in the yard? Most people want to know what the weather forecast will hold for the next several days so they can plan their outdoor activities accordingly. If you are at work, you may simply want to know what the current temperature is so you can plan that walk at lunchtime. Weather plays an important factor in most everything we do. How many people in a hurry turn on the evening news just to catch the weather forecast for the next several days?
The Desktop Weather program provides this information on your computer, where most of us spend our days working. Want to know what the current temperature is? With the Desktop Weather program you can simply look down at the temperature icon in the system tray. Want to know what Mother Nature holds in store for the next several days? Double-click the Desktop Weather’s temperature icon in the system tray to display the Desktop Weather form showing the seven-day forecast.
In this chapter you will learn how to customize the Desktop Weather program, which uses a Web Service to retrieve the weather data for your area. This program uses the Web Service created by the National Weather Service in the United States to provide weather data for the United States. However, if you live in another country, you can adapt the Desktop Weather program to use a Web Service from anyone who provides weather information in your country.
Some of the technologies included in the Desktop Weather program are as follows:
Accessing a Web Service
Accessing a Web site programmatically
Reading XML
Using application and user settings in the app.config file
app.config
Using the NotifyIcon class to create an icon in the system tray
NotifyIcon
... less
Have you done any online shopping lately? Have you visited a Web site to read an article only to have to register and... more
Have you done any online shopping lately? Have you visited a Web site to read an article only to have to register and enter yet another login and password? It seems that just about every Web site you visit and want to interact with wants you to register, entering a login name and password. Some Web sites are good about requiring strongly typed passwords: passwords that contain uppercase and lowercase letters, numbers, and special characters. Some Web sites don’t support special characters in their passwords. Each Web site has its own special set of rules about password strength and length.
Trying to keep up with your login names and passwords for the various Web sites that you frequent can become tiresome. This is especially true for Web sites that you visit less frequently because you are prone to forgetting your login and password.
This is where the Password Keeper application can assist you. This application keeps track of the Web site URL you visit and your login and password associated with that Web site. The best part of this application is that it keeps all of this information in an encrypted format so that your personal data is not compromised in the event that someone gains access to your computer. In this chapter you will learn how the Password Keeper is put together and how to use the technologies employed in this application.
The main technologies used in this application are as follows:
Reading and writing XML data
Encrypting and decrypting data
Hashing data
When writing software applications that run on a server, you typically place the required configuration values for that... more
When writing software applications that run on a server, you typically place the required configuration values for that application in the system registry. This placement makes your application more secure than it would be if you put those values in an application configuration file. The system registry is typically restricted to only those users who have permissions to view it, whereas it is most likely that anyone could browse to the folder where your application is installed and view the application configuration file.
One challenge of using the registry in your applications is knowing how to create registry keys programmatically from your application and setting and reading key values stored in the registry. The Application Registry Manager program demonstrated in this chapter should help you to gain a better understanding of how to perform these tasks within your own applications. This application demonstrates creating and deleting registry keys for an application, as well as setting and deleting the values for those keys.
Using the RegistryKey class in the .NET Framework
RegistryKey
Using a TreeView control
TreeView
Using a ListView control
ListView
Recursively calling a procedure to enumerate values
How do you know whether your application is doing its job? If you have a Web application or Windows application,... more
How do you know whether your application is doing its job? If you have a Web application or Windows application, you can visually see what is being done by the application. You can enter data, click through some screens, and then view the data that was entered. This is a visual indication that the application is doing the job it was designed to do.
However, if you have written a Web Service or Windows Service, you have no visual indicators that the service is doing the job that it was designed to do, as it has no user interface (UI). This is where event logging comes into play. Built into the operating system, the event log exposes three pre-built logs: application, security, and system. The application log can be written to by any application; and using the Event Viewer that comes with the operating system, you can view the various events in the application log.
Now suppose your service is not behaving as expected and no events are being written to the application log. How are you going determine what is happening inside the service? This is where trace writing comes into play. Trace writing enables you to monitor the health of your application by having your application write trace events at different levels: error, warning, informational, and verbose. The first section of this chapter explains these different levels in detail.
This chapter also shows you how to write events to the application log and how to write trace events to a custom event logall of which are viewable using the Event Viewer. You’ll also learn how to control the level of trace writing so that you are getting the level of information needed without hampering the performance of your application.
Instead of writing a brand-new application just to write event log and trace messages, the Application Registry Manager program has been enhanced to provide this functionality. This serves two purposes. One, it provides a useful and functional application that can benefit from these technologies. Two, it provides an application that can be run in debug mode, which enables you to see how these technologies are used step by step.
The main technologies used in this chapter are as follows:
Creating an application-specific event resource DLL
Creating an event source
Writing events to the application log
Creating and configuring a trace switch
Writing various levels of trace information to a custom event log
In the last chapter you explored writing events to the application event log and writing trace events to a custom event... more
In the last chapter you explored writing events to the application event log and writing trace events to a custom event log. Writing events from your application provides important information about what your application is doing, and writing trace events provides important information about how your application is performing.
Now suppose that your application has been deployed to a production environment to which developers are not granted access. How are you to determine how your application is performing and how are you to view the events that your application is writing?
This is where the Wrox Event Log Service program comes into the picture. This Windows Service can be installed on the same production machine as your application, and can be configured to process several times a day to read the application event log and custom trace log and e-mail those events to you that were logged by your application. This enables you to monitor the health of your application and to see what events your application is writing.
In this chapter you will learn how to read events from the application event log and custom trace log on a timed schedule, how to process those events, and how to e-mail the events to a variety of people. All of the information that the Wrox Event Log Service needs could be supplied in a application configuration file but will be supplied in the registry using the Application Registry Manager program.
The main topics covered in this chapter are as follows:
Reading values from the registry
Using a system timer to execute code on a timed event
Reading events from the application event log and custom trace log
Creating and e-mailing event log messages
Have you ever used the Notepad application that comes with Windows? Did you ever wish that it had a toolbar that provided... more
Have you ever used the Notepad application that comes with Windows? Did you ever wish that it had a toolbar that provided the icons for cut, copy, and paste? Did you ever wish that it had a spell checker? Have you ever wondered how Microsoft Word automatically corrects text as you type? Have you ever wanted to create a multi-threaded application but weren’t quite sure how to go about it?
This chapter answers all of these questions and more as you examine a multi-threaded Notepad application that includes an auto-correct feature that automatically corrects words as you type and provides a spell checker that can be invoked via an icon on the toolbar.
The Notepad Plus application uses the Component Object Model (COM) exposed by Microsoft Word 2003 to access the spell checker features included in that application, as well as the method used to extract the list of auto-correct words and their replacements.
While this may not be desirable for some readers, it demonstrates a couple of important points. First and foremost, it demonstrates how to tap into the rich features of Microsoft Word 2003 using the COM interfaces. It also demonstrates how to create a multi-threaded application.
Therefore, running the application in this chapter requires that Microsoft Word 2003 is installed on your computer, as well as the Microsoft Office Primary Interop Assemblies. When the design of the application is discussed, I’ll explain how to update the COM reference to use other versions of Microsoft Word. The “Configuring the Application” section at the end of this chapter discusses the Microsoft Office Primary Interop Assemblies that are also required.
Accessing the public methods exposed by the Microsoft Word 2003 COM interface
Using the BackgroundWorker class to create a multi-threaded application
BackgroundWorker
Extending an existing control in the .NET Framework
Using the BinaryFormatter class to serialize objects to and from the disk
BinaryFormatter
The .NET Framework has come a long way since its first release in 2001. It has implemented functionality in various classes... more
The .NET Framework has come a long way since its first release in 2001. It has implemented functionality in various classes that make developing applications easier and faster. For example, the My namespace introduced in version 2.0 of the .NET Framework made a lot of common tasks such as accessing application and computer information easier to code and faster.
My
However, there is one area in which the .NET Framework is still lacking, and that is in providing feature-rich printing functionality. The framework provides classes that enable you to access the Print and Print Preview dialogs, but it lacks the actual classes that perform printing. This task is left up to the developer to implement, and it typically requires complex logic for formatting text on a page and sending it to the printer.
In this chapter I’ll cover the implementation of feature-rich printing functionality in the RichTextBoxExtended control. This control has been enhanced with printing functionality that supports printing a document with various fonts and colors. In addition, the control implements this functionality so that all the user of the RichTextBoxExtended control has to do is to invoke the Print method to print the text. This enables a developer to use this control and automatically have the printing functionality already built in.
RichTextBoxExtended
Print
Using the PrintDocument, PrintPreviewDialog, and PrintDialog classes
PrintDocument
PrintPreviewDialog
PrintDialog
Using the WIN32 SendMessage API to format the print text and send it to the printer
SendMessage
Support for printing the entire document, the current page, a range of pages, and a selection of text via selections made in the PrintDialog class
If you read the title for this chapter and thought to yourself, not another chapter on data binding using the wizards... more
If you read the title for this chapter and thought to yourself, not another chapter on data binding using the wizards and strongly typed datasets, you could not have been farther from the truth. The data wizards in the Visual Studio .NET Integrated Development Environment (IDE) are ideal for creating applications that use data binding and strongly typed datasets, but these types of interfaces do not lend themselves well to extensibility and changing business requirements.
This chapter takes a different approach to data binding: binding various data sources to commonly used controls in code. This approach provides several key benefits, such as control over when your data sources are populated, when controls are bound, control over refreshing or even changing a control’s data source, and an application that allows for changing business requirements and business rules.
This chapter focuses on data binding using the following data sources: DataSet, DataView, DataTable, XML, ArrayList, and user-defined business objects. Using these data sources, data binding is discussed and demonstrated using the following controls: ComboBox, ListBox, DataGridView, and ListView. Anyone who has used the ListView control before knows that it does not natively support data binding. This chapter extends this control to support data binding through code.
DataSet
DataView
DataTable
ArrayList
ComboBox
ListBox
DataGridView
The main technologies covered in this chapter are as follows:
Using the XmlTextWriter class to generate XML
XmlTextWriter
Using the MemoryStream class to pass data between classes
MemoryStream
Using a user-defined business object as a data source
Extending the ListView control to provide the DataSource, DisplayMember, and ValueMember properties
DataSource
DisplayMember
ValueMember
A lot of Windows and Web applications rely on the use of images to spruce up their user interface and to convey visual... more
A lot of Windows and Web applications rely on the use of images to spruce up their user interface and to convey visual information to the user. It is not uncommon for multiple applications within an organization to share the same images, such as a company logo image or tag line image. Keeping these images in a common central repository is key to ensuring that all applications display the same image, thereby achieving a uniform look. Media storage preferences vary from organization to organization: Some use a common shared folder on the network, others a database, or even a source control system.
This chapter explores storing and managing images in a database, particularly a SQL Server 2005 Express database. Therefore, a requirement for this chapter is that the target computer must have SQL Server 2005 Express installed on it. The Database Image Manager application provides it own SQL Server 2005 Express database and automatically attaches the database in SQL Server Express.
This application enables you to add, update, and delete images in a database. The user interface (UI) for this application enables you to view thumbnail images of all images contained in the database, select an image for editing, resize the image, and then update the image in the database.
Using SQL Server 2005 Express to attach a database
Using the SqlConnection, SqlCommand, and SqlDataReader objects to manage images in the database
SqlConnection
SqlCommand
SqlDataReader
Using the Bitmap, Image, Graphics, and MemoryStream classes to manipulate images
Bitmap
Image
Graphics
Creating of a Thumbnail user-control to display image thumbnails in the UI
Thumbnail
I believe the TextBox control is one of the most powerful and versatile controls in the Toolbox.... more
TextBox
I believe the TextBox control is one of the most powerful and versatile controls in the Toolbox. This control can be used for data entry such as names and addresses, enabling you to set the width of the TextBox to the approximate size of the data to be entered. You can also bind the TextBox to data from a DataSet to display data from your database. Set one property on a TextBox control and it can be used for passwords, preventing the password from being seen or copied. Set a different property on this control and the TextBox becomes a big multi-line text editor.
However, for all of its power and flexibility, the TextBox control still lacks some basic properties that would enhance the user experience and make the developer’s job easier. These are properties that prevent the user from entering numeric data in a name field, for example, or that require numeric data and disallow character data in a phone number field. These are basic data entry tasks, and properties like these would greatly enhance this already versatile control.
Another simple and basic feature lacking in the TextBox control is the ToolTip property. Why should a developer be forced to drag another control to the designer surface of a form just to implement a ToolTip property? This is a very basic property that enhances the user’s experience with any application.
ToolTip
The Custom Controls application in this chapter extends the TextBox control to provide some of these basic features, and other helpful features, and then demonstrates their usefulness and functionality. This application implements nine new properties for the TextBox control and overloads an existing property to enhance, it making it more useful. The existence of these new properties reduces the amount of code that you, as a developer, have to write to support a rich user experience when using the TextBox control.
Using the CategoryAttribute, DescriptionAttribute, and DefaultAttribute classes to categorize, describe, and assign values to properties
CategoryAttribute
DescriptionAttribute
DefaultAttribute
Using the ToolTip class to provide built-in tooltip functionality for a TextBox control
Overloading an existing property to enhance its functionality
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they must be viewed using the Adobe Reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapter on Demand File Any Wrox Chapter on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974 (United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Related Books
Visual Basic Resources