Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

C# ПІДРУЧНИКИ / c# / Premier Press - C# Professional Projects

.pdf
Скачиваний:
475
Добавлен:
12.02.2016
Размер:
14.7 Mб
Скачать

788 Project 6 CREATING A MOBILE APPLICATION

Adding Code to the Back Button in the frmUnattended Form

Similar to writing the code for the Back button in the frmPending form, you can add the following code to the Back button of the frmUnattended form.

private void cmdBack2_Click(object sender, System.EventArgs e)

{

 

Y

stUnattended.Items.Clear();

 

ActiveForm=frmSelectOption;

 

}

 

 

 

After creating the MobileCallStatus application,you can test the application in an

 

L

emulator. The following section discusses how to test a mobile application in an

emulator.

F

 

M

 

Testing the MobileCallStatusA

E

 

Application in an Emulator

T

 

 

To test your application in an emulator, perform the following steps:

1.On the View menu, point to the Mobile Explorer Browser option.

2.In the displayed list, select the Show Browser option.

3.Type the address of the mobile Web form in the Address box of the emulator and then press Enter.

TIP

While using an emulator, you can use the keyboard to type the information or navigate through the pages. While working with the actual device, such as a mobile phone, you can use the keys on the mobile phone.

You can type the address of the forms in the Address box to view all the forms in the MobileCallStatus application. Figure 33-14 shows the frmLogon form in an emulator.

Team-Fly®

IMPLEMENTING THE BUSINESS LOGIC

Chapter 33

789

 

 

 

 

FIGURE 33-14 The frmLogon form in an emulator

Navigating to the next form takes you to the frmSelectOption form, as shown in Figure 33-15.

FIGURE 33-15 The frmSelectOption form in an emulator

790 Project 6 CREATING A MOBILE APPLICATION

In the frmSelectOption form, if the user selects the View Pending Calls option, the frmPending form is displayed as shown in Figure 33-16.

FIGURE 33-16 The frmPending form in an emulator

However, if the user selects the Show Unattended Calls option in the frmSelectOption form, the frmUnattended form is displayed. Figure 33-17 shows the frmUnattended form in an emulator.

IMPLEMENTING THE BUSINESS LOGIC

Chapter 33

791

 

 

 

 

FIGURE 33-17 The frmUnattended form in an emulator

Summary

In this chapter, you created the MobileCallStatus application. While creating the application, you looked at the default code created by Visual Studio .NET for a mobile Web application. Finally, you learned to write the code for the MobileCallStatus application.

This page intentionally left blank

PARTIXBeyond

the Labs

This page intentionally left blank

Chapter 34

Advanced

C# Concepts

796

Part IX

BEYOND THE LABS

 

 

 

In this chapter, you will learn about COM+, System.Messaging namespace, and asynchronous message queuing.

COM+

Before I introduce you to COM+, you need to understand the concepts of COM, MTS, and Windows DNA.

What Is COM?

As you might be aware, COM stands for component object model, and it is a model for construction of binary-compatible software components introduced by Microsoft. In simple terms, COM is a specification and implementation framework that allows you to create modular, object-oriented, customizable, and upgradeable distributed applications using a number of programming languages. COM enables you to develop components that can communicate with other components irrespective of the programming language or tool you choose to develop it.Therefore, COM allows you to concentrate on developing your application and not bother about the internals of the components.

COM allows clients to invoke services provided by COM-compliant components (COM objects). Services implemented by COM objects are exposed through a set of interfaces that represent the point of contact between clients and the object.

Why COM?

In order to understand the features provided by COM, you first need to understand the rationale for its existence. Binary code has been in use for a long time now. Libraries have been used in C and C++ from the very beginning. Windows programmers have been reusing DLLs (dynamically linked libraries). But there were other issues.

Libraries created using C/C++ compilers were often incompatible with executables created using a different C/C++ compiler. Secondly, DLLs were language

ADVANCED C# CONCEPTS

Chapter 34

797

 

 

 

 

dependent. Moreover, updating DLLs posed greater problems. Compatibility between versions was not achieved because of memory allocation reasons. Changed DLLs often broke executables designed for an earlier version.

Benefits of COM

COM was an alternative developed by Microsoft to overcome these problems. The major benefits of COM are:

COM components can provide functionality in a standard way.

COM provides for component interoperability.

COM provides a good versioning mechanism that allows one system component to be updated without requiring updates to other components in the system.

COM components can be implemented in a number of programming languages.

Before we proceed further, I will take you through some commonly used terms in COM.

Interfaces

An interface is a specification that defines the type of behavior a class must implement. An interface provides a group of related methods that are pure virtual functions. These methods are not implemented in the interface but are implemented in the class that implements the interface.The class that implements the interface methods is referred to as coclass. When the coclass is instantiated,the instance that is created is referred to as component object.

A class that inherits an interface must implement every member of the interface. An interface enables other programs to access the functionality provided by your component.

Consider the following example, where a COM object behaves like a clock. The clock object supports two interfaces, IClock and IAlarm. The IClock interface provides the methods to set and read current time. The IAlarm interface provides the alarm and methods.