Launchers related to MarketPlace in Windows Phone

In this post we will discuss three important launchers related to Windows Phone Market Place

  • MarketPlaceHubTask launcher
  • MarketPlaceReviewTask launcher
  • MarketPlaceDetailTask launcher

MarketPlaceHubTask launcher

This is used to launch Windows Phone Market Place client application. You can launch market place client application along with music content as below,


MarketplaceHubTask marketplaceHubTask = new MarketplaceHubTask();
marketplaceHubTask.ContentType = MarketplaceContentType.Music;
marketplaceHubTask.Show();

You can set content type of the search either as Application or Music. MarketPlaceContentType is defined as below,

clip_image002

Market place client application will be launched as below,

clip_image003

MarketPlaceReviewTask launcher

This is used to launch market place client application with review page. Market place application review page can be launched as below,



MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();

It will ask user confirmation for Submit or Cancel. It will ask user confirmation for Submit or Cancel. After selecting submit option user will be redirected to review page of market place application.

MarketPlaceDetailTask launcher

This is used to launch market place client application with details page of specified application. You need to pass unique content identifier of application to get detail page of the application from market place. If you don’t set unique content identifier then detail page of current application will be launched in windows phone market place client application.

You can launch detail page of current application as below,


MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
marketplaceDetailTask.Show();

You can launch detail page of a specific application by passing content identifier.

These are three important launchers for market place client application and you may use them frequently in your application. I hope this post is useful. Thanks for reading.

WebBrowserTask and MediaPlayerLauncher in Windows Phone

In this post, we will see WebBrowserTask launcher and MediaPlayer launcher.

WebBrowserTask launcher launches web browser application and display specified URL. This is defined as below,

image

You can set target URL either as string or as Uri. User will be asked for the confirmation. You can navigate to a URL as below,



WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri("http://debugmode.net", UriKind.Absolute);
webBrowserTask.Show();

On running you will be navigated to given URL as below,

image

MediaPlayerLauncher is used to launch media player application and play the video from specified URL. This class is defined as below,

image

You can set desired controls of media player to be shown to user. Available media player controls are as below.

image

If you want to show more than one control to the user then you need to append them using OR operator and set them as value of control property.

image

You can also specify location of the media file in MediaLocationType property. MediaLocationType takes one of three values.

 

image

 

Install represents application installation directory, Data represents isolated storage and None value need to be set for external media.

You can play media with file from isolated storage as below,



MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();

mediaPlayerLauncher.Media = new Uri("SongVideo.wmv", UriKind.Relative);
mediaPlayerLauncher.Location = MediaLocationType.Data;
mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause |
MediaPlaybackControls.Stop|
MediaPlaybackControls.FastForward;
mediaPlayerLauncher.Orientation = MediaPlayerOrientation.Landscape;

mediaPlayerLauncher.Show();

In this way you can work with MediaPlayerLauncher.

In this post we discussed on WebBrowserTask and MediaPlayerLauncher. You may need to call these native applications from your app. I hope this post is useful. Thanks for reading.

Code to search location on Bing Map

BingMapTask launcher is used to search a location and mark it on the Bing map. It is defined as below,

image

Search term need to be set as string. If geo coordinate of center is not provided then BingMapTask will search a location on basis of user’s current location.

Hospitals can be located and marked on the Bing map from user’s current location as below,


BingMapsTask bingMapsTask = new BingMapsTask();
bingMapsTask.SearchTerm = "hospital";
bingMapsTask.ZoomLevel = 2;
bingMapsTask.Show();

You can set the zoom level of the map as well. In this way you can search a location and mark that on Bing map.

I hope this post is useful. Thanks for reading.

MarketPlaceSearchTask in Windows Phone

MarketPlaceSearch Task launcher is used to launch Marketplace client application with the searched result set in the criteria. It helps to search to marketplace from the application.

MarketPLaceSearchTask is defined as below,

image

