• DaveDev

    Are you stuck behind a Firewall with no access to Twitter? Here’s the juicy bits in case you missed it!


    I still think I have one of the coolest jobs at Microsoft.  Not only do I get to speak my mind online, conferences, workshops and usergroups but I also get to go into actual customer accounts.  Which brings me to Twitter.  I know it sounds crazy to a lot of my Facebook, Twitter, and FriendFeed buds but many organizations still block sites like Twitter and Facebook.  Yup, completely blocked!  No to mention access to IM clients like the new Live Messenger.


    As someone who spent the last five years in a corporate environment “lockdown” before coming to Microsoft I can relate.  We all know that most of the really good information today comes from your fellow devs online via blogs, forums, twitter and sites like Channel9

       DaveDev-Facebook  DaveDev-TwiiterFeed DaveDev-XboxLive

    These technologies also interoperate allowing you to host feeds of your activities in one place.  My blog for example has my latest X-Box Live happenings, Facebook, Twitter and my Facebook status gets updated from my Twitter feeds.  Twitter has become THE place to post great links (most likely due to the 140 char limit) and I’m not just talking about humorous pop culture references.  Real juicy technical bits!  I recently was at an internal “Developer Day” at a large financial institution (the name would be very familiar to you if I mentioned it).  Out of 120+ people in the room only 5 were on twitter.   That is only 4%!  The other 96% of those guys aren’t seeing any of the links I’m posting.  They can’t even go look at the html page of my feed because the Twitter.com domain name is blocked!

    Realizing this I’ve decided to repost my technical links up on my blog.  I’ve left out my tweets about non-technical stuff or what’s going on in my personal life.  If you still want those bits you can find them up on Twitter.  But for everyone who has missed out here are some of the recent technical tweets going back to December that I think you’ll enjoy.  An “RT” means re-tweet and is a link someone else posted that I thought was important enough to share.  You can follow those people too by going to twitter.com and then their @name, for example twitter.com/mix09.

    Here is the list…

    Mike Swanson has updated the Adobe Illustrator to XAML Plug-In. Check it out! http://bit.ly/u2qe

    RT @MIX09: RT @ch9: Scott Guthrie On Silverlight, MIX09, Keynotes, Developers and Designers http://tinyurl.com/czx82s

    RT @Veronica: Apple vs. Palm: the in-depth analysis http://bit.ly/ypEc

    RT @shanselman: *Wow*,REALLY nice WPF ClickOnce Twitter Client via @blackgold9 http://snurl.com/chirp (.net 3.5 sp1 use http://bit.ly/QxNi8)

    RT @adkinn: 6 Things I Bet You Didn't Know About Data Binding in WPF from Nate Zaugg http://ff.im/-Ig00

    Microsoft Surface - Retail Banking Demo http://bit.ly/tc38. See it in person too at the NYC Enterprise DevCon http://bit.ly/Zufu

    Good article on current perceptions of Microsoft and how the company is changing that - http://bit.ly/82Zn

    Anyone else notice that Photosynth is running as a Silverlight control now? Both at CNN Site http://twurl.nl/kn5753 and on Photosynth Site.

    RT @Pete_Brown: my article on styling the charts in the Silverlight toolkit came out today: http://tinyurl.com/92n8om Nice job Pete!

    Linux/Moonlight and PPC Mac SL 1.0 now working for Obama Inauguration Silverlight stream! Nice work guys! http://tinyurl.com/789asq

    Wow - amazing must watch video of inspiration http://tinyurl.com/5qfrpl. Found via the NYC planecrash rescuers site - janiskrums.com

    64 and 32 bit versions of WIndows7 beta are up on MSDN Subscribers page now! Go grab it. http://msdn.microsoft.com

    Zune team isolated 30gig lockup probs. Had to do with 2006 models clock w/ leap year. Will fix automatic 1/1/09. http://tinyurl.com/873k8z

    Honoring its cross platform commitment the LiveLabs team just released Seadragon Mobile for iPhone http://tinyurl.com/5tn6qm . Works great!

    All MDC attendees are going to get BETA1 of WIndows7! Win7 has been my primary o/s since M3 build. Check it out: http://msdndevcon.com.

    Good site with all sorts of LINQ examples: http://tinyurl.com/62j6sb. If you're like me this will help your SQL brain think LINQ.

    Great Wired article about the new Microsoft under Ozzie's direction. http://tinyurl.com/5zhz7q

    If you do have access to Twitter at work but haven’t joined up yet here are my thoughts on why I think you should.  Don’t forget to follow me with your favorite Twitter client too.  If you run into any snags getting started feel free to leave me feedback on via this blog and I’ll walk you through.  Hope to see you all online!

    Bookmark and Share

  • DaveDev

    Defining Layout in a Windows 8 Metro Style App using CSS3, HTML and JavaScript



    I have been coding a Windows 8 Metro Style App using the new Windows 8 Release Preview bits and Visual Studio Express 2012 RC.  The app is going to be a retro shooter that takes advantage of HTML5 Canvas for the main game engine along with several Windows 8 Metro Style App Features.  This post is going to cover how to layout the elements of your game interface on the screen. 

    My game’s Layout is made up of two screens: a Main Menu (which is the default screen upon loading for first time) and then an actual Game Screen where gameplay takes place.  I used CSS3 (specifically floats) to align my Player Score, Name, Level and other screen elementals.  Let’s dive into how each screen is set up.

    Main Menu

    The Main Menu displays current game version number, game title and a button to begin game play.  It also includes an AppBar Menu (not shown in the screenshots below) that can be accessed at any time.  Here is what the Main Menu looks like:





    You will notice that I am playing the game along side another application (IE 10) like some of my players will most likely do.  The screen can be rendered in three different states based which are named fullscreen, filled or snapped mode.  I want to point out that having your application support multiple screen sizes and Viewstates is a very important feature of all Metro Style Apps.  If you haven't already read it definitely check out the Scaling to Different Screens post on the official Windows 8 Blog.



    Since this is such an important topic broke out this topic into two posts.  We will cover layout in this post and how to detect and scale for the different Viewstates here.  In the interest of simplicity this post will concentrate on just getting the elements lined up in the fullscreen mode (the default for all Metro Style Apps).  Let’s take a look at how we do that:  

    Inside of my default.html page we see that the title image, game version and play button are just standard html elements wrapped inside a <Div> tag I call divMenu.

    <div id="divMenu">
            <img id="imgMenu" src="/images/menutitle.png" />
            <div id="txtVersion"></div>
            <button id="btnStart">PLAY</button>

    All of our custom layout occurs in a css file called space.css we reference in our default.html like so:

    <!-- App references -->
    <link href="/css/default.css" rel="stylesheet">
    <link href="/css/space.css" rel="stylesheet"/>
    <script src="/js/default.js"></script>
    <script src="/js/sound.js"></script>
    <script src="/js/ship.js"></script>
    <script src="/js/starField.js"></script>


    Thanks to CSS3 Web Fonts we can easily assign different type faces to our screen elements.  For my game I downloaded the Final Frontier Old Style font a royalty free font available off the web.  I then tell both the version text and button text to use this font.  Each of the elements I assign the maximum width and height I would like along with the text font size.  imgMenu is also told to be aligned 120px down from the top of the screen.

    @font-face {
        font-family: 'Final Frontier Old Style'; 
        src: url( '/fonts/finalold.ttf');
    #imgMenu {
        max-width: 555px; 
        max-height: 118px; 
        top: 120px;
    #txtVersion {
        font-family: 'Final Frontier Old Style'; 
        font-size: 20px;
        color: #ffd800;
    #btnStart {
        width: 300px;
        height: 150px;
        font-family: 'Final Frontier Old Style'; 
        font-size: 30px;  
        z-index: 100;


    Remembering that Windows 8 devices come in all different shapes and sizes I programmatically set the  menu elements up on the center of the screen at runtime.  This happens in the showMenu function inside my default.js file.  I calculate the exact center of the screen and then set the x and y coordinates of my elements like you see below.

    //Set Up Menu Screen UI Elements
    function showMenu(event) {
        menuEnabled = true;
        txtPlayerName.style.visibility = "hidden";
        txtScore.style.visibility = "hidden";
        imgPlayer.style.visibility = "hidden";
        imgMenu.style.visibility = "visible";
        btnStart.style.visibility = "visible";
        txtVersion.innerHTML = GAME_VERSION;
        txtVersion.style.visibility = "visible";
        txtLevel.style.visibility = "hidden";
        var menuX, btnX, btnY;
        menuX = (SCREEN_WIDTH - imgMenu.width) / 2;
        btnX = (SCREEN_WIDTH - btnStart.clientWidth) / 2;
        btnY = (SCREEN_HEIGHT - btnStart.clientHeight) / 2;
        imgMenu.style.posLeft = menuX;
        btnStart.style.posLeft = btnX;
        btnStart.style.posTop = btnY;


    Game Screen

    The Game Screen  displays the player’s score, level, name and picture.  This is also where we are declaring our HTML5 Canvas tag.  Similarly to the Main Menu screen it can appear in all three Viewstates but we will focus on the Fullscreen mode for this post.





    All of these elements (except for the player image) are standard <div> tags wrapped inside a main <div> tag we call divGame  inside of our space.css file.

    <div id="divGame">
            <div id="txtScore">Score: 0</div>    
            <div id="txtLevel">Level: 0</div>
            <div id="divPlayer">
                 <div id="txtPlayerName">Player1</div>
                 <img id="imgPlayer" src="/images/helmet.png" />
    <div id="txtNewLevel"></div>
    <div id="divRoot" data-win-control="WinJS.UI.ViewBox">
        <canvas id="canvas" ></canvas>


    Just like the Main Menu we assign the custom Font to our text elements and position them on screen using floats. 

    @font-face {
        font-family: 'Final Frontier Old Style'; 
        src: url( '/fonts/finalold.ttf');
    #txtScore {
        font-family: 'Final Frontier Old Style';
        font-size: 50px;
        color: #ffd800;
        text-align: left;
        margin-left: 10px;
    #txtPlayerName {
        font-family: 'Final Frontier Old Style'; 
        font-size: 50px;
        color: #ffd800;
    #txtLevel {
        font-family: 'Final Frontier Old Style'; 
        font-size: 50px;
        color: #ffd800;
        top: 0;
    #divPlayer {
        position: absolute; 
        top: 0; 
        right: 0; 
    #imgPlayer {
        max-width: 100px; 
        max-height: 50px;
    #txtNewLevel {
        font-family: 'Final Frontier Old Style'; 
        font-size: 100px;
        visibility: hidden;


    Finally we set up all of our on screen elements through the startGame function once the player clicks on the Play button to begin.  

    //Set up Game Screen UI Elements
     function startGame(event) {
         imgPlayer.style.visibility = "visible";
         imgMenu.style.visibility = "hidden";
         btnStart.style.visibility = "hidden";
         txtVersion.style.visibility = "hidden";
         txtLevel.style.visibility = "visible";
         var lvlX = (SCREEN_WIDTH - txtLevel.clientWidth) / 2;
         txtLevel.style.posLeft = lvlX;
         menuEnabled = false;


    Game Coordinate System

    The last piece we need to set up is a coordinate system for our game.  This includes the size of each ship, the area of the screen they can be drawn on before appearing on the opposite side, and then the current width and height of the screen.  The screen width and height will determine how big our Canvas element needs to be rendered at as well.

    I use four different variables inside the default.js file for this with the ships width and height remaining constant (I created all of my ship images to be this size) and then the screen width and height to change based on the resolution of our current Windows 8 device.

    var SCREEN_WIDTH = 1366;
    var SCREEN_HEIGHT = 768;
    var SHIP_WIDTH = 190;
    var SHIP_HEIGHT = 100;


    We then calculate what the size of our canvas should be during our initialize function:

    //Init Canvas
    canvas = document.getElementById("canvas");
    ctx = canvas.getContext("2d");
    //Set up Coordinates for Screen Size
    //Adjust for different screen sizes
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    SCREEN_HEIGHT = canvas.height;
    SCREEN_WIDTH = canvas.width;
    //Set boundries to be one ship size
    MAX_X = canvas.width - (SHIP_WIDTH + 20);
    MAX_Y = canvas.height - (SHIP_HEIGHT + 50);


    By setting up the coordinate system at run time we can support multiple resolutions and even dynamically scale to fit higher resolutions if the user changes them (for example docking a tablet and attaching a bigger monitor).  Here is an example of our game running on a 1366x768 tablet size screen as well as a 2560x1440 which you would typically see in a 27” inch all in one pc.



    All of the elements align directly center with the version showing up in the bottom right.  I also have the ability to scale up the image and button size when in a different resolution.  I am not doing that in the screen shot above but will show you how using CSS3 transforms in my next post covering Viewstates.



    I hope this post has given you an idea of how easy it is to lay out interface elements in your Metro Style App using CSS3, HTML5 and JavaScript.  If you are currently working on a Windows 8 app and want to get into the Windows Store I would love to hear about it!

    You may also want to check out my previous Windows 8 Metro Style Development Tips:

  • DaveDev

    Attention all Windows Phone Developers – Phone Tools, Mango bits, and AppHub have all been updated!


    The Windows Phone Team has recently pushed out three important updates that you should take advantage of.

    Developer Tools Beta 2 Refresh (Release Candidate)

    The first of the new updates is for the Windows Phone Developer Tools.  Cliff Simpkins from the Phone Team has a break down of some of the new features on his official blog post here.  His top 5 are as follows:

      • Application platform APIs are now locked; you can feel confident to start getting ready for submitting your apps next month.
      • Emulator now has a nifty screenshot capability built in, allowing you quickly snap quality images of your app without the need of separate tools or cropping time. The images are great for use in app submission process or to share on your blog or with folks such as my team (hint hint).
      • The profiler has been greatly improved and provides memory profiling.
      • As of this drop, you can install NuGet into the free version of the WPSDK tools. I find NuGet to be one of my favorite productivity boosters and I’m happy to see the extension supported in the free tools.
      • The drop includes an initial peek at the Marketplace Test Kit; with the RC release, you’ll be able to use the included version of this toolkit to test your XAP file against the same certification testing tools that we use when ingesting apps for the Marketplace. For this refresh, it’s there but not fully functional; but more on this in a future blog post.

    You will also notice a new RC (Release Candidate) in the control panel tools listing.


    Be sure to read the full official blog post here.

    Mango Bits

    There has also been a refresh of the Mango Bits that you can flash your phone with.  There are some new features inside this update, like native Twitter integration, you can take advantage of as well.  Head on over to the WinSuperSite for a breakdown on what is new inside this RC.

    The update is being pushed out to eligible devices as we speak.  You can also check for it manually by following these important steps:

    • Make a copy of the backup you took when you updated to the Mango Beta 2 pre-release and put it in a safe place, if it isn’t in one already
      Note: Make sure that you copy this backup and put it somewhere else; uninstalling Zune will auto-delete any backups previously taken
    • Return to Connect.Microsoft.com (we’re using the same program you were invited to join last month) and download the freshly posted files, which includes a new Zune client and a new UpdateWP executable
    • Head to the Control Panel and uninstall the Beta 2 software (Zune client and UpdateWP) and tools (WPSDK) that you installed last month
    • Install the new software and tools that you just downloaded from Connect
    • Fire up the new Zune client beta (4.8.2134.0) to check for the new update


    • Zune will then update your phone from 7661 to 7712



    AppHub Changes

    The Marketplace has been hard at work at updating the reporting features of AppHub as well as launching marketplaces in several new countries.  Some of these exciting features include:

    • Geographic expansion: publish to 19 new consumer markets, submit from 7 new developer markets and coming soon, expansion of markets for in-app advertising!
    • New private distribution options: developers can now privately distribute their apps using beta and targeted distribution options.
    • Enhanced application management: we’ve made a lot of additional improvements to how you manage and publish your application in the App Hub itself, in response to your feedback.

    I have seen an uptick in downloads for my own DoodlePad apps when the new markets when online.  You can see the spike in downloads in the chart below:


    It is important to point out however that you need to go into AppHub and select these new countries in order to be published to them.  By default your application will not be available in the new marketplaces unless you specifically tell it to be.  This includes apps that  previously selected “Worldwide Distribution” you will need to go back in and select worldwide again.

    Be sure to check out the official blog post here for all the details.

    Happy Coding!


  • DaveDev

    Windows Phone 7 Tip - How to automatically sync your OneNote documents to the Cloud


    OneNote for Windows Phone 7

    OneNote is one of my favorite Microsoft Office applications and an amazing note taking tool.  I use it constantly to take screen shots of websites or applications, quick dictation, to-do lists, and even some sketching/doodles (via my Tablet’s pen).  One of the goals of the OneNote Team was to bring that note taking application to all three screens (PC, Cloud and Phone).  With the release of Windows Phone 7 that goal became a reality and we can now sync notes between all three screens.  Changes made on the phone will be available on our desktop and changes made on our desktop will show up in a web browser.  If you haven’t checked out the free Office Web Applications yet you owe it to yourself to take a peek.  Office Web Applications are part of SharePoint, are available when editing or viewing any Office document on your Skydrive as well as through other services like Docs.com and Office Live Workspace.

    Four Easy Steps to Cloud Sync

    What I don’t think we have done a good job of is actually exposing this functionality on Windows Phone 7 easily.  I had a conversation just last night with someone who was adamant about Windows Phone 7 not being able to cloud sync One Note Documents yet.  This prompted me to write this blog post in hopes I can make it easier for you as well. 

    Step 1 – Open Microsoft Office Hub

    When we first open up the Office Hub we are presented with a list of shortcuts to our most recently used OneNote Documents.  You can also tap and hold on these shortcuts to pin them to your start experience on the phone (I use this for quick to-do or shopping lists).  What is not obvious at first is you need to hit the All icon to get to the rest of your documents and open up the syncing option. In the below screenshot you will notice I have just created a quick OneNote document called DaveDev and I am now going to click on the All icon.


    Main Menu - Click ALL

    Step 2  - Click on Refresh icon on the Application Bar

    This will take you to a list of Pages in your current Notebook.  Windows Phone 7 only has one Notebook by default where all of your Pages will be stored.  When we enable syncing however we will start to pull down all Notebooks from the Cloud.  This means we can select these other Notebooks and create Pages in them right on the phone.  So while we cannot create Notebooks directly on the phone we can integrate with them existing ones.  If we bring up the full Application Bar we will notice a Refresh icon.  Go ahead and click that now.

    Document ListDocument List


    Step 3 – Confirm that you want to start syncing your documents with Skydrive

    You will be asked to confirm that you want to begin syncing OneNote with your Skydrive.  What Skydrive would that happen to be?  When you created/entered your Windows Live ID into the phone you were automatically given 25 gigabytes of free storage in the cloud (what a nice present eh?).  Office Documents on Windows Phone 7 are integrated with your Windows Live ID so it will take care of everything for you.  Exactly the same way the Zune Marketplace and X-Box Live integration works.  Go ahead and confirm that you want to enable Skydrive sync.

    SkyDrive Confirmation Prompt

    You will now be notified during the process of the sync status.  First it will connect up to Windows Live and then it will set up a default notebook (Unfiled Notes) if it does not already exist.

    Connecting to Windows Live!Creating Default Notebook


    Step 4 – Verify that your notebooks and pages have synced

    Now that we have enabled sync you will notice some changes.  First, all of your notes will now include the SkyDrive Folder (Personal) and OneNote Notebook (Unfiled Notes) they have been synced to.  You will also notice a Notebooks option that is now available.


    Swiping the screen to the left or clicking on Notebooks will take you to the new Notebooks screen.  This screen will display the status of all your Notebooks currently located in Skydrive as well as their Sync status.

    Synced Notebooks and Pages!

    Notice too that you now have the ability within each Note to sync immediately back to your Skydrive.  Clicking on the Refresh icon will kick off this process for you.

    DaveDev Note - Sync Button


    Viewing your One Note documents from the Cloud

    So now we have One Note running on our Windows Phone 7 device and we have One Note running on our Windows 7 PC.  But, let’s say we are out, maybe over at a friends house, and we need to pull up a quick One Note document.  I told you our stuff is in the cloud so we should be able to get to it from any Web Browser, right?  Of course! 

    Simply point your browser to Windows Phone Live and you will be presented with a bunch of functionality for your phone.  This is really where your cloud integration comes alive!  X-Box Live achievements, avatar customizations, contacts, calendar, phone tracking, photos as well as our newly synced OneNote documents are accessible here.  Simply click on the View All link under OneNote and you will be taken directly into the OneNote Web App.


    OneNote at http://WindowsPhone.live.com

    Like all of the Office Web Apps the One Note Web App is full featured and even includes the familiar Office Ribbon.  Notice along the top you can see the current Skydrive folder my Notebooks are synced under (Personal Web).  This is the same folder we saw displayed on our Windows Phone 7 device.  On the left pane you can now navigate between all of your notebooks and their included pages.  Opening up my newly synced document will display it in the editor on the write and any changes here will save back to the desktop and my phone.

    SkyDrive - Editing my OneNote Docs

    To the Cloud

    Hopefully this eliminated any confusion you might have had around enabled Cloud sync for Office One Note documents on your Windows Phone 7 Device.  Although we only do this for OneNote today we have already announced a free Windows Phone 7 update later this year that will sync your Excel, PowerPoint and Word documents as well.  These documents will be able to sync back to your Skydrive like we have shown here in addition to the already existing SharePoint functionality. 

Page 3 of 68 (272 items) 12345»