Improve readability of highlighted RBCs.
authorGreg Burri <greg.burri@gmail.com>
Wed, 13 Jan 2016 13:44:16 +0000 (14:44 +0100)
committerGreg Burri <greg.burri@gmail.com>
Wed, 13 Jan 2016 13:44:16 +0000 (14:44 +0100)
Parasitemia/Parasitemia/GUI/GUI.fs
Parasitemia/Parasitemia/GUI/ImageSourcePreview.xaml
Parasitemia/Parasitemia/GUI/RBCFrame.xaml

index 2132363..62670e6 100644 (file)
@@ -126,6 +126,31 @@ let run (defaultConfig: Config) =
     let updateGlobalParasitemia () =
         txtGlobalParasitemia.Text <- parasitemiaText state.GlobalParasitemia
 
+    let updateViewportPreview () =
+        for preview in stackPreviews.Children |> Seq.cast<Views.ImageSourcePreview> do
+            let srcImg = preview.Tag :?> SourceImage
+            if Some srcImg = state.CurrentImage then
+                preview.viewport.Visibility <- Visibility.Visible
+
+                let canvasWidth = canvasCurrentImage.ActualWidth * currentScale
+                let canvasHeight = canvasCurrentImage.ActualHeight * currentScale
+                let previewWidth = (preview.ActualWidth - preview.BorderThickness.Left - preview.BorderThickness.Right)
+                let previewHeight = (preview.ActualHeight - preview.BorderThickness.Top - preview.BorderThickness.Bottom)
+
+                let marginLeft = previewWidth * (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Left) / canvasWidth - 2.
+                let marginRight = previewWidth * (canvasWidth - (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Right) - scrollViewCurrentImage.ViewportWidth) / canvasWidth - 2.
+                let marginTop = previewHeight * (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Top) / canvasHeight - 2.
+                let marginBottom = previewHeight * (canvasHeight - (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Bottom) - scrollViewCurrentImage.ViewportHeight) / canvasHeight - 2.
+
+                preview.viewport.Margin <-
+                    Thickness(
+                        marginLeft,
+                        marginTop,
+                        marginRight,
+                        marginBottom)
+            else
+                preview.viewport.Visibility <- Visibility.Hidden
+
     let rec setAsInfected (rbc: RBC) (infected: bool) =
         state.SetAsInfected rbc infected
         canvasCurrentImage.Children
@@ -140,23 +165,24 @@ let run (defaultConfig: Config) =
         updateGlobalParasitemia ()
 
     and RBCFrame (rbc: RBC) : Views.RBCFrame =
-        let f = RBCFrameFromExisting rbc (Views.RBCFrame())
-        f.menuRBCSetAsHealthy.Click.AddHandler(fun obj args -> setAsInfected (f.Tag :?> RBC) false)
-        f.menuRBCSetAsInfected.Click.AddHandler(fun obj args -> setAsInfected (f.Tag :?> RBC) true)
-        f.ContextMenuOpening.AddHandler(
+        let frame = RBCFrameFromExisting rbc (Views.RBCFrame())
+        frame.SetValue(Panel.ZIndexProperty, Int32.MaxValue - rbc.num) // To be sure the
+        frame.menuRBCSetAsHealthy.Click.AddHandler(fun obj args -> setAsInfected (frame.Tag :?> RBC) false)
+        frame.menuRBCSetAsInfected.Click.AddHandler(fun obj args -> setAsInfected (frame.Tag :?> RBC) true)
+        frame.ContextMenuOpening.AddHandler(
             fun obj args ->
-                if (f.Tag :?> RBC).infected
+                if (frame.Tag :?> RBC).infected
                 then
-                    f.menuRBCSetAsHealthy.Visibility <- Visibility.Visible
-                    f.menuRBCSetAsInfected.Visibility <- Visibility.Collapsed
+                    frame.menuRBCSetAsHealthy.Visibility <- Visibility.Visible
+                    frame.menuRBCSetAsInfected.Visibility <- Visibility.Collapsed
                 else
-                    f.menuRBCSetAsHealthy.Visibility <- Visibility.Collapsed
-                    f.menuRBCSetAsInfected.Visibility <- Visibility.Visible)
+                    frame.menuRBCSetAsHealthy.Visibility <- Visibility.Collapsed
+                    frame.menuRBCSetAsInfected.Visibility <- Visibility.Visible)
 
