Windows Mobile 6.5 + Exchange 2010 + Outlook 2010 = Desktop SMS Messaging

by Nick 22. April 2010 13:31

This is awesome! My Exchange account over at www.myhostedsolution.com has been migrated to their new Exchange 2010 hosting servers. This means that I can finally do SMS synchronisation between my mobile, running Windows Mobile 6.5, and my Inbox. Better still, with Outlook 2010 I can both view and reply to SMS messages from within Outlook. All of this without having to configure any additional settings or services.

Here are the few steps you have to do.

  1. Upgrade your Exchange account to Exchange 2010. If you set up hosting with www.myhostedsolution.com you get this included in you subscription for free by default. Did I mention they have unlimited storage so is awesome value.
  2. Go into ActiveSync on your Windows Mobile 6.5 device and enable synchronization of Text Messages. This should enable synchronization of your text messages with your Exchange 2010 server. When I first upgraded to Exchange 2010 the option to synchronize text messages didn’t appear in ActiveSync on my device so I ended up wiping the device and setting up the account again.
    image
  3. The next piece is to install or upgrade to Outlook 2010. This sports a much newer interface, including the ability to send SMS messages. After installing and configuring your account (or if you’re upgrading, after your data file has been upgraded) you should see an email from Outlook 2010 entitled “Send and receive text messages on your computer!” which indicates that your mobile device is synchronizing text messages and Outlook is ready to send messages.

Sending Text Messages from Outlook 2010

From the New Items drop down select Text Message (SMS)
image

This will open the Text Message window where you can enter your message. Note the list of emoticons in the ribbon.

image

Once you’ve written your message, hit Send. When your device next synchronizes you should see a notification that your SMS message has been sent. That’s right, Outlook 2010 synchronizes the message to be sent to Exchange 2010, which then synchronizes it to your mobile device, which then sends it using your mobile phone account. No additional services necessary!

image

If you get an SMS Message it will be synchronized to Exchange 2010, then on to Outlook 2010, appearing in your Inbox along with your email. Careful if you’re working for an organisation that monitors email as your text messages will now be accessible to your Exchange administrators.

image

You can of course reply to an SMS and it will be sent out again via Exchange, Outlook…. your device. You do need to make sure your device is synchronizing, otherwise your SMS messages won’t be sent.

Tags:

Development

Don’t Install Web Deployment Tool using the Web Platform Installer

by Nick 22. April 2010 03:49

After a bit of time wondering why I couldn’t just hit Publish on my web application within Visual Studio 2010 and have it deployed using the new Web Deployment Tool I tracked it down to some missing bits. I’d just gone through the process of building a new development server and as part of setting up the services I need I used the Web Platform Installer. What I wanted to do was configure the server so that when I create a new web project on my development machine using VS2010 I could then use Publish from within VS to deploy it to my development server. Having read through a couple of blog posts on how to do this I figured it can’t be that difficult since most of them say “install the Web Deployment Tool using the Web Platform Installer” and then Publish away. Well it isn’t that easy basically because the platform installer only installs half the bits.

Installing WebDeploy and Management Service

Ok, so lets start with the bits you do need to make sure you install. These are the Web Deployment Tool (of course) and the Management Service (not so obvious but kinda required if you want to remotely publish your applications to IIS).

image image

Now the next thing to do is to go and actually install the Web Deployment Tool from the MSI. You can do this by downloading it from http://www.iis.net/download/WebDeploy. This should prompt you to change, repair or remove – select Change and install the missing components. This will give you the bits in IIS Manager to actually manage permissions and delegation so that you can remotely deploy your application.

So far you’ve been doing the default install for the Web Deployment Tool which uses port 80…. but wait, isn’t that what your website is running on? If it is, then you need to customise your install, for example:

msiexec /i <msi_filename> /passive ADDLOCAL=ALL LISTENURL=http://+:8080/MSDEPLOY2/

Alternatively, if you’re like me and only building a dev server then you could always just change your web site (within IIS) to run off a different port. In my case I created a new Web Site using port 8080, which meant I just went with the defaults for webdeploy.

Remote Access

Select the Web Server node in IIS Manager followed by double-clicking the Management Service icon. Stop the Management Service from the Actions list – this will enable the Enable Remote Connections checkbox. Check the Enable Remote Connections checkbox. You can configure other options such as the port and the SSL certificate to use. You need to make sure there is an exception in the server firewall for the port used by the Management Service. By default the Management Service uses a self signed certificate – this isn’t an issue if your doing internal deployments and the clients don’t care about ensuring the integrity of the server they are communicating with. If you are exposing it out of your network you should change the certificate. Start the Management Service from the Actions pane.

image

Configure Deployment Account

The next step is to set up the Management Service for remote deployment of your web application. In my case I set up a Windows user, WebsiteDeploy, that belongs to the Administrators group. This is the user that will create the application within IIS on the server when you publish your web application.

Within IIS Manager select the Web Site you want to enable remote deployment for. Double-click the icon entitled IIS Manager Permissions in the Feature View when the Web Site is selected. From the Actions list select Allow User and enter or select the name of the user that you want to enable (in my case WebsiteDeploy).

image

Delegation

Now that you have enabled the user you need to delegate remote access to that user. You do that by selecting the web server node and double-clicking the Management Service Delegation (this icon doesn’t appear if you only use the Web Platform Installer to install the Web Deployment Tool). Select Add Rule from the Actions list and then select Deploy Applications with Content. If you only want to deploy content then you can select the Deploy Content Only option.

image

I went with the default values and that seems to work for the new rule.

image

You may need to restart the Management Service which you can do by reselecting the Web Server node in IIS Manager, select the Management Service feature and then click Restart from the Actions pane.

You should now be ready to deploy from within Visual Studio 2010. To test this capability I created a new web application, WebApplication1, based on the ASP.NET Web Application. Without making any changes to the application I right-clicked the Web Application project node in Solution Explorer and selected Publish.

image

