Highlight RBC simultaneous in the preview and in the current image
[master-thesis.git] / Parasitemia / ParasitemiaUI / GUI.fs
index 89f38e3..74aba27 100644 (file)
@@ -81,14 +81,18 @@ let run (defaultConfig : Config) (fileToOpen : string option) =
         statusMessageTimer.Stop ()
         statusMessageTimer.Start ()
 
-    let highlightRBCFrame (frame : RBCFrame) (highlight : bool) =
-        let rbc = frame.Tag :?> RBC
-        if highlight then
-            frame.border.StrokeThickness <- 3. * frame.border.StrokeThickness
-            if not rbc.infected && not rbc.setManually && not displayHealthy then frame.Opacity <- 1.
-        else
-            frame.border.StrokeThickness <- frame.border.StrokeThickness / 3.
-            if not rbc.infected && not rbc.setManually && not displayHealthy then frame.Opacity <- 0.
+    let highlightRBC (rbc : RBC) (highlight : bool) =
+        // let rbc = frame.Tag :?> RBC
+        // Find the two frames in previews and current image.
+
+        for rbcFrame in (win.stackRBC.Children |> Seq.cast<RBCFrame>).Concat(win.canvasCurrentImage.Children |> Seq.cast<RBCFrame>) 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.
 
     let zoomToRBC (rbc : RBC) =
         win.scrollViewCurrentImage.ScrollToHorizontalOffset (rbc.center.X * currentScale - win.scrollViewCurrentImage.ViewportWidth / 2. + win.borderCurrentImage.BorderThickness.Left)
@@ -194,9 +198,9 @@ let run (defaultConfig : Config) (fileToOpen : string option) =
                     frame.menuRBCSetAsHealthy.Visibility <- Visibility.Collapsed
                     frame.menuRBCSetAsInfected.Visibility <- Visibility.Visible
         )
-        frame.ContextMenuClosing.AddHandler (fun obj args -> if not frame.IsMouseOver then highlightRBCFrame frame false )
-        frame.MouseEnter.AddHandler (fun obj args -> highlightRBCFrame frame true)
-        frame.MouseLeave.AddHandler (fun obj args -> if not frame.grid.ContextMenu.IsOpen then highlightRBCFrame frame false)
+        frame.ContextMenuClosing.AddHandler (fun obj args -> if not frame.IsMouseOver then highlightRBC (frame.Tag :?> RBC) false )
+        frame.MouseEnter.AddHandler (fun obj args -> highlightRBC (frame.Tag :?> RBC) true)
+        frame.MouseLeave.AddHandler (fun obj args -> if not frame.grid.ContextMenu.IsOpen then highlightRBC (frame.Tag :?> RBC) false)
         frame
 
     and updateRBCFramesPreview () =