top

Creating .NET TV Applications

The Tizen .NET framework allows you to easily and efficiently create applications for Tizen. This topic describes the basic steps for creating and running a .NET TV application. It also describes how you can create a Tizen project as part of a cross-platform solution.

Study the following instructions to help familiarize yourself with the Tizen .NET application development process. With the instructions, you can create and run a basic .NET application, which displays some text on the screen with no user interaction.

  1. Before you start developing Tizen applications, set up development environment.

  2. Create a project using Visual Studio.
    This step shows how you can use a predesigned project template that creates all the basic files and folders required for your project.

  3. Build the application.
    After you have implemented code for the features you want, this step shows how you can build the application to validate and compile the code.

  4. Deploy and run the application.
    This step shows how you can deploy and run the application on the emulator or a real device.

Creating a Project

The following example shows you how to create and configure a basic Tizen .NET application project in Visual Studio. An application project contains all the files that make up an application.

To create a new Tizen .NET project:

  1. Launch Visual Studio.
  2. In the Visual Studio menu, select "File > New > Project".
    Figure 1. New project creation

    Figure 1. New project creation


    The "New Project" dialog opens.
  3. Select "Templates > Visual C# > Tizen", and select the "Blank App (Xamarin.Forms)" template.
    Define the project properties and click "OK". You can enter the name, location, and solution name.
    Figure 2. "New Project" dialog

    Figure 2. "New Project" dialog


    The Tizen Project Wizard opens.
  4. Define the profiles to add to your solution. Click "OK".
    Figure 3. Tizen Project Wizard

    Figure 3. Tizen Project Wizard


    If you select the "Common" profile, you cannot select "Mobile" or "TV".

A solution with 2 or 3 projects is created and shown in the "Solution Explorer" view:

  • The "<projectname>" project contains the Xamarin.Forms code shared across platforms.
  • If you select the common profile in the Tizen Project Wizard, a common project titled "<projectname>.Tizen" is added. It contains code to instantiate your common application within the Tizen framework.
  • If you select the mobile profile in the Tizen Project Wizard, a mobile project titled "<projectname>.Tizen.Mobile" is added. It contains code to instantiate your mobile application within the Tizen framework.
  • If you select the TV profile in the Tizen Project Wizard, a TV project titled "<projectname>.Tizen.TV" is added. It contains code to instantiate your TV application within the Tizen framework.

Figure 4. Project with mobile and TV profiles

Figure 4. Project with mobile and TV profiles

If you are already familiar with Xamarin.Forms, this project has the same structure as a Xamarin.Forms portable application. The "<projectname>" project is the portable class library and the others are the platform-specific projects; however, in Tizen .NET, only the Tizen platform-specific project is generated.

The ".cs" file in the portable project already contains simple Xamarin.Forms code that makes a basic UI.

Adding TV-specific NuGet Packages

To use Tizen .NET TV-specific features in the application, you must add the "Tizen.NET.TV" NuGet package to your project.

To add the Tizen.NET.TV NuGet package:

  1. If you have not yet added the "Tizen .NET TV" package source to the Package Manager, add it:

    a. In the Visual Studio menu, select "Tools > NuGet Package Manager > Package Manager Settings".

    b. Select "Package Sources".
    c. To add a new package source, click "+".
    d. In the "Name" and "Source" fields, enter "Tizen .NET TV" and "https://tizen.myget.org/F/tizenfxtv/api/v2", and click "Update".

    Figure 5. Adding the package source

    Figure 5. Adding the package source


    e. To close the "Options" window, click "OK".

  2. In the "Solution Explorer" view, right-click the project name, and select "Manage NuGet Packages".

  3. From the "Package source" drop-down menu in the upper-right corner, select "Tizen .NET TV".

  4. Select the "Tizen.NET.TV" package and click "Install".

    Figure 6. Install the NuGet package

    Figure 6. Install the NuGet package

  5. In the "Solution Explorer" view, right-click the "Tizen.NET.TV" NuGet package, and select "Properties".

  6. In the "Properties" panel, in the "ExcludeAssets" field, enter "Runtime".

    Figure 7. Package properties panel

    Figure 7. Package properties panel


    You can now use TV-specific features in the application.

Building the Application

After you have created the application project, you can implement the required features. In this example, only the default features from the project template are used, and no code changes are required.

When your application code is ready, build the application. The building process performs a validation check and compiles your files. You must sign the application package with an author certificate when building the application. If you have not yet registered a Tizen certificate in Visual Studio, see Certificate Manager.

There are 2 different ways to build the application:

  • In the Visual Studio menu, select "Build > Build Solution".
  • In the "Solution Explorer" view, right-click the solution name and select "Build".

Tizen .NET applications are always deployed as installed packages. The package files have the ".tpk" file extension, and the package generation is controlled by the manifest file. The Visual Studio template generates the manifest file ("tizen-manifest.xml") to the top level of the "<projectname>.Tizen" project (if you create a project with both mobile and TV profiles, a separate manifest file is generated for each profile).

After you have built the application, deploy and run it.

Deploying and Running the Application

To run the application, you must first deploy it to the target: either a device or an emulator. Deploying means transferring the package file (".tpk") to the target and invoking the Tizen package manager to install it.

To deploy and run the application on the emulator:

  1. In the Visual Studio menu, select "Tools > Tizen > Tizen Emulator Manager".
  2. In the Emulator Manager, select an emulator from the list, and click "Launch".
    If no applicable emulator exists, create one.
    Figure 8. Tizen Emulator Manager

    Figure 8. Tizen Emulator Manager

  3. Once you launch an emulator, you can deploy the application by clicking the emulator in the Visual Studio toolbar.
    Figure 9. Emulator in Visual Studio toolbar

    Figure 9. Emulator in Visual Studio toolbar


    You can change the deployment target in the Visual Studio toolbar by selecting the target from the drop-down list.
    Figure 10. Deployment target selection

    Figure 10. Deployment target selection

  4. If deployment is successful, the application icon is visible on the emulator or device screen. Click the icon to launch the application. The following figure shows the launched application on the TV emulator.
    Figure 11. Application running on the TV emulator

    Figure 11. Application running on the TV emulator

Creating Tizen Projects as Cross-platform Solutions

The Xamarin cross-platform template consists of a shared PCL (Portable Class Library) and multiple platform-dependent application projects. If you create your Tizen project as a cross-platform solution, you can easily add other platform-dependent project versions, such as iOS and Android™, to the same solution later.

To create a cross-platform solution and add a Tizen project to it:

  1. In the Visual Studio menu, go to "File > New > Project".
  2. Select "Visual C# > Cross-Platform > Cross Platform App (Xamarin)", and click "OK".
    Figure 12. Cross-platform project creation

    Figure 12. Cross-platform project creation

  3. Select "Blank App" and the "Portable Class Library (PCL)" code sharing strategy, and click "OK".
    Figure 13. Template selection

    Figure 13. Template selection

  4. In the "Solution Explorer" view, right-click the new solution and select "Add > New Project".
    Figure 14. Adding project to solution

    Figure 14. Adding project to solution

  5. Select "Visual C# > Tizen > Cross-Platform > Blank App (Xamarin.Forms)" and click "OK".
    Figure 15. Tizen application project creation

    Figure 15. Tizen application project creation

  6. In the Tizen Project Wizard, define the Tizen application package name and profile, and click "OK".
    The Solution Explorer view shows the 1 or 2 Tizen projects (depending on the selected profiles) that are added to the existing cross-platform Xamarin.Forms solution. The Tizen project is set as the startup project.
    Figure 16. Tizen project added to solution

    Figure 16. Tizen project added to solution