-        f.ContextMenuClosing.AddHandler(fun obj args -> if not f.IsMouseOver then highlightRBCFrame f false )
-        f.MouseEnter.AddHandler(fun obj args -> highlightRBCFrame f true)
-        f.MouseLeave.AddHandler(fun obj args -> if not f.grid.ContextMenu.IsOpen then highlightRBCFrame f false)
-        f
+        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
 
     and updateRBCFramesPreview () =
         match state.CurrentImage with
@@ -182,6 +208,8 @@ let run (defaultConfig: Config) =
             stackRBC.Children.RemoveRange(currentPreview, stackRBC.Children.Count - currentPreview)
         | _ -> ()
 
+        updateViewportPreview ()
+
     let updateRBCFramesCurrent () =
         match state.CurrentImage with
         | Some srcImg ->
@@ -193,6 +221,7 @@ let run (defaultConfig: Config) =
                         RBCFrameFromExisting rbc (canvasCurrentImage.Children.[currentCanvas] :?> Views.RBCFrame)
                     else
                         let f = RBCFrame rbc
+                        f.Root.Opacity <- 0.7
                         canvasCurrentImage.Children.Add(f) |> ignore
                         f
 
@@ -251,31 +280,6 @@ let run (defaultConfig: Config) =
             state.CurrentImage <- Some srcImg
             updateCurrentImage ()
 
-    let updateViewportPreview () =
-        for preview in stackPreviews.Children |> Seq.cast<Views.ImageSourcePreview> do
-            let srcImg = preview.Tag :?> SourceImage
-            if Some srcImg = state.CurrentImage then
-                preview.viewport.Visibility <- Visibility.Visible
-
-                let canvasWidth = canvasCurrentImage.ActualWidth * currentScale
-                let canvasHeight = canvasCurrentImage.ActualHeight * currentScale
-                let previewWidth = (preview.ActualWidth - preview.BorderThickness.Left - preview.BorderThickness.Right)
-                let previewHeight = (preview.ActualHeight - preview.BorderThickness.Top - preview.BorderThickness.Bottom)
-
-                let marginLeft = previewWidth * (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Left) / canvasWidth - 2.
-                let marginRight = previewWidth * (canvasWidth - (scrollViewCurrentImage.HorizontalOffset - borderCurrentImage.BorderThickness.Right) - scrollViewCurrentImage.ViewportWidth) / canvasWidth - 2.
-                let marginTop = previewHeight * (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Top) / canvasHeight - 2.
-                let marginBottom = previewHeight * (canvasHeight - (scrollViewCurrentImage.VerticalOffset - borderCurrentImage.BorderThickness.Bottom) - scrollViewCurrentImage.ViewportHeight) / canvasHeight - 2.
-
-                preview.viewport.Margin <-
-                    Thickness(
-                        marginLeft,
-                        marginTop,
-                        marginRight,
-                        marginBottom)
-            else
-                preview.viewport.Visibility <- Visibility.Hidden
-
     let addPreview (srcImg: SourceImage) =
         let imgCtrl = Views.ImageSourcePreview(Margin = Thickness(3.))
 
index 262c89d..1064059 100644 (file)
@@ -14,7 +14,9 @@
             </ContextMenu>
          </Grid.ContextMenu>
          <Image x:Name="imagePreview" />
-         <TextBlock x:Name="txtImageNumber" Padding="2" Text="42" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#4C000000" Foreground="White" Margin="0,0,3,3"/>
+         <Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#4C000000" Margin="0,0,3,3" CornerRadius="5" >
+            <TextBlock x:Name="txtImageNumber" Padding="2" Text="42" Foreground="White" />
+         </Border>
          <Rectangle x:Name="viewport" Margin="24,30,71,26" Stroke="#BFFFFF00" RenderTransformOrigin="0.5,0.5"/>
       </Grid>
    </Border>
index 1a904c1..124dc6f 100644 (file)
             <MenuItem x:Name="menuRBCSetAsInfected" Header="_Set as infected" />
          </ContextMenu>
       </Grid.ContextMenu>
-      <Rectangle x:Name="border" Fill="#00000000">
-      </Rectangle>
+      <Rectangle x:Name="border" Fill="#00000000" />
       <Polygon x:Name="manuallyAdded" Points="0,0 12,0, 12,12" Fill="Black" HorizontalAlignment="Right" VerticalAlignment="Top" />
-      <TextBlock x:Name="txtRBCNumber" Padding="2" Text="42" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#4C000000" Foreground="White" Margin="0,0,3,3"/>
+      <Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,3,3" Background="#66000000" CornerRadius="5">
+         <TextBlock x:Name="txtRBCNumber" Padding="2" Text="42" Foreground="White" />
+      </Border>
    </Grid>
 </UserControl>
\ No newline at end of file