<?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>fs4learning &#187; GUI</title>
	<atom:link href="http://robotics.icstweb.org/fs4learning/tag/gui/feed/" rel="self" type="application/rss+xml" />
	<link>http://robotics.icstweb.org/fs4learning</link>
	<description>Just another Robotics.icstweb.org weblog</description>
	<lastBuildDate>Thu, 16 Apr 2009 19:51:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WPF &amp; F#</title>
		<link>http://robotics.icstweb.org/fs4learning/2008/12/27/wpf-f/</link>
		<comments>http://robotics.icstweb.org/fs4learning/2008/12/27/wpf-f/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 22:41:53 +0000</pubDate>
		<dc:creator>xni</dc:creator>
				<category><![CDATA[Using neural networks for solving partial differential equations]]></category>
		<category><![CDATA[.NET framework 3.0]]></category>
		<category><![CDATA[GUI]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/fs4learning/?p=36</guid>
		<description><![CDATA[In this post I would like to write a few words about creating user interfaces to F# programs. I don&#8217;t know about constructors for GUI, and I&#8217;m not sure about their existance at all, what&#8217;s why in this article we will create UI using objects of .NET Framework 3.0; At first, we need to add [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I would like to write a few words about creating user interfaces to F# programs.</p>
<p>I don&#8217;t know about constructors for GUI, and I&#8217;m not sure about their existance at all, what&#8217;s why in this article we will create UI using objects of .NET Framework 3.0;</p>
<p>At first, we need to add some references to our project to make WPF available. This references are: <strong>PresentationCore</strong>, <strong>PresentationFramework</strong> and <strong>WindowsBase</strong> (all of dll&#8217;s are located at C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\)</p>

<div class="wp_syntax"><div class="code"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">type</span> ResultWindow <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">class</span>
    <span style="color: #06c; font-weight: bold;">inherit</span> Window</pre></div></div>

<p>Here we are creating a class called ResultWindow, that inherites defined in the framework class <strong>Window</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">val</span> <span style="color: #06c; font-weight: bold;">mutable</span> <span style="color: #06c; font-weight: bold;">private</span> minX <span style="color: #a52a2a;">:</span> <span style="color: #06c; font-weight: bold;">float</span></pre></div></div>

<p>I use <strong>val</strong> keyword for declaration of the field. It&#8217;s much more simple to use mutable structures instead of immutable, but I need to notice that you shouldn&#8217;t use mutable stuctures in pure functional code. All of class members declared with <strong>val</strong> keyword must be defined in constructor.</p>

<div class="wp_syntax"><div class="code"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">new</span> <span style="color: #6c6;">&#40;</span> <span style="color: #5d478b; font-style: italic;">(* parameters here *)</span> <span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">as</span> this <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#123;</span>
        <span style="color: #5d478b; font-style: italic;">(* definition of fields *)</span>
        minX <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0.0</span>
                                     <span style="color: #6c6;">&#125;</span> <span style="color: #06c; font-weight: bold;">then</span>
        <span style="color: #5d478b; font-style: italic;">(* some other actions *)</span></pre></div></div>

<p>Now it&#8217;s time to create a method (static methods are created without <strong>this.</strong> prefix).</p>

<div class="wp_syntax"><div class="code"><pre class="ocaml" style="font-family:monospace;">member this<span style="color: #a52a2a;">.</span><span style="color: #060;">DrawGrid</span> <span style="color: #a52a2a;">=</span>
        <span style="color: #06c; font-weight: bold;">let</span> gridLine <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">new</span> Line<span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #5d478b; font-style: italic;">(* and many-many lines of code *)</span></pre></div></div>

<p>If you are not familiar to WPF my advise is to read some books about it. For example:</p>
<li><a href="http://blogs.msdn.com/dsyme/archive/2008/01/05/learning-wpf-through-f-and-vice-versa-by-john-liao.aspx">Don Syme&#8217;s WebLog</a></li>
<li>Practical WPF Graphics Programming &#8212; Jack Xu, Ph.D</li>
<li>WPF Recipes in C# 2008 &#8212; Sam Noble, Sam Bourton, Allen Jones</li>
<p>At the pictures presented below you can see analytic and neural solution graphics:</p>
<p><a href="http://robotics.icstweb.org/fs4learning/files/2008/12/sin2pix.jpg"></a></p>
<p><a href="http://robotics.icstweb.org/fs4learning/files/2008/12/sin2pix.jpg"><img class="alignnone size-medium wp-image-38" src="http://robotics.icstweb.org/fs4learning/files/2008/12/sin2pix.jpg" alt="" /></a><a href="http://robotics.icstweb.org/fs4learning/files/2008/12/x2-x-d183d181d0bad0bed180d0b5d0bdd0bdd18bd0b9-d0b4d0be-d0bed188d0b8d0b1d0bad0b8-1e-3.jpg"><img class="alignnone size-medium wp-image-39" src="http://robotics.icstweb.org/fs4learning/files/2008/12/x2-x-d183d181d0bad0bed180d0b5d0bdd0bdd18bd0b9-d0b4d0be-d0bed188d0b8d0b1d0bad0b8-1e-3.jpg" alt="" /></a><br />
I don&#8217;t publish my code in this post, because it is quite large. You can <a href="http://cid-6656593f7ed14dcf.skydrive.live.com/self.aspx/FSharp/Atrificial%20Neural%20Network/2008.12.26/ResultWindow.fs" target="_blank">download</a> it.</p>
 <img src="http://robotics.icstweb.org/fs4learning/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=36" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/fs4learning/2008/12/27/wpf-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
