F5 Debug…

Building & Debugging the Technology!!!

Archive for February 22nd, 2012

Microsoft IT CAMPS in 4 Cities

Posted by Karthikeyan Anbarasan on February 22, 2012

Friends,

The second version of the Microsoft IT CAMPS is scheduled in 4 cities in India, Microsoft IT Camps are designed specifically for IT Infrastructure and Application Specialists, Strategic IT Managers and Tactical IT Managers – with experience of managing an organization’s IT infrastructure. The event will provide you with an opportunity to speak with and have your questions answered by Evangelists who work in infrastructure deployment and management day-in and day-out. Attend the exclusive technical sessions, armed with your questions on Private Cloud, System Centre Technologies, Infrastructure Components, and related technologies. Below is the planned agenda for this 4-city(Mumbai, Hyderabad, Bangalore and Chennai) event series.

 

AGENDA:

09:00am – 10:00am Registration

10:00am – 10:15am Welcome Keynote

10:15am – 11:00am Understanding the Microsoft Private Cloud

11:00am – 11:20am Overview of the System Center Technologies

11:20am – 11:35am Tea and Coffee break

11:35am – 12:35pm Deploy and Manage the Infrastructure Components

12:35pm – 01:35pm Lunch

01:35pm – 02:35pm Deploy and Manage the Private Cloud Infrastructure

02:35pm – 04:35pm Deploy and Manage the Service Layer

04:35pm – 04:50pm Tea and Coffee break

04:50pm – 05:50pm Deploy and Manage the Applications and VM’s

05:50pm – 06:00pm Ask the Experts [Q & A]

Venue Details and Timing:

Mumbai:

  • Date - March 2, 2012 , 9:00AM to 6:00PM
  • Venue – The Leela
  • Address Sahar, Mumbai, Maharashtra

Hyderabad:

  • Date – March 7, 2012, 9:00AM to 6:00PM
  • Venue – Taj Deccan
  • Address – Banjara Hills, Hyderabad, Andhra Pradesh

Bangalore:

  • Date – March 9, 2012, 9:00AM to 6:00PM
  • Venue – Taj Vivanta
  • Address – MG Road Bangalore, Karnataka

Chennai:

  • Date – March 13, 2012, 9:00AM to 6:00PM
  • Venue – Le Royal Meridien
  • Address – #1, GST Road, St. Thomas Mount, Chennai, Tamil Nadu

Registration Link – http://www.microsoft.com/india/events/itcamps/registration.aspx

Why to wait, register for the event in your respective city and enjoy!!!

Posted in IT CAMPS | Tagged: , , | Leave a Comment »

Learn Windows Phone 7 Development in 31 Days – Day 22 – Working with Device Information in WP7

Posted by Karthikeyan Anbarasan on February 22, 2012

01 Download ToolsDownload Source CodeDownload as PDF FileSubscribe to F5debugComplete Article Listing

Introduction:

In this article we are going to see how to get the Device information for managing the device. We will see how to make use of the Device detection API’s available with the Windows Phone 7 SDK to detect the Device information, Memory detection, Keyboard installed or not etc with the API.

To detect the device information, we are going to use the DeviceExtendedProperties class. We have different options to get the information of the device, network etc.. with the API. We will see only retrieving the device information here with this article. We are going to retrieve the below list of device information

    S No                    Information                                Description
1 DeviceUniqueId Gets device Unique ID.
2 DeviceManufacturer Gets Device Manufacture details.
3 ApplicationCurrentMemoryUsage Gets Application Memory Usage.
4 ApplicationPeakMemoryUsage Gets Application Memory Leak Usage.
5 DeviceName Gets the Device Name.
6 DeviceFirmwareVersion Gets the Firmware Version.
7 DeviceHardwareVersion Gets the Hardware Version.
8 DeviceTotalMemory Gets the physical Memory RAM Usage.
9 Power Source Indicates if the device works with power or battery.
10 Iskeyboardpresent Indicates if any physical keyboard is installed with device
11 IsKeyboardDeployed Indicates if the user deploy the physical keyboard
12 ApplicationMemoryUsageLimit Gets the maximum amount of memory.

Let us jump start to see the step by step process on how to implement the device information class to get the information and show it to the end users.

Steps:

Open Visual Studio 2010 and create a new Silverlight for Windows Phone 7 Application with a valid project name as shown in the screen below.

2012-01-26 20h25_16
Now let us start with our design to see the device informations in one page. Once we are done with the design we can see the screen looks like below screen. Just copy the XAML code to get the same look and feel. Else we can directly drag and drop the controls from the tool box and design it as per the requirement.

XAML Code:


