Follow these steps to transform the C# Windows Media Center Application Template in the 5.2 version of the SDK into a background application.
1. Create a new project using the Windows Media Center Application template in versions 5.2 or later of the Windows Media Center Software Development Kit.
2. Finalize the project using the instructions outlined in the Readme.htm document included with the template.
3. Double click Resources.rex in Solution Explorer to open for editing.
4. In Resources.resx…
a. Press Control+1 to select strings.
b. Modify the DialogCaption string to read “Dialog Caption”.
c. Press Control+5 to select files.
d. Delete the 5 MCML files (Button, Controls, Menu, RepeatItem and Styles).
e. Select File > Save from the menu.
5. Delete the Markup folder in Solution Explorer.
6. Double click Application.cs in Solution Explorer to open for editing.
7. In Application.cs…
a. Delete: private HistoryOrientedPageSession session;
b. Delete: public Application() : this(null, null){}.
c. Delete: public string[] MyData{…}
d. Modify public Application(HistoryOrientedPageSession session, AddInHost host) to read as follows:
public Application(AddInHost host)
{
this.host = host;
singleApplicationInstance = this;
}
e. Modify public void GoToMenu() to read as follows:
public void Start()
string temp = "Background applications do something here.";
DialogTest(temp);
f. Modify public void DialogTest(string strClickedText) to read as follows:
public void DialogTest(string strClickedText)
int timeout = 5;
bool modal = true;
string caption = Resources.DialogCaption;
if (host != null)
MediaCenterEnvironment.Dialog(strClickedText,
caption,
new object[] { DialogButtons.Ok },
timeout,
modal,
null,
delegate(DialogResult dialogResult) { });
else
Debug.WriteLine("DialogTest");
g. Select File > Save from the menu.
8. Double click Launch.cs in Solution Explorer to open for editing.
9. In Launch.cs…
a. Delete private static HistoryOrientedPageSession s_session;.
b. Modify public void Launch(AddInHost host) as follows:
public void Launch(AddInHost host)
Application app = new Application(host);
app.Start();
c. Select File > Save from the menu.
10. Double click Registration.xml in Solution Explorer to open for editing.
11. In Registration.xml modify <category category="More Programs"/> to read as follows:
<category category="Background"/>
12. Select File > Save from the menu.
13. In Solution Explorer select the [ApplicationName] project.
14. Select Project > [ApplicationName] Properties from the menu.
15. Delete the MCMLVerifier post-build event command line items in the Build Events tab of the properties (this line begins with “%windir%\eHome\McmlVerifier.exe…”).
16. Select Build > Rebuild Solution from the menu.
17. Run “DevInstall.cmd” from a command prompt with Administrator privileges to perform a development install or follow the instructions to generate an MSI and install.
18. Launch Windows Media Center – the application should display a dialog shortly after Windows Media Center launches.
19. Run “DevInstall.cmd /u” from a command prompt with Administrator privileges to perform a development install or uninstall using the MSI. Otherwise you will get a dialog box each time you launch Windows Media Center.
Disclaimer All information available via this site is provided 'as is' with no warranties and confers no rights.