F5 Debug…

Building & Debugging the Technology!!!

101 How to on Windows Phone – How to #29 – Using Isolated Storage Explorer Tool in Windows Phone

Posted by Karthikeyan Anbarasan on May 20, 2012


 

In this short tutorial we are going to see an interesting tool which is used to explore the Isolated Storage file with ease. To begin with Isolated Storage in Windows Phone 7 is something similar which we have with Silverlight. In Windows Phone 7 Isolated storage is space provided to store the data locally which is isolated from the other application. Each application can have their own space(storage) so that other application data cannot be shared with in the application which gives more security to the data. In case if we need to share the data then we can have Azure storages or any other cloud medium to share the data between the applications. Learn more on Isolated Storage using the article Learn Windows Phone 7 Development in 31 Days – Day 24 – Working with Isolated Storage’s in WP7

Taken into consideration you are familiar with the Isolated Storage concept, Microsoft has provided with some cool tool along with the SDK for Windows Phone 7. Isolated Storage Explorer tool is a command line tool which is used to explore the files that are saved with the Isolated storage, with this tool we can save, replace or delete the files that are stored. There are many third party Explorers as well which have a nice user interface which is used for the same purpose. Here we will see both the tools in detail on how to use it effectively.

Microsoft Isolated Storage Explorer Tool:

This tool comes with the installation of Windows Phone SDK, and the tool will be available in the SDK directory with the name ISETool.exe. Based on the operating system we have installed the tool will reside in one of the below 2 places.

  • Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool
  • Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool

 

image

Open Visual Studio Command Line and open the tool to see the list of options available as shown below.

image

Now let us see how we can use this tool in our application which uses the Isolated Storage. Open the project in Visual Studio, then build and execute the project in Windows Phone Emulator as shown in the screen below (We are using pre complied starter kit downloaded over the web) for easy accessibility. Create some files and data that are stored in the Isolated Storage so that it will be easy for us to explore using the tool.

image

Now we have added some data and its on the Isolated Storage, to explore using the tool we need to first grab the product ID from the WPAppManifest.XML file from the folder as shown in the screen below.

image

Now the syntax to explore the root folder of the Isolated storage will be as shown below (Navigate to the tool path using Command Prompt and execute the below code).

Code to execute in command prompt – ISETool.exe dir xd 0ac364e8-6697-4ed7-b27e-1fc274990b3b

We can see the expected output as shown in the screen below.

image

Now let us take the 3rd party tool which do the same thing of exploring the Isolated Storage but with a much graphical view. The tool is available in Codeplex and it can be downloaded using the link http://wp7explorer.codeplex.com/ Just download and install the package and we are done we can see the tool as shown in the screen below.

SNAGHTML1c37b0a

If we are going to use this tool, we need to make code changes in our existing code which uses this Isolated Storage explorer. Please check this documentation on how to use this explorer much more easier with step by step implementation Using WP7 Isolated Storage Explorer. So in this tutorial we have seen the Isolated Storage explorer tool which can be used effectively to get the list of files and folders that are saved in the Isolated storage.

Posted in Windows Phone 7 | Tagged: , , , , , , , , , , , , , , , | Leave a Comment »

101 How to on Windows Phone – How to #28 – Play with Save Ringtone Task in Windows Phone

Posted by Karthikeyan Anbarasan on May 19, 2012


 

In this tutorial we are going to see how to use the Save Ringtone task with windows phone application development. We have seen similar kind of tasks in our previous tutorials like Save Email Address task, Save Phone Number task etc. Similar to those task this will also be used in day to day life of saving new ringtones to the storage that can be used when ever we are in need to change the ringtone on some specified task. This task basically enables the application user to launch the ringtone application and save a ring tone to the existing list.

As per the Microsoft recommendations (MSDN Documentation), each and every music file which is used to be assigned for the ringtone much meet the following specification as shown below.

  • Ringtone files must be of type MP3 or WMA.
  • Ringtone files must be less than 40 seconds in length.
  • Ringtone files must not have digital rights management (DRM) protection.
  • Ringtone files must be less than 1 MB in size.

