cf7ed67a2f70ccc1353a7ec2163f8ccd62ec45b6
1
module Parasitemia.GUI
5 open System.Windows.Media
6 open System.Windows.Markup
7 open System.Windows.Shapes
8 open System.Windows.Controls
10 open System.Diagnostics
11 open Microsoft.Win32 // For the common dialogs.
14 open Emgu.CV.Structure
19 let run (defaultConfig
: Config) =
20 let app = new Application()
21 let mainWindow = Views.MainWindow()
22 let ctrl (name
: string): 'a =
23 mainWindow.Root.FindName(name) :?> 'a
25 // Utils.log <- (fun m -> log mainWindow m)
27 let state = State.State()
29 let exit: Controls.MenuItem = ctrl "menuExit"
30 let save: Controls.MenuItem = ctrl "menuSave"
31 let load: Controls.MenuItem = ctrl "menuOpen"
33 let txtPatient: Controls.TextBox = ctrl "txtPatient"
36 let synchronizeState () =
37 state.PatientID <- txtPatient.Text
39 let synchronizeView () =
40 txtPatient.Text <- state.PatientID
42 exit.Click.AddHandler(fun obj args
-> mainWindow.Root.Close())
43 save.Click.AddHandler(fun obj args
->
45 if state.FilePath = ""
47 let dialog = SaveFileDialog(AddExtension = true, DefaultExt = Pia.extension
, Filter = Pia.filter
);
48 let res = dialog.ShowDialog()
49 if res.HasValue && res.Value
51 state.FilePath <- dialog.FileName
56 load.Click.AddHandler(fun obj args
->
57 // TODO: if current state not saved and not empty, ask to save it.
58 let dialog = OpenFileDialog(Filter = Pia.filter
)
59 let res = dialog.ShowDialog()
60 if res.HasValue && res.Value
62 state.FilePath <- dialog.FileName
66 (*let txtPatient: Controls.TextBox = ctrl "txtPatient"
67 txtPatient.TextChanged.AddHandler(fun obj args ->
68 state.PatientID <- txtPatient.Text)*)
70 (*saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
71 saveFileDialog1.FilterIndex = 2 ;
72 saveFileDialog1.RestoreDirectory = true ;*)
74 // display mainWindow img
75 mainWindow.Root.Show()