- (*for rbc in srcImg.rbcs do
- let rectangle = Rectangle(Height = float rbc.size.Height, Width = float rbc.size.Width, )*)
+
+ // Remove all image canvas children and add the RBC.
+ canvasCurrentImage.Children.Clear()
+ for rbc in srcImg.rbcs do
+ let rectangle =
+ Rectangle(
+ Height = rbc.size.Height,
+ Width = rbc.size.Width,
+ Stroke = (if rbc.infected then colorRBCInfected else colorRBCHealthy),
+ StrokeThickness = 1.,
+ Fill = SolidColorBrush(Color.FromArgb(0uy, 0uy, 0uy, 0uy)),
+ Tag = rbc,
+ Opacity = if rbc.infected then 1. else 0.)
+ Canvas.SetLeft(rectangle, rbc.center.X - rbc.size.Width / 2.)
+ Canvas.SetTop(rectangle, rbc.center.Y - rbc.size.Height / 2.)
+ canvasCurrentImage.Children.Add(rectangle) |> ignore
+ rectangle.MouseEnter.AddHandler(
+ fun obj args -> match obj with
+ | :? Rectangle as r ->
+ r.StrokeThickness <- 3.
+ if not (r.Tag :?> RBC).infected then r.Opacity <- 1.
+ | _ -> ())
+ rectangle.MouseLeave.AddHandler(
+ fun obj args -> match obj with
+ | :? Rectangle as r ->
+ r.StrokeThickness <- 1.
+ if not (r.Tag :?> RBC).infected then r.Opacity <- 0.
+ | _ -> ())