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
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
stackRBC.Children.RemoveRange(currentPreview, stackRBC.Children.Count - currentPreview)
| _ -> ()
+ updateViewportPreview ()
+
let updateRBCFramesCurrent () =
match state.CurrentImage with
| Some srcImg ->
RBCFrameFromExisting rbc (canvasCurrentImage.Children.[currentCanvas] :?> Views.RBCFrame)
else
let f = RBCFrame rbc
+ f.Root.Opacity <- 0.7
canvasCurrentImage.Children.Add(f) |> ignore
f
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.))