Let us see the steps on how to achieve this task in real time for a Windows phone application.

Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Save Ringtone Task as shown in the screen below.

SNAGHTML122f46f

Now drag and drop few controls to the screen which is used to trigger event that launches the Save Ringtone chooser Task. Once we designed the screen with the controls we can see the screen looks like below. We have added a button control to trigger the event and text block control to show the end result after the task is completed as shown in the screen below.

image

XAML Code:

<phone:PhoneApplicationPage
x:Class=”F5debugHowto28.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:phone=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone”
xmlns:shell=”clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″
mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”768″
FontFamily=”{StaticResource PhoneFontFamilyNormal}”
FontSize=”{StaticResource PhoneFontSizeNormal}”
Foreground=”{StaticResource PhoneForegroundBrush}”
SupportedOrientations=”Portrait” Orientation=”Portrait”
shell:SystemTray.IsVisible=”True”>

<!–LayoutRoot is the root grid where all page content is placed–>
<Grid x:Name=”LayoutRoot” Background=”Transparent”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”*”/>
</Grid.RowDefinitions>

<!–TitlePanel contains the name of the application and page title–>
<StackPanel x:Name=”TitlePanel” Grid.Row=”0″ Margin=”12,17,0,28″>
<TextBlock x:Name=”ApplicationTitle” Text=”F5debug How to Series” Style=”{StaticResource PhoneTextNormalStyle}”/>
<TextBlock x:Name=”PageTitle” Text=”Save Ringtone” Margin=”9,-7,0,0″ Style=”{StaticResource PhoneTextTitle1Style}”/>
</StackPanel>

<!–ContentPanel – place additional content here–>
<Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″>
<Button Content=”Save Ringtone” Height=”72″ HorizontalAlignment=”Left” Margin=”9,6,0,0″ Name=”button1″ VerticalAlignment=”Top” Width=”441″ />
<TextBlock Height=”277″ HorizontalAlignment=”Left” TextWrapping=”Wrap” Margin=”29,108,0,0″ Name=”textBlock1″ Text=”" VerticalAlignment=”Top” Width=”407″ />
</Grid>
</Grid>

PhoneApplicationPage>

 

Now add a ringtone to the root folder of the application, here basically we have 2 options one is we can store the ringtone directly to the Isolated storage so that it will not be packed with the .XAP file else if we use it directly from the application the audio file will be packaged with the .XAP file which basically will increase the size and as well it will be not in the isolated storage. If we are going to use the Isolated Storage we need to isostore: with the audio file name and if its directly from the root then we need to use as appdata:

image

Now we need to write our code in the button click event to trigger the Save Ringtone task, which basically allows the user to save the ring tone and also provides some additional options to assign the ringtone for default ringing or we can use it for future as well. To do that just go to the code behind and first add the USING handler code on top with the existing using statements as shown in the code below.

using Microsoft.Phone.Tasks;

Next is to add the below code to the button click event which basically creates an instance of the Save Ringtone task which saves the audio file which we are going to include in the project. Also we have some properties which can be used to set the ringtone display name as shown in the code below.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugHowto28
{
public partial class MainPage : PhoneApplicationPage
{
SaveRingtoneTask srtTask;

// Constructor
public MainPage()
{
InitializeComponent();
srtTask = new SaveRingtoneTask();
srtTask.Completed += new EventHandler<TaskEventArgs>(srtTask_Completed);
}

private void button1_Click(object sender, RoutedEventArgs e)
{
srtTask.Source = new Uri(“appdata:/Ringtone1.mp3″);
srtTask.DisplayName = “F5debug Ringtone”;
srtTask.Show();
}

void srtTask_Completed(object sender, TaskEventArgs e)
{
if (e.TaskResult == TaskResult.OK)
{
textBlock1.Text = “Ring Tone Saved Successfully!!!”;
}
else if (e.TaskResult == TaskResult.Cancel)
{
textBlock1.Text = “User Cancellation!!!”;
}
else
{
textBlock1.Text = “Ring Tone couldnot be saved!!!”;
}
}
}
}

