X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FGUI.fs;h=35bc2ad4ceac3206621058683b8c26104392db22;hp=ade197ed9d4fdd0f5d8f260d8ef71c68e4a6bd7e;hb=e8d14548fc5b127970fccb19bad146512f7ac6d9;hpb=b87b35b922551f122228df1fd9c530bbb807935a diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index ade197e..35bc2ad 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -226,7 +226,6 @@ let run (defaultConfig : Config) (fileToOpen : string option) = RBCFrameFromExisting srcImg rbc (win.canvasCurrentImage.Children.[currentCanvas] :?> Views.RBCFrame) else let f = RBCFrame srcImg rbc - f.Opacity <- 0.7 win.canvasCurrentImage.Children.Add(f) |> ignore f @@ -267,7 +266,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = displayStatusMessage "Document saved" with | :? IOException as ex -> - Log.Error(ex.ToString()) + Log.Error "%O" ex MessageBox.Show(sprintf "The document cannot be save in \"%s\"" state.FilePath, "Error saving the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore let saveCurrentDocumentAsNewFile () = @@ -385,7 +384,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateGUI () with | :? IOException as ex -> - Log.Error(ex.ToString()) + Log.Error "%O" ex state.FilePath <- previousFilePath MessageBox.Show(sprintf "The document cannot be loaded from \"%s\"" filepath, "Error loading the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore @@ -415,7 +414,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = Export.exportResults state dialog.FileName with | :? IOException as ex -> - Log.Error(ex.ToString()) + Log.Error "%O" ex MessageBox.Show(sprintf "The results cannot be exported in \"%s\"" state.FilePath, "Error exporting the files", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore let importImage () = @@ -430,7 +429,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = addPreview srcImg with | _ as ex -> - Log.Error(ex.ToString()) + Log.Error "%O" ex MessageBox.Show(sprintf "Unable to read the image from \"%s\"" filename, "Error adding an image", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore updateGlobalParasitemia () @@ -438,6 +437,16 @@ let run (defaultConfig : Config) (fileToOpen : string option) = if noSourceImage then updateCurrentImage () + let showAnalysisWindow () = + if Analysis.showWindow win state then + updateGlobalParasitemia () + updateCurrentImage () + + let setHighlightRBC (highlight : bool) = + displayHealthy <- highlight + updateRBCFramesPreview () + updateRBCFramesCurrent () + win.txtPatient.TextChanged.AddHandler(fun obj args -> state.PatientID <- win.txtPatient.Text) win.menuExit.Click.AddHandler(fun obj args -> win.Close()) @@ -451,17 +460,9 @@ let run (defaultConfig : Config) (fileToOpen : string option) = win.menuAnalysis.SubmenuOpened.AddHandler(fun obj args -> win.menuStartAnalysis.IsEnabled <- state.SourceImages.Count() > 0) - win.menuStartAnalysis.Click.AddHandler(fun obj args -> - if Analysis.showWindow win state then - updateGlobalParasitemia () - updateCurrentImage () - ) + win.menuStartAnalysis.Click.AddHandler(fun obj args -> showAnalysisWindow ()) - win.menuHightlightRBC.Click.AddHandler(fun obj args -> - displayHealthy <- win.menuHightlightRBC.IsChecked - updateRBCFramesPreview () - updateRBCFramesCurrent () - ) + win.menuHightlightRBC.Click.AddHandler(fun obj args -> setHighlightRBC win.menuHightlightRBC.IsChecked) win.menuAbout.Click.AddHandler(fun obj args -> About.showWindow win) @@ -601,6 +602,29 @@ let run (defaultConfig : Config) (fileToOpen : string option) = ) ) |> ignore + // Show analysis dialog. + win.InputBindings.Add( + Input.KeyBinding( + ViewModule.FunCommand((fun obj -> showAnalysisWindow ()), (fun obj -> state.SourceImages.Count() > 0)), + Input.KeyGesture(Input.Key.Y, Input.ModifierKeys.Control) + ) + ) |> ignore + + // Toggle RBC highlight. + win.InputBindings.Add( + Input.KeyBinding( + ViewModule.FunCommand( + ( + fun obj -> + win.menuHightlightRBC.IsChecked <- not win.menuHightlightRBC.IsChecked + setHighlightRBC win.menuHightlightRBC.IsChecked + ), + (fun obj -> true) + ), + Input.KeyGesture(Input.Key.H, Input.ModifierKeys.Control) + ) + ) |> ignore + // Viewport preview. win.scrollViewCurrentImage.ScrollChanged.AddHandler(fun obj args -> updateViewportPreview ())