X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FAnalysis.fs;h=25060157c7b527e120ee38767ee53b3b8cd3bcb0;hb=2e3cd07dd099944059ef5e7a7f5ef57ffe3d677b;hp=70d9ef0ec3323e90d17d422ac09d58fd32294fb0;hpb=23466ba92c5595f6c0b9f97c86a221a4e5ffebe9;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaUI/Analysis.fs b/Parasitemia/ParasitemiaUI/Analysis.fs index 70d9ef0..2506015 100644 --- a/Parasitemia/ParasitemiaUI/Analysis.fs +++ b/Parasitemia/ParasitemiaUI/Analysis.fs @@ -21,8 +21,8 @@ open Types let showWindow (parent: Window) (state: State.State) : bool = let win = Views.AnalysisWindow() win.Root.Owner <- parent - win.Root.Left <- parent.Left + parent.ActualWidth / 2. - win.Root.Width / 2. - win.Root.Top <- parent.Top + parent.ActualHeight / 2. - win.Root.Height / 2. + win.Root.Left <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Left) + parent.ActualWidth / 2. - win.Root.Width / 2. + win.Root.Top <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Top) + parent.ActualHeight / 2. - win.Root.Height / 2. let logListener = { new Logger.IListener with @@ -60,11 +60,15 @@ let showWindow (parent: Window) (state: State.State) : bool = imageSourceSelection.lblDateLastAnalysis.Content <- if srcImg.dateLastAnalysis.Ticks = 0L then "" else srcImg.dateLastAnalysis.ToString() imageSourceSelection.txtResolution.Text <- if srcImg.dateLastAnalysis.Ticks = 0L then "" else srcImg.config.Parameters.resolution.ToString() - imageSourceSelection.menuZoom50X.Click.AddHandler(fun obj args -> imageSourceSelection.txtResolution.Text <- "230000") - imageSourceSelection.menuZoom100X.Click.AddHandler(fun obj args -> imageSourceSelection.txtResolution.Text <- "460000") - imageSourceSelection.butDPICalculator.Click.AddHandler(fun obj args -> - match DPICalculator.showWindow win.Root with + for ppi in Utils.predefinedPPI do + let menu = MenuItem() + menu.Header <- ppi.ToString() + menu.Click.AddHandler(fun obj args -> imageSourceSelection.txtResolution.Text <- ppi.ppi.ToString()) + imageSourceSelection.predefinedValuesMenu.Items.Add(menu) |> ignore + + imageSourceSelection.butPPICalculator.Click.AddHandler(fun obj args -> + match PPICalculator.showWindow win.Root with | Some resolution -> imageSourceSelection.txtResolution.Text <- resolution.ToString() | None -> ()) @@ -128,17 +132,18 @@ let showWindow (parent: Window) (state: State.State) : bool = | Some results -> for id, cells in results do state.SetResult (int id) cells - - win.Root.Dispatcher.Invoke(fun () -> - win.stackSourceImagesSelection.IsEnabled <- true - win.butStart.IsEnabled <- true - win.butClose.Content <- "Close" - updateSourceImages ()) - Logger.Log.User("All analyses terminated successfully") atLeastOneAnalysisPerformed <- true analysisPerformed <- true - | None -> ()) + | None -> + Logger.Log.User("Analysis aborted") + + win.Root.Dispatcher.Invoke(fun () -> + win.progress.Value <- if maybeResults.IsSome then 100. else 0. + win.stackSourceImagesSelection.IsEnabled <- true + win.butStart.IsEnabled <- true + win.butClose.Content <- "Close" + updateSourceImages ())) } |> Async.Start | _ -> ()) @@ -151,5 +156,6 @@ let showWindow (parent: Window) (state: State.State) : bool = lock monitor (fun () -> if not analysisPerformed then + // To cancel the current analysis if one is running on the next call to the progress function. analysisCancelled <- true atLeastOneAnalysisPerformed)