You can see in the definition that, you can set MarketplaceContentType and SearchTerms. MarketPlaceContentType is defined as below,

image

So it can take either Application or Music as value. Now if you want to search music in market place then you can do that as below,


MarketplaceSearchTask task = new MarketplaceSearchTask();
task.ContentType = MarketplaceContentType.Music;
task.SearchTerms = "Waiting for Tonight";
task.Show();


You will get Market place search application launched as below,

image

If you want to search any application like debugmode , you can search as below,


MarketplaceSearchTask task = new MarketplaceSearchTask();
task.ContentType = MarketplaceContentType.Applications;
task.SearchTerms = "debugmode";
task.Show();


You will get Market place search application launched as below,

clip_image001[6]

In this way you can use MarketPlaceSearchTask. I hope this post is useful. Thanks for reading.

 

Clipboard API in Windows Phone

In this post we will see Clipboard API support in Windows Phone. Clipboard API support came as part of Windows Phone 7.5 and it was not part of Windows Phone 7.

Class is defined in System.Windows namespace as below,

clip_image002

You can set text as below,

clip_image004

In above snippet txtSource is a text box. You can check whether clipboard has some data or not as below,

clip_image006

One very important point you need to keep in mind that you cannot use GetText() method in Windows Phone. If you try to do that you will get security exception as below,

clip_image007

For security reason access to clipboard data is prohibited in Windows Phone. In this way you can use Windows Phone Clipboard API. I hope this post is useful. Thanks for reading .

 

MongoDB with CSharp

Before you start working with MongoDB using C Sharp, I recommend you to read MongoDB on Windows quick start in 5 minute and download MongoDB for CSharp from here

Start MongoDB server

If you would have gone through MongoDB on Windows quick start in 5 minute then you know how to start MongoDB server. However just for quick recap you need to start MongoDB server as below,

You can connect to MongoDB server as below by executing mongod exe

image

By default MongoDB stores data inside data folder of C Drive. You need to explicitly create this folder as well.

Add required library in solution

You will get a solution when you download MongoDB for CSharp from here . Open the solution in Visual Studio and build it.

image

Take MongoDB.dll and add this reference to your project.

Create Project and perform operations

For purpose of this blog post, I am going to create a console application. I have added MongoDB.dll as reference in console application project.

Create DataBase

If you want to create a database, you can create as below,

clip_image002

Above code will connect to MongoDB and create a database called Bloggers, if it does not exist.

Add Record in DataBase

You can add record as below,

clip_image002[6]

Where blogger is collection you get over database as below,

clip_image004

Delete Record from DataBase

image

You can delete a record by just providing one key value as well like below,

image

Fetch a Record

To fetch a particular document or record you need to create document and provide key value as below.

image

FindOne() function returns a document . You need to call Get function with key value as input to fetch the value.

For your reference full source code is as below,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB;

namespace ConsoleApplication34
{
class Program
{
static void Main(string[] args)
{

//Create Database
Mongo mongoDBdataBase = new Mongo();
mongoDBdataBase.Connect();
var dataBaseToWork = mongoDBdataBase.GetDatabase("Bloggers");
//Create Collection
var blogger = dataBaseToWork.GetCollection("blogger");

//Insert Records
var b = new Document();
b["Name"] = "Dhananjay";
b["Country"] = "India";
blogger.Insert(b);
b["Name"] = "G Block";
b["Country"] = "USA";
blogger.Insert(b);

//Fetch Record
var searchBlogger = new Document();
searchBlogger["Name"] = "Dhananjay";
var result = blogger.FindOne(searchBlogger);
Console.WriteLine(result.Get("Country").ToString());

Console.ReadKey(true);

}
}
}

In this way you can perform operations on MongoDB using CSharp. I hope this post is useful. Thanks for reading.

MongoDB on Windows quick start in 5 minute

In this 5 minute post, we will do quick start for MongoDB on Windows. I will show you the way to connect to MongoDB Server and to start the administrative shell.

