X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FGUI.fs;h=3b6789408efed6c67719a6580a1f5025f94f6303;hb=3e1a96b6a5648ec75f019b40d4ce4b7e9cae3650;hp=74aba278a90043356b76910dfd14d4db3b87e60b;hpb=be048d85a1519bd45f516a88720a629d693a2be2;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index 74aba27..3b67894 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -50,11 +50,11 @@ let run (defaultConfig : Config) (fileToOpen : string option) = frame.manuallyAdded.Fill <- color frame.border.Stroke <- color - let frameStrokeThickness (averageRBCSize : float) = - max 1. (averageRBCSize / 60.) + let frameStrokeThickness () = + state.CurrentImage |> Option.map (fun img -> max 1. (img.AverageRBCSize / 100.)) |> Option.defaultValue 1. - let frameFontSize (averageRBCSize : float) = - max 1. (averageRBCSize / 6.) + let frameFontSize () = + state.CurrentImage |> Option.map (fun img -> max 1. (img.AverageRBCSize / 6.)) |> Option.defaultValue 1. let createRBCFrameFromExisting (srcImg : SourceImage) (rbc : RBC) (frame : RBCFrame) (frameThickness : float) (fontSize : float) (isTextBelow : bool) : RBCFrame = frame.Visibility <- Visibility.Visible @@ -82,17 +82,23 @@ let run (defaultConfig : Config) (fileToOpen : string option) = statusMessageTimer.Start () let highlightRBC (rbc : RBC) (highlight : bool) = - // let rbc = frame.Tag :?> RBC - // Find the two frames in previews and current image. + let highlightRBCFrame (rbcFrame : RBCFrame) (strokeThickness : float) = + if highlight then + rbcFrame.border.StrokeThickness <- 2. * strokeThickness + if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 1. + else + rbcFrame.border.StrokeThickness <- strokeThickness + if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 0. - for rbcFrame in (win.stackRBC.Children |> Seq.cast).Concat(win.canvasCurrentImage.Children |> Seq.cast) do + for rbcFrame in win.stackRBC.Children |> Seq.cast do if (rbcFrame.Tag :?> RBC) = rbc then - if highlight then - rbcFrame.border.StrokeThickness <- 3. * rbcFrame.border.StrokeThickness - if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 1. - else - rbcFrame.border.StrokeThickness <- rbcFrame.border.StrokeThickness / 3. - if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 0. + highlightRBCFrame rbcFrame 1. + + let strokeThicknessCanvas = frameStrokeThickness () + + for rbcFrame in win.canvasCurrentImage.Children |> Seq.cast do + if (rbcFrame.Tag :?> RBC) = rbc then + highlightRBCFrame rbcFrame strokeThicknessCanvas let zoomToRBC (rbc : RBC) = win.scrollViewCurrentImage.ScrollToHorizontalOffset (rbc.center.X * currentScale - win.scrollViewCurrentImage.ViewportWidth / 2. + win.borderCurrentImage.BorderThickness.Left) @@ -232,8 +238,8 @@ let run (defaultConfig : Config) (fileToOpen : string option) = match state.CurrentImage with | Some srcImg -> let mutable currentCanvas = 0 - let strokeThickness = frameStrokeThickness srcImg.AverageRBCSize - let fontSize = frameFontSize srcImg.AverageRBCSize + let strokeThickness = frameStrokeThickness () + let fontSize = frameFontSize () for rbc in srcImg.RBCs do let frame = if currentCanvas < win.canvasCurrentImage.Children.Count then @@ -584,7 +590,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Save. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> saveCurrentDocument ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> saveCurrentDocument ()), (fun obj -> true)), Input.KeyGesture (Input.Key.S, Input.ModifierKeys.Control) ) ) |> ignore @@ -592,7 +598,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Save as. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> saveCurrentDocumentAsNewFile ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> saveCurrentDocumentAsNewFile ()), (fun obj -> true)), Input.KeyGesture (Input.Key.S, Input.ModifierKeys.Control ||| Input.ModifierKeys.Shift) ) ) |> ignore @@ -600,7 +606,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Open. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> askLoadFile ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> askLoadFile ()), (fun obj -> true)), Input.KeyGesture (Input.Key.O, Input.ModifierKeys.Control) ) ) |> ignore @@ -608,7 +614,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // New file. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> newFile ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> newFile ()), (fun obj -> true)), Input.KeyGesture (Input.Key.N, Input.ModifierKeys.Control) ) ) |> ignore @@ -616,7 +622,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Export results. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> exportResults ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> exportResults ()), (fun obj -> true)), Input.KeyGesture (Input.Key.E, Input.ModifierKeys.Control) ) ) |> ignore @@ -624,7 +630,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Import an image. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> importImage ()), (fun obj -> true)), + Utils.FunCommand ((fun obj -> importImage ()), (fun obj -> true)), Input.KeyGesture (Input.Key.A, Input.ModifierKeys.Control) ) ) |> ignore @@ -632,7 +638,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Show analysis dialog. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ((fun obj -> showAnalysisWindow ()), (fun obj -> state.SourceImages.Count () > 0)), + Utils.FunCommand ((fun obj -> showAnalysisWindow ()), (fun obj -> state.SourceImages.Count () > 0)), Input.KeyGesture (Input.Key.Y, Input.ModifierKeys.Control) ) ) |> ignore @@ -640,7 +646,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Toggle RBC highlight. win.InputBindings.Add ( Input.KeyBinding ( - ViewModule.FunCommand ( + Utils.FunCommand ( ( fun obj -> win.menuHightlightRBC.IsChecked <- not win.menuHightlightRBC.IsChecked