<?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>midnight muse &#187; Personal</title>
	<atom:link href="http://midnightmuse.com.au/category/personal/feed/" rel="self" type="application/rss+xml" />
	<link>http://midnightmuse.com.au</link>
	<description>Richard Wright's musings about software and other things that take his fancy</description>
	<lastBuildDate>Thu, 15 Sep 2011 14:01:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Physics for fun</title>
		<link>http://midnightmuse.com.au/2009/06/06/physics-for-fun/</link>
		<comments>http://midnightmuse.com.au/2009/06/06/physics-for-fun/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 07:57:12 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=175</guid>
		<description><![CDATA[New physics site <a href="http://midnightmuse.com.au/2009/06/06/physics-for-fun/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My son has a <a href="http://www.tonywright.id.au/">new site </a>dealing with physics.</p>
<p>He is a Phd student at Wollongong University studying the theoretical aspects of nano technology. There is nothing there yet but over the coming months he will be publishing papers and useful articles related to this area of physics.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2009/06/06/physics-for-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filling the Songs ListBox</title>
		<link>http://midnightmuse.com.au/2008/08/29/filling-the-songs-listbox/</link>
		<comments>http://midnightmuse.com.au/2008/08/29/filling-the-songs-listbox/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 23:45:05 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Presenter]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/?p=128</guid>
		<description><![CDATA[It is time to show a collection of songs <a href="http://midnightmuse.com.au/2008/08/29/filling-the-songs-listbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After the last post I saved some songs and built a list box to hold the song titles. I should say a little about that. These days I don&#8217;t write any SQL. I know that I still can write it because I wrote a simple SQL query for someone else a week or so ago. But I let someone else do it. By that I mean that I use an Object Relational Mapper. In my case I use <a href="http://www.llblgen.com">LLBL Gen Pro</a>.  There are others out there but I have been using this for a few years now and I quite like it.</p>
<p>Some would suggest that using an O/RM is overkill for such a simple database schema. And it is. At this stage I don&#8217;t even know if I am going to use a database. But I have gotten so used to querying my databases through LLBL Gen that it is easier to just use it.</p>
<p>To get a collection of songs is pretty easy.<br />
<code><br />
public EntityCollection GetAllSongs()<br />
{<br />
EntityCollection songs= new EntityCollection(new SongEntityFactory());<br />
ExcludeFieldsList exFields = new ExcludeFieldsList();<br />
exFields.Add(SongFields.Lyrics);<br />
ISortExpression sorter = new SortExpression(SongFields.Title | SortOperator.Ascending);<br />
using(DataAccessAdapter da = new DataAccessAdapter())<br />
da.FetchEntityCollection(songs,null,0,sorter,null,exFields);<br />
return songs;<br />
}<br />
</code><br />
This code is pretty straightforward. Line one creates a new collection of songs. The sorter says to sort on the Title field. LLBL Gen allows to different modes of data access: Adapter and Self-servicing. Adapter uses a DataAccessAdapter to fetch the entities. Self-servicing has a collection class for each type of entity and there are methods on the collection class to get the entities to fill the collection. This is simple enough to probably warrant using Self-Servicing, but again, I have been used to using Adapter, and so this is what I went with. It may change later, but that is not really an issue. At this stage I just want to be able to populate a list box.</p>
<p>The second line in the method is interesting. I said earlier that I am still uncertain if I will be using a database. But if I stick with it, I don&#8217;t know if I will populate the listbox with an entity collection. Performance wise it would probably make more sense to use a read only list. LLBL Gen will create TypedList classes for you, or you can generate your own dynamic list. But at the moment I just created a collection to see how it all hangs together. But doing this means pulling in a lot of data from the database that I don&#8217;t want. The database table for song has fields for Title, Author and Lyrics. The Title and Author are varchar(50) at the moment. That was the default size in SQLServer and it will do to start with. Lyrics, however, is much bigger. How big should it be? I don&#8217;t know yet, so I have set it to varchar(Max). The second line in the method says don&#8217;t get back the lyrics field. When I want to show the lyrics for a particular song I call another method to get the words.</p>
<p>So I saved a few songs and populated a listbox. Populating the listbox in WPF is pretty easy. I used a mixture of procedural code and xaml to accomplish it. My methods for accessing the database, that is, the code above, is held in a separate project called Tasks, for want of a better name. The songs listbox is held in a separate WPF control called SongListCtrl. To fill the listbox if use the following method<br />
<code><br />
private void FillSongsListBox()<br />
{<br />
songs = tasks.GetAllSongs();<br />
songsListBox.ItemsSource = songs;<br />
}<br />
</code><br />
The ItemsSource property binds the songs collection to the songsListBox. In the Xaml code I set the DisplayMemberPath to Title and that is what is shown in the listbox.</p>
<p>Now comes the hard part. I have a list of songs and I need to display the words. The first thing is to go back to database and get the Lyrics for that song, as explained earlier. I also created a new class SongSelectionEventArgs, which derives from EventArgs and has a property, SongEntity. The EventHandler is done with the standard generic event declaration<br />
<code><br />
public static event EventHandler SelectSong;</p>
<p>public static void OnSelectSong(object sender, SongSelectionEventArgs e)<br />
{<br />
if (SelectSong != null)<br />
SelectSong(sender, e);<br />
}<br />
</code><br />
Now the window that contains the SongListCtrl can listen to changes in the listbox selection. This is all pretty standard stuff. In WPF it works exactly the same way as in winforms. Although there are other ways to handle behaviour, for example using commands as I mentioned in the last post.</p>
<p>It is now time to show the songs on the monitor, and on a separate monitor, which in production will be a projector. This was a major problem as we will see in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2008/08/29/filling-the-songs-listbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Life as a farmer</title>
		<link>http://midnightmuse.com.au/2006/03/16/life-as-a-farmer/</link>
		<comments>http://midnightmuse.com.au/2006/03/16/life-as-a-farmer/#comments</comments>
		<pubDate>Thu, 16 Mar 2006 02:12:58 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Farming]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://midnightmuse.com.au/2006/03/16/life-as-a-farmer/</guid>
		<description><![CDATA[<p>My wife and I have moved. We now live on a farm, with live animals.</p> <a href="http://midnightmuse.com.au/2006/03/16/life-as-a-farmer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For a number of reasons, which I won&#8217;t go into now, my wife and I have moved. We are still in the Shoalhaven but we are living on a farm.</p>
<p>Nearly five years ago we left Sydney and headed to the South Coast of NSW. We spent nearly a year in Bega, and for two city people that was quite an experience. We then headed back north and settled at Culburra Beach. For those who aren&#8217;t familiar with the area it is about 25 kms south east of Nowra, more east than south. And about 2 hours drive from Sydney.</p>
<p>We are now at Toolijooa, which is about the same distance from Nowra, but north east, perhaps a bit more north than east. And it has been a big change for us.</p>
<p>Work wise it makes no difference. I am still about the same distance from my client base, but with easier access to Wollongong, which is the closest major city.</p>
<p>There are pluses and minuses as far as I am concerned. At Culburra Beach I was very close to the water. The beach was just over the sand hills, maybe 50 metres away. The river and the boat ramp where I launched my boat to go fishing was 2kms down the road. Now the beach is about 3kms and the boat ramp 6 or 7. But they aren&#8217;t big problems.</p>
<p>Even though it is only about a 40 minute drive back to Culburra Beach we miss many of the friends we have there. One of my fishing mates who used to work in IT, and still does contract work use to drop in every week or so for a cup of coffee and a chat. It is a long way for him to go for a cup of coffee. However, he is a Project Manager, and as all programmers know, Project Managers are not too bright, so he mightn&#8217;t think that an hour and half round trip for coffee is a problem.</p>
<p>On the plus side we are much closer to our families. Our youngest son lives in Wollongong, but our other children, as well as my wife and my brothers, sisters and parents live in Sydney. So we are closer to them.</p>
<p>It is the farming bit that is the problem. There are around 100 cows on this farm. Actually they are not all cows, some are bulls, or so I&#8217;ve been told &#8211; I don&#8217;t get close enough to them to find out.</p>
<p>So I now divide my time between writing code, and opening and closing farm gates. At least these are beef cattle and I don&#8217;t have to milk them!</p>
]]></content:encoded>
			<wfw:commentRss>http://midnightmuse.com.au/2006/03/16/life-as-a-farmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