Very first you need to download 64 bit binaries for Windows 64 bit from here . After downloading unzip downloaded ZIP file at any location of your choice. After extracting rename folder to mongodB

Next navigate to folder in which you unzipped the downloaded binaries. You will get below executable file downloaded.

image

Most important exe are, Mongod.exe to connect to mongo database server and Mongo.exe to start administrative shell.

By default MongoDB creates database and store data in Data folder inside C Drive. You need to create this folder manually. You need to create them as below,

image

You can connect to MongoDB server as below by executing mongod exe

image

Once server is started, you can start administrative shell as below by executing mongo command.

image

From administrative shell if you want to add two numbers, you can do that as below,

image

By default, It connects to database test

image

If you want to insert data you can do that as below, below command will create a database called debugmode [only when first row is inserting] and then add name as dj.

image

You can explore Help option to know more about the executable and commands. In further article we will go deeper on same and explore working with MongoDB and CSharp.

I hope this post is useful. Thanks for reading

 

Creating Hello World Windows Azure Node.js Web Application

Node.js is enjoying much popularity and Glenn Block is helping us to bring it on Windows Azure. In this tutorial, I will walkthrough step by step to create your first Windows Azure Node.js Web Application. I have divided this tutorial in three parts as installing required SDK, creating Web Application and then publishing to Windows Azure portal. Purpose of this tutorial is to help you in setting up environment and publishing. In further tutorials we will dig deeper.

Install Windows Azure SDK for Node.JS

To start with Node.JS on Windows Azure you need to install Windows Azure SDK for Node.JS. You can Get Windows Azure SDK for Node.JS from here. You need to install it from Web Installer. You will get below dialog box to install Windows Azure SDK for Node.JS

clip_image002

After successful installation, you should get below confirmation dialog .

clip_image004

By this  step SDK has been installed on your machine.

Create Node Application

To create Node application, click on Start and then select Windows Azure PowerShell for Node.JS. Run this as administrator

clip_image005

On command prompt create a Node directory in C drive as below,

clip_image006

After creating Node directory you need to create a solution. You can create solution as below,

clip_image007

I have created a solution called MyApplication. You can see files created inside the solution is as below,

clip_image008

There are four files created. If you are coming from Windows Azure background, you must be aware of other three files than deploymentSettings.json file. deploymentSettings.json file stores local setting for Windows Azure PowerShell deployment cmdlets.

Next you need to add a WebRole to the solution. To add WebRole execute below PowerShell command. If you don’t provide any name then by default WebRole name would be WebRole1. However I am providing name as WebRoleForNodeJS

clip_image009

Now if you list files created inside WebRoleForNodeJS , you will find configuration files and a JS file.

clip_image010

Most important file is server.js. This file contains starter code for Node.JS. You need to add codes in this file. Go ahead and open this file in NotePad. As of now, I am leaving default code created by the tool.

Server.js


var http = require('http');
var port = process.env.port || 1337;
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello NodeJS from Debugmode\n');
}).listen(port);

Run Locally on Windows Azure Emulator

To run it locally, go ahead and execute below PS command to start Windows Azure Emulator.

clip_image011

You can see is running in emulator as below,

clip_image012

Publish to Windows Azure Portal

To publish it to Windows Azure portal, first you need to take Publish Setting. You can take that as below,

clip_image013

You will be redirected to live login page. Sign in to download Publish Setting file. After login you should able to download PublishSetting file. Download file inside Node folder you created in previous steps.

clip_image015

Next you need to import PublishSetting file as below,

clip_image016

Note : Publishsettings file only needs to be imported once on the machine to set it up. You do not need to do that each time you create a service.

After importing PublishSetting file, you can publish to Windows Azure portal as below,

clip_image018

In above command name is the unique name and location is one of the Windows Azure Data center. After successfully publish operation , you should able to see Node.js running on Windows Azure portal.

clip_image019

This is what all required to create first application. In further post I will discuss much deeper on the same. I hope this post is useful. Thanks for reading