Compiled Experience Windows Platform Development http://compiledexperience.com en Wed, 25 Mar 2015 03:32:31 +0000 Wed, 25 Mar 2015 03:32:31 +0000 Windows 10 and Caliburn.Micro initial comments <p>As I briefly <a href="http://compiledexperience.com/blog/posts/windows-10-sdk/">mentioned yesterday</a>, the Windows 10 Technical Preview tools have been released. My first experiments were about ensuring Caliburn.Micro still works well. </p> <p>For the most part it works fine, you can read my full thoughts on the <a href="http://caliburnmicro.com/announcements/windows-10-uap-initial/">Caliburn.Micro website</a>.</p> Wed, 25 Mar 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/windows-10-caliburn-initial http://compiledexperience.com/blog/posts/windows-10-caliburn-initial nigel.sampson@compiledexperience.com (Nigel Sampson) Windows 10 SDK released <p>In a bit of surprise news (I wasn&#39;t expecting this till <a href="http://www.buildwindows.com/">Build</a>) but Microsoft have just announced the release of the <a href="http://dev.windows.com/en-US/windows-10-developer-preview-tools">Windows 10 Technical Preview Tools</a>. This will let us build and upgrade our apps to the Windows 10 Universal App Platform.</p> <p>To help you get started I&#39;d recommend checking out the <a href="https://github.com/Microsoft/Windows-universal-samples">sample apps</a> on GitHub, and the <a href="https://channel9.msdn.com/Series/Developers-Guide-to-Windows-10-Preview">Developer&#39;s Guide to Windows 10 Preview</a> on Channel 9.</p> <p>I&#39;ll start to post more of what I discover as I go through them.</p> Tue, 24 Mar 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/windows-10-sdk http://compiledexperience.com/blog/posts/windows-10-sdk nigel.sampson@compiledexperience.com (Nigel Sampson) Preventing zoom on WebView <p>In an upcoming version of <a href="http://compiledexperience.com/windows-apps/hub-bug/">Hub Bug</a> I&#39;m using an embedded WebView to display Markdown content (yay!). This works fantastically in a desktop experience, touch however is a different experience.</p> <p>Web has some peculiarities about it&#39;s layout, it won&#39;t resize to fit it&#39;s content instead it needs to be a fixed layout and to make use of it&#39;s built in scrolling for any content larger than it&#39;s current viewport.</p> <p>We can work around this issue most of the time, however part of this scrolling comes zooming which means on touch devices the user can pinch zoom your content which usually isn&#39;t something you want with an embedded WebView.</p> <p>So how do we disable this? Initially I experimented with the <code>viewport</code> with no success.</p> <div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content=</span><span class="s">&quot;width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0&quot;</span><span class="nt">&gt;</span> </code></pre></div> <p>Thankfully <a href="http://www.markermetro.com/">Marker Metro</a>&#39;s resident html/js expert <a href="https://twitter.com/dkarzon">Damian Karzon</a> came to the rescue with the following css.</p> <div class="highlight"><pre><code class="language-css" data-lang="css"><span class="nt">html</span> <span class="p">{</span> <span class="o">-</span><span class="n">ms</span><span class="o">-</span><span class="k">content</span><span class="o">-</span><span class="n">zooming</span><span class="o">:</span> <span class="k">none</span><span class="p">;</span> <span class="p">}</span> </code></pre></div> <p>We now have embedded html content in the app that feels a part of the app and not that weird <em>floating on top</em>.</p> Mon, 02 Feb 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/webview-zoom http://compiledexperience.com/blog/posts/webview-zoom nigel.sampson@compiledexperience.com (Nigel Sampson) MVP ComCamp 2015 <p>I&#39;ll be speaking in a few weeks at an in person seminar here in Auckland called <a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032610281&amp;Culture=en-AU&amp;community=0">MVP CompCamp 2015</a> on February the 10th . It&#39;s a good chance to meet and connect some of the NZ MVP&#39;s and learn some cool things on Azure and how it intersects with App development.</p> <p>You can <a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032610281&amp;Culture=en-AU&amp;community=0">register here</a>, look forward to seeing you.</p> Fri, 23 Jan 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/comcamp-2015 http://compiledexperience.com/blog/posts/comcamp-2015 nigel.sampson@compiledexperience.com (Nigel Sampson) The nature of breaking changes <p><a href="http://caliburnmicro.com/">Caliburn.Micro</a> like most .NET open source projects these days tries to follow <a href="http://semver.org/">Semantic Versioning</a>, it helps with Nuget and <a href="http://docs.nuget.org/docs/reference/versioning">versioning dependencies</a> and gives some measure of confidence to users of libraries updating libraries to newer versions.</p> <p>One of the major guidelines is: </p> <blockquote> <p>Increment the MAJOR version when you make incompatible API changes.</p> </blockquote> <p>which in my opinion is a very good approach and one we should strive to achieve. But what is &quot;an incompatible API change&quot; or as it&#39;s otherwise known &quot;a breaking change&quot;?</p> <p>We&#39;re looking at bringing a decent chunk of major functionality in <a href="http://caliburnmicro.com/">Caliburn.Micro</a> and want to do it in way that doesn&#39;t elicit us pushing to v10 in a few months.</p> <p>There&#39;s no hard and fast answer, if a user of your assembly depended on a bug then fixing that bug would be a breaking change for them.</p> <p>I remember reading an article from the .NET team where they had to consider changing the signature of private methods as a potential breaking change due to the use of reflection. I&#39;d consider that overkill for almost all developers. However adding extra overloads or adding optional parameters to public methods could break code that depended on reflection.</p> <p>Sometimes breaking changes can because by the interactions of different libraries, a great example from <a href="http://caliburnmicro.com/">Caliburn.Micro</a> was where we added <code>[DataContact]</code> to <code>PropertyChangedBase</code>, a fairly innocent change to allow people to serialize their view models with the out of the box serializers. What we didn&#39;t know was that <a href="http://james.newtonking.com/json">Json.NET</a> respects that property and this was a breaking change for anyone using that serializer. </p> <p>I don&#39;t think you&#39;re ever going to find a hard and fast rule about what consists a breaking change. Each change needs to be evaluated on a case by case basis and thoughts on how developer are most commonly using your libraries.</p> <p>What are your thoughts?</p> Wed, 14 Jan 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/breaking-changes http://compiledexperience.com/blog/posts/breaking-changes nigel.sampson@compiledexperience.com (Nigel Sampson) Goals for 2015 <p>I find it&#39;s a good idea to set out my goals for the year so I can look back and see how I&#39;ve done. Last year was mostly about survival with the arrival of my daughter, hopefully this year I can really get back into it.</p> <p>When setting goals like this I feel they should be really high level and more about direction than finite end goals. I heard a great quote a few nights ago from Claudia Batten that sums it up beautifully.</p> <blockquote> <p>We think that we&#39;re here and we want to be there and we expect a straight line. If we expect a straight line the disappointments that we get when that doesn&#39;t come feel like failures and they feel like points where we want to give up.</p> </blockquote> <h3>Goals</h3> <ol> <li><a href="http://fsharp.org/">F#</a> - It&#39;s always a good thing for a developer to learn a new language, especially when it&#39;s in a different paradigm that what you work with every day. While I can read / understand F# actually building software with it is certainly a goal. I can see a real space building the core logic of an app in F# and the UI in C#. Will have to see how well this works.<br></li> <li><a href="http://xamarin.com/">Xamarin</a> - Experimenting more with this, potentially adding <a href="http://caliburnmicro.com/">Caliburn.Micro</a> support and generally just broadening my experience in mobile app development.</li> <li><a href="https://gist.github.com/staltz/868e7e9bc2a7b8c1f754">Functional Reactive Programming</a> - Apps are becoming increasingly complicated and we need something to help deal with this. A lot of the concepts in <a href="http://reactiveui.net/">Reactive UI</a> appeal to me, part of this will be looking at ways to better integrate the features of <a href="http://caliburnmicro.com/">Caliburn.Micro</a> I love into this as well.</li> <li><a href="http://compiledexperience.com/windows-apps/hub-bug/">Hub Bug for Windows 10</a> - I&#39;ve been working on a design refresh plus foundations for new features for Hub Bug that I&#39;ll probably hold off on till use whatever new features are coming in Windows 10 (if applicable). </li> <li>More Posts - Every blog author pretty much has this goal, I usually start strong but fade off near the end of a year.</li> <li>Speaking - Last year had more public speaking than any other point in my career and I&#39;m starting to get a taste for it (a Toastmasters course we held at Marker Metro certainly helped), I hope to continue with this and maybe try and speak somewhere outside of New Zealand.</li> </ol> <p>So that&#39;s the plan for 2015, I think there&#39;s a consistent theme across all the goals and a broad direction rather than just a straight line.</p> <p>Here&#39;s a to great 2015 for everyone.</p> Wed, 07 Jan 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/goals-2015 http://compiledexperience.com/blog/posts/goals-2015 nigel.sampson@compiledexperience.com (Nigel Sampson) Renewed MVP 2015 <p>Really pleased to declare I&#39;ve been re-awarded the Microsoft MVP for 2015 in Windows Platform development. I&#39;ve a big year planned which I hope to share with you all soon.</p> <p>Here&#39;s to a successful 2015.</p> Mon, 05 Jan 2015 00:00:00 +0000 http://compiledexperience.com/blog/posts/mvp-2015 http://compiledexperience.com/blog/posts/mvp-2015 nigel.sampson@compiledexperience.com (Nigel Sampson) Turning good apps into great ones <p>Last week I did a talk for the <a href="http://www.microsoft.co.nz/msa">Microsoft Student Accelerator</a> on the little things that turn good apps into great ones.</p> <p>I&#39;ve had requests for the slides which are below.</p> <iframe src="https://onedrive.live.com/embed?cid=D28A1F0AF33100D0&resid=D28A1F0AF33100D0%2126511&authkey=ALzV4xX2zDnylrA&em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe> Wed, 26 Nov 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/msa-2014 http://compiledexperience.com/blog/posts/msa-2014 nigel.sampson@compiledexperience.com (Nigel Sampson) Spectrum <p>Another week, another open source project, introducing <a href="https://github.com/nigel-sampson/spectrum"><strong>Spectrum</strong></a>.</p> <h3>What is it?</h3> <p>Spectrum is a library to manipulate colours in the .NET framework, specifically in the RGB, HSL and HSV colour spaces.</p> <p>It&#39;s currently not designed to the be all and end all in terms of colour but more to assist developers in building harmonious colour schemes for their applications.</p> <p>It exists as two parts:</p> <ol> <li><strong>Spectrum</strong> is the core library that contains the classes you&#39;d expect in a library such as this. It&#39;s a portable class library covering all the major platforms (math is very portable).</li> <li><strong>Spectrum.Universal</strong> is the interesting part and is where I hope to extend most of all, it&#39;s a playground for how we can use colour space calculations in our apps. It&#39;s portable across Windows 8 and Windows Phone 8.1.</li> </ol> <h3>How does it work?</h3> <p>The core Spectrum library has only three classes <code>Color.RGB</code>, <code>Color.HSL</code> and <code>Color.HSV</code>, these naturally have methods to convert between themselves.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="kt">var</span> <span class="n">accent</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Color</span><span class="p">.</span><span class="n">RGB</span><span class="p">(</span><span class="m">240</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span> <span class="kt">var</span> <span class="n">hsl</span> <span class="p">=</span> <span class="n">accent</span><span class="p">.</span><span class="n">ToHSL</span><span class="p">();</span> <span class="n">Assert</span><span class="p">.</span><span class="n">AreEqual</span><span class="p">(</span><span class="k">new</span> <span class="n">Color</span><span class="p">.</span><span class="n">HSL</span><span class="p">(</span><span class="m">36.6</span><span class="p">,</span> <span class="m">0.928</span><span class="p">,</span> <span class="m">0.488</span><span class="p">),</span> <span class="n">hsl</span><span class="p">);</span> </code></pre></div> <p>The <code>Color.HSL</code> class has number of helper methods to create other related colours.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="kt">var</span> <span class="n">hsl</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Color</span><span class="p">.</span><span class="n">HSL</span><span class="p">(</span><span class="m">90</span><span class="p">,</span> <span class="m">0.5</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="kt">var</span> <span class="n">compliment</span> <span class="p">=</span> <span class="n">hsl</span><span class="p">.</span><span class="n">ShiftHue</span><span class="p">(</span><span class="m">180.0d</span><span class="p">);</span> <span class="kt">var</span> <span class="n">analogous</span> <span class="p">=</span> <span class="n">hsl</span><span class="p">.</span><span class="n">GetAnalogous</span><span class="p">();</span> </code></pre></div> <p>It gets more interesting when we start to use <strong>Spectrum.Universal</strong>. This contains a few Xaml Value Converters that can shift between <code>Windows.UI.Color</code> instances for us.</p> <p>Given resource declarations like the following:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;converters:ComplimentConverter</span> <span class="na">x:Key=</span><span class="s">&quot;Compliment&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;converters:ShiftLightnessConverter</span> <span class="na">x:Key=</span><span class="s">&quot;ShiftLightness&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;converters:ShiftHueConverter</span> <span class="na">x:Key=</span><span class="s">&quot;ShiftHue&quot;</span> <span class="nt">/&gt;</span> </code></pre></div> <p>and our base accent colour:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;Color</span> <span class="na">x:Key=</span><span class="s">&quot;AccentColor&quot;</span><span class="nt">&gt;</span>#FF0088D1<span class="nt">&lt;/Color&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;AccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource AccentColor}&quot;</span><span class="nt">/&gt;</span> </code></pre></div> <p>We can create lighter and darker versions of that same colour using</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;LightenedAccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{Binding </span> <span class="s"> Source={StaticResource AccentColor}, </span> <span class="s"> Converter={StaticResource ShiftLightness}, </span> <span class="s"> ConverterParameter=0.3}&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;DarkenedAccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{Binding </span> <span class="s"> Source={StaticResource AccentColor}, </span> <span class="s"> Converter={StaticResource ShiftLightness}, </span> <span class="s"> ConverterParameter=-0.3}&quot;</span><span class="nt">/&gt;</span> </code></pre></div> <p>as well as create a minor accent colour</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;SecondaryAccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{Binding </span> <span class="s"> Source={StaticResource AccentColor}, </span> <span class="s"> Converter={StaticResource ShiftHue}, </span> <span class="s"> ConverterParameter=-120}&quot;</span><span class="nt">/&gt;</span> </code></pre></div> <p>We can now manage an app&#39;s full palatte of colour resources by tweaking a few base colours.</p> <h3>Where I can get this?</h3> <p>Source is on <a href="https://github.com/nigel-sampson/spectrum">GitHub</a>, and is also on <a href="http://www.nuget.org/packages/Spectrum.Universal/">Nuget</a>.</p> Fri, 24 Oct 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/spectrum http://compiledexperience.com/blog/posts/spectrum nigel.sampson@compiledexperience.com (Nigel Sampson) Octokit.Caching <p>A few months ago I tweeted about a new open source project <a href="https://github.com/nigel-sampson/octokit.caching"><strong>Octokit.Caching</strong></a> but completely forgot do any more announcing.</p> <blockquote class="twitter-tweet" lang="en"><p>Simple etag caching for Octokit <a href="https://t.co/il9asLfZkJ">https://t.co/il9asLfZkJ</a> cc <a href="https://twitter.com/shiftkey">@shiftkey</a> <a href="https://twitter.com/haacked">@haacked</a></p>&mdash; Nigel Sampson (@nigelsampson) <a href="https://twitter.com/nigelsampson/status/485379375550849025">July 5, 2014</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> <h3>What does it do?</h3> <p>It&#39;s a compact library designed to add simple caching to <a href="https://github.com/octokit/octokit.net">Octokit.NET</a> a GitHub API client library for .NET. It maintains an internal cache of all requests and responses to and from the GitHub API. </p> <p>If you make a request where a cached response is already available then it appends the <code>If-None-Match</code> header with the cached <a href="http://en.wikipedia.org/wiki/HTTP_ETag">etag</a>.</p> <p>If the server returns a <code>304 Not Modified</code> then we return the cached response, otherwise we return the new response while modifying the cache.</p> <h3>Where&#39;s the cache?</h3> <p><a href="https://github.com/nigel-sampson/octokit.caching">Octokit.Caching</a> comes with an interface <code>ICache</code> and a default implementation <code>NaiveInMemoryCache</code></p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="k">public</span> <span class="k">interface</span> <span class="n">ICache</span> <span class="p">{</span> <span class="n">Task</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;</span> <span class="n">GetAsync</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="kt">string</span> <span class="n">key</span><span class="p">);</span> <span class="n">Task</span> <span class="n">SetAsync</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="kt">string</span> <span class="n">key</span><span class="p">,</span> <span class="n">T</span> <span class="k">value</span><span class="p">);</span> <span class="n">Task</span> <span class="nf">ClearAsync</span><span class="p">();</span> <span class="p">}</span> </code></pre></div> <p>It&#39;s built for you to extend easily with something like <a href="https://github.com/akavache/Akavache">Akavache</a>.</p> <h3>Where can I get it?</h3> <p>The source is available on <a href="https://github.com/nigel-sampson/octokit.caching">Github</a> and is available on <a href="https://www.nuget.org/packages/Octokit.Caching/">nuget</a>.</p> Tue, 21 Oct 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/octokit-caching http://compiledexperience.com/blog/posts/octokit-caching nigel.sampson@compiledexperience.com (Nigel Sampson)