Wednesday, February 27, 2013 #

Playing with Windows 8 Sensors – Light Sensor

 

Its been a great ride for all of us who Love Technology and play with what it can do for us with the devices that we have. In search to explore new stuff that can be done with the wide range of sensors that are available for us these days I have come across this wonderful post done by Sacha Barber about Light sensor on Windows 8. “Fun With Windows 8 Light Sensor” is where you can look how the light sensor can be used to control the Google Earth.

I either can follow him and implement the same but I decided to start learn the basics first and then jump onto more complex implementations, and I decided to write blog posts along my journey so you have a smooth understanding of what we are going to do with sensors.

This post is about Light Sensor (100 Level) – Here we are just going to initialize the light sensor and read the Luminance value (which is measured in LUX). You cal always wiki the LUX and learn more about it .

Let me start now and show what I did to get the following final result.

image

The number  “122” is the Luminance value that the light sensor on my Surface Pro read from the light ambience in my room. Here you go, very simple to follow.

1. Open Visual Studio 2012 (I am on Surface Pro, any computer with light sensor that can run VS is a minimum requirement)

2. File >> New >> Project (Select/Enter the stuff that are marked in Red)

NewProject

Since this is a very small application I selected the Blank App Template. Now Visual Studio Creates a Blank Windows 8 Application.

When you run it you will see a black blank windows, since we don't have anything on the app yet.

3. Lets put some stuff on the page to show up on the screen so that we don't see blank page. Since I am like many of you guys who are not great designers or Lazy to write the UI code, Microsoft have Blend for us. I open Blend and opened my project and below is who it looked.

BlendPage

The Red box to the left is the tree structure of the application. The Blank application template only gives a blank grid and I added a stackpanel under it to stack my text. Below is how it  looked after i had my UI design done.

BlendPage2

Its very clear that i have a stackpanel with 4 textblocks (labels), Title, Author area, the Box to show the Luminance value, and a help text to show how to activate it.

4. Now go back to VS 2012 and you shall see something like this

Caution

here click “Yes to All” to save the changes that are made on Blend, now you will see the UI changes on VS 2012 as well. Now if you run the App it shall look like below rather than a blank black window like it was earlier.

EmptyApp

5. Now lets get back to the code and add few lines of code and shall see the light sensor do its magic. So far when you run the app what we see on the page is contenst from the MainPage.xaml

Now lets click on the little arrow next to it to add code behind (open MainPage.xaml.cs)

You will see a constructor which Initializes the component and right above that Initialize a private variable

private LightSensor _sensor; (you might need to add a reference to Windows.Devices.Sensors)

and add the following code right below InitializeComponent() call in the constructor

private LightSensor _sensor;

_sensor = LightSensor.GetDefault();
if (_sensor != null)
{
    LuxValue.Text = "";
}
else
{
    LuxValue.Text = "No Light Sensor Found";
}

what basically we are doing it getting a new local instance of LightSensor before the constructor is called and checking the default value of the sensor after the MainPage object has been initialized, if that default value is null then it means that there is no sensor and we show the “No Light Sensor” text if not we just don't do anything.

6. in the same MainPage.xaml.cs file you will also get an override method called OnNavigatedTo , this is the method that is called when the app is completely loaded (to put in simple terms). and this is where we have to call the function that reads the Luminance value from the light sensor and displays in the box that is shown in step 3 second image.

and this is how it looks

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    _sensor.ReadingChanged += new TypedEventHandler<LightSensor, LightSensorReadingChangedEventArgs>(ReadingChanged);
}

I am calling an async method on the OnNavigatedTo so that the Luminance ReadingChanged event is called continuously and the number is shown every time the value changes. below is that the ReadingChanged method looks like

async private void ReadingChanged(object sender, LightSensorReadingChangedEventArgs e)
{
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        LightSensorReading reading = e.Reading;
        LuxValue.Text = String.Format("{0}", reading.IlluminanceInLux);
    });
}

and thats it, everything is in place and lets run the app and we shall see the same windows as step4 second image, but if you read the help text at the bottom asking you to wave before the sensor so that the ReadingChanged event is activated and the Luminance number is shown.

