Pages

Friday, December 31, 2010

Code profiler for Windows Phone 7

EQATEC  has recently release comes a code-profiler that can profile your WP7 Silverlight app on real phone hardware, as well as on the emulator. The profiler is free for single-assembly applications. You can download it now from www.eqatec.com.

For more info check out Channel 9 – World’s first profiler for Windows Phone 7 or the Eqatec  profiler website.

 

Thursday, December 30, 2010

Crop the webbrowser control in a Windows Phone 7 app

When building my Windows Phone 7 app – I needed to login into LinkedIn – unfortunately the login page of LinkedIn does not seem to scale as well as the Twitter login page so I decided to only show a specific part of the page within the WebBrowser control for Windows Phone. I kind of got it working by using the Clip property (for reference see How to: Crop an object (Silverlight))

<phone:WebBrowser HorizontalAlignment="Stretch" 
Name="webBrowser1" VerticalAlignment="Stretch" Height="466" Width="480"
IsScriptEnabled="True" Visibility="Collapsed">
<phone:WebBrowser.Clip>
<RectangleGeometry Rect="0,0,400,300" />
</phone:WebBrowser.Clip>
</phone:WebBrowser>




Saturday, December 25, 2010

WP7 Barcode Scanning using ZXing and Microsoft.Phone.Media.Extended

     When I first saw this blog post from Kevin Marshall it crossed my mind that it could be used for barcode scanning in order to get the same user experience you have on Android and iPhone. I've contacted Kevin to give me some details/source code for the project and a few days ago he sent me his project that is already posted on his blog here. Kevin also thought of the possibility to use it for barcode scanning, but his sample works only with QR codes. Looking at the project I saw that he was using VideoCamera class that has no Focus capability needed to take a "clean" picture of the barcode. The PhotoCamera class, on the other hand, has Focus  implemented so I simply changed the class from VideoCamera to Photocamera. In the Grab method I call the Focus method and then using the AutoFocusCompleted event I decode the barcode. For decoding I use my ZXing port. The results are pretty good as you can see in this video I've uploaded to YouTube. There are some optimizations that can be done like cropping the WritableBitmap at the dimensions of the red rectangle, but even with the full image (640x480) the speed was acceptable on my LG Optimus 7 .
     The source code and the xap of the app (that you can deploy if you have a developer/unlocked phone) are included in my latest release of the ZXing port available on CodePlex. To compile the source you will need to follow the steps Kevin indicated in this post and also you will find some hints/files here. If you start a new project you will also need to add   "ID_CAP_CAMERA" capability to WMAppManifest.xml. This, for the moment, is a hack and I don't think the application will pass Microsoft certification, but you can try. 
  "Reflecting" Microsoft.Phone.Media.Extended I saw no reason why Microsoft won't give access to developers to this assembly (put it in the SDK)! Why limit developers to do great apps when this is the first thing Microsoft needs for the Windows Phone Platform? 
     Special thanks to Kevin for the source code.


NAMASTE

Thursday, December 23, 2010

DropBox library for Windows Phone 7

    So here it is.... I finally published the DropBox client library on CodePlex. It is a fully functional Dropbox client library for Windows Phone 7 and it is the same I've used to build BoxFiles. The first version of BoxFiles received a pretty bad review from http://wmpoweruser.com as it was using only the official API that doesn't have any method for generating links to files (the only way to open a file in Windows Phone 7), but after some searching I've found the API and I think that the current version (1.3) is a pretty good app. I will keep my bad review as they asked 50$ to review the application again. In the following weeks I will publish a new version of the Backup/Restore IsolatedStorage project using Dropbox instead of WCF.
  I've put a lot of work in this library so if you use it please sustain my work by buying the application and please "try" not to publish a similar app to BoxFiles on the Marketplace. 
   I've also published the Sqlite and the ZXing projects on CodePlex so you can grab the source code directly from there.

  I wish you a Merry Christmas!


NAMASTE

Learn Silverlight for Windows Phone 7 - [Part-3]

It is pretty simple to develop Windows Phone 7 application. It is a cool new mobile platform from Microsoft. Developers use Silverlight, XNA Framework and of course .NET compact framework for developing Windows Phone 7 applications. Programs for Windows Phone 7 are written in .NET managed code using C#.NET.

In this part I am going to describe how to get familiar with windows phone development using very traditional program that is “Hello World”J.

Let us open Visual Studio 2010 or Visual Studio 2010 Express for Windows Phone; here I have VS 2010 Ultimate. Now go to file menu and File à New à Project and then you see a list of project templates of Silverlight for windows phone 7.

  1. Windows Phone Application
  2. Windows Phone Databound Application
  3. Windows Phone Class Library
  4. Windows Phone Panorama Application
  5. Windows Phone Pivot application

Now here we have to choose Windows Phone Application Template then enter the project name of the application i.e. (WP_Hello_World) and press OK Button.

Now we are able to view default XAML page in IDE, we can say that it’s a form just like in a windows mobile application development SDK (I know windows mobile developer got it:). here we go…

Here I am going to develop a very simple UI for hello world application. Now we add few controls by dragging and dropping from the Toolbox (TextBlock, TextBox and Button) to the XAML page. After this the XAML will be automatically generated. See in the below picture.

Now the UI is ready, it looks like the picture shown below.

Now just double click on the button control, the following code will be generated in the XAML.cs file which is also known as code behind.

private void btnClickMe_Click(object sender, RoutedEventArgs e)
{

MessageBox.Show("Hello " + txtName.Text + "!", this.Name, MessageBoxButton.OK);

}

In the button click event I have used very traditional message box, as we are already aware. This message box class is derived from System.Windows Namespace.

Important: To select the target for WP application for Windows Phone Emulator; which is by default set in the WP project if you want to run your application in Windows Phone Device then you must have to connect your Windows Phone 7 device with your development machine and set the target as Windows Phone Device.

Now our program is ready to execute, now press F5 to run the application in the debug mode or press the combination of Ctrl+F5 to run the application in the release mode. See this picture

Now I enter the name and click on “Click Me” Button, then a pop-up message will appear on the screen with name. See below picture.

That’s all for the Hello World application for Windows Phone 7. Follow up this series for more advance topics.

Download Source Code and Article

:)

Thank you!