Add a logger assembly and split the main assembly in two : the UI and the parasitemia...
[master-thesis.git] / Parasitemia / ParasitemiaUI / About.fs
diff --git a/Parasitemia/ParasitemiaUI/About.fs b/Parasitemia/ParasitemiaUI/About.fs
new file mode 100644 (file)
index 0000000..5f9ce81
--- /dev/null
@@ -0,0 +1,33 @@
+module ParasitemiaUI.About
+
+open System
+open System.Windows
+open System.Windows.Media
+open System.Windows.Markup
+open System.Windows.Shapes
+open System.Windows.Controls
+open System.Diagnostics
+
+let showWindow (parent: Window) =
+    let window = Views.AboutWindow()
+    window.Root.Owner <- parent
+    window.Root.Left <- parent.Left + parent.ActualWidth / 2. - window.Root.Width / 2.
+    window.Root.Top <- parent.Top + parent.ActualHeight / 2. - window.Root.Height / 2.
+
+    let ctrl (name: string): 'a = window.Root.FindName(name) :?> 'a
+
+    let butClose: Button = ctrl "butClose"
+    let txtAbout: TextBlock = ctrl "txtAbout"
+
+    let version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version
+    let txtVersion = sprintf "%d.%d.%d" version.Major version.Minor version.Revision
+    txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(txtVersion)
+
+#if DEBUG
+    txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(" - DEBUG")
+#endif
+
+    butClose.Click.AddHandler(fun obj args -> window.Root.Close())
+
+    window.Root.ShowDialog() |> ignore
+