Sample out put window

image

The “123” is the Luminance value from the light sensor on my surface pro in my room. I used my windows phone flash app pointed directly to the light sensor and the number increased to around 12000 (simulating sun)

And there we go, out first very simple app that reads the data from the sensor and the complete code can be downloaded from my public skydrive at LightSensor1 CodeDownload

Further updates are going to come soon, please stay tuned and let me know your comments.

Thank you

Vijaya Malla.

Posted On Wednesday, February 27, 2013 8:38 PM | Comments (0)

Friday, February 15, 2013 #

My Experience with free source control from Microsoft

 

Microsoft has been very generous with all the free stuff they are giving to the developer community and among that is a free source control  (tfs ). It is free for 5 developers and is a very little after that. if you are small business and a single developer like me who works on random projects then this is the best solution (in my mind) for all of us (visual studio developers).

Just register at https://tfs.visualstudio.com/ and can start your source control in seconds.

Things you can do :

  • Create your projects, check in your code directly from your VS 2010 or VS 2012 (I am using 2012 now)
  • Create a project with a scrum pattern or an agile pattern,
  • can create product back log, and track the breakdown, track velocity and even add people to the project and make it secure by not inviting others.
  • track checkins from multiple people from the team, track their progress thru SBI’s. etc
  • and many more

Please take a moment to check out this and share your experiences.

An App on windows phone and surface (work online and offline) would be awesome to have.

I know the online tfs has been in the market for long time but I wanted to share my experiences.

Vijaya Malla.

Posted On Friday, February 15, 2013 12:59 PM | Comments (4)

Error Cannot map server path because it is not rooted beneath a team project

 

What happened: I have an online TFS account (if you don’t have one please go to visual studio and subscribe, free for 5 people team). I recently bought a surface pro and started creating various test projects.

I created a test project on vs 2012 on my surface, then connected to my TFS (free) and then I decided to sync my project to my TFS, I right clicked on my solutions to add it to source control but then I got the following error

“Error Cannot map server path $/project name/path name because it is not rooted beneath a team project” what happened was I have no local path setup for my source control, so I synched my source control to a local folder and then moved my test project to this local path, then I continued the same adding my solution to the source control and it worked.

very simple solution. I know there are so many articles about this but this is my experience and I am sharing it.

Thank you
Vijaya Malla.

Posted On Friday, February 15, 2013 5:40 PM | Comments (1)

Saturday, February 9, 2013 #

Surface Pro 128 GB and Its Availabiltiy at Microsoft Store

A Microsoft unpaid Evangelist journey to get Surface Pro 128GB

It us who tell other people about Microsoft cool products and the technologies and how easy they are to get things done. blah..blah.. etc...

This is what happened today : Surface Pro release date

I was there at a local Microsoft Store (Tysons Corner, VA) a week ago to get a reservation card for Surface Pro and they were are all gone, felt very happy that people are still interested in Microsoft. The sales representative told me that the store opens at 10:00AM today (2/9/13) so I was keeping money aside for the pro and went to the store at 9:00AM and was hoping there would be a line but there is none, so I ran to the store and was told by the Manger that they were all sold out the 128GB ones.

 

I also called another store close by Pentagon City Mall, VA and they don't have them either.

 

They only had 35 128GB ones and they will get the next shipment in 3-5 days, I don't know what they are going to sell to 128GB pro customers? If they don't trust their product to maintain enough stock I don't know how they would expect us to trust their product .

If this is the way they want to get the market and make people think that they were selling out stocks very soon, its like bluffing themselves.

For the past two years I have been an unpaid Microsoft Evangelist (very proud) but today I kinda lost trust in them.

I don't know if I feel any bad if they get to where Dell is today.

Posted On Saturday, February 9, 2013 10:52 AM | Comments (2)

Wednesday, February 29, 2012 #

Religions, Casts and now Technology

