X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FGUI.fs;h=77281d3aaaf3e697f78aa7b912a5bcdd7da7ad65;hb=1b8e45987bde692ab5602c281f878707f70459b7;hp=8438b4b196095e1613bddb8b2cf5238c259c0080;hpb=23466ba92c5595f6c0b9f97c86a221a4e5ffebe9;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index 8438b4b..77281d3 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -273,7 +273,7 @@ let run (defaultConfig: Config) (fileToOpen: string option) = with | :? IOException as ex -> Log.Error(ex.ToString()) - MessageBox.Show(sprintf "The document cannot be save in '%s'" state.FilePath, "Error saving the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore + MessageBox.Show(sprintf "The document cannot be save in \"%s\"" state.FilePath, "Error saving the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore let saveCurrentDocumentAsNewFile () = match askDocumentPathToSave () with @@ -394,7 +394,7 @@ let run (defaultConfig: Config) (fileToOpen: string option) = | :? IOException as ex -> Log.Error(ex.ToString()) state.FilePath <- previousFilePath - MessageBox.Show(sprintf "The document cannot be loaded from '%s'" state.FilePath, "Error loading the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore + MessageBox.Show(sprintf "The document cannot be loaded from \"%s\"" filepath, "Error loading the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore let askLoadFile () = let dialog = OpenFileDialog(Filter = PiaZ.filter) @@ -425,18 +425,9 @@ let run (defaultConfig: Config) (fileToOpen: string option) = with | :? IOException as ex -> Log.Error(ex.ToString()) - MessageBox.Show(sprintf "The results cannot be exported in '%s'" state.FilePath, "Error exporting the files", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore + MessageBox.Show(sprintf "The results cannot be exported in \"%s\"" state.FilePath, "Error exporting the files", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore - win.txtPatient.TextChanged.AddHandler(fun obj args -> state.PatientID <- win.txtPatient.Text) - - win.menuExit.Click.AddHandler(fun obj args -> win.Root.Close()) - win.menuSave.Click.AddHandler(fun obj args -> saveCurrentDocument ()) - win.menuSaveAs.Click.AddHandler(fun obj args -> saveCurrentDocumentAsNewFile ()) - win.menuOpen.Click.AddHandler(fun obj args -> askLoadFile ()) - win.menuNew.Click.AddHandler(fun obj args -> newFile ()) - win.menuExportResults.Click.AddHandler(fun obj args -> exportResults ()) - - win.menuAddSourceImage.Click.AddHandler(fun obj args -> + let importImage () = let dialog = OpenFileDialog(Filter = "Image Files|*.png;*.jpg;*.tif;*.tiff", Multiselect = true) let res = dialog.ShowDialog() if res.HasValue && res.Value @@ -450,13 +441,24 @@ let run (defaultConfig: Config) (fileToOpen: string option) = with | _ as ex -> Log.Error(ex.ToString()) - MessageBox.Show(sprintf "Unable to read the image from '%s'" filename, "Error adding an image", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore + MessageBox.Show(sprintf "Unable to read the image from \"%s\"" filename, "Error adding an image", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore updateGlobalParasitemia () if noSourceImage then - updateCurrentImage ()) + updateCurrentImage () + + win.txtPatient.TextChanged.AddHandler(fun obj args -> state.PatientID <- win.txtPatient.Text) + + win.menuExit.Click.AddHandler(fun obj args -> win.Root.Close()) + win.menuSave.Click.AddHandler(fun obj args -> saveCurrentDocument ()) + win.menuSaveAs.Click.AddHandler(fun obj args -> saveCurrentDocumentAsNewFile ()) + win.menuOpen.Click.AddHandler(fun obj args -> askLoadFile ()) + win.menuNew.Click.AddHandler(fun obj args -> newFile ()) + win.menuExportResults.Click.AddHandler(fun obj args -> exportResults ()) + + win.menuAddSourceImage.Click.AddHandler(fun obj args -> importImage ()) win.menuAnalysis.SubmenuOpened.AddHandler(fun obj args -> win.menuStartAnalysis.IsEnabled <- state.SourceImages.Count() > 0) @@ -588,6 +590,12 @@ let run (defaultConfig: Config) (fileToOpen: string option) = FSharp.ViewModule.FunCommand((fun obj -> exportResults ()), (fun obj -> true)), Input.KeyGesture(Input.Key.E, Input.ModifierKeys.Control))) |> ignore + // Import an image. + win.Root.InputBindings.Add( + Input.KeyBinding( + FSharp.ViewModule.FunCommand((fun obj -> importImage ()), (fun obj -> true)), + Input.KeyGesture(Input.Key.A, Input.ModifierKeys.Control))) |> ignore + // Viewport preview. win.scrollViewCurrentImage.ScrollChanged.AddHandler(fun obj args -> updateViewportPreview ())