<phone:PhoneApplicationPage
x:Class="F5debugWp7DeviceInformation.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 WP7 TUTORIALS" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Device Info" 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">
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,23,0,0" Name="ttDeviceInfo" Text="F5debug - Device Information List" VerticalAlignment="Top" Width="438" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,76,0,0" Name="ttdeviceuniqueid" Text="Device Unique ID:" VerticalAlignment="Top" Width="176" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,76,0,0" Name="txtDeviceUniqueID" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,112,0,0" Name="textBlock4" Text="Device Manufacturer:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,112,0,0" Name="txtDeviceManufacturer" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,148,0,0" Name="textBlock6" Text="Device Name:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,148,0,0" Name="txtDeviceName" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,184,0,0" Name="textBlock8" Text="Firmware Version:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,184,0,0" Name="txtFirmwareVersion" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,220,0,0" Name="textBlock10" Text="Hardware Version:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,220,0,0" Name="txtHardwareVersion" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,251,0,0" Name="textBlock12" Text="Total Memory:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,251,0,0" Name="txtTotalMemory" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,287,0,0" Name="textBlock14" Text="Current Memory:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,287,0,0" Name="txtCurrentMemory" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,323,0,0" Name="textBlock16" Text="Peak Memory:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,323,0,0" Name="txtPeakMemory" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,394,0,0" Name="textBlock18" Text="Power Source:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,394,0,0" Name="txtPowerSource" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,430,0,0" Name="textBlock20" Text="Keyboard Installed:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,430,0,0" Name="txtkeyboardinstalled" Text="" VerticalAlignment="Top" Width="219" />
<Button Content="Get Details" Height="72" HorizontalAlignment="Left" Margin="46,520,0,0" Name="button1" VerticalAlignment="Top" Width="359" Click="button1_Click" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,467,0,0" Name="textBlock3" Text= "Keyboard Deployed:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,467,0,0" Name="txtKeyboardDeployed" Text="" VerticalAlignment="Top" Width="219" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,359,0,0" Name="textBlock1" Text="Maximum Memory:" VerticalAlignment="Top" Width="200" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="218,359,0,0" Name="txtMaximuMemory" Text="" VerticalAlignment="Top" Width="219" />
</Grid>
</Grid>

<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>

2012-01-26 20h58_07
Now let us start with our code to get the device information and load it to the respective text blocks one by one as shown in the code below. We can use the Device Status class to get the details of the device properties except the device unique ID. We will write the code later to get the unique id of the device.

Code Behind:


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.Info;
using System.Windows.Threading;

namespace F5debugWp7DeviceInformation
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
txtCurrentMemory.Text = DeviceStatus.ApplicationCurrentMemoryUsage.ToString();
txtMaximuMemory.Text = DeviceStatus.ApplicationMemoryUsageLimit.ToString();
txtPeakMemory.Text = DeviceStatus.ApplicationPeakMemoryUsage.ToString();
txtTotalMemory.Text = DeviceStatus.DeviceTotalMemory.ToString();

txtDeviceManufacturer.Text = DeviceStatus.DeviceManufacturer.ToString();
txtDeviceName.Text = DeviceStatus.DeviceName.ToString();

txtFirmwareVersion.Text = DeviceStatus.DeviceFirmwareVersion.ToString();
txtHardwareVersion.Text = DeviceStatus.DeviceHardwareVersion.ToString();

txtKeyboardDeployed.Text = DeviceStatus.IsKeyboardDeployed.ToString();
txtkeyboardinstalled.Text = DeviceStatus.IsKeyboardPresent.ToString();

txtPowerSource.Text = DeviceStatus.PowerSource.ToString();

//txtDeviceUniqueID.Text = "";
}
}
}

2012-01-26 21h18_57
Now let us write the code for getting the Device Unique ID as shown in the code below. We use the DeviceExtendedProperties property TryGetValue to get the Unique ID, since we get it as a byte array we do a conversion to the string and assign it to the text block as shown below.

Code Behind:


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.Info;
using System.Windows.Threading;

namespace F5debugWp7DeviceInformation
{
public partial class MainPage : PhoneApplicationPage
{
public static string val;

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

private void button1_Click(object sender, RoutedEventArgs e)
{
txtCurrentMemory.Text = DeviceStatus.ApplicationCurrentMemoryUsage.ToString();
txtMaximuMemory.Text = DeviceStatus.ApplicationMemoryUsageLimit.ToString();
txtPeakMemory.Text = DeviceStatus.ApplicationPeakMemoryUsage.ToString();
txtTotalMemory.Text = DeviceStatus.DeviceTotalMemory.ToString();

txtDeviceManufacturer.Text = DeviceStatus.DeviceManufacturer.ToString();
txtDeviceName.Text = DeviceStatus.DeviceName.ToString();

txtFirmwareVersion.Text = DeviceStatus.DeviceFirmwareVersion.ToString();
txtHardwareVersion.Text = DeviceStatus.DeviceHardwareVersion.ToString();

txtKeyboardDeployed.Text = DeviceStatus.IsKeyboardDeployed.ToString();
txtkeyboardinstalled.Text = DeviceStatus.IsKeyboardPresent.ToString();

txtPowerSource.Text = DeviceStatus.PowerSource.ToString();

string strUniID = GetDeviceUniqueID();

txtDeviceUniqueID.Text = strUniID.ToString();
}

public string GetDeviceUniqueID()
{
byte[] getresult = null;
object uniqueId;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
{
getresult = (byte[])uniqueId;
}
val = Convert.ToBase64String(getresult);
return val;
}

}
}

2012-01-26 21h26_49

Now we are done with our code, let us build and execute the application by pressing F5 directly from the keyboard and we can see the application loaded to the Windows Phone 7 Emulator as shown in the screen below with the expected output.

image

Conclusion:

So in this article we have seen how to get the device information details and the device unique id using the Device Status class in detail.

Thanks for reading my article. If you like my blog and if you are interested in getting the latest updates on new articles, kindly follow me through one of these options.

F5Debug FacebookF5debug LinkedInF5debug TwitterF5debug GooglePlusF5debug RSSFeed

Posted in Windows Phone 7 | Tagged: , , , , , , , , , , , , , , , , , , , | 2 Comments »