Hello World with Monoberry

Monoberry is a library that allow the native application developing with Mono and C#, in the actual version, only graphic applications can be developed with Open GL ES 1.0 and 2.0, besides an access to the BlackberryPlatform Service libraries.

Tools required to Develop with Monoberry

To develop with Monoberry, the following tools are required:
-          Visual Studio 2012 (Professional, Premium o Ultimate) - http://www.microsoft.com/visualstudio/eng/downloads#d-2012-editions
-          Blackberry OS 10 Native SDK - http://developer.blackberry.com/native/download/
-          Blackberry OS 10 Emulator  - http://developer.blackberry.com/native/download/
-          Monoberry Tools for Visual Studio - http://visualstudiogallery.msdn.microsoft.com/b4803586-b446-4df1-8254-978f00ceb52d
The tools should be installed in the order from the list shown before.

Hello World with Monoberry

The creation of an application of Monoberry, is very easy like any other mobile platform. For this first example we will create a dialogue chart where the next message is shown: “Hello world from Latin America with Monoberry”.

Step 1: Create a new Project

To create a new Project, you have to open Visual Studio 2012, and then go to the option File-> New -> Project and then choose the option Monoberry Application, as seen on the next print screen:

We’ll name the project “HelloWorldMonoberry” and then we click on the “OK” button.
Then an assistant is displayed so that we can configure the basic parameters of the application:

The first step is to configure the SDK, in case to be the first Project, we don’t have any SDK registered, we must register clicking on the “Manage SDKS” button, this will open a new window where we should type the SDK name and the path that we want to register, for our example we’ll use the following data and click the “Add” button: 
-          Name: Default SDK
-          Path: C:\bbndk\host_10_0_9_404

Then we’ll close the dialogue chart clicking on the “Close” button and then we can choose the SDK, to go forward in the assistant:

As a next step, we have to configure the emulator, for this we have to ad done, with a name and IP address, to get the emulator’s IP address, we have to open the emulator and scroll down, on the left corner you can see the address, as seen on the print screen:

For this guide we’ll use the following:
-          Name: Test Device
-          IP Address:

For the third step, we have to add the application´s basic data, like name, author, author’s identifier, description and extra permissions for the application can run. The following data will be used as example:
-          Name: HelloWorld
-          Autor: Unknown
-          AutorID: hYAVVGfacBFUKY7rJsXs2e2lxY0
-          Description: Basic Hello World Application

For the last step, the assistant will display a summary of all the entered data, so you can check that they are correct:

After clicking on the “Finish” button, the assistant will close and Visual Studio will proceed to create the project, which will have the following structure:

Step 2: Clear the Project

We have to delete the file, Cube.cs  and then delete all the code lines referent to that class, from the method Main housed in the Program.cs file, so that it is like shown: 
using System;
using System.Text;
namespace HelloWorldMonoberry
    class Program
        public static void Main(string[] args)

Step 3: Add the Monoberry libraries

As a next step we have to add the Monoberry libraries from NuGet, for this reason we will open the Package Manager Console and run the following sentence:
-          Install-Package MonoRuntimeForMonoberry
-          Install-Package Monoberry
The first sentence adds the Mono runtime for Blackberry OS 10 together with the basic libraries for operating Monoberry which are:
-          MsCorLib
-          System.dll
-          System.Drawing.dll
-          System.Xml.dll
The second sentence will add the Monoberry reference to our project:
-          BlackberryPlatformService.dll
-          OpenTKBlackberry.dll

Step 4: Add code to display a dialogue

The next step, will add the objects necessary to display a dialogue on the screen. The dialogue is simple:
                var run = true;
                string message = string.Format("Hola Mundo desde Latinoamérica con Monoberry!. BPS Version: {0}",
                while (run)
                    Dialog.Alert("CLOSE ME!", message, new Button("Close", () => run = false));


As you can see, we just call a dialogue, where we sent the following parameters:
-          Título: “CLOSE ME!”
-          Mensaje: “Hola mundo desde Latinoamerica con Monoberry!....”
-          Boton: new Button("Close", () => run = false), el Segundo parametro del boton, es el comportamiento que tendrá cuando se lo pulse.

Step 5: Launch the application

To launch the application, first we have to enable a previous configuration. First we have to go to the project’s properties, to the Debug section:

In this section, we have to enable the “Start external program” option and the path, we have to add the powershell’s location, which is: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
After, in the argument section we have to add the following (the file path ““Monoberry_Launcher.ps1” should be the same from the project):
-file "C:\Users\user.name\Documents\Visual Studio 2012\Projects\HelloWorldMonoberry\HelloWorldMonoberry\PackagerScripts\Monoberry_Launcher.ps1"
With everything configured, the only thing we need is to save the changes from the project’s properties and launch the application with “Ctrl + F5”: 

Publicar un comentario en la entrada