![]() |
Модераторы: Partizan, gambit |
![]() ![]() ![]() |
|
Medved |
|
|||
![]() Эксперт ![]() ![]() ![]() ![]() Профиль Группа: Завсегдатай Сообщений: 7209 Регистрация: 15.9.2002 Где: Kazakhstan, Astan a Репутация: 3 Всего: 154 |
Буду рад любой помощи в переводе изложенного материала на русский язык.
-------------------- |
|||
|
||||
VisualProgrammerNET |
|
|||
![]() Почётный халявщик ![]() ![]() Профиль Группа: Участник Сообщений: 461 Регистрация: 30.10.2005 Где: Зеленоград Репутация: 4 Всего: 6 |
А переводить надо и все те материалы, что под ссылками? Или картинки и подписи только?
-------------------- 3 ГОДА НА ![]() |
|||
|
||||
Medved |
|
|||
![]() Эксперт ![]() ![]() ![]() ![]() Профиль Группа: Завсегдатай Сообщений: 7209 Регистрация: 15.9.2002 Где: Kazakhstan, Astan a Репутация: 3 Всего: 154 |
Да что угодно. Когда я делал выборку, старался использовать минимум английского текста. Было бы неплохо, если бы кто-нибудь что-нибудь дополнил.
-------------------- |
|||
|
||||
Medved |
|
|||
![]() Эксперт ![]() ![]() ![]() ![]() Профиль Группа: Завсегдатай Сообщений: 7209 Регистрация: 15.9.2002 Где: Kazakhstan, Astan a Репутация: 3 Всего: 154 |
Smart Client - Composite UI Application Block
http://msdn.microsoft.com/library/en-us/dn....asp?frame=true The following diagram shows these two layers in the architecture of a .NET-based distributed application. ![]() Figure 1: Component layers found in distributed applications and services built with .NET Figure 2 shows an example of the kind of rich user interface applications that the Composite UI Application Block can help you to produce. Meanwhile, the QuickStarts and a simple walkthrough example that demonstrates the fundamentals of the framework will help you to understand the structure and principles of the Composite UI Application Block. These examples and the related documentation are installed with the CAB framework. ![]() Figure 2: Sample call center application Design of the Composite UI Application Block Model-View-Controller (MVC) http://msdn.microsoft.com/library/default....html/DesMVC.asp Дополнительный материал: Java библиотека - Триада MVC в действии Delphi. Практика применения паттернов проектирования
![]() Figure 3: MVC class structure MVP patterns ![]() Figure 4: Comparison of the MVC and MVP patterns Design for Modularity Figure 5 shows how these components interoperate. ![]() Figure 5: Components typically found in a Composite UI Application Block application Design of the WorkItem The design of the Composite UI Application Block primarily supports applications built using a consistent set of patterns. One of the default patterns is the Model-View-Controller (MVC) pattern. These types of applications generally consist of:
![]() Figure 6: Composite UI Application Block application Event Broker ![]() Figure 7: The Event Broker System Threat Model ![]() Figure 8: The CAB start-up and service loading sequence ![]() Figure 9: Asynchronous execution of event subscriptions Subsystems of the Composite UI Application Block The Composite UI Application Block consists of a number of subsystems that interoperate to provide the functionality that the application block provides. Figure 10 shows the grouping of these subsystems. ![]() Figure 10: Subsystems of the Composite UI Application Block -------------------- |
|||
|
||||
Medved |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() Эксперт ![]() ![]() ![]() ![]() Профиль Группа: Завсегдатай Сообщений: 7209 Регистрация: 15.9.2002 Где: Kazakhstan, Astan a Репутация: 3 Всего: 154 |
"Hello World"
The sample application used in this walkthrough implements the common "Hello World" scenario, which allows you to focus on the application's design and architecture. Physical Architecture In this example, simple code in a separate module implements the model. In response to the view loading, the presenter within this module obtains the results from the model, and updates the view. Communication between the view and the presenter is through a defined interface. Using interfaces establishes a contract between the participants, which forces the appropriate separation and reduces dependency. ![]() Figure 17 The result of running the completed application
![]() Figure 11: The components in the completed example application Stage 1: Creating the Shell and the Form Your first task is to create the project that acts as the main shell for the application. Figure 12 shows the architecture of the application you have created so far. As the application starts and you call the Run method in your Main routine, the CAB creates the ShellForm form and the root ShellWorkItem. ![]() Figure 12: The components at the end of Stage 1 To create the shell and form 1. Create a new C# Windows Forms application. Name the new application ShellApplication. 2. In the Solution Explorer window, rename Form1.cs to ShellForm.cs. To add references to the core classes 1. In the Solution Explorer window, right-click References and then click Add Reference.
2. In the New Item dialog, select Class and name it ShellWorkItem.cs. 3. In the new class file, add the following using statement for the namespace:
4. Edit the ShellWorkItem class declaration so that it is public, and inherits from WorkItem:
To initialize and display the form from within the root WorkItem 1. In the Solution Explorer window, rename the file Program.cs to ShellApplication.cs and open it. 2. Edit the existing using statement for the WinForms namespace to use the CompositeUI.WinForms namespace classes:
3. Replace the static class ShellApplication with a public class that inherits from FormShellApplication, and which instructs the CAB to load the ShellForm form into the ShellWorkItem:
4. Add the [STAThread] attribute to the static Main method in this class. This method executes when the application starts, and it must instantiate your ShellApplication class and call the Run method. The FormShellApplication class inherits from the CabApplication class, which contains the Run method implementation:
Stage 2: Creating and Loading the Module In this stage, you add the module that provides the view to display on the ShellForm form. ![]() Figure 13: The components at the end of Stage 2 To add the module that provide the view 1. Right-click the top-level Solution 'Shell Application' entry in the Solution Explorer window, click Add, then click New Project. 2. Select the Class Library project type and name it MyModule. In this example, the new module contains a child WorkItem. To add references to the core classes 1. Add Reference.
2. In the New Item dialog for the MyModule project, select Class and name it MyWorkItem.cs. 3. Add the following using statement for the namespace to your new class file:
4. Edit the MyWorkItem class declaration so that it is public and inherits from WorkItem:
To add a class to your project 1. Rename the file Class1.cs to MyModuleInit.cs. This is the file Visual Studio added to your new project. 2. In the MyModuleInit.cs file, add the following using statements for the three namespaces you will reference classes from:
3. Edit the class declaration to inherit from ModuleInit as shown here:
4. Add the following variable to reference the WorkItemTypeCatalogService (using the IWorkItemTypeCatalogService interface) so that you can access it to register your WorkItem:
5. Add the following public property to the class that sets the value of the myCatalogService variable. Use the [ServiceDependency] attribute on this property so that the dependency injection feature of the underlying ObjectBuilder utility will create an instance of the service and pass back a reference to it:
6. Override the Load method of the ModuleInit class so that it registers your module's WorkItem. The code here calls the corresponding method of the base class first, as is usual practice, however the Load method of the ModuleInit class does nothing and so this line could be omitted:
Note: In Stage 4 of this walkthrough, you will change this code to use the RootWorkItem to add a child WorkItem. This illustrates some of the different techniques that you can use in CAB applications. To instruct the CAB to load the new module 1. In the ShellApplication project, open the New Item dialog box and select XML File. Name it ProfileCatalog.xml. Edit the file as shown in the following code to load the module named MyModule.dll:
Stage 3: Adding the TabWorkspace ![]() Figure 15. The ShellForm form with the SplitContainer and TabWorkspace controls ![]() Figure 14. The components at the end of Stage 3 To add a TabWorkspace to the shell application 1. Open the file ShellForm.cs in the form designer, and resize it to 500 x 300 pixels by dragging the form edges, or by setting the Size property in the Properties window. 2. From the Containers section of the Toolbox, drag a SplitContainer control onto the form. Drag the center splitter so that the two panels are approximately the same width. 3. The CAB workspace controls, such as TabWorkspace and ZoneWorkspace do not appear in the Toolbox by default. Right-click the Toolbox, click Items..., and then click Browse..... 4. In the \Src\CS\CompositeUI.WinForms\bin\Debug\ subfolder of the folder where you installed the CAB files, select the file Microsoft.Practices.CompositeUI.WinForms.dll. 5. Drag a TabWorkspace onto the form and drop it onto the left-hand panel of the SplitContainer control. 6. Right-click the new TabWorkspace control and click Properties. In the Properties window, navigate to the Dock property and set it to Fill. This positions the workspace control to fill the panel, and adds two default tabs to it. 7. Right-click the TabWorkspace control and click Remove Tab. Then repeat this step to remove the second tab. Your form should now look like Figure 15. Stage 4: Creating and Showing the SmartPart ![]() Figure 11: The components at the final stage of building the application To create an interface for the view and the presenter to communicate 1. Right-click the MyModule project entry in Solution Explorer, click Add, and then click New Item. In the New Item dialog, click Interface and name it IMyView.cs. Add the public keyword to the interface statement. Then declare the two members of this interface as an event named Load and a string property named Message as shown in the following code:
Now you can create the SmartPart user control. In this example, the SmartPart contains a Label control that displays a message in the shell. ![]() Figure 16. The completed MyView user control To create a SmartPart user control 1. Right-click the MyModule project entry in Solution Explorer, and click Add, and then click New Item. In the New Item dialog box, select User Control and name it MyView.cs. 2. Resize the user control in the form designer window to 250 x 250 pixels. 3. Drag a Label control from the Toolbox onto the user control and drop it near the top left corner. 4. In the Properties window for the Label control, change the Font Size property to 10. Your user control should now look like Figure 16. Within the user control, you must now implement the IMyView interface that you created earlier. This means that the user control must expose a property named Message. Internally, the user control sets the Text property of the Label control to the value of the Message property. To implement the IMyView interface 1. Right-click the design surface and select View Code. Add the IMyView interface to the class declaration so that the user control class implements this interface:
2. Right-click IMyView and click Implement Interface, then click Implement Interface in the fly-out menu. 3. Replace the two throw statements that Visual Studio generates with two statements that get and set the value of the Message property:
The next step is to create the class that acts as the presenter in the MVP pattern. It manipulates the SmartPart you just created. The presenter hooks into the Load event of the view and exposes an event handler for this event. The event handler set the Message property of the view. To create the presenter class 1. In the New Item dialog, select Class and name it MyPresenter.cs. 2. Edit the opening class declaration to make it public, and add a variable of type IMyView to the class to reference the view through the interface that you created for it:
3. Create a constructor for the class. The constructor takes a reference to the view, sets it as the view for this presenter, and subscribes to the Load event of the view:
4. Create an event handler for the Load event. This sets the Message property of the Label control:
In the next stage, you modify the ModuleInit class so that it gets a reference to the WorkItem in the module, and calls the Run method of this WorkItem. To get a reference to the WorkItem 1. Open the MyModuleInit.cs file and add the following variable immediately after the existing myCatalogService variable declaration. The variable will contain a reference to the root ShellWorkItem:
2. Add a public property to the class. This property sets the value of the parentWorkItem variable. Use the [ServiceDependency] attribute on this property so that the dependency injection feature of the underlying ObjectBuilder utility references the existing WorkItem, and passes back a reference to it:
3. Modify the Load method that you added during Stage 2. This creates an instance of the module's WorkItem within the context of the root ShellWorkItem using the AddNew method, then calls the Run method of the new WorkItem. You retrieve the Workspace using its name and pass this Workspace to the Run method. In this example, the target is the TabWorkspace named tabWorkspace1 that you placed into the SplitContainer control on the form:
In the final step, you implement the Run method in the module's WorkItem to create a new instance of the view, instantiate the presenter, and show the view within the TabWorkspace. To create and show the view 1. Open the file MyWorkItem.cs, and add the following using statement for the namespace that contains the IWorkspace class you will use in your new code:
2. Create a public Run method that accepts as a parameter a reference to the TabWorkspace. It is a good idea to declare the parameter as of type IWorkspace instead of TabWorkspace. If in future you decide to change the type of workspace used in the shell form, you will not have to change the method declaration:
3. Add statements to the Run method that create a new instance of the MyView class (using the AddNew method of the Items collection of this WorkItem), and a new instance of the MyPresenter class. Passing the view instance you just created to the presenter connects them together:
4. Add statements to the Run method that add the new presenter to the current WorkItem, and call the Show method of the TabWorkspace to display the view:
![]() Figure 11: The components in the completed example application Figure 11 repeats the schematic that you saw near the start of this walkthrough. It shows all of the components in the completed application. At run time, the application initializes and loads the main form (ShellForm). It then loads the module (MyModule) that is specified in the ProfileCatalog.xml file. The module registers its WorkItem (MyWorkItem) with the RootWorkItem that is exposed by the shell, and calls the Run method. The Run method of the module's WorkItem creates a new instance of the user control (MyView) and the presenter (MyPresenter). It adds the presenter to the module's WorkItem, and shows the MyView user control in the TabWorkspace. The module handles the Load event of the MyView user control and sets the Message property of the user control, which displays the message in the Label control. -------------------- |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() ![]() |
Прежде чем создать тему, посмотрите сюда: | |
|
Используйте теги [code=csharp][/code] для подсветки кода. Используйтe чекбокс "транслит" если у Вас нет русских шрифтов. Что делать если Вам помогли, но отблагодарить помощника плюсом в репутацию Вы не можете(не хватает сообщений)? Пишите сюда, или отправляйте репорт. Поставим :) Так же не забывайте отмечать свой вопрос решенным, если он таковым является :) Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, mr.DUDA, THandle. |
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей) | |
0 Пользователей: | |
« Предыдущая тема | Общие вопросы по .NET и C# | Следующая тема » |
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |