44dd881d4e84c42defd400ddb2ebba10f8b98d18
[master-thesis.git] / Parasitemia / ParasitemiaUI / About.fs
1 module ParasitemiaUI.About
2
3 open System
4 open System.Windows
5 open System.Windows.Media
6 open System.Windows.Markup
7 open System.Windows.Shapes
8 open System.Windows.Controls
9 open System.Diagnostics
10
11 let showWindow (parent: Window) =
12 let window = Views.AboutWindow()
13 window.Root.Owner <- parent
14 window.Root.Left <- parent.Left + parent.ActualWidth / 2. - window.Root.Width / 2.
15 window.Root.Top <- parent.Top + parent.ActualHeight / 2. - window.Root.Height / 2.
16
17 let ctrl (name: string): 'a = window.Root.FindName(name) :?> 'a
18
19 let butClose: Button = ctrl "butClose"
20 let txtAbout: TextBlock = ctrl "txtAbout"
21
22 let linkHESSO: Documents.Hyperlink = ctrl "linkHESSO"
23 let linkCHUV: Documents.Hyperlink = ctrl "linkCHUV"
24 let linkGBurri: Documents.Hyperlink = ctrl "linkGBurri"
25
26 let version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version
27 let txtVersion = sprintf " %d.%d.%d" version.Major version.Minor version.Revision
28 txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(txtVersion)
29
30 let navigateTo = Navigation.RequestNavigateEventHandler(fun obj args ->
31 Process.Start(ProcessStartInfo(args.Uri.AbsoluteUri)) |> ignore
32 args.Handled <- true)
33
34 linkHESSO.RequestNavigate.AddHandler(navigateTo);
35 linkCHUV.RequestNavigate.AddHandler(navigateTo);
36 linkGBurri.RequestNavigate.AddHandler(navigateTo);
37
38 #if DEBUG
39 txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(" - DEBUG")
40 #endif
41
42 butClose.Click.AddHandler(fun obj args -> window.Root.Close())
43
44 window.Root.ShowDialog() |> ignore
45