X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FAnalysis.fs;h=43987d1cf3d890ab15f79c4e3003dc9301093ddd;hb=95f9edf71456c8bf89a91850800f66efc2c9d4da;hp=13ce48b46cccde791d57578f11631e0cfbf188ff;hpb=42d4db26f30bccbcc2e1b6d1f82a5b04a1f3dcd2;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaUI/Analysis.fs b/Parasitemia/ParasitemiaUI/Analysis.fs index 13ce48b..43987d1 100644 --- a/Parasitemia/ParasitemiaUI/Analysis.fs +++ b/Parasitemia/ParasitemiaUI/Analysis.fs @@ -1,25 +1,18 @@ module ParasitemiaUI.Analysis open System -open System.IO open System.Linq open System.Windows -open System.Windows.Media -open System.Windows.Markup -open System.Windows.Shapes open System.Windows.Controls -open System.Diagnostics -open Microsoft.Win32 // For the common dialogs. - -open Emgu.CV.WPF +open ParasitemiaUIControls open ParasitemiaCore.UnitsOfMeasure open ParasitemiaCore.Config open Types let showWindow (parent : Window) (state : State.State) : bool = - let win = Views.AnalysisWindow () + let win = AnalysisWindow () win.Owner <- parent win.Left <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Left) + parent.ActualWidth / 2. - win.Width / 2. win.Top <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Top) + parent.ActualHeight / 2. - win.Height / 2. @@ -54,10 +47,10 @@ let showWindow (parent : Window) (state : State.State) : bool = win.stackSourceImagesSelection.Children.Clear () let width = int win.stackSourceImagesSelection.ActualWidth for srcImg in state.SourceImages do - let imageSourceSelection = Views.ImageSourceSelection (Tag = srcImg, Margin = Thickness 3.) + let imageSourceSelection = ImageSourceSelection (Tag = srcImg, Margin = Thickness 3.) imageSourceSelection.Tag <- srcImg - imageSourceSelection.txtImageNumber.Text <- string srcImg.Num + imageSourceSelection.txtImageNumber.Text <- string srcImg.RomanNum let height = srcImg.Img.Height * width / srcImg.Img.Width imageSourceSelection.imagePreview.Source <- BitmapSourceConvert.ToBitmapSource (srcImg.Img.Resize (width, height, Emgu.CV.CvEnum.Inter.Cubic)) imageSourceSelection.chkSelection.IsChecked <- Nullable (srcImg.DateLastAnalysis.Ticks = 0L) @@ -95,7 +88,7 @@ let showWindow (parent : Window) (state : State.State) : bool = // Get the new parameters for each image. If an error occurs then 'None' is returned and a message box is displayed. // The boolean is 'true' if the image is selected (checked). let getInputImagesParameters () : (SourceImage * bool * Parameters) list option = - let sourceImagesControls = win.stackSourceImagesSelection.Children |> Seq.cast + let sourceImagesControls = win.stackSourceImagesSelection.Children |> Seq.cast let parameters = seq { for srcImgCtrl in sourceImagesControls do @@ -103,10 +96,10 @@ let showWindow (parent : Window) (state : State.State) : bool = let isChecked = srcImgCtrl.chkSelection.IsChecked match parseAndValidatePPI srcImgCtrl.txtResolution.Text with | Some resolution -> - yield Some (srcImg, isChecked.HasValue && isChecked.Value, { srcImg.Config.Parameters with resolution = resolution * 1. }) + Some (srcImg, isChecked.HasValue && isChecked.Value, { srcImg.Config.Parameters with resolution = resolution * 1. }) | None -> MessageBox.Show (sprintf "No resolution defined for the image number %d" srcImg.Num, "No resolution defined", MessageBoxButton.OK, MessageBoxImage.Information) |> ignore - yield None + None } |> Seq.takeWhile (fun e -> e.IsSome) |> Seq.map (fun e -> e.Value) |> List.ofSeq if parameters.Count () <> sourceImagesControls.Count () then @@ -125,7 +118,7 @@ let showWindow (parent : Window) (state : State.State) : bool = for srcImg, selected, parameters in imagesParameters do srcImg.Config.Parameters <- parameters // Save parameters. if selected then - yield string srcImg.Num, srcImg.Config, srcImg.Img + string srcImg.RomanNum, srcImg.Config, srcImg.Img ] if imagesToProcess.IsEmpty then @@ -148,7 +141,7 @@ let showWindow (parent : Window) (state : State.State) : bool = match maybeResults with | Some results -> for id, cells in results do - state.SetResult (int id) cells + state.SetResult id cells Logger.Log.Info "All analyses terminated successfully" atLeastOneAnalysisPerformed <- true analysisPerformed <- true