This blog post is not to hurt any one, just a thought that I got in my mind when I was walking from an Apple Store to a Microsoft Store. I am not judging any one here but if you are from the DC area and been to Tysons Corner’s Apple and Microsoft Store you can see the change on how the migration happened from the Apple to the Microsoft Store.

Lets all do a time travel back to couple of centuries , we have sees lot of videos, documentaries & movies that showed us how and what people were doing back in the days. They didn’t have a lot to do except fighting for Water, Food and Shelter. As that trend got more and more popular, we introduced a new concept called “RELIGION”. Religion in my view is a set of rules that are written in a sequential order for the people to follow (same as what we do in programming these days). In the same way we have multiple ways of programming, there were multiple religions that are designed and followed by people themselves.

CASTS: Once the word religion got popular with the increase in the number of people on our mother planet Earth, we started dividing that into “CASTS” (Casts are more prominent in Asia). If Religion is a pattern that we use to write our code, Casts will be the platform like .NET, PHP, Python and so on. For example if you belong to a family of Kings then your caste will be “Kshathriya”, if you belong to a family of business then you are a “Vysya”.

There is a common pattern in my view that we are putting ourselves into, dividing ourselves into groups and living in our own world.

TECHNOLOGY: This is the most fashionable word these days. Everything and everyone is very hyped by this word. Technology cut through all the lines that we drew over centuries and made everyone belong to one big family. We all enjoyed being connected to our piers all over the world. It doesn’t matter where you are and what you do by profession, we are all connected to one big family called INTERNET.

I don’t think this is a happy ending for our story because, I think Technology is the new Religion. And what you use is the new Cast.

FUTURE: In my view, “CLOUD” is the one that is going to break the cycle and bring us together as one family. It doesn’t matter which technology or what device you are on but everyone talks to the CLOUD.

So, Build your APPS on CLOUD, and lets all get connected as one big family.

Thank you for your time, hope you got what I meant.

Let me know what you think in the comments section

Posted On Wednesday, February 29, 2012 9:52 AM | Comments (0)

Sunday, January 15, 2012 #

WP Development With “Essential WP 7.5 Application Development with Silverlight”– Part 4of Many

TOMBSTONING (Application Lifecycle)

Today we are going to talk about “Application Lifecycle” of an application in Windows Phone. Before we write our first application it is good to have a good understating on how your application is going to be treated by the phone (OS) depending on any user action. Every stage of the application is critical to think before we create our first application. Our application is going to run with so many other things that are on the phone (apps, songs, radio, mail etc.). Since the “User Experience” is what users love about their phone is only possible by following the application life cycle. Even to get our application published to the Market place depends on how we are handling all the user actions and how we are following the application life cycle. Lets concentrate here a little bit.

Windows Phone provides the best user multi tasking experience, this is done by pausing, suspended without alerting the user about the application is being paused. But the system notifies the application when it is pausing it or when it is resuming. In the pause and resume state the application is given a chance to either save the data and reload the data back to the screen when the application is being resumed. Every application on a windows phone will have 5 states in its life time. This process is called Tombstoning. Below is a diagram that shows the 5 stages of an application in detail. If an user ignores the pause or resume states of an application then the OS considers it as an re-start of an application. The developer may ignore to add the pause and resume states to his/her application but it is useful for the user if we have this implemented. This gives the user a best user experience which Windows Phone users are found of. Please take a minute and understand the image (re-created from the book with colors for better understanding), below that show the 5 stages of an application.

THIS IMAGE IS VERY SELF EXPLANATORY, EVERY STATE OF AN APPLICATION IS EXPLAINED WITH THE REASON WHEY THE USER/OS PUTS YOUR APPLICATION IN THAT STATE AND WHAT HAPPENS WHEN OUR APPLICATION STATE CHANGES.

tombstoningImage

Thanks to our Author Shawn Wildermuth for a great illustration what happens to our application. This is going to be very helpful in the process of our application development. A good understanding of this tombstoning process makes our application stand out among other applications in the market place by giving the user the best user experience.

Posted On Sunday, January 15, 2012 10:23 PM | Comments (1)

Tuesday, January 10, 2012 #

