+ let updateSourceImages () =
+ stackImagesSourceSelection.Children.Clear()
+ let width = int stackImagesSourceSelection.ActualWidth
+ for srcImg in state.SourceImages do
+ let imageSourceSelection = Views.ImageSourceSelection(Tag = srcImg, Margin = Thickness(3.))
+
+ let updateResolution () =
+ match parseAndValidatePPI imageSourceSelection.txtResolution.Text with
+ | Some resolution -> srcImg.config.Parameters <- { srcImg.config.Parameters with resolution = resolution * 1.<ppi> }
+ | None -> ()
+
+ imageSourceSelection.txtImageNumber.Text <- srcImg.num.ToString()
+ 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<bool>(srcImg.dateLastAnalysis.Ticks = 0L)
+ imageSourceSelection.lblDateLastAnalysis.Content <- if srcImg.dateLastAnalysis.Ticks = 0L then "<Never>" else srcImg.dateLastAnalysis.ToString()
+
+ imageSourceSelection.txtResolution.Text <- srcImg.config.Parameters.resolution.ToString()
+ imageSourceSelection.menuZoom50X.Click.AddHandler(fun obj args -> imageSourceSelection.txtResolution.Text <- "200000"; updateResolution ())
+ imageSourceSelection.menuZoom100X.Click.AddHandler(fun obj args -> imageSourceSelection.txtResolution.Text <- "400000"; updateResolution ())
+
+ imageSourceSelection.txtResolution.PreviewTextInput.AddHandler(fun obj args ->
+ let text = imageSourceSelection.txtResolution.Text + args.Text
+ args.Handled <- match parseAndValidatePPI text with Some _ -> false | None -> true)
+
+ imageSourceSelection.imagePreview.MouseLeftButtonDown.AddHandler(fun obj args ->
+ let checkbox = imageSourceSelection.chkSelection
+ checkbox.IsChecked <- Nullable<bool>(not (checkbox.IsChecked.HasValue && checkbox.IsChecked.Value)))
+
+ imageSourceSelection.txtResolution.LostFocus.AddHandler(fun obj args -> updateResolution ())
+
+ stackImagesSourceSelection.Children.Add(imageSourceSelection) |> ignore
+