From ef07574f9326af515348bfbd8a0cf606ec337c3a Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 22 Mar 2021 23:33:13 +0100 Subject: [PATCH] Add two buttons to select or unselect all image to analyse --- .../ParasitemiaCore/ParasitemiaCore.fsproj | 6 ++--- Parasitemia/ParasitemiaUI/Analysis.fs | 16 +++++++++++++ Parasitemia/ParasitemiaUI/GUI.fs | 23 ++++++++++++------- .../ParasitemiaUI/ParasitemiaUI.fsproj | 6 ++--- .../ParasitemiaUIControls/AnalysisWindow.xaml | 17 ++++++++++---- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj b/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj index 700dcbf..2825174 100644 --- a/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj +++ b/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj @@ -3,9 +3,9 @@ Library net5.0 - 1.0.13 - 1.0.0.13 - 1.0.0.13 + 1.0.14 + 1.0.0.14 + 1.0.0.14 Greg Burri CHUV & HES-SO diff --git a/Parasitemia/ParasitemiaUI/Analysis.fs b/Parasitemia/ParasitemiaUI/Analysis.fs index 43987d1..928c15f 100644 --- a/Parasitemia/ParasitemiaUI/Analysis.fs +++ b/Parasitemia/ParasitemiaUI/Analysis.fs @@ -107,6 +107,18 @@ let showWindow (parent : Window) (state : State.State) : bool = else Some parameters + win.butSelectAll.Click.AddHandler ( + fun obj args -> + for srcImgCtrl in win.stackSourceImagesSelection.Children |> Seq.cast do + srcImgCtrl.chkSelection.IsChecked <- true + ) + + win.butUnselectAll.Click.AddHandler ( + fun obj args -> + for srcImgCtrl in win.stackSourceImagesSelection.Children |> Seq.cast do + srcImgCtrl.chkSelection.IsChecked <- false + ) + win.butClose.Click.AddHandler (fun obj args -> win.Close ()) win.butStart.Click.AddHandler ( @@ -125,6 +137,8 @@ let showWindow (parent : Window) (state : State.State) : bool = MessageBox.Show ("No image selected", "Cannot start analysis", MessageBoxButton.OK, MessageBoxImage.Information) |> ignore else win.stackSourceImagesSelection.IsEnabled <- false + win.butSelectAll.IsEnabled <- false + win.butUnselectAll.IsEnabled <- false analysisPerformed <- false win.butStart.IsEnabled <- false win.textLog.Text <- "" @@ -152,6 +166,8 @@ let showWindow (parent : Window) (state : State.State) : bool = fun () -> win.progress.Value <- if maybeResults.IsSome then 100. else 0. win.stackSourceImagesSelection.IsEnabled <- true + win.butSelectAll.IsEnabled <- true + win.butUnselectAll.IsEnabled <- true win.butStart.IsEnabled <- true win.butClose.Content <- "Close" updateSourceImages () diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index c85017f..40b3965 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -82,16 +82,23 @@ let run (defaultConfig : Config) (fileToOpen : string option) = statusMessageTimer.Start () let highlightRBC (rbc : RBC) (highlight : bool) = - let strokeThickness = frameStrokeThickness () + let highlightRBCFrame (rbcFrame : RBCFrame) (strokeThickness : float) = + if highlight then + rbcFrame.border.StrokeThickness <- 3. * strokeThickness + if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 1. + else + rbcFrame.border.StrokeThickness <- strokeThickness + if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 0. - for rbcFrame in (win.stackRBC.Children |> Seq.cast).Concat(win.canvasCurrentImage.Children |> Seq.cast) do + for rbcFrame in win.stackRBC.Children |> Seq.cast do if (rbcFrame.Tag :?> RBC) = rbc then - if highlight then - rbcFrame.border.StrokeThickness <- 3. * strokeThickness - if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 1. - else - rbcFrame.border.StrokeThickness <- strokeThickness - if not rbc.infected && not rbc.setManually && not displayHealthy then rbcFrame.Opacity <- 0. + highlightRBCFrame rbcFrame 1. + + let strokeThicknessCanvas = frameStrokeThickness () + + for rbcFrame in win.canvasCurrentImage.Children |> Seq.cast do + if (rbcFrame.Tag :?> RBC) = rbc then + highlightRBCFrame rbcFrame strokeThicknessCanvas let zoomToRBC (rbc : RBC) = win.scrollViewCurrentImage.ScrollToHorizontalOffset (rbc.center.X * currentScale - win.scrollViewCurrentImage.ViewportWidth / 2. + win.borderCurrentImage.BorderThickness.Left) diff --git a/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj b/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj index d6e4ebc..4e02997 100644 --- a/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj +++ b/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj @@ -4,9 +4,9 @@ WinExe net5.0-windows true - 1.0.0.13 - 1.0.0.13 - 1.0.13 + 1.0.0.14 + 1.0.0.14 + 1.0.14 Greg Burri CHUV & HES-SO diff --git a/Parasitemia/ParasitemiaUIControls/AnalysisWindow.xaml b/Parasitemia/ParasitemiaUIControls/AnalysisWindow.xaml index e124cc5..ba5159a 100644 --- a/Parasitemia/ParasitemiaUIControls/AnalysisWindow.xaml +++ b/Parasitemia/ParasitemiaUIControls/AnalysisWindow.xaml @@ -11,18 +11,27 @@ - + + - - + + + + + +