How to change your Windows Phone Emulator Skin

Hi Everyone,

By now you are very well aware of the Windows Phone and the development environment that you get after installing Windows Phone SDK on your computer. And if you have tested the tools you might have seen the Windows Phone Emulator which looks like the Test Phone Microsoft showed when they launched Windows Phone last year. Since the launch of the first Windows Phone, we have enough options to choose from on what type/size/memory/color/specs that we want in the phone that we use. Among all the phones out there the best Windows Phone I think is the Nokia Lumia 900.

But as a developer, we want the same kind of experience on our computer when we develop applications for Windows Phone. There is good new for us. Telerik announced new Nokia Lumia skins for the Emulator that we use for the development purposes. Here is what you have to do to change your Windows Phone Emulator.

  • First backup your default Emulator skins ( Navigate to “C:\ProgramFiles\Microsoft XDE\1.0” )
  • Download the Telerik Skins for Windows Phone Emulator here (you have to login to Telerik to download this file, Register if you don’t have an account, it is going to be very useful)
  • Extract them
  • You can either change it to a Lumia 710 or a Lumia 800
  • Copy the skin files from the extracted folder (WM7_Skin_Down.png, WM7_Skin_Mask.png, WM7_Skin_Up.png, WM7_SKin.xml) and replace with the files that you see in the folder that you opened in your first step.
  • After the replace, open the Windows Phone Emulator by going to Start\Windows Phone SDK 7.1\Windows Phone Emulator
  • You should see the new Lumia Skin. That’s it my friends, now you have a Lumia Skin.
  • Share your experiences in the commentsThank you Vijaya Malla.

Posted On Tuesday, January 10, 2012 2:41 PM | Comments (1)

Sunday, January 8, 2012 #

WP Development With “Essential WP 7.5 Application Development with Silverlight”– Part 3of Many

Apart from the Introduction that I gave from my previous blog posts about the book and the Windows Phone 7.5 Development, I think we have to jump into the technology of it.

In this post we are going to talk about the Design Language, Real Estate, Input Patterns.

Design Language: Design Language in my view is something that first strikes to the user/developer when they think of the application usage/development. How you want to design your application or how they users react with the navigation screens/patters etc. And how as a developer you want to show the application on the startup screen etc. Once we have the idea of what we are going to present the user then it will be very easy to develop. Windows Phone provides multiple ways you can communicate with the user, most popular ones are Live Tiles, Toast Message, Alerts, Notifications, Updates etc. We are going to talk about what they are in specific and also do some sample programs. For more information on User Experience Design Guidelines for Windows Phone please visit this page from MSDN

WPRealEstate This is how the Real Estate of Windows Phone is divided. System tray is managed by the phone Operating system, this is where you see the time, signal strength, alerts etc. I think it will be a good idea to have this area always visible to the user unless you are developing a game or something that you think it is really required to use it for your application.
Logical Client Area is where you show your application to the user, any application data and any other points of interaction.
Application Bar is a very interesting place where you can give the user more options about your application, this can be set as hidden and the user can access it by clicking on it and it will show the options.
As a developer we have to be very careful on what options you are going to show in here. They have to be relevant to the screen the user is on at that moment. we will talk more about this in the series.

 

Input Patters this is where the real developer in us comes out and does some  miracles. Since we are targeting on a mobile device we are limited with the resources that we have like the size of the screen, processing speeds and hardware/software input buttons to talk to your application. As a developer we have to consider the common Input Patterns that every user is familiar with like Touch, Hardware Buttons, Keyboards, sometimes Sensors etc.Direclty from the book that we are referring to has a wonderful pictorial representation of how the Touch should be thought in the design of our application, please check the following carefully. I think this is going to be a big help when we design our application. This image is very self explanatory.

TouchPattern

Hardware Buttons, Luckily we have some hardware (on some phones) buttons on Windows Phone which the user can use to talk to the application. Every Windows phone has three buttons on the face, Back, Home and Search. Back button should take the user to the previous step they were on and if it is was the first screen of your application it should at least take them to the home screen. Home button at any point should take the user to the Home screen and it should change the status of your application from Running to Suspended state (we are going to discuss this soon), and finally Search button should let them do the search on the phone.