image

Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.

Output Screens:

image

So in this tutorial we have seen how to use the Save ringtone task which saves the selected ringtone to the Ringtone list and as well provide the configuration to default the ring tone which we added through the application. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , , , , , , , , , , , , | Leave a Comment »

101 How to on Windows Phone – How to #27 – Play with Phone Number Chooser Task in Windows Phone

Posted by Karthikeyan Anbarasan on May 18, 2012


 

In this tutorial we are going to see how to use the Phone Number Chooser task with Windows Phone development. With this task we can extract the phone number of a particular contact which the user selects to get the information. We can use this task in our application in cases like we need to get the list of contact numbers of a particular contact. This task simply opens the contact application up on which the user selects the contact it will trigger an event to collect the information and gets back in a task result which can be used to get the information which we will be looking for. Let us see the steps on how to achieve this task in real time for a Windows phone application.

Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Phone Number Chooser Task as shown in the screen below.

SNAGHTMLbb8399

Now drag and drop few controls to the screen which is used to trigger event that launches the Phone Number Chooser Task. Once we designed the screen with the controls we can see the screen looks like below. We have added a button control to trigger the event and text block control to show the end result after the task is completed as shown in the screen below.

image

XAML Code:

<phone:PhoneApplicationPage
x:Class=”F5debugHowto27.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:phone=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone”
xmlns:shell=”clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″
mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”768″
FontFamily=”{StaticResource PhoneFontFamilyNormal}”
FontSize=”{StaticResource PhoneFontSizeNormal}”
Foreground=”{StaticResource PhoneForegroundBrush}”
SupportedOrientations=”Portrait” Orientation=”Portrait”
shell:SystemTray.IsVisible=”True”>

<!–LayoutRoot is the root grid where all page content is placed–>
<Grid x:Name=”LayoutRoot” Background=”Transparent”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”*”/>
</Grid.RowDefinitions>

<!–TitlePanel contains the name of the application and page title–>
<StackPanel x:Name=”TitlePanel” Grid.Row=”0″ Margin=”12,17,0,28″>
<TextBlock x:Name=”ApplicationTitle” Text=”F5debug How to Series” Style=”{StaticResource PhoneTextNormalStyle}”/>
<TextBlock x:Name=”PageTitle” Text=”Phone Number Chooser” Margin=”9,-7,0,0″ Style=”{StaticResource PhoneTextTitle1Style}”/>
</StackPanel>

<!–ContentPanel – place additional content here–>
<Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″>
<Button Content=”Get Phone Number of Chris” Height=”72″ HorizontalAlignment=”Left” Margin=”9,6,0,0″ Name=”button1″ VerticalAlignment=”Top” Width=”441″ />
<TextBlock Height=”277″ HorizontalAlignment=”Left” TextWrapping=”Wrap” Margin=”29,108,0,0″ Name=”textBlock1″ Text=”" VerticalAlignment=”Top” Width=”407″ />
</Grid>
</Grid>

</phone:PhoneApplicationPage>

 

Now we need to write our code in the button click event to trigger the Phone Number Chooser task, which basically opens the Contacts application to select a contact from which the phone number will be extracted. To do that just go to the code behind and first add the USING handler code on top with the existing using statements as shown in the code below.

using Microsoft.Phone.Tasks;

