Thursday, 10 November 2016

Xamarin iOS for Simulator and Screenshots

I love the Xamarin iOS Simulator for Windows, much easier than VNC'n to my Mac or having to constantly use my iPhone when I'm only playing around with UI and stuff.

It has all the features you'd expect like show/hide keyboard, home button, rotate, trigger call etc. It also has capture screenshot which would be super handy.

Tonight I needed to take a few screenshots so got trigger happy with the screenshot button but.... I couldn't find where they went!

To cut a long story short I ended up using Process Monitor to find where the files were being written and it turns out they go to a Xamarin\iOS Simulator folder within your pictures folder. I never use mine on my development machine so didn't even consider checking there.

So two tip Pro Tips:

  1. Xamarin iOS Simulator for Windows Screenshots goto: C:\Users\{username}\Xamarin\iOS Simulator
  2. Not sure where files are or whats using them... Don't forget about Process Monitor

Wednesday, 10 February 2016

HTML 5 Web Capture Quirks

Today I've been playing around with HTML 5 Web Camera capture and for the most part its been quite easy. HTML5Rocks has a good intro post which covers many things.

Now it came to testing and everything worked as expected in Chrome and Firefox however in Microsoft Edge (We all test in MS Edge don't we.... ) I found an odd behavior. 

I'm being quite lazy and wanting a 640 x 480px image, so 4:3 aspect ratio which I then take a smaller portion from. Below is what it looks like in Chrome:

However in Edge I was getting:

Originally my source was just:

navigator.getUserMedia({video:true}, (stream) => {

So I decided to add explicit constraints:

 var constraints = {
                video: {

                    width: 640,
                    height: 480,
navigator.getUserMedia(constraints, (stream) => {

However the results were still the same. I then started digging around any Edge documentation I could find and found my way to the initial edge announcement of user media support Midway through this they talk about the various constraints they support and what their defaults are. Turns out these are different than Chrome and Firefox.

Edge by default has an aspect ratio of 1.7777777778 (16:9) and this overrides the height and width I was providing.  To get everything consistent I then simply modified my constraints object to ensure it includes the aspect ratio and everything start behaving itself :)

  var constraints = {
                video: {

                    minWidth: 640,
                    minHeight: 480,
                    aspectRatio: 1.33333333
            navigator.getUserMedia(constraints, (stream) => {

Don't you love browser implementation quirks ;)

Thursday, 13 August 2015

Experiences from using existing projects within VS2015

I've been using VS2015 since an early preview at home but now it's launched I've been trialling it with many of our solutions within work trying to iron out any associated pain before we upgrade every developer (that hasn't already ;)).

One thing I've noticed across a few of our web projects that's caught a few people out is an issue with the new version of IIS Express, and actually if we ever got to deploying to IIS 10.

For many of our web projects we have added additional mimeTypes via the web.config to allow IIS to serve up woff2 files, previously you would have done this via:

        <mimeMap fileExtension=".woff2"mimeType="application/font-woff2" />

However IIS 10, and therefore IIS Express 10, now handles this mimeType automatically. When you run your existing projects via VS2015 you will find all of your websites styling and images suddenly disappear. This can be quite alarming and confusing as the dynamic ASP.Net content loads fine, but all of your static content doesn't.

By using dev tools to investigate the request and response for one of the static resources you will find:
 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
When you then look at the response you find:

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Config Error   Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.woff2'

This nicely points out the issue, the static file handler already knows about the woff2 mimetype, the trick now is how to solve this for IIS 10 but still maintain the fix for older versions. This is as simple as removing the existing mimemap for the fileExtension before adding it.

        <remove fileExtension=".woff2" /> 
        <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /> 

This seems a bit mad as I had expected that if an add duplicate would fail wouldnt a removal of a non existing item, but meh it works ;)

So there we have it an odd issue that's actually really simple to resolve. I hope any other issues I find are as easy to fix ;)

Wednesday, 5 August 2015

Developing a Microsoft Band App Using Windows Universal Apps i.e Windows 10

Last week I finally picked myself up a Microsoft Band and instantly started thinking about potential app ideas and that's where they were left, as thoughts :) However unfortunately I also got knocked off my bike last week and ended up with a fractured elbow (at least this is all it was). Today I finally got my sling off and have been given a ton of Physio exercises so I can actually get my arm moving properly again, at the moment it sucks.

These Physio exercises have to be done every hour in order to ensure I regain full mobility of my arm but it's kind of a drag to remember. I started by simply using the Band's Countdown App to remind me to do these, but whilst traveling this afternoon I thought of writing an App that not only reminded me to do these exercises but also logged and could display how many iterations of the exercises I performed and how fast etc. Needless to say tonight I started playing with the Band SDK and decided to start a series of blog posts that outlines how I get on and things I learnt etc.

Stage One - Getting a Windows Universal App up and running.

I started off by getting a new Windows Universal App created and then using Nuget to install the Band SDK Package [Microsoft.Band]. I then looked through the Microsoft Band SDK documentation on how you need to set things up etc. Here's where I noticed that the documentation and infact a lot of the SDK is all targeted at Windows 8.1 but I'm trying to write for the Windows 10 era. So for Universal Windows Apps where in the SDK documentation it talks about "Windows Store Applications Capabilities" you need to do the following:

  1. Open Package.appxmanifest and navigate to the Capabilities tab
  2. Then scroll down to the Proximity checkbox and enable it
  3. Right click your package.appxmanifest within solution explorer and select View Code. Note: if this is still open from the previous step you'll be prompted that the designer will be closed.
  4. Navigate to the Capabilities XML Node and add the following to the bottom:
<DeviceCapability Name="bluetooth.rfcomm">
   <Device Id="any">
    <!-- Used by the Microsoft Band SDK -->
    <Function Type="serviceId:A502CA9A-2BA5-413C-A4E0-13804E47B38F" />
    <!-- Used by the Microsoft Band SDK -->
    <Function Type="serviceId:C742E1A2-6320-5ABC-9643-D206C677E580" />

With this done you can then follow the other code samples within the SDK documentation which I won't document here. What I do want to mention is how on first appearances is quite easy and clear to use. You ensure you have permissions to use a sensor, you start / stop collecting readings and readings are raised via events with some easy to understand structured types, and as you'd expect it's all async. :)

In my next post I'm going to talk about how I've decided to make use of some of the sensor data and how to manage the sheer volume.

Monday, 2 June 2014

My Favourite Visual Studio Features #myVSUK

It's been really interesting to read some of people's submissions for the Visual Studio Features competition. Quite varied.

I thought I'd add my top 5 into the mix, although I've probably missed the deadline :)

1 - Test Explorer

Test Explorer, Docked Left in my Main Window

I really love having Test Explorer baked in, especially when the XUnit runner is installed. Previously I used to use ReSharper's test manager but now I pretty much only use this. The addition of playlists in VS2013 has also helped.

You can run tests automatically after build, search your tests and group in various ways. One of my most used features.

2 -  Navigate To or as I say Ctrl + T

Finding those Test Types are now just one Key Combo away :)

This is another feature I used to use Resharper extensively for, the ability to quickly find a type by name. Just hit Ctrl+, start typing, instant win :)

3 - Server Explorer with Azure Integration

Managing and Viewing Azure Services is now simple
Before I got VS2013 I was often using 3rd party management tools for viewing my Azure resources, be this storage or just general management of what I use, this used to work well but then I started using Server Explorer and everything changed. Its amazing how just having the tight integration within VS means everything feels much quicker, less context switching etc. Everything is presented well and you can easily add / remove services from within VS no more having to login into the portal.

As much as I love this feature it does have a few issues, for me it seems to constantly forget my login details, so if I happen to have VS crash or have rebooted I have to re login, as my account uses 2-Step Authentication (Which everyone's should ;)) it's a bit of a faff.

4 - Editor Extensions

If only VS could do this.... Oh look an extension...

This may seem like an odd feature to include but I think having Extensions within Visual Studio is a game changer. You have always had the ability to install IDE extensions, Resharper etc however they were always "drawn on top" or didn't feel quite native. Now that the IDE has been redesigned to be fully extensible, the editors. test explorer etc, your experience can be greatly enhanced by some simple extension that is fully integrated.

Personally I wouldn't be without Web Essentials, Productivity Power Tools, Chutzpah, XUnit Runner

I even know friends and colleagues who write extensions just to make their lives easier.

5 - Full VS Colour Schemes

Which theme do I use today...

I debated adding this to my list, I know other's have said Intellisense, IntelliTrace etc which are great features however I think its often underestimated the effect changing the VS Theme has.

I've always changed my editor area theme from the default to often something dark, I've blogged about this before, but now having the full IDE change really reduces the clashes and I think looks better and improves the overall integrated feel. I loved blend having the dark theme so now VS has I'm happy ;)

Depending on how I'm feeling, and more often how my eyes are feeling I sometimes switch between blue and dark.

And there we are 5 of my favourite Visual Studio IDE features :)