Mat Velloso's Blog

Anything about Azure, Windows 8, XAML, Windows Phone, Visual Studio, .Net, Office 365, HTML5, SQL Server, well... you got the idea

September, 2010

Posts
  • Mat Velloso's Blog

    Windows Phone 7 Emulator: Simulating the accelerometer

    • 1 Comments

    One of the challenges when using the emulator is that yous simply don't have some hardware specific functionality, such as the accelerometer. In order to overcome this, there are different possible implementations:

     

    1-Use the keyboard:

    Probably the simplest alternative is to use your computer keyboard. Once you have your app running on the emulator, you can enable the keyboard input by pressing the "Pg Up" key. From that point on, you can automate your code to recognize when it is running on the emulator, and switch from the accelerometer to the keyboard input.

    A great example is in the Windows Phone 7 training kit. Once you have it downloaded, look for a sample game named "MarbleMaze". In the Accelerometer.cs class you will find something like this:

    if (Microsoft.Devices.Environment.DeviceType == DeviceType.Device)

    {

    // if we're on device, we'll just grab our latest reading from the accelerometer

    }

    else

    {

    // if we're in the emulator, we'll generate a fake acceleration value using the arrow keys

    // press the pause/break key to toggle keyboard input for the emulator

    }

     

    From that point on, the game deals with keyboard input when on the emulator, as this:

     

    KeyboardState keyboardState = Keyboard.GetState();

     

    stateValue.Z = -1;

     

    if (keyboardState.IsKeyDown(Keys.Left))

    stateValue.X = -.1f;

    if (keyboardState.IsKeyDown(Keys.Right))

    stateValue.X = .1f;

    if (keyboardState.IsKeyDown(Keys.Up))

    stateValue.Y = .1f;

    if (keyboardState.IsKeyDown(Keys.Down))

    stateValue.Y = -.1f;

     

    stateValue.Normalize();

     

    Very simple and works fine.

    Now you may want a little more precision than that, so next option would be:

    2-Use the mouse:

    Very similar to the previous example, but now we can do something like:

     

    MouseState newMouseState = Mouse.GetState();

    stateValue.Z =-1;

    stateValue.X = newMouseState.X - oldMouseState.X;

    stateValue.Y = oldMouseState.Y - newMouseState.Y;

     

    oldMouseState.X = newMouseState.X;

    oldMouseState.Y = newMouseState.Y;

    stateValue.Normalize();

     

    So this is a very simplistic example (and by the way, would only work with the left button pressed all the time) where we capture the delta of the current position and previous position and use this to build our vector. We could extend this to play with the Z value as well, either capturing some specific keyboard key and swapping the Y for the Z or any other trick like that. Works pretty well for me. There are other approaches for using the mouse here and I'm happy to point you to some examples if you need. Just ask me.

    3-Use augmented reality:

    Now if you are really ambitious about simulating the experience of holding the phone and moving it, there are options such as this one. This cool codeplex project uses a webcam to simulate the accelerometer in a very interesting way. You can read more about it in the Nikos Kastellanos blog.

    4-Other options:

    I've seen articles showing ways of hacking certain videogame controllers and other devices for that purpose but I don't think I should comment about those J People can be very creative sometimes...

  • Mat Velloso's Blog

    Hotmail with IE9 experience

    • 5 Comments

    As more sites are making use of the new IE 9 technologies we can start building a more interesting start menu with our favourite links:

     

     

    Of course you can also do the task bard pinning. I personally like to organize these at the start menu instead. :)

  • Mat Velloso's Blog

    Showing some love for VB developers: Visual Basic CTP for Phone Developer tools is available for download!

    • 0 Comments

    Although I'm more a C# person, I know that many of you would much more prefer to develop using VB.Net.

    If that's the case, today we are making available the CTP of Visual Basic for the Phone Developer. You can get it from here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a808a69d-6119-47b7-b858-262be5c49915&displaylang=en 

     

  • Mat Velloso's Blog

    Small business? Need antivirus? Microsoft Security Essentials!

    • 0 Comments

    As announced today ( http://blogs.msdn.com/b/mssmallbiz/archive/2010/09/22/announcing-microsoft-security-essentials-available-free-to-small-businesses-in-october.aspx ) MS Security Essential can now be used for free by businesses with up to 10 PCs.

    I know quite a few people who will be very happy about that.

     

  • Mat Velloso's Blog

    Yes, it looks awesome. Yes, it is on Flight Simulator. Great work, Air New Zealand!

    • 0 Comments

    Air New Zealand did a wonderful job customizing Flight Simulator for this video:

    http://travel.msn.co.nz/airlines/7985924/all-black-domestic-jet-to-hit-the-skies

    And the aircraft looks really pretty, doesn't it?

  • Mat Velloso's Blog

    Very detailed documentation for IE 9 beta developers

    • 0 Comments

    Internet Explorer 9 Beta Guide for Developers:

    http://msdn.microsoft.com/en-nz/ie/ff468705(en-us).aspx

     

  • Mat Velloso's Blog

    Big Screen byRemote: A windows media remote access for Windows Phone 7

    • 0 Comments

    Another brilliant app for Windows Phone 7:

    http://www.youtube.com/watch?v=GjcqTWC1EuI

    More details here:

    http://mobilewares.spaces-df.live.com/Blog/cns!78533A1A2E078194!8153.entry?wa=wsignin1.0&sa=285172810

     

  • Mat Velloso's Blog

    Free online training: Microsoft Windows Phone 7 Advanced Topics - Part 1

    • 0 Comments

    You can register here:

    https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032462274&EventCategory=2&culture=en-US&CountryCode=US

     

  • Mat Velloso's Blog

    Windows Phone 7 development: Some ideas to get you inspired.

    • 1 Comments

    I've collected a few examples of what people are doing on Windows Phone 7 and would like to share them with you:

    Game: Ilomilo, simply beautiful game.

    App: OpenTable, restaurants  reservation app.

    App: Shazam

    App: Netflix

    App: Feed Reader, read more about it here.

    App: Foursquare, a location-aware, social networking app.

    App: Flixster

    App: WP7 MousePad

    Game: Flight Control game

    Game: Samarium Wars, a very well done little game, classic.

    Game: Alpha Jax, another very cool game.

    Library: SharePhone: Not quite an app, but an API for connecting SharePoint 2007/2010 with your Phone app. (Keep in mind Windows Phone 7 has SharePoint support built in the user interface, this sample is about building custom apps with SharePoint support)

    Library: Phone 7 Action Pack, yet another library for making it easier to deliver some common app functionality.

    Helper: Multi-touch simulator, one challenge we can have when developing an app for WP7, without having the proper device, is how to simulate multi touch on it. This sample (I haven't tested it yet but looks functional) shows how to simulate it on a normal desktop.

    Game: Bye bye Brian, yet another game, nice graphics.

    App: DoodlePad, a fun sketching app for WP7 (and it's free).

    App: Simple audio analyser, interesting app demonstrating the possibilities around sound wave analysis/visualization.  

    Game sample: CPU Skinning, a very nice XNA sample showing the 3D graphics possibilities on Windows Phone 7. If you want to learn about building 3D games on Windows Phone I'd recommend you to download this source and have a very good look at it. (Tip: Try to add gesture support, make it able to zoom in and out for example. It took me a while to get it to work)

    App: Papersketch, simple but quite nice little toy.

    Inspired? Start planning yours then! And keep an eye on our WP7 dev challenge that will happen in October.

     

  • Mat Velloso's Blog

    Internet Explorer 9 beta is available! And here's some information for developers

    • 1 Comments

    Internet Explorer 9 beta is here!

    And I am very happy to see the feedbacks from people who have been using it. But don't believe me, try it!

    Actually I just found this post telling a little of story about the evolution of the IE logo and some very odd places where it's been used. Quite interesting!

    Now why should we developers care about IE9?

    For several reasons, such as:

    It is fast!

    No, not just "yeah, I guess it's all right". I'm talking about "woohoo!" kind of fast.  Read about performance and benchmarks and why some benchmarks tend to not relate so much to the real world experience.

    I'm talking about a much better script engine, hardware acceleration and several other features that help improving the performance of your browsing experience.

    Hardware acceleration is the same technology that makes games deliver amazing graphics to your screen. We used to allow developers to take advantage of these things only by using APIs such as DirectX or XNA. Now it is also in your browser. And the best part is that you don't need to use any plugins or proprietary languages to make it work. Just HTML and script is enough.

    Again, don't believe me, test it. (My favourite is the "Browser Hunt" game. Classic!).

    It gives a lot more real estate to your page, rather than for the browser itself.

    You asked for it and we did it. Load and loads of real estate so netbooks and lower resolution monitors can still make most of the web navigation experience.

    According to Jared Newman, from PC World "I'd say Microsoft is the winner on room to browse.".

    But if you miss any of the toolbars (such as favourites, Bing bar and etc.) you definitely can still enable them.

    It supports HTML 5!

    We believe that supporting HTML 5 goes far beyond ticking boxes and saying "Yeah, we have this". So we have been working in order to improve the number and quality of test cases with W3C so quality can also be assessed, beyond a simple "yes/no" check.

    How does that affect IE 9?

    Read more about it here.

    Or check by yourself. For instance look at this example:

    IE 9 Beta 1:

     

    Browser "X":

     

    Any noticeable difference?  (And try to select the text within each one)

    We are all developers here and we know the value of good test cases so I won't try explaining what you know better than I do. What we want to achieve here is a better, standardized way of validating standards compliance so all of us can write code once and only once.

    Makes sense to me, does it make sense to you?

    Developer toolbar:

    Now that's a great tool. Open IE 9, navigate to any page you want and then hit "F12":

     

    That's the developer toolbar. What does it do? Among other things: HTML/CSS/Feed/Links validation (against W3C standards), changing browser and document mode to/from IE 9, 8 and 7, code profiler, network capturing... Well, let me show some of these things:

    Code profiling:

     

    Network capturing:

     

    Point is that with the out of the box tool you can do quite a lot of testing, bug fixing and validation on your pages.

    Pinning tabs and jumpstart menus:

    If you are using Windows 7, you can also take advantage of a very cool OS feature you probably used before: Pinning items into the taskbar.

    Let me give you an example. Drag the Facebook tab on your IE 9 to your Windows 7 taskbar. Then, right click at the icon:

     

    You can see that not only you've got a new shortcut for your favourite page, but that shortcut gives you a few menu options.

    -Hey! You just told us that you are concerned about standards compliance and now you make a page that only runs on IE 9 and Windows 7! You liar!

    Wait! First of all, pinning shortcuts to the taskbar is only supported on Windows 7. We can't go back and change every other OS to support the same feature. Second, the way we do this is with meta tags. They won't break any other browser experience. Third, if you don't like it, you don't have to use it.

    As you know, in Windows 7 you can also pin shortcuts into your start menu. So with IE 9 it looks like this:

     

    Cool?

    What I like about this is that it gives your page some sort of "Application-like experience". You almost forget there is a browser there. And that's how I can describe a good web browser: A browser that you don't even notice it is there when you're using it.

    Now if you really want to give it a better application-like experience, you can also script changes in your task bar icon, just like Facebook does:

     

    That way, you can inform users when your page requires attention.

    Several other improvements:

    I don't even know where to start from. Better DOM capabilities, improved look and feel, automatic measuring and alerting around add-ons performance (so users can make informed decisions around what can be causing performance problems to a browser) and so many others...

     

    So what I ask of you is very simple: Don't make your mind before actually testing it. Fair enough?

    And contact me if you have any questions.

     

Page 1 of 1 (10 items)