Next is to add the below code to the button click event which basically creates an instance of the Phone Number Chooser task and once the event is completed another event is raised which has the selected contacts details in the task result as output as shown in the code below. Basically the Phone number chooser task has 2 properties which we get in the result while the event is triggered. We will be getting the Display name as well as the phone number of the selected contact.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugHowto27
{
public partial class MainPage : PhoneApplicationPage
{

PhoneNumberChooserTask pncTask;

// Constructor
public MainPage()
{
InitializeComponent();

pncTask = new PhoneNumberChooserTask();
pncTask.Completed += new EventHandler<PhoneNumberResult>(pncTask_Completed);
}

private void button1_Click(object sender, RoutedEventArgs e)
{
pncTask.Show();
}

void pncTask_Completed(object sender, PhoneNumberResult e)
{
if (e.TaskResult == TaskResult.OK)
{
textBlock1.Text = “Selected Contact is – ” + e.DisplayName + ” and Contact number is – ” + e.PhoneNumber;
}
}
}
}

 

image

Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.

Output Screens:

image

So in this short tutorial we have seen how to make use of the Phone Number chooser task which is used to choose a contacts phone number that can be used internally with in the application as per the requirement. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , , , , , , | Leave a Comment »

101 How to on Windows Phone – How to #26 – Play with Save Phone Number Task in Windows Phone

Posted by Karthikeyan Anbarasan on May 17, 2012


 

In this tutorial we are going to see how to make use of the Save Phone Number task in Windows Phone development. This task is something similar to the Save Email Address task which we have seen in our earlier tutorial, this task is also common that it will be used in our day to day work. With this task we can save the Phone number to a contact on the user selection. With this task we can trigger to save the Phone number from our application with simple clicks. This task opens the contact application and provides an option to the end user to select the contact to which the phone number need to be saved. Let us see the steps on how to achieve this task in real time for a Windows phone application.

Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Save Phone Number Task as shown in the screen below.

SNAGHTML81b571

Now drag and drop few controls to the screen which is used to trigger event that launches the Save Phone Number Task. Once we designed the screen with the controls we can see the screen looks like below. We have added a button control to trigger the event and text block control to show the end result after the task is completed as shown in the screen below.

image

XAML Code:

<phone:PhoneApplicationPage
    x:Class="F5debugHowto26.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!–LayoutRoot is the root grid where all page content is placed–>
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!–TitlePanel contains the name of the application and page title–>
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="F5debug How to Series" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Save Phone Number Task" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!–ContentPanel – place additional content here–>
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Save Phone Number" Height="72" HorizontalAlignment="Left" Margin="9,6,0,0" Name="button1" VerticalAlignment="Top" Width="441" Click="button1_Click" />
            <TextBlock Height="277" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="29,108,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="407" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>

 

Now we need to write our code in the button click event to trigger the Save Phone Number task, which basically opens the Contacts application to select a contact to which the Phone number need to be added. To do that just go to the code behind and first add the USING handler code on top with the existing using statements as shown in the code below.

using Microsoft.Phone.Tasks;

Next is to add the below code to the button click event which basically creates an instance of the Save Phone Number task and once the event is completed another event is raised which takes the result as output with which we can conclude on the action taken as shown in the code below.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugHowto26
{
    public partial class MainPage : PhoneApplicationPage
    {
        SavePhoneNumberTask spnTask;

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            spnTask = new SavePhoneNumberTask();
            spnTask.Completed += new EventHandler<TaskEventArgs>(spnTask_Completed);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            spnTask.PhoneNumber = "0123456789";
            spnTask.Show();
        }

        void spnTask_Completed(object sender, TaskEventArgs e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                textBlock1.Text = "Phone Number Saved Successfully!!!";
            }
            else if (e.TaskResult == TaskResult.Cancel)
            {
                textBlock1.Text = "User Cancellation!!!";
            }
            else
            {
                textBlock1.Text = "Phone Number couldnot be saved!!!";
            }
        }
    }
}

image

Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.

Output Screens:

image

image

So in this tutorial we have seen how to use the Save Phone Number task to save the Phone number of a specified contact by launching the contact application directly from the application which is very much useful in our day to day tasks. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , , , , , , | Leave a Comment »