X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FGUI%2FGUI.fs;fp=Parasitemia%2FParasitemia%2FGUI%2FGUI.fs;h=cf7ed67a2f70ccc1353a7ec2163f8ccd62ec45b6;hb=3ddaf64dc5ba6a7066a279ad75b9a1ee72194639;hp=0000000000000000000000000000000000000000;hpb=6b550c3faf4dea77738fa5c27cd9af277f45549c;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/GUI/GUI.fs b/Parasitemia/Parasitemia/GUI/GUI.fs new file mode 100644 index 0000000..cf7ed67 --- /dev/null +++ b/Parasitemia/Parasitemia/GUI/GUI.fs @@ -0,0 +1,76 @@ +module Parasitemia.GUI + +open System.IO +open System.Windows +open System.Windows.Media +open System.Windows.Markup +open System.Windows.Shapes +open System.Windows.Controls +open System.Drawing +open System.Diagnostics +open Microsoft.Win32 // For the common dialogs. + +open Emgu.CV +open Emgu.CV.Structure +open Emgu.CV.WPF + +open Config + +let run (defaultConfig: Config) = + let app = new Application() + let mainWindow = Views.MainWindow() + let ctrl (name: string): 'a = + mainWindow.Root.FindName(name) :?> 'a + + // Utils.log <- (fun m -> log mainWindow m) + + let state = State.State() + + let exit: Controls.MenuItem = ctrl "menuExit" + let save: Controls.MenuItem = ctrl "menuSave" + let load: Controls.MenuItem = ctrl "menuOpen" + + let txtPatient: Controls.TextBox = ctrl "txtPatient" + + + let synchronizeState () = + state.PatientID <- txtPatient.Text + + let synchronizeView () = + txtPatient.Text <- state.PatientID + + exit.Click.AddHandler(fun obj args -> mainWindow.Root.Close()) + save.Click.AddHandler(fun obj args -> + synchronizeState () + if state.FilePath = "" + then + let dialog = SaveFileDialog(AddExtension = true, DefaultExt = Pia.extension, Filter = Pia.filter); + let res = dialog.ShowDialog() + if res.HasValue && res.Value + then + state.FilePath <- dialog.FileName + state.Save() + else + state.Save()) + + load.Click.AddHandler(fun obj args -> + // TODO: if current state not saved and not empty, ask to save it. + let dialog = OpenFileDialog(Filter = Pia.filter) + let res = dialog.ShowDialog() + if res.HasValue && res.Value + then + state.FilePath <- dialog.FileName + state.Load() + synchronizeView ()) + + (*let txtPatient: Controls.TextBox = ctrl "txtPatient" + txtPatient.TextChanged.AddHandler(fun obj args -> + state.PatientID <- txtPatient.Text)*) + + (*saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; + saveFileDialog1.FilterIndex = 2 ; + saveFileDialog1.RestoreDirectory = true ;*) + + // display mainWindow img + mainWindow.Root.Show() + app.Run() \ No newline at end of file