<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Richard Dutton &#187; Software Development</title>
	<atom:link href="http://www.dutton.me.uk/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dutton.me.uk</link>
	<description>Software Engineering, Photography, Travel, Stuff...</description>
	<lastBuildDate>Wed, 07 Sep 2011 16:12:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rolling back to previous ClickOnce versions</title>
		<link>http://www.dutton.me.uk/2011/09/07/rolling-back-to-previous-clickonce-versions/</link>
		<comments>http://www.dutton.me.uk/2011/09/07/rolling-back-to-previous-clickonce-versions/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 16:12:23 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[back]]></category>
		<category><![CDATA[click once]]></category>
		<category><![CDATA[clickonce]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[roll]]></category>
		<category><![CDATA[roll back]]></category>
		<category><![CDATA[rollback]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=401</guid>
		<description><![CDATA[I&#8217;ve been deploying software using Microsoft&#8217;s ClickOnce mechanism a lot lately and despite enjoying  its simplicity, especially in comparison to some of the more complicated MSI Setup Projects I&#8217;ve inherited, I&#8217;ve found myself slightly nervous about its abililty to turn a simple software code update into a potentially massively distributed network of fail with its [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been deploying software using Microsoft&#8217;s ClickOnce mechanism a lot lately and despite enjoying  its simplicity, especially in comparison to some of the more complicated MSI Setup Projects I&#8217;ve inherited, I&#8217;ve found myself slightly nervous about its abililty to turn a simple software code update into a potentially massively distributed network of fail with its Auto Updating feature.</p>
<p>Because of this, you occasionally have a rather urgent need to roll back everyone to the last working version, and this turns out to be rather easy.<span id="more-401"></span></p>
<p>In the publish&#8217;s output folder you will see a file called &#8220;&lt;application name&gt;.application&#8221;. This is the ClickOnce Application Deployment Manifest and contains a load of details about the application and in particular the version to install and where to find it.</p>
<p>You will also see an &#8220;Application Files&#8221; folder which will contain a folder for each version of your application deployed so far. To revert all of your users to a previous version, simply copy the &#8220;&lt;application name&gt;.application&#8221; file from the relevant version subdirectory over the one in the root, then either point your users at your ClickOnce location or if you had the application set to check for and apply updates automatically just tell them to restart. The application will detect that there is a &#8220;newer&#8221; version (even if that version is in fact older) and allow the user to install it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2011/09/07/rolling-back-to-previous-clickonce-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RichTextBox ScrollToCaret() bug</title>
		<link>http://www.dutton.me.uk/2011/08/31/richtextbox-scrolltocaret-bug/</link>
		<comments>http://www.dutton.me.uk/2011/08/31/richtextbox-scrolltocaret-bug/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 09:23:02 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[richtextbox]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[scrolltocaret]]></category>
		<category><![CDATA[win forms]]></category>
		<category><![CDATA[windows forms]]></category>
		<category><![CDATA[winforms]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=395</guid>
		<description><![CDATA[I recently needed to add selective colour to text in a Windows Forms TextBox. TextBox doesn&#8217;t support this, but its close sibling RichTextBox does and as they both derive from TextBoxBase, the conversion in code was painless. The original TextBox control would automatically set the caret (cursor) position to the end of the text and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to add selective colour to text in a Windows Forms TextBox. TextBox doesn&#8217;t support this, but its close sibling RichTextBox does and as they both derive from TextBoxBase, the conversion in code was painless.</p>
<p>The original TextBox control would automatically set the caret (cursor) position to the end of the text and use ScrollToCaret() to ensure the last line was always visible after dynamically adding content. This doesn&#8217;t quite work the same when called on a RichTextBox as it appears to scroll until just the very top of the caret is visible, resulting in at best a few pixels of the last line&#8217;s text visible.</p>
<p>Quite a bit of googling of the problem reveals lots of discussion but not much in the way of a suggested solution.</p>
<p>Fortunately, user32.dll provides calls we can use to set the scroll position and we can access these unmanaged functions through P/Invoke as follows:</p>
<pre class="c-sharp">
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
    public int x;
    public int y;

    public POINT()
    {
    }

    public POINT(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}

const int SB_VERT = 1;
const int EM_SETSCROLLPOS = 0x0400 + 222;

[DllImport("user32", CharSet = CharSet.Auto)]
static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos);

[DllImport("user32", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, POINT lParam)
</pre>
<p>Then, when you want to set the scroll position (&#8220;control&#8221; is your RichTextBox instance):</p>
<pre class="c-sharp">
int min, max;
GetScrollRange(control.Handle, SB_VERT, out min, out max);
SendMessage(control.Handle, EM_SETSCROLLPOS, 0, new POINT(0, max - control.Height));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2011/08/31/richtextbox-scrolltocaret-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft 70-511 Exam Passed</title>
		<link>http://www.dutton.me.uk/2011/08/15/microsoft-70-511-exam-passed/</link>
		<comments>http://www.dutton.me.uk/2011/08/15/microsoft-70-511-exam-passed/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 15:06:15 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[.net framework 4]]></category>
		<category><![CDATA[70-511]]></category>
		<category><![CDATA[certified]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[mcts]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[microsoft certified technology specialist]]></category>
		<category><![CDATA[windows applications]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=391</guid>
		<description><![CDATA[Last week I passed the Microsoft 70-511: Windows Application Development with Microsoft .NET Framework 4 exam, making me a Microsoft Certified Technology Specialist! This is the first of four exams I&#8217;m aiming to complete in order to become a Microsoft Certified Professional Developer.]]></description>
			<content:encoded><![CDATA[<p>Last week I passed the Microsoft 70-511: Windows Application Development with Microsoft .NET Framework 4 exam, making me a Microsoft Certified Technology Specialist!</p>
<p><a href="http://www.dutton.me.uk/wp-content/uploads/2011/08/MCTSrgb_1369.png"><img class="aligncenter size-full wp-image-392" title="MCTS 70-511" src="http://www.dutton.me.uk/wp-content/uploads/2011/08/MCTSrgb_1369.png" alt="" width="366" height="80" /></a></p>
<p>This is the first of four exams I&#8217;m aiming to complete in order to become a Microsoft Certified Professional Developer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2011/08/15/microsoft-70-511-exam-passed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to handle Command Line Arguments in WPF Applications</title>
		<link>http://www.dutton.me.uk/2011/02/21/how-to-handle-command-line-arguments-in-wpf-applications/</link>
		<comments>http://www.dutton.me.uk/2011/02/21/how-to-handle-command-line-arguments-in-wpf-applications/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 16:12:03 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[arguments]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[command line arguments]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Startup]]></category>
		<category><![CDATA[StartupEventArgs]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=378</guid>
		<description><![CDATA[I&#8217;ve not considered it before as up to now I haven&#8217;t required it, but obviously in a WPF Application you don&#8217;t have a nice static void Main(string[] args) { ... } with a useful string array of arguments like you do in a regular C# console app, so how do you access them? In a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve not considered it before as up to now I haven&#8217;t required it, but obviously in a WPF Application you don&#8217;t have a nice</p>
<pre name="code" class="c-sharp">static void Main(string[] args)
{
...
}</pre>
<p>with a useful string array of arguments like you do in a regular C# console app, so how do you access them?</p>
<p>In a default WPF application, the entry point to the program is <span id="more-378"></span>the <strong>Application</strong> object. This object has an event <strong>Startup</strong> which is fired, unsurprisingly on startup of your app and contains <strong>StartupEventArgs</strong>. You can query this object to get to your arguments as follows:</p>
<pre name="code" class="c-sharp">
public partial class App : Application
 {
   ///
   /// A static string array containing our start-up command line arguments
   ///
   public static string[] Args;

   protected override void OnStartup(StartupEventArgs e)
   {
       Args = e.Args;
       base.OnStartup(e);
   }
}</pre>
<p>Store them in a static member and then you can access them elsewhere in your application as <strong>Apps.Args</strong>.</p>
<p>So far, so good. But what happens if you actually need some arguments to run, and so want to check and fail gracefully if they don&#8217;t exist? I found that if I checked in my <strong>OnStartup</strong> handler, I still couldn&#8217;t halt the start-up of my application on error.</p>
<p>Instead, I added a <strong>Loaded</strong> event handler to my MainWindow. This is fired once the Application and MainWindow have been loaded so I know I my static Args member will have been set by the time it is fired. I can do all the validation I want on my argument array and decide whether to continue execution or stop and provide an error to the user.</p>
<pre name="code" class="c-sharp">
public MainWindow()
{
     InitializeComponent();

     // Make sure the command line arguments have been processed
     this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    if (App.Args.Length == 1)
    {
        // everything is good, do stuff
    }
    else
    {
        // ERROR!!!
        MessageBox.Show("Not enough arguments!");
        App.Current.Shutdown();
     }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2011/02/21/how-to-handle-command-line-arguments-in-wpf-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OK &#8211; Cancel behaviour with data binding in WPF</title>
		<link>http://www.dutton.me.uk/2010/10/11/ok-cancel-behaviour-with-data-binding-in-wpf/</link>
		<comments>http://www.dutton.me.uk/2010/10/11/ok-cancel-behaviour-with-data-binding-in-wpf/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 14:05:33 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[GetBindingExpression]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=346</guid>
		<description><![CDATA[As much as I am a fan of the Mac OSX and iPhone approach of modifying a setting and having it apply immediately without any further user interaction, my current work involves designing GUIs for Industrial Control and Automation systems where the old &#60;OK&#62; &#60;Cancel&#62; buttons are still required (often by law) which brought up [...]]]></description>
			<content:encoded><![CDATA[<p>As much as I am a fan of the Mac OSX and iPhone approach of modifying a setting and having it apply immediately without any further user interaction, my current work involves designing GUIs for Industrial Control and Automation systems where the old &lt;OK&gt; &lt;Cancel&gt; buttons are still required (often by law) which brought up the question of how to do this in WPF with data binding where, depending on the control, updates are triggered either in real-time or on loss of focus.</p>
<p>The answer is in one of the attributes of Binding called &#8220;<strong>UpdateSourceTrigger</strong>&#8221; which has the following options:</p>
<ul>
<li><strong>LostFocus</strong> &#8211; Update bound property when the control loses focus (TextBox default).</li>
<li><strong>PropertyChanged</strong> &#8211; Update bound property in real-time.</li>
<li><strong>Explicit </strong>- Update bound property when UpdateSource() is called</li>
</ul>
<p>It is this last setting which allows us to delay updating our bound property until we tell it to.</p>
<p>Let&#8217;s say we have a UserControl containing a TextBox, &#8216;MyTextBox&#8217; which is bound to some Dependency Property and two buttons, &#8216;OK&#8217; and &#8216;Cancel&#8217;. Depending on how you hook your buttons up (with RoutedCommands or click handlers (eugh!)) the &#8216;OK&#8217; button&#8217;s code looks like this:</p>
<pre name="code" class="c-sharp">
BindingExpression be = MyTextBox.GetBindingExpression(TextBox.TextProperty);
if (be!=null) be.UpdateSource();</pre>
<p>The &#8216;Cancel&#8217; button&#8217;s code does the reverse:</p>
<pre name="code" class="c-sharp">
BindingExpression be = MyTextBox.GetBindingExpression(TextBox.TextProperty);
if (be!=null) be.UpdateTarget();</pre>
<p>Et voila! Your dependency property will now only update when you want it to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2010/10/11/ok-cancel-behaviour-with-data-binding-in-wpf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Handling events from within a ControlTemplate in WPF</title>
		<link>http://www.dutton.me.uk/2010/02/13/handling-events-from-within-a-controltemplate-in-wpf/</link>
		<comments>http://www.dutton.me.uk/2010/02/13/handling-events-from-within-a-controltemplate-in-wpf/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 07:00:42 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[events inside a ControlTemplate]]></category>
		<category><![CDATA[events within a ControlTemplate]]></category>
		<category><![CDATA[GetTemplateChild]]></category>
		<category><![CDATA[OnApplyTemplate]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[RoutedEvent]]></category>
		<category><![CDATA[RoutedEventhandler]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=323</guid>
		<description><![CDATA[Here&#8217;s an interesting one that had me stumped for a few hours. Following on from my previous post, where I explained how to create a ControlTemplate to style a TextBox in WPF, I&#8217;ve got an object, TextEntryBox, which dervies from a TextBox (it provides some custom event handlers when text is entered, but to all [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting one that had me stumped for a few hours.</p>
<p>Following on from my <a href="http://www.dutton.me.uk/2010/02/13/how-to-create-a-controltemplate-for-a-wpf-textbox/" target="_blank">previous post</a>, where I explained how to create a ControlTemplate to style a TextBox in WPF, I&#8217;ve got an object, TextEntryBox, which dervies from a TextBox (it provides some custom event handlers when text is entered, but to all intents and purposes, it&#8217;s a regular TextBox).</p>
<p>I wanted to style my TextEntryBox, this time including a button within my ControlTemplate (this will eventually toggle an on-screen keyboard pop-up, but that&#8217;s another blog post!). I came up with this:<br />
<span id="more-323"></span></p>
<pre name="code" class="xml">
<Style TargetType="{x:Type my:EntryTextBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type my:EntryTextBox}">
                <DockPanel>
                    <Border BorderThickness="1"
                    	HorizontalAlignment="Stretch"
                    	BorderBrush="DarkGray"
                    	Background="White"
                    	Width="100">
                        <DockPanel>
                            <Button x:Name="PART_KeyboardPopupButton"
                            	DockPanel.Dock="Right"
                            	Width="15"
                            	Height="10"/>
                            <ScrollViewer Margin="0"
                            	Background="Transparent"
                            	HorizontalAlignment="Stretch"
                            	x:Name="PART_ContentHost"/>
                        </DockPanel>
                    </Border>
                </DockPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
</pre>
<p>All&#8217;s well and good, until I want to try and handle the Click event for that button within my TextEntryBox class. Even Matthew MacDonald&#8217;s &#8220;Pro WPF in C# 2008&#8243; which has proved a lifesaver for all things WPF since I&#8217;ve been working with this technology only had the following words of wisdom;</p>
<blockquote><p>&#8220;You can&#8217;t attach event handlers in the control template. Instead, you&#8217;ll need to give your elements recognizable names and attach event handlers to them programmatically in the control constructor&#8221;</p></blockquote>
<p>But whatever I tried I couldn&#8217;t access the event in my constructor, until I remembered the seperation between the visual and logical trees in WPF.</p>
<p>The template is applied at runtime, and so elements contained within it it are part of the visual tree. My class, and therefore my class&#8217; constructor is executed within the logical tree, so I needed to attach my event handler after the template had been applied. You can do this by overriding OnApplyTemplate in your class, obtain the template that&#8217;s being applied, and then you have access to the named button&#8217;s events, like this:</p>
<pre name="code" class="c-sharp">
public override void OnApplyTemplate()
{
    DependencyObject d = GetTemplateChild("PART_KeyboardPopupButton");
    if (d != null)
    {
        (d as Button).Click += new RoutedEventHandler(KeyboardPopupButton_Click);
    }

    base.OnApplyTemplate();
}
</pre>
<p>Note the null check, as someone could have applied a completely different template to the object.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2010/02/13/handling-events-from-within-a-controltemplate-in-wpf/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to create a ControlTemplate for a WPF TextBox</title>
		<link>http://www.dutton.me.uk/2010/02/13/how-to-create-a-controltemplate-for-a-wpf-textbox/</link>
		<comments>http://www.dutton.me.uk/2010/02/13/how-to-create-a-controltemplate-for-a-wpf-textbox/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 06:00:10 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[ContentHost]]></category>
		<category><![CDATA[ControlTemplate]]></category>
		<category><![CDATA[PART_ContentHost]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ScrollViewer]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[TextBox]]></category>
		<category><![CDATA[x:Name]]></category>
		<category><![CDATA[x:Name="Part_ContentHost"]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=325</guid>
		<description><![CDATA[This is a short post, but has one specific piece of information I want to keep. Q: If you want to create a ControlTemplate to provide a custom style for a TextBox, how do you specify where the text goes when it&#8217;s used in WPF? A: The answer was hidden in the depths of the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short post, but has one specific piece of information I want to keep.</p>
<p>Q: If you want to create a ControlTemplate to provide a custom style for a TextBox, how do you specify where the text goes when it&#8217;s used in WPF?</p>
<p>A: The answer was hidden in the depths of the MSDN Documentation. You have to include a &lt;ScrollViewer&gt; within your ControlTemplate with an x:Name value of &#8220;PART_ContentHost&#8221;.</p>
<p>Here&#8217;s a noddy example:</p>
<pre name="code" class="xml">
<Style TargetType="{x:Type TextBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type TextBox}">
                <DockPanel>
                    <Border BorderThickness="1"
                               BorderBrush="DarkGray"
                               Background="White"
                               Width="100">
                        <DockPanel>
                            <ScrollViewer Background="Transparent"
                                               HorizontalAlignment="Stretch"
                                               x:Name="PART_ContentHost"/>
                        </DockPanel>
                    </Border>
                </DockPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2010/02/13/how-to-create-a-controltemplate-for-a-wpf-textbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Personal Route Logging with MobileMe&#8217;s Find My iPhone</title>
		<link>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/</link>
		<comments>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 15:16:13 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[find my iphone]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[google maps api]]></category>
		<category><![CDATA[mobileme]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=276</guid>
		<description><![CDATA[Although I&#8217;m struggling to achieve a happy co-existence between Google&#8217;s Calendars and Contacts and my MobileMe subscription (still fighting dupes and funny syncs with the wrong numbers being associated with the wrong contacts etc&#8230; but that&#8217;s for another blog post!), one part of MobileMe I was keen to do something with was their &#8220;Locate My [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/mobileme/whats-new/"><img class="alignright" title="Find My iPhone" src="http://images.apple.com/mobileme/features/images/fmip_messages_20100622.png" alt="" width="358" height="294" /></a>Although I&#8217;m struggling to achieve a happy co-existence between Google&#8217;s Calendars and Contacts and my MobileMe subscription (still fighting dupes and funny syncs with the wrong numbers being associated with the wrong contacts etc&#8230; but that&#8217;s for another blog post!), one part of MobileMe I was keen to do something with was their &#8220;Locate My iPhone&#8221; feature. Regular apps aren&#8217;t allowed to run in the background on the iPhone, making any form of auto-updating tracking application all a bit &#8220;manual&#8221;  (e.g. Google Latitude on the iPhone), Apple have provided the ability to get the location of your iPhone automatically, but as it&#8217;s <a href="http://www.apple.com/mobileme/whats-new/" target="_blank">officially</a> being touted as a feature to use when you&#8217;ve lost your iPhone it&#8217;s tucked away within the &#8220;Account Settings&#8221; section of the MobileMe web page.</p>
<p>This was screaming out to be screen-scraped and <span id="more-276"></span>developer Tyler Hall has stepped up to the plate with <a href="http://clickontyler.com/blog/2009/06/sosumi-a-mobileme-scraper/" target="_blank">Sosumi &#8211; A MobileMe Scraper</a>. Using Sosumi is literally a case of including the class in your PHP, instantiating it with your MobileMe username and password and calling its locate method which returns an object containing the current latitude, longitude and result accuracy, it&#8217;s as simple as that!</p>
<p>At the moment I&#8217;ve got a cron job on my server hitting this every five minutes and logging to a database. If the data hasn&#8217;t changed since the last logged entry, a counter is incremented and timestamp_last is set. A very simple Google Map displays these locations as points on a map but I&#8217;ve got loads of ideas of stuff to play about with, such as:</p>
<ul>
<li>Plot the reported accuracy of each location as a circle on the map, more Google Maps fiddling.</li>
<li>Modify which points are mapped based on time and date ranges through the webpage, some PHP + AJAX experience.</li>
<li>Store locations of common places I visit, then for each point logged (taking into account the accuracy range) I can programatically work out where I am.  Could then auto-generate &#8220;Richard is at work&#8221;, &#8220;Richard is at home&#8221;, etc&#8230; reports for my blog/twitter/facebook etc&#8230; =).</li>
</ul>
<p>Bit sad I know, but it seemed too good for a total sync-monkey like myself and I&#8217;ll never pass up an opportunity, however contrived, for a PHP mash-up!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>All quiet on the blogging front&#8230;</title>
		<link>http://www.dutton.me.uk/2009/08/13/all-quiet-on-the-blogging-front/</link>
		<comments>http://www.dutton.me.uk/2009/08/13/all-quiet-on-the-blogging-front/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 22:03:34 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[General Rantings]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[NDIS]]></category>
		<category><![CDATA[NDIS 5.1]]></category>
		<category><![CDATA[network driver]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[windows driver]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=250</guid>
		<description><![CDATA[I know I&#8217;ve been pretty quiet as far as technical blog posts are concerned but I&#8217;ve not abandoned this blog, I&#8217;ve been working over the last few months entirely on Windows network driver development (NDIS 5.1), something which I profess to having absolutely no prior experience with so there really wasn&#8217;t anything relevant to blog [...]]]></description>
			<content:encoded><![CDATA[<p>I know I&#8217;ve been pretty quiet as far as technical blog posts are concerned but I&#8217;ve not abandoned this blog, I&#8217;ve been working over the last few months entirely on Windows network driver development (NDIS 5.1), something which I profess to having absolutely no prior experience with so there really wasn&#8217;t anything relevant to blog about.</p>
<p>I&#8217;ve been making notes throughout the whole experience and so plan to post them shortly with the aim of helping anyone else who finds themselves in a similar situation and needs to get up to speed with Windows network driver development (NDIS 5.1). I am by no means an expert but want to share what I&#8217;ve learnt so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2009/08/13/all-quiet-on-the-blogging-front/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#&#8217;s Null-Coalescing (??) Operator</title>
		<link>http://www.dutton.me.uk/2009/04/22/cs-null-coalescing-operator/</link>
		<comments>http://www.dutton.me.uk/2009/04/22/cs-null-coalescing-operator/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 07:31:10 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[c# operator]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[null coalescing]]></category>
		<category><![CDATA[null coalescing operator]]></category>
		<category><![CDATA[nullable]]></category>
		<category><![CDATA[nullable type]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=212</guid>
		<description><![CDATA[Although I&#8217;ve always been a big fan of the ternary operator, kudos goes to the Refactoriser (you know who you are!) for pointing me in the direction of an even more effective way of obfsuca^H^H^H tidying up my code; the ?? operator. The null-coalescing operator (to call it by its more catchy name) allows you [...]]]></description>
			<content:encoded><![CDATA[<p>Although I&#8217;ve always been a big fan of the <a href="http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx" target="_blank">ternary operator</a>, kudos goes to the Refactoriser (you know who you are!) for pointing me in the direction of an even more effective way of obfsuca^H^H^H tidying up my code; the <a href="http://msdn.microsoft.com/en-us/library/ms173224(VS.80).aspx" target="_blank">?? operator</a>.</p>
<p>The null-coalescing operator (to call it by its more catchy name) allows you to provide an alternative value in the event that the reference type object (or nullable value type) you are trying to access evaluates to null. So instead of having to do something like this:</p>
<pre name="code" class="csharp">
            int? myNullableInt = null;
            int myInt;

            if (myNullableInt == null)
            {
                myInt = -1;
            }
            else
            {
                myInt = (int)myNullableInt;
            }
</pre>
<p>You can do this in-line:</p>
<pre name="code" class="csharp">
myInt = myNullableInt ?? -1;
</pre>
<p>Apologies for the heavily contrived and quite pointless example, but at least it gets the syntax down and should make it apparent how useful this operator can be when dealing with a mixture of nullable and non-nullable types.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2009/04/22/cs-null-coalescing-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

