From: Greg Burri Date: Wed, 13 Jan 2016 13:44:16 +0000 (+0100) Subject: Improve readability of highlighted RBCs. X-Git-Tag: 1.0.11~54 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=a5d61d4974c211bd8dd4e5de07c690489d9507c7;p=master-thesis.git Improve readability of highlighted RBCs. --- diff --git a/Parasitemia/Parasitemia/GUI/GUI.fs b/Parasitemia/Parasitemia/GUI/GUI.fs index 2132363..62670e6 100644 --- a/Parasitemia/Parasitemia/GUI/GUI.fs +++ b/Parasitemia/Parasitemia/GUI/GUI.fs @@ -126,6 +126,31 @@ let run (defaultConfig: Config) = let updateGlobalParasitemia () = txtGlobalParasitemia.Text <- parasitemiaText state.GlobalParasitemia + let updateViewportPreview () = + for preview in stackPreviews.Children |> Seq.cast 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 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.)) diff --git a/Parasitemia/Parasitemia/GUI/ImageSourcePreview.xaml b/Parasitemia/Parasitemia/GUI/ImageSourcePreview.xaml index 262c89d..1064059 100644 --- a/Parasitemia/Parasitemia/GUI/ImageSourcePreview.xaml +++ b/Parasitemia/Parasitemia/GUI/ImageSourcePreview.xaml @@ -14,7 +14,9 @@ - + + + diff --git a/Parasitemia/Parasitemia/GUI/RBCFrame.xaml b/Parasitemia/Parasitemia/GUI/RBCFrame.xaml index 1a904c1..124dc6f 100644 --- a/Parasitemia/Parasitemia/GUI/RBCFrame.xaml +++ b/Parasitemia/Parasitemia/GUI/RBCFrame.xaml @@ -13,9 +13,10 @@ - - + - + + + \ No newline at end of file