You’ll notice that all I needed to enter for the Service URL was the ip (or machine name) of the server you are deploying too. Of course this does rely on the Management Service port (default is 8172) being open on the firewall of your server. Also, don’t for get to Allow untrusted certificates unless you configured the Management Service to use a trusted certificate.

Hope this helps you get your server set up for One-Click Publishing. Let me know if there are pieces missing that I may have overlooked.

Tags:

Development

Microsoft Silverlight Analytics Framework with Google Analytics

by Nick 9. April 2010 15:43

Yesterday I spent a somewhat frustrating day getting familiar with the Microsoft Silverlight Analytics Framework that was announced at MIX. It was frustrating not because the framework is hard to use, in fact far from it, but because there was a small bug in the GoogleAnalytics library that prevented it working in certain timezones (I tested it in Australia, New Zealand and parts of Europe and it appeared that there were issues in most timezones outside the US). This issue has now been resolved so if you are going to work with the GoogleAnalytics library with the SL Analytics Framework, make sure you get the latest source code, rather than downloading the initial release.

Firstly, some important URLs that you may want to take a look at:

- The Microsoft Silverlight Analytics Framework (http://msaf.codeplex.com/)

- The MSAF Google Analytics page (http://msaf.codeplex.com/wikipage?title=Google%20Analytics)

- Google’s information on working with the MSAF (http://code.google.com/apis/analytics/docs/tracking/silverlightTrackingIntro.html)

Ok, now let’s get started. To demonstrate how you can do this let’s use the default Silverlight Navigation project template from Visual Studio. We’ll add Google Analytics tracking so that you can track when users go between pages.

The first thing to do is to download the latest MSAF bits. Go to the codeplex site, click on the Source Code tab and then click the Download link under the Latest Version sign. This will download a zip file, which you should expand on your machine. Within the expanded folder locate the Silverlight 3 solution file (eg \msaf-45617\Silverlight.3\Microsoft.WebAnalytics\Microsoft.WebAnalytics.sln) and open it in Visual Studio 2008. You will see some prompts, one for the password to a signing key (just cancel this dialog) and some relating to source control (you can permanently remove the source control bindings). Once loaded, you want to rebuild the following projects:

- Microsoft.WebAnalytics

- Microsoft.WebAnalytics.Behaviors

- Microsoft.WebAnalytics.Navigation

For each of these projects grab the generated dll and copy it to a temporary folder. We’ll be needing these later on. Also from the Assemblies folder (eg \msaf-45617\Silverlight.3\Microsoft.WebAnalytics\Assemblies) copy out the Google.WebAnalytics assembly).

We’ll create a new Silverlight application within Visual Studio using the Silverlight Navigation Application project template.

image

Add references to the dlls you copied to the temporary folder to your Silverlight application (not the associated web project). Also add a reference to System.Windows.Interactivity.

To wire up the MSAF you can either manually write the XAML, or you can open your Silverlight application in Expression Blend. I prefer the latter as it gives you great designer support for adding behaviors to your pages.

Open up the Assets window in Expression Blend and expand out the Behaviors node. Locate the ConsoleAnalytics behavior and drag it onto the LayoutRoot node in the Objects and timeline window.

image

Do the same for the TrackAction behavior, dragging it onto the ContentFrame node.

image

With the TrackAction behavior selected, go to the Properties window and locate the Trigger window. From the EventName dropdown select the Navigated event.

image

Press F5 and run the application. Make sure that the test page is displayed, rather than default.aspx (eg http://localhost:60288/MSAFWithGoogleSampleTestPage.aspx) When it loads in Internet Explorer press F12 to show the developer tools. Select the Script tab and watch the Console window on the right as you click on the Home and About buttons on you Silverlight application.

image

You can see from the console window that the tracking event is being raised each time you navigate between the frames of this application. The output is a result of using the ConsoleAnalytics that you added to the LayoutRoot. But it’s currently not sending anything to Google Analytics. To do this, you need to add the reference to Google Analytics library…

From the Assets window open the Locations node and go to the Google.WebAnalytics node. Drag the GoogleAnalytics behavior onto the LayoutRoot node in the Objects and timeline window.

Now, you’ll need to ensure you have a Google analytics account. If not go to www.google.com/analytics and sign up for an account. Once you have an account you can go into your account and locate the Web Property ID. Go to the overview page and you should see the Web Property ID as in the following image.

image

Copy this value and paste it into the Web Property ID in the Google Analytics section of the Properties window.

image

You probably also want to specify a Category so that you can data mine the events logged with Google Analytics. You’re read to run your application, so press F5 to run it.

Download and run fiddler and you can see that there are calls out to Google Analytics each time you click on the Home or About buttons.

image 

Hopefully this will help you get up and running with Google Analytics in conjunction with the Microsoft Silverlight Analytics Framework.

Tags:

Development

Windows Phone 7: Add Reference for Syndication

by Nick 7. April 2010 02:20

In my previous post, Building an RSS Reader for Windows Phone 7, you may have wondered how I was able to reference SyndicationFeed as this class is in the System.ServiceModel.Syndication namespace which isn’t available in the default list of references for a new Windows Phone 7 project, nor is this assembly in the list of .NET assemblies when you do Add Reference.

The secret is that you need to add a reference to the desktop Silverlight v3 assembly, C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.ServiceModel.Syndication.dll. This will get deployed along with your application, giving you access to the Syndication namespace.

Happy RSS Reading!

Tags:

Development

Building an RSS Reader for Windows Phone 7

by Nick 6. April 2010 19:38

I noticed that Sam over on the Silverlight Show posted about a Windows Phone 7 Series RSS Reader which uses the WebBrowser control to render the content. I figured that whilst that was a neat approach to displaying content an alternative would be to parse the feed, extract the content and display using a combination of TextBlock, Run and LineBreak elements. The following screenshot shows my blog being viewed using such an approach.

image 
Here’s the core code that makes this all happen. It uses the SyndicationFeed class to extract the posts – in my case I’ve just embedded the feed source as a text resource file (hence var rss = RssResources.BlogPosts, where RssResources is a reference to the designer generated wrapper). I then loop through looking for html tags, specifically end of paragraphs and images. I’m sure there’s a more elegant way of doing this but for demo purposes this did the trick.

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Load RSS into a feed
            var rss = RssResources.BlogPosts;
            using(var strm = new System.IO.StringReader(rss))
            using(var reader = System.Xml.XmlReader.Create(strm))
            {
                var feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader);
                // Regular expression to look for html tags
                var tagFinder = new System.Text.RegularExpressions.Regex("<(.|\n)+?>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                // Create the initial textblock
                var txt = new TextBlock() { TextWrapping = TextWrapping.Wrap };
                this.stackPanel1.Children.Add(txt);
                foreach (var item in feed.Items)
                {
                    // Add a title
                    txt.Inlines.Add(new Run() { FontWeight = FontWeights.Bold, Text = item.Title.Text });
                    txt.Inlines.Add(new LineBreak());
                    var itemText = item.Summary.Text;
                    var match = tagFinder.Match(itemText);
                    var startidx = 0;
                    while (match.Index >= 0 && match.Length > 0)
                    {
                        if (match.Value == "</p>" || match.Value == "<p />" || match.Value == "<br />")
                        {
                            // Found the end of a paragraph, so append this text to the textblock
                            var text = itemText.Substring(startidx, match.Index - startidx);
                            text = tagFinder.Replace(text, "");
                            txt.Inlines.Add(text);
                        }
                        else if (match.Value.Contains("<img"))
                        {
                            // Add the text up to the image tag
                            var text = itemText.Substring(startidx, match.Index - startidx);
                            text = tagFinder.Replace(text, "");
                            txt.Inlines.Add(text);

                            // Locate the url of the image
                            var idx = match.Value.IndexOf("src");
                            var url = match.Value.Substring(idx + 5, match.Value.IndexOf("\"", idx + 6) - (idx + 5));

                            // Create an image and add to stackpanel
                            var img = new Image() { Source = new BitmapImage(new Uri(url)) };
                            img.Width = this.scrollViewer1.ActualWidth / 2;
                            img.Stretch = Stretch.UniformToFill;
                            this.stackPanel1.Children.Add(img);

                            // Create a new textblock and add to stackpanel
                            txt = new TextBlock() { TextWrapping = TextWrapping.Wrap };
                            this.stackPanel1.Children.Add(txt);
                        }

                        // Look for the next tag
                        startidx = match.Index + match.Length;
                        match = tagFinder.Match(itemText, match.Index + 1);

                    }
                    // Add the remaining text
                    txt.Inlines.Add(itemText.Substring(startidx));

                    // Add some space before the next post
                    txt.Inlines.Add(new LineBreak());
                    txt.Inlines.Add(new LineBreak());
                }
            }
        }

Tags:

Development

Disabling Debugging Security for Windows Mobile

by Nick 2. April 2010 01:00

Every time I get a new device I go through almost one debug cycle before I’ve had enough and decide to disable the Windows Mobile security. If you aren’t familiar with Windows Mobile security there are essentially one (for pocketpc/Windows Mobile Professional) or two levels (for smartphone/Windows Mobile Standard). In both cases, if security is enabled the device will prompt you, as in the following screenshot, to allow untrusted assemblies to run on the device. Of course, this includes a number of assemblies that are used during debugging, so a royal pain to have to click Yes for each assembly that is loaded.

image

The easiest way to disable this “feature” is to use the Device Security Manager that comes with Visual Studio 2008 (Tools –> Device Security Manager). So long as your device is connected via ActiveSync or Windows Mobile Device Center you should see a display similar to the next image – this shows my device with Prompt One Tier as the current setting.

image

Selecting “Security Off” and hitting the Deploy to Device means that I can easily debug applications without having to click Yes to those annoying prompts.

image

Happy coding…..

Tags:

Development

BeeMobile4.NET Gets Designer Support in Visual Studio for Windows Mobile Applications

by Nick 1. April 2010 12:07

I’ve just been in contact with the team at BeeMobile4.net and they told me that they now have full designer support within Visual Studio 2005 and Visual Studio 2008 for all their controls. When you purchase their iPack you not only get all their controls but the ability to use them from the toolbox in Visual Studio. Of course, since Windows Mobile application development isn’t supported in Visual Studio 2010 their controls don’t appear there!

Here’s a quick walk through of the experience. Firstly, love the installation process – good attention to detail through the install process.

image

Once installed I was amazed by the number of controls they now have on offer.

image

Rather than go through each of the controls in painful detail I downloaded their sample application that showcases all the controls:

image image image

Here you can see a splash screen with an on screen progress bar and a semi-transparent header. The next image includes two main regions including a list, all with transparency so you can see the background. The third image shows you their semi-transparent message box – this is configurable to control both the text, opacity and the buttons displayed.

imageimage

  image image

These four images just show some of the other controls in action.

If you’re doing Windows Mobile development I’d highly recommend these controls as a great starting point to make your application look amazing. Also, if you have other specific control requirements, contact the team at BeeMobile4.Net as they are able to build controls to suit your requirements.

Tags: ,

Development

Windows Mobile Marketplace gets Deep Linking on Device

by Nick 25. March 2010 13:33

For quite a while now you have been able to deep link to your application listed on Marketplace using a url of the form https://marketplace.windowsphone.com/details.aspx?appId=LinkID where the LinkID is unique to your application.  If you want to find the LinkID for any application you simply need to find it in the marketplace and then look in the address bar. Depending on how you found your application you will most likely have a url similar to:

http://marketplace.windowsphone.com/details.aspx?appId=89c01d91-48a1-4e09-895e-74db2ced5345&retURL=/search.aspx%3Fkeywords%3Dcricket

As you can see this is essentially a deep link with some additional information on the end of it. Simply strip off all the extra parameters to give you a deep link that you can use.

http://marketplace.windowsphone.com/details.aspx?appId=89c01d91-48a1-4e09-895e-74db2ced5345

Now when it comes to providing a deep link on the device I think the team has completely missed the point. In the post Drive App Downloads with Marketplace Deeplinking they shown how you can invoke the marketplace client application on the device, passing in the LinkID of the application as follows:

System.Diagnostics.Process.Start("\\Windows\\WMMarketplaceFullClient.exe", "/appid:LinkID");

Now I had to double read this… surely the only way to do something like this would be to have an application already running on the device… and doesn’t that imply that the user already has your application installed on the device… which means they’ve probably already been to marketplace, found, purchased and installed your application… what’s the point in providing this mechanism????

Ok, in answer to that question I can see that if you have multiple Windows Mobile applications in marketplace then you can increase sales by providing cross links between your applications. That way once someone buys one of your applications, they are more likely to buy the others. Alternatively you could provide a free/trial version with a link to the paid version.

Personally I see that there is an obvious gap here – how do I provide a deep link to my application on a mobile web site (or even a standard web site that is accessible via a WM device) that can be resolved on the device via the marketplace client. It wouldn’t be out of the question to have a link such as wmapp://LinkID that would be handled by the marketplace client in order to display the appropriate application. This link could be used when the site detects the page being browsed by a windows mobile client.

Tags:

Development

Zune Software 4.2 in Windows Update for Windows Phone

by Nick 25. March 2010 12:43

I somehow only just realised that Windows Update was blinking at me indicating there were updates available. I’m usually pretty good about installing all the important ones but this time I noticed there was an optional component titled Zune Software 4.2. I had to ask…”why am I getting an update for Zune software when I’ve never installed the Zune software”. Not thinking much about it I proceeded with the download and subsequent install.

image

Now it occurred to me that I’d heard that the Zune software is going to be used by Windows Phone 7 to sync media, which seems logical since all Windows Phone 7 series devices are a Zune device. Having downloaded the developer tools (see http://developer.windowsphone.com if you want them) I figured that it this update must have to do with some component that was part of those tools. Spinning up a couple of my VMs I tested this out – sure enough on the VM that had the dev tools installed, there was the update but on the other VM, without the dev tools, the update was missing.

Unfortunately just because there appears to be a relationship there, doesn’t mean that you can start syncing with the Windows Phone 7 emulator. I tried both with the emulator that ships with the dev tools and the hacked emulator image that’s floating around. I’m sure there’s probably a magic unlock code/flag that you can set to enable syncing but at this stage I’m just waiting for the next official drop from Microsoft where we’ll hopefully see more of what’s going to be available in the platform as part of the emulator.

Tags:

Development

Detecting Orientation with Windows Phone 7

by Nick 22. March 2010 15:53

With the preview developer bits for building Windows Phone 7 applications now publically available I was experimenting with a few things and one of the first things I went looking for is support for handling device orientation. More specifically the event where the orientation of the device changes. Now you can actually do this two ways: you can either attach to the OrientationChanged event on the PhoneApplicationPage, or since your page inherits from this class you can override the OrientationChanged method. Note there is also an OrientationChanging event/method pair that you can also use.

        private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        { … }

OR

       protected override void OnOrientationChanged(OrientationChangedEventArgs e)
       {
           base.OnOrientationChanged(e);
           ….
       }

One of the interesting things to note is that if you are actually interested in whether the device is now in portrait or landscape you have to be careful how you test the new orientation. For example the following condition will probably never be true:

if (e.Orientation == PageOrientation.Portrait)

If you take a look at the PageOrientation enumeration you will see that it actually defines values for each orientation:

public enum PageOrientation
    {
        None = 0,
        Portrait = 1,
        Landscape = 2,
        PortraitUp = 5,
        PortraitDown = 9,
        LandscapeLeft = 24,
        LandscapeRight = 52,
    }

So the only way the previous condition would hold true is if the system decided to return an Orientation set to the more general Portrait, rather than the specifics of PortraitUp and PortraitDown.

Fine you say, it must be a flag in which case you have to “AND” it to work out whether it’s in Portrait or Landscape. Well yes, but you need to make sure that you only do that with the Portrait value. You will notice that the values associated with these values are not your typical flag values of 1, 2, 4, 8 etc. This means that when you AND say the Landscape value of 2 (binary 00010) with LandscapeLeft (binary 11000) you will get 0, when you were expecting to get a value of 2. Luckily when you are testing against Portrait you will notice that both PortraitUp (binary 00101) and PortraitDown (binary 01001) you will get the value 1, which is what you’d expect. So the code for doing different actions based on just the Portrait/Landscape orientation would look something like:

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
       {
           if ((e.Orientation & PageOrientation.Portrait)>0)
           {…}
           else
           {…}
       }

Perhaps someone out there can let me know why the enumeration has the values it does? Clearly I’m missing the obvious here, or perhaps this is a feature of the current preview bits.

Tags:

Development

Enabling Windows Phone 7 Themes in Emulator Applications

by Nick 21. March 2010 19:32

I just noticed that Peter has put up a post on how to make a Windows Phone 7 application theme aware. I couldn’t help but recall one of the more obscure side comments in one of the MIX sessions where the presenter commented out a bunch of code in the App.xaml file in order to get theming to work correctly.  Anyhow, if you’re interested the section of xaml to comment out is the following:

        <!-- Brush Resources -->
        <!--<SolidColorBrush x:Key="PhoneAccentBrush" Color="{StaticResource PhoneAccentColor}"/>
        <SolidColorBrush x:Key="PhoneBackgroundBrush" Color="{StaticResource PhoneBackgroundColor}"/>
        <SolidColorBrush x:Key="PhoneContrastForegroundBrush" Color="{StaticResource PhoneContrastForegroundColor}"/>
        <SolidColorBrush x:Key="PhoneForegroundBrush" Color="{StaticResource PhoneForegroundColor}"/>
        <SolidColorBrush x:Key="PhoneInactiveBrush" Color="{StaticResource PhoneInactiveColor}"/>
        <SolidColorBrush x:Key="PhoneDisabledBrush" Color="{StaticResource PhoneDisabledColor}"/>
        <SolidColorBrush x:Key="PhoneSubtleBrush" Color="{StaticResource PhoneSubtleColor}"/>
        <SolidColorBrush x:Key="PhoneContrastBackgroundBrush" Color="{StaticResource PhoneContrastBackgroundColor}"/>
        <SolidColorBrush x:Key="PhoneTextBoxBrush" Color="{StaticResource PhoneTextBoxColor}"/>
        <SolidColorBrush x:Key="PhoneBorderBrush" Color="{StaticResource PhoneBorderColor}"/>
        <SolidColorBrush x:Key="PhoneTextSelectionBrush" Color="{StaticResource PhoneTextSelectionColor}"/>
        <SolidColorBrush x:Key="TransparentBrush" Color="Transparent"/>—>

You should be aware that this effectively breaks the current design experience within Visual Studio and can even cause the IDE to crash.  I actually closed all my open documents before making this change and then un-commented the xaml once I was done testing the theme support.

Anyhow, here’s a (poorly designer) test application that shows the Light theme option:

image

Tags:

Development

Windows Phone 7 series, Silverlight, XNA, Compact Framework, Background Processing and… Symbian S60

by Nick 16. March 2010 00:12

So here are a few things I found interesting from the first day of MIX:

- Windows Phone 7 series…. duh, well yes that one was obvious. It seems that nearly everyone is talking about it. In case you’ve been living in a hole somewhere you’ll have noticed that the development story is Silverlight and XNA for this platform

- Compact Framework v3.7. If you inspect System.Environment.OSVersion in the emulator you’ll see that it reports version Microsoft Windows CE 7.0.6077. This is confirmed by this post that talks about the WP7 Programming Model.

- Background Processing – That’s right, if you’re application is a good phone citizen (as defined by Microsoft of course) and you don’t consume too many resources your application will continue to operate in the background. This is demonstrable in the emulator if you create a background thread that increments a counter or prints a debug statement – when your application looses focus it will continue to increment/print.

- Symbian S60 support for Silverlight (in-browser model). The Silverlight model for WP7 is entirely out of browser. In fact your Silverlight application will be deployed via Marketplace and will not have any contact as such with the browser. S60 support, as discussed in the post Silverlight on Nokia S60 platform, is in-browser and is only a very limited subset of Silverlight 2. The obvious questions here are whether WP7 will get SL in-browser support (they’ve already been talking about Flash inclusion but why not SL) and which other platforms will be next to get in-browser support.

I’m sure there will be plenty more bits emerging from MIX over the coming days.

Tags: ,

Development

Windows Phone 7 series Developer Preview…. Virtual Machine Fail

by Nick 15. March 2010 07:37

Having sat through the MIX keynote I was excited to see the announcement of the Windows Phone 7 series development tools.  These can all be downloaded from http://developer.windowsphone.com.  The downloads are only compatible with VS2010 RC and so installing these on my main machine (which I haven’t had a chance to upgrade from the beta) is going to be a major effort.  I thought I’d go an install them on one of my many virtual machines I have running on my Hyper-V server – FAIL… According to the release notes this is not a supported option. I also noticed that round-tripping between VS and Blend is not supported – doesn’t that defeat the whole purpose?

Scenarios Not Supported

  • Opening Windows Phone projects in Expression Blend® is not supported, except for Expression Blend 4 Beta with “MICROSOFT EXPRESSION BLEND ADD-IN PREVIEW FOR WINDOWS PHONE.”
  • Round-trip editing of the Windows Phone projects between Expression Blend and Visual Studio is not supported.
  • Windows XP and Windows Server® are not supported.
  • Virtual PC and Hyper-V™ are not supported.

I’m actually guessing the issue with Virtual PC/Hyper-V is to do with the emulator, rather than the actual developer experience. This is something that we saw with very old versions of the Windows Mobile emulator where they couldn’t be run in a virtual machine – this was fixed when the emulator was moved to true ARM emulation.

Update: I’ve just finished installing the tools on a VM and the emulator, whilst slow to load the first time did in fact load and run my hello world application. Big kudos to Microsoft – the tooling looks great so far.

Also, don’t forget to check out the following discussion documents on the platform and designing for Windows Phone 7 series.

Tags:

Development

Jamie Oliver live in Centennial Park with food from Sydney Picnics

by Nick 14. March 2010 01:49

We just got back from a fantastic evening watching Jamie Oliver prepare some gourmet delights on the stage in Centennial Park. He’s got such a great stage presence. Between him, the audience and his good mate, Ben O’Donoghue, Jamie brought the full song-and-dance production to Sydney, delivering an evening that will be remembered for a while to come.

 

Normally at these event you’re left drooling as all the best food ends up being created and eaten on stage by those fortunate enough to make themselves noticed at the front of the event. Not to be left feeling hungry we came prepared and had our own picnic courtesy of the Sydney Picnic Co.

After looking around at a number of different picnic providers I settled on the Sydney Picnic Co because they seemed to have the same idea about food as I do – it’s there to be enjoyed rather than to just fill you up. The selection of cold meats, wild onions, risoni and of course the Valrhona chocolate pots made for an amazing feast from which none of us went hungry. In fact we got a picnic sized for 4 and walked away with enough food for lunch tomorrow (and yes, there’s going to be some arguing over who gets what….).

Anyhow, a big thanks to the Sydney Picnic Co for making a great event and unforgettable experience. If you’re looking to do a picnic in the park or at the beach I can’t recommend them enough!

Tags:

Development

Windows Phone 7 – Will it be everything Microsoft wants it to be?

by Nick 11. March 2010 18:35

Charlie Kindel’s posted about some internal planning that the team did as part of building Windows Phone 7 series. I’m assuming that this isn’t an ordered list but I’m also guessing that this was the order the points were on some list somewhere (perhaps as they were written on a whiteboard during a brainstorming session). If this is the case, it’s concerning that “It’s easy to build beautiful applications users just love" falls at the bottom of the list.

For those that are familiar with Windows Mobile development you’ll have gone through the list and gone yep, yep, yep to most of the points. Most of these points we could achieve on the current Windows Mobile platform (perhaps with the exception of protecting the developers IP and until recently a single marketplace). Where Windows Mobile sucks is the ability to generate awesome applications that users really want to use – it’s not impossible by the way, just hard to do. Actually, it’s hard to do this full stop. I’d almost stake my life on it that despite Microsoft’s attempt at making it easy to build “beautiful” applications, beauty is definitely in the eye of the beholder and we are going to get some hideous creations appearing on the marketplace.

I’m looking forward to MIX next week when we’ll hear just how great we can my Windows Phone 7 series applications.

Tags:

Development

OpenGL: More on Transforms

by Nick 9. March 2010 01:58

In OpenGL- Rotate, Scale and Translate I took a very simple example of transforming some text but what happens if you want to do something more complex. For example you want to have a pair of strings that you can transform around the screen together (ie not have to worry about transforming individually. To do this we can use a form of layering in our rendering where each layer can contain any number of items that will be rendered together. Each layer can be transformed with the resulting transform being applied to each item in the layer.

We’re going to start off by defining an abstract class called ScreenWidget. I’ve used widget because I couldn’t think of a more “correct” name to call items that are going to be displayed on the screen. If there is a better name, do tell me as I’m keen to stick with a vocabulary that is well understood.

abstract class ScreenWidget
    {
        public Vector3f Position { get; set; }
        public Vector3f Anchor { get; set; }
        public Vector3f Scale { get; set; }
        public float Angle { get; set; }
        public Vector3f RotationAxis { get; set; }

        public ScreenWidget()
        {
            Scale = new Vector3f(1, 1, 1);
            RotationAxis = new Vector3f(0,0,1);
        }

        public unsafe void Draw()
        {

            gl.PushMatrix();
            gl.Translatef(Position.X, Position.Y, Position.Z);
            gl.Scalef(Scale.X, Scale.Y, Scale.Z);
            gl.Rotatef(Angle, RotationAxis.X, RotationAxis.Y, RotationAxis.Z);
            gl.Translatef(-Anchor.X, -Anchor.Y, -Anchor.Z);

            DrawComponents();
            gl.PopMatrix();
        }

        protected abstract void DrawComponents();

        public virtual void Setup() {}

        public virtual void Update(float secondsSinceLastUpdate){}
    }

In the ScreenWidget class we can see that it tracks values for position, anchor, scale, angle and rotation axis. It’s worth noting that the position is actually the position of the anchor point within the containing widget. If the widget isn’t nested within another widget then the position will be the position of the anchor point on the screen.

The Draw method on the ScreenWidget is called in order to render all items contained within the widget to the screen. Before doing so it applies a sequence of transforms to scale, rotate and position the widget correctly with respect to its containing widget (and thus subsequently the screen).

What’s interesting is that all these transforms and the call to DrawComponents (which by the way is what an overriding class has to implement in order to actually render items to the screen) are wrapped in a pair of PushMatrix and PopMatrix method calls.  Essentially this ensures that the OpenGL model matrix (ie the matrix that is used to transform items being rendered) is the same when the method ends as when the method started – failure to do this may lead to unexpected results with items being incorrectly positioned, scaled or rotated further on during rendering. PushMatrix pushes the current matrix onto a temporary stack, whilst PopMatrix pops the top matrix on the stack off and makes it the current matrix.

We’ll start by creating the simplest of widgets, the TextWidget:

class TextWidget:ScreenWidget
{
    OpenGLFont font;
    GlyphRun title;
    public override void Setup()
    {
        font = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
        title = new GlyphRun(font, "Hello World!", new Size(int.MaxValue, int.MaxValue), OpenGLTextAlignment.Left, true);
        this.Anchor = new Vector3f(title.Size.Width / 2, title.Size.Height / 2, 0);
    }
    protected override void DrawComponents()
    {
        title.Draw();
    }
}

As you can see the TextWidget simply creates a GlyphRun object that can be draw during the DrawComponents method. Also note that the Anchor property has been set based on the size of the title. This will ensure that if this widget is rotated or scaled it will be done based on the centre of the text, rather than a corner.

Next is a simple container widget, funnily enough called ContainerWidget:

class ContainerWidget : ScreenWidget
    {

        TextWidget text;
        TextWidget text2;
        public override void Setup()
        {
            text = new TextWidget();
            text.Position = new Vector3f(10,10, 0);
            text.Angle = 30;
            text.Setup();

            text2 = new TextWidget();
            text2.Position = new Vector3f(20, 20, 0);
            text2.Angle = 50;
            text2.Setup();
        }
        protected override void DrawComponents()
        {
            text.Draw();
            text2.Draw();
        }

    }

You can see that the two TextWidget instances have been position and rotated by different amounts. Before we can see this we’ll need to go back to our MainForm and create an instance of the ContainerWidget.  The Draw method will then be called on this instance in order to draw the two nested GlyphRuns.

public partial class MainForm : ApplicationForm
{

    public MainForm()
    {
        InitializeComponent(); 
    }

    ContainerWidget widget;
    protected override void SetupScene()
    {
        base.SetupScene();

        widget = new ContainerWidget();
        widget.Position = new Vector3f(0, 0, 0);
        widget.Setup();
    }

    protected override void DrawScene()
    {
        base.DrawScene();

        widget.Draw();

    }

    protected override void UpdateScene(float secondsSinceLastUpdate)
    {
        base.UpdateScene(secondsSinceLastUpdate);

        widget.Update(secondsSinceLastUpdate);
    }
}

As you can see this keeps both the MainForm and the ContainerWidget very clean in terms of the code than needs to be written to display elements.

image

This image isn’t particularly great as the two pieces of text are mostly off screen. So lets modify just the position of the ContainerWidget in the DrawScene method of the MainForm:

gl.PushMatrix();
gl.Translatef(100.0f, 100.0f, 0);
widget.Draw();
gl.PopMatrix();

This gives a much clearer picture of the two pieces of text but note that we only needed to translate the container widget.

image

Tags:

Development

OpenGL: Rotate, Scale and Translate

by Nick 8. March 2010 16:28

In my previous post, OpenGL ES Wrapper- Your First Application, you would have seen that we were creating a GlyphRun that we then draw. This is actually a wrapper class that handles all the processing required to draw the text on the screen. However, it doesn’t handle the positioning of the text on the screen – by default it is located at the origin ie (0,0,0).

To move this text around the screen we can specify an amount to translate, scale or even rotate the text by using the appropriate OpenGL commands. One thing to note here is that the order in which you do these operations may change the result you see. For example in the following images the original text (first image) is translated by (50,50,0) and then rotate around the z axis by 40 degrees.

image

Now apply translation and rotation – note the order of the gl.Translate and gl.Rotate method calls.

gl.Translatef(50.0f,50.0f,0);
gl.Rotatef(40.0f,0,0,1.0f);
title.Draw();

 image 

Now apply translation and rotation in the other order.

gl.Rotatef(40.0f,0,0,1.0f);
gl.Translatef(50.0f,50.0f,0);
title.Draw();

image

You can see that the order that rotate and translate are applied makes a difference. Interestingly they almost appear in the wrong order. In the second image the original image has been translated by (50,50,0) then rotated to get the text to where it appears, whilst in the previous image the text has been rotated by 40 and then translated. This is a result of the way OpenGL uses matrix multiplication to apply transforms to what you are drawing. Each time you issue a transform the corresponding matrix is multiplied against the current matrix to calculate the position of the items you drawing.

The other thing you’ll notice is that the text appears to be rotating around the top left corner of the text. To get it to rotate around the centre of the text, you need to apply a translate function to position the text with its centre at the origin, prior to rotating it and then translating it back into it’s final position.

image image image

Update – here’s the code for doing this additional translation (again, note the order that they’re done in)

gl.Translatef(50.0f, 50.0f, 0);
gl.Rotatef(40.0f, 0, 0, 1.0f);
gl.Translatef(-title.Size.Width/2, -title.Size.Height/2, 0);
title.Draw();

Tags:

Development

OpenGL ES Wrapper: Your First Application

by Nick 8. March 2010 01:12

In my previous post on Getting Started with OpenGL on Windows Mobile I talked about taking the existing OpenGL ES wrapper by Koushik Dutta and extending it to make it easier to work with.  In this, and subsequent posts, I’ll show you how you can take this wrapper and start building out an application.

To get started create a new Smart Device project in Visual Studio 2008.

image image

Note that I’ve created this against the Windows Mobile 5 SDK – if you can find a legacy device still running WM5 which supports OpenGL then this application will still run. I only bother building against the later SDKs if I particularly need one of the few features that were added since WM5.

Next, copy the two OpenGL projects from the this link into your solution folder and add them to your solution within Visual Studio. Also, go ahead and add a project reference from your application to both OpenGL projects.

image

You won’t be needing the designer support for your form but you do need some of the initialization values set in the Form1.designer.cs file. It’s up to you whether you move the InitializeComponent method from your Form1.designer.cs file into your Form1.cs, and then delete Form1.designer.cs, or just leave the designer.cs file there and ignore it.

At this stage I’d recommend renaming Form1 to something more descriptive. In this case my application is only going to have a single form so I have used MainForm. In the MainForm.cs file I’ve modified the class to inherit from ApplicationForm, rather than just Form – this gives me all the OpenGL initialization I talked about previously, as well as some virtual methods that can be implemented to setup, draw and update the current scene:

public partial class MainForm : ApplicationForm
    {
        public MainForm()
        {
            InitializeComponent();
        }

        protected override void SetupScene()
        {
            base.SetupScene();
        }

        protected override void DrawScene()
        {
            base.DrawScene();
        }

        protected override void UpdateScene(float secondsSinceLastUpdate)
        {
            base.UpdateScene(secondsSinceLastUpdate);
        }
    }

In this case we’re going to simply implement Hello World by creating a Font and GlyphRun in the SetupScene method:

OpenGLFont font;
GlyphRun title;
protected override void SetupScene()
{
    base.SetupScene();

    font = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
    title = new GlyphRun(font, "Hello World!", new Size(int.MaxValue, int.MaxValue), OpenGLTextAlignment.Left, true);
}

Then to draw the text on the screen, simply update the Draw method:

protected override void DrawScene()
        {
            base.DrawScene();

            title.Draw();
        }

 

 

image

Not the worlds greatest demo, but surprisingly simple for an OpenGL application. In the next post we’ll start to investigate what you can really do with OpenGL that you can’t do easily with traditional Windows Forms application.

Note: In the InitializeOpenGL function within ApplicationForm you need to include the following call otherwise your text will appear as a solid white rectangle:

gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);

Tags:

Development

Getting Started with OpenGL on Windows Mobile

by Nick 6. March 2010 12:52

There are a number of good posts on working with OpenGL on Windows Mobile via the .NET Compact Framework but one thing I’ve noticed is that they don’t really try to wrap the OpenGL functionality in a way that makes it reusable as an application/game framework. Mostly the logic for rendering was intermingled with windows forms logic, such as OnPaint, which was intermingled with logic for updating the current scene. If you look at say XNA you notice that the model is very simple – essentially they have a single run loop consisting of Update and Draw. I set out to update the OpenGL ES wrapper initially provided by Koushik Dutta and since extended with some great examples across at XDA Developers. Here’s what I came up with to start with.

If you grab the OpenGL ES wrapper you will notice that at its core is essentially a single Windows Form that handles the OnPaint method in order to draw using OpenGL primitives. Nearly all the computation and rendering is done in this method. In the constructor and subsequent initialization methods there are a number of OpenGL ES calls in order to setup the display, surface and context required in order for OpenGL to draw to the screen. In order to create a reusable framework that would be a starting point for any project undertaken in OpenGL all this code would have to be wrapped in a way that it doesn’t need to be duplicated for each project.

I decided to go down the path of creating an abstract form which I called the ApplicationForm. This form has three virtual methods that the overriding form needs to implement:

protected virtual void SetupScene(){}

protected virtual void UpdateScene(float secondsSinceLastUpdate){}

protected virtual void DrawScene(){}

As you can imagine these form the basis of the Draw-Update rendering loop. Of course SetupScene is called prior to the first iteration of this loop to ensure the scene is correctly setup before the first call to Draw. Unlike some implementations which rely on a For/While loop and DoEvents (to allow windows events to be processed) I went with the approach that works in conjunction with the existing windows message pump. When the form needs to be painted the OnPaint method is invoked:

protected override void OnPaint(PaintEventArgs e)
       {
           base.OnPaint(e);

           // Draw the current scene
           RunDrawScene();

           egl.SwapBuffers(_display, _surface);
           gl.Clear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);

           // Update the current scene
           RunUpdateScene();
       }

As you can see this does a single pass of the rendering loop.  What’s interesting is the implementation of the RunUpdateScene method:

private void RunUpdateScene()
       {
           // Check for running instance - exit if already running
           if (Interlocked.CompareExchange(ref isUpdating, 1, 0) == 1)
           {
               return;
           }

           // Only instance running, so create the thread in which to
           // invoke the UpdateScene method
           ThreadPool.QueueUserWorkItem((async) =>
           {
               try
               {
                   // Calculate the time in seconds since last update
                   var seconds = (float)Environment.TickCount/1000.0f;
                   var diff = 0.0f;
                   if (this.lastUpdate > 0)
                   {
                       diff = seconds - this.lastUpdate;
                   }
                   this.lastUpdate = seconds;

                   // Invoke the virtual UpdateScene method
                   UpdateScene(diff);
               }
               finally
               {
                   // Make sure this method can be re-entered
                   Interlocked.Decrement(ref isUpdating);

                   // Invoke "Invalidate" on the control which will cause
                   // the control to be refreshed (ie OnPaint called) leading
                   // to another iteration of Draw and Update
                   this.BeginInvoke((Action)(() => { Invalidate(); }));
               }
           });
       }

Essentially this method wraps the actual call to UpdateScene for three reasons:

  1. To ensure only one instance of UpdateScene is being invoked at any time
  2. To push the call to UpdateScene onto a separate thread. This prevents the UI from blocking whilst it’s in running.
  3. To invoke Invalidate once UpdateScene has completed. This ensures that OnPaint will be invoked again and that the draw-update loop will be invoked again.

In the next post I’ll show you how to get started with this wrapper by overriding the ApplicationForm.  In the meantime, try it yourself….

Tags:

Development

Breaking Changes: Windows Phone 7 series Development Story

by Nick 5. March 2010 09:47

Well the cat’s out of the bag… actually no all that’s happened is that Microsoft has confirmed that one of the cats that was in the bag is now dead: The rumour that legacy applications will run on Windows Phone 7 series is officially dead with Charlie Kindel confirming the lack of backwards compatibility in a post entitled Different Means Better with the new Windows Phone Developer Experience.

What’s interesting is just how well the whole Windows Phone 7 series announcements have been. If you look at other blogs from Microsoft, they all have similar posts talking about the decisions that were made in order to give developers an awesome platform to start building applications on. For example the following blogs all have posts coinciding with Charlie’s post:

Andre Vrignaud: www.ozymandias.com

Break with the Past, Bright New Future: Windows Phone Application Development Platform built on XNA and Silverlight

Christian Schormann: electricbeach.org

Windows Phone 7 Series for Designers and Developers

Shawn Hargreaves: blogs.msdn.com/shawnhar

Backward compatibility

Anand Iyer: www.artificialignorance.net/blog

Windows Phone 7 Series – Developers, Developers, Developers

Michael Klucher: klucher.com

Gaming Development for the Go!

Also confirmed in a twitter Q&A at @WP7dev was support for both Silverlight and XNA development for Windows Phone 7 series. Hopefully this will provide a much more consistent rapid development environment for building phone applications whilst still making them perform.

Currently on Windows Mobile we have a number of technologies to choose from, none of which provide a great experience to both developer and consumer without a lot of cycles invested in making your application look good. The worst part about this is not the cycles spent working out what the application should look like (eg working with a designer to make it look awesome), it’s the wasted cycles having to code it from the ground up each time.

Native C++: Sure you can do nearly anything you want but you take a major productivity hit. Not to mention building a team of top notch c++ developers is becoming very difficult.

WinForms: This just sux for anything other than a mundane LOB application. Sure you can use some of the transparency tools out there to get stylish buttons, or override OnPaint to DIY it to make it look reasonable but you aren’t really going to be doing much in the way of animations, rotating elements etc.

Direct3D: Well this is a technology flop in so far as there is little hardware rendering support out there on a lot of devices. Best to ignore this one….

OpenGL: This is an interesting beast. You can write all your code in C#, yet you have the power of doing nearly any sort of animation, rotation, translation, in fact there is a lot you can do with vectors, triangles and quads. Documentation on getting started and troubleshooting is a little light on but once you get things up and running the results are quite good. You do of course have to think in matrices, projections etc which for those not familiar with these constructs can pose a bit of a learning barrier.

So, if you were going to build a mobile application today, what would you do….. Well contrary to Charlie’s post in which he suggests that developers will continue to build for Windows Mobile, I suspect the reality is that nearly every mobile developer out there will start building Windows Phone 7 series applications as soon as the tooling arrives.

Tags:

Development

Powered by BlogEngine.NET 2.0.0.36

Automotive Theme by Car Leasing Experts

 

Page List