My main motto is to make the development process as simple as possible and make everyone capable of creating an application for yourselves, of course publish it to the market. Please continue reading my series.

Posted On Sunday, January 8, 2012 11:49 AM | Comments (1)

Saturday, January 7, 2012 #

WP Development With “Essential WP 7.5 Application Development with Silverlight”– Part 2of Many

If you are not following Shawn Wildermuth or haven't bought the Essential WP 7.5 Application Development with Silverlight I would highly recommend.

I am not going to talk about why we need a smartphone or how smartphone is taking over all the World, We all know how it started and where it took and where is going to take us in the future. Since we all know the future of the Mobile Eco systems I think it will be a good time to be a part of. lets jump into our series of blog posts of Windows Phone 7.5 Development.

This is how the first three best smart phones look like IPhone, Android and Windows Phone. Hopefully you can see the difference right away and what I meant by being special being a windows phone developer from my previous post.

iphone android windows

The start screen is the killer for Windows Phone where you can see the live tiles instead of icons that does nothing but taking you the application. The live tiles on Windows Phone does more than just taking you to the application but also shows the notification or more information about the application. And in my view that is what a smartphone is all about. It should make our life easy with other things so that we can be more connected to our family and friends (people).

After you have installed all the necessary tools that we need to develop windows phone applications we can open the installed the Windows Phone Emulator by going to Start and type Windows Phone Emulator and you should see it in the list of items and when you open it is going to look like below

image If you haven't installed the necessary tools for Windows Phone development, please see below
1. Need a PC or Windows on a MAC (obviously right?)
2. I have installed Visual Studio 2010 professional, you can download a version of Visual Studio Express good for just WP development. please follow the link for more installation instructions
This is going to be one installation for all your Windows phone 7.5 (Mango) development.

Now we are ready to develop our first windows phone application.

My next post is going to introduce little basics on windows phone real estate and little bit on What and How ‘s of the Phone. See you there.

Posted On Saturday, January 7, 2012 6:00 PM | Comments (1)

WP Development With “Essential WP 7.5 Application Development with Silverlight”– Part 1of Many

I wanted to introduce to you all to a wonderful book that I came across recently by, Shawn Wildermuth “Essential Windows Phone 7.5 Application Development with Silverlight”. I never bought a text book but I decided to buy this and start reading it, as I was going thru the book I decided that I made a good buy here.

This book is very easy to read and a very good place to start developing Applications for Window Phone 7.5 with Silverlight.

This series of blog posts are going to be on just Windows Phone Development using this book “Essential WP 7.5 Application Development with Silverlight”. More information about the author Shawn Wildermuth (click on the name).

I am not going to invent anything here just to be sure. I am one of you guys who wanted to start developing applications for Windows Phone and not sure where to start. I just started my journey to complete this book and by the end of the book hopefully we can all have at least one application on the Windows Market Place. My idea to extend this blog series is to develop a WP 7.5 application and then convert that application to a cloud based application with HTML 5, so that we deploy the same to all Eco-Systems.

All I am doing is to give you the bullet points from the book and also give you the sample projects that we create along this journey.

WHAT you need to know and WHY ?

1. It is a known fact that iOS and Android has a huge market and few 100K apps on their market place, think before you decide to write an app for those two or Windows Phone, coz those two markets are almost saturated unless you are going to invent the next Facebook, you are not going to win the market. As Windows Phone market place is not saturated and just recently expanding to the other parts of the world , I think it is right time to start writing your next Big thing on Windows Phone.

2. Since almost everyone on Earth user Microsoft solutions and with their step towards Windows Azure, I think it is the right time to do the next big thing on Windows and reach as many people are there on the Earth with a smartphone.

THINK BEFORE YOU DO.

Lets start our Journey to at least our next BIG thing.


---- Let me know what you think, my first Blog ever ----

Posted On Saturday, January 7, 2012 5:14 PM | Comments (0)