Media Center Markup Language Preview Tool
The Windows Media Center Markup Language Preview Tool (McmlPad) is a Windows Media Center application that allows you to browse to and view MCML files. This tool can also be used for certain types of debugging (such as syntax checking, focus and input checking, and UI region boundary indications). This tool is only supported on a computer running Windows Vista with Windows Media Center.
McmlPad is registered as a Windows Media Center application, so you can run McmlPad within Windows Media Center (browse to Online Media, Program Library, and then choose MCML Preview Tool).
You can also run McmlPad as a stand-alone application. The stand-alone version is useful for testing UI, but it cannot run code that depends on other Windows Media Center features or APIs.
Using McmlPad to Develop UI
McmlPad lets you develop individual portions of a UI, and is specifically designed to not scale the MCML content when you view it in stand-alone mode. When you view the MCML content in Windows Media Center, McmlPad inherits the proportional scaling that is applied to all applications that run within Windows Media Center.
One reason for this design is for the authoring and preview cycle in UI design so that you can view the UI at full size (for example, when working on a small feature within the UI). Because Windows Media Center scales the content proportionally to the window, the visual elements can get quite small when you want to switch quickly between your MCML authoring environment and McmlPad. For example, compare the size of the button in each of the windows in the following figure. The window on the left shows McmlPad running in Windows Media Center and is scaled smaller. The window on the right shows the stand-alone version of McmlPad and the content is full size:
.jpg)
Evaluating Layout and Behavior
In stand-alone mode, McmlPad lets you see how your layout looks and works in different sizes and aspect ratios. Windows Media Center is mostly designed for widescreen (16:9) and standard (4:3) display. You can also set the screen resolution to a different size (such as 1920 x 1200 pixels for a 16:10 aspect ratio) and run Windows Media Center at full screen to view different aspect ratios. However, changing the screen resolution this way can be tedious during UI development. By contrast, you can run McmlPad with an arbitrary size. The following figure shows the snowflake sample gallery at a 4:1 aspect ratio:
.jpg)
When the size of the window is increased, the gallery grows to accommodate more rows and columns of data without having to change the panel that contains the snowflakes, recompiling, installing to the GAC, or registering it in Windows Media Center. Instead, because there is no proportional scaling, the item sizes remain unchanged and more snowflakes are displayed. The following figure shows the result:
.jpg)
The following tips are useful for working with McmlPad:
- To view proportional scaling in McmlPad, use
<ScaleLayout MaintainAspectRatio="true" AllowScaleUp="true" AllowScaleDown="true"/> in your test harness. For an example, see the <UI Name="TestWrapper"> markup in the Default.mcml file in the Z sample application. - To switch between 16:9 and 4:3 aspect ratios, select the top or bottom window frame, hold CTRL, and size the window up or down. The window snaps to the 16:9 aspect ratio. To reverse, select the right or left window frame, hold CTRL, and size the window up or down.
Testing Pages
McmlPad has a page concept, but it is distinctly different and simpler than the page concept (the PageSession and HistoryOrientedPageSession classes) within Windows Media Center. A page is basically a <UI Name="Pagename"> element in markup, but the underlying functionality for what a page does is provided by Windows Media Center. McmlPad is designed to work with the visual layer of the platform only. So, once you are ready to test page behavior, you should also use McmlPad within Windows Media Center (rather than the stand-alone version) to test the UI and application.
An even better approach is to test the page behavior early in the application development cycle using wire-frame resources. The simple button in the Media Center Markup Language Sampler provides an example of UI to use as a placeholder to implement and test the layout and data binding that involves your page variables. You can replace the simple button later with a button that is fully designed.
Testing UI
In stand-alone mode, McmlPad allows you the flexibility to create a test harness for your UI. The following figure shows an example of a simple test harness for a button:
.jpg)
McmlPad in Windows Media Center (the top right window) is running an application (a compiled assembly) for testing the button functionality. In this example, it calls a method to display a Windows Media Center dialog box.
McmlPad in stand-alone mode (the bottom right window) shows the result of pressing F5 in Visual Studio—the MCML code is loaded and shows the different ways to instantiate the button using different properties.
The following figure shows a test harness for the Z sample application, which takes advantage of MCML layouts and rules to step through all of the UI:
.jpg)
On the right, each UI defines an individual page within the Z sample application. Selecting an item loads an MCML <UI> into the larger, 4:3 area on the left. This test harness is defined by Default.mcml in the sample code, which is included with the Windows Media Center SDK.
Use the following procedure to use the F5 test harness functionality in Microsoft Visual C# 2005 Express Edition with the Z sample application (otherwise, McmlPad reports an exception and closes when you press F5 because the Z test harness can't find the data):
- Open a command prompt with administrator privileges.
- Navigate to C:\Program Files\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Z\.
- Run Command.CreateDevEnvironment.cmd.
- Make the following changes in Microsoft Visual C# 2005 Express Edition:
- In Solution Explorer, select Solution 'Z' (2 Projects).
- From the Project menu, select Set as Startup Projects.
- From the Project menu, select Properties.
- In Solution Z Property Pages, under Common Properties click Startup Project.
- Select Single Startup Project, and then select Z from the drop-down list.
- Click OK.
- From the Debug menu, select Start Debugging (or press F5) to start the Z test harness.
To start McmlPad from within Microsoft Visual C# 2005 Express Edition, you must edit the .csproj file for the solution because the Start Action setting is not available in the Visual C# 2005 Express Edition. The following example code from the Z.csproj file shows the additional XML code:
<PropertyGroup>
<UseVSHostingProcess>true</UseVSHostingProcess>
<StartWorkingDirectory>$(windir)\eHome</StartWorkingDirectory>
<StartArguments>-load:"resx://Z/Z.Resources/Default" -assemblyredirect:"$(FullyQualifiedOutputPath)" -markupredirect:"resx://Z/Z.Resources/,file://$(MSBuildProjectDirectory)\Markup\,.mcml"</StartArguments>
<StartAction>Program</StartAction>
<StartProgram>$(windir)\eHome\McmlPad.exe</StartProgram>
</PropertyGroup>
The XML code contains the following McmlPad parameters:
- -load:"resx://Z/Z.Resources/Default"
Loads the Z assembly and navigates to the Default.mcml resource. Default.mcml is never used by the application once installed—its only purpose is to provide the test harness.
- -assemblyredirect:"$(FullyQualifiedOutputPath)"
Loads the assembly from a specific location. When $(FullyQualifiedOutputPath) is evaluated, it returns a path such as C:\Program Files\Microsoft SDKs\Windows Media Center\v5.0\Samples\Windows Media Center Presentation Layer Samples\Z\bin\Debug\. This does not work if the assembly is registered to the Global Assembly Cache, so be mindful of when you run Command.InstallAndRegister.cmd contained in the sample solution.
- -markupredirect:"resx://Z/Z.Resources/,
file://$(MSBuildProjectDirectory)\Markup\,.mcml"
Replaces instances of resx:// with file:// and appends .mcml. This allows you to build the assembly once, load the Default.mcml test harness into McmlPad, make changes to the source MCML, and test the results of those changes by refreshing McmlPad without having to rebuild the assembly.
You can use these McmlPad parameters at the command line or by using the Media Center Markup Language (MCML) Preview Tool Launcher PowerToy. These parameters allow you to create a compiled assembly and open MCML files directly in McmlPad to edit and preview your changes in real time, and to view changes to markup by refreshing McmlPad. And, you avoid having to recompile, install to the GAC, and register the application in Windows Media Center. The following figure shows the MCML Preview Tool Launcher PowerToy:
.jpg)
In this example, the PowerToy sets the command-line parameters for McmlPad. After changing the markup, you can press F5 to refresh the McmlPad window without needing to recompile. This also allows you to make changes to the UI without committing them to the compiled assembly.
McmlPad Command-Line Parameters
The stand-alone file mcmlpad.exe, located in the \Windows\ehome folder, can be run at the command line with the following parameters. All parameters must begin with a forward slash (/) or a dash (-).
| Parameter | Description |
| /animations:false | This parameter starts McmlPad with animations disabled. |
| /animations:true | This parameter starts McmlPad with animations enabled. |
| /direction:ltr | This parameter starts McmlPad in left-to-right (LTR) display mode. |
| /direction:rtl | This parameter starts McmlPad in right-to-left (RTL) display mode. |
| /dx9 | This parameter starts McmlPad in DirectX graphics mode. The DirectX graphics mode simulates rendering markup in a full-fidelity graphics environment that is typically used when Windows Media Center is rendered on the Media Center PC or on an Extender device such as an Xbox 360. |
| /folder:folder_path | This parameter specifies a folder to watch for resource changes. McmlPad automatically refreshes as changes occur, or at a set interval if one was specified using the /interval parameter. |
| /gdi | This parameter starts McmlPad in Graphics Device Interface (GDI) graphics mode. The GDI graphics mode simulates rendering markup in a low-fidelity graphics environment that does not support DirectX graphics mode. |
| /interval:seconds | This parameter specifies the interval, in seconds, at which to refresh McmlPad when changes occur to resources in a specified folder (if the /folder parameter was used).
- When set to a value less than or equal to zero, refreshes are performed in real time.
- When set to a value greater than zero, refreshes are performed at the specified interval.
|
| /load:file://mcml_file | This parameter starts McmlPad and attempts to navigate to the specified uniform resource identifier (URI). You can use this as a startup command in a debugging environment to more easily debug markup. Supported URIs for this parameter include file://, http://, res://, and resx://. |
| /position:xxxx,yyyy | This parameter starts McmlPad at the specified window location. |
| /size:xxxx,yyyy | This parameter starts McmlPad with the specified window size to test rendering markup at various display resolutions, and to simulate aspect ratios such as 4 x 3 and 16 x 9. |
| -assemblyredirect:full_path | This switch specifies a local directory from which to load an assembly for debugging purposes. McmlPad searches this local directory before searching the Global Assembly Cache (GAC) and \windows\ehome.
For example: -assemblyredirect:c:\directory Notes Only one directory can be passed in, and it must not contain a trailing backslash. This switch does not work if the assembly is also installed into the GAC. The .NET Framework always loads the assembly from the GAC when possible. |
| -markupredirect:before_string,after_string,suffix_to_append_to_the_end | This switch specifies a local directory from which to load resources for debugging purposes. McmlPad replaces all instances of before_string in res:// and resx:// resource strings in markup files with after_string, then appends the resource identifier, then appends the suffix_to_append_to_the_end.
suffix_to_append_to_the_end is optional. Examples: -markupredirect:resx://McmlSampler/,file://c:\directory\,.mcml Causes the following replacements: xmlns:spin="resx://McmlSampler/Scenarios.SimpleSpinner" becomes xmlns:spin="file://c:\directory\Scenarios.SimpleSpinner.mcml" -markupredirect:res://McmlSampler/,file://c:\directory\ Causes the following replacement: xmlns:spin="res://McmlSampler/Scenarios.SimpleSpinner.mcml" becomes xmlns:spin="file://c:\directory\Scenarios.SimpleSpinner.mcml" You can specify multiple groups of before_string,after_string,suffix_to_append_to_the_end by separating each group by semicolons. |
See Also