let run (defaultConfig : Config) (fileToOpen : string option) =
let app = new Application ()
let win = MainWindow ()
+ win.Title <- Constants.APPLICATION_NAME
let state = State.State defaultConfig
let mutable currentScale = 1.
statusMessageTimer.Start ()
let highlightRBC (rbc : RBC) (highlight : bool) =
- let strokeThickness = frameStrokeThickness ()
+ let highlightRBCFrame (rbcFrame : RBCFrame) (strokeThickness : float) =
+ if highlight then
+ rbcFrame.border.StrokeThickness <- 2. * 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<RBCFrame>).Concat(win.canvasCurrentImage.Children |> Seq.cast<RBCFrame>) do
+ for rbcFrame in win.stackRBC.Children |> Seq.cast<RBCFrame> 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<RBCFrame> 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)
updateDocumentStatus ()
let loadFile (filepath : string) =
+ let displayLoadingErrorMessage (message : string) =
+ MessageBox.Show (sprintf "The document cannot be loaded from \"%s\": %s" filepath message, "Error loading the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore
+
askSaveCurrent ()
let previousFilePath = state.FilePath
try
state.Load ()
updateGUI ()
with
+ | PiaZ.VersionFileNewerException fileVersion ->
+ state.FilePath <- previousFilePath
+ displayLoadingErrorMessage $"File version ({fileVersion}) is newer than supported one ({PiaZ.CURRENT_FILE_VERSION}), you may update Parasitemia to the latest version"
+
| :? IOException as ex ->
Log.Error "%O" ex
state.FilePath <- previousFilePath
- MessageBox.Show (sprintf "The document cannot be loaded from \"%s\"" filepath, "Error loading the document", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore
+ displayLoadingErrorMessage "IO Error"
let askLoadFile () =
let dialog = OpenFileDialog (Filter = PiaZ.filter)
MessageBox.Show (sprintf "The results cannot be exported in \"%s\"" state.FilePath, "Error exporting the files", MessageBoxButton.OK, MessageBoxImage.Error) |> ignore
let importImage () =
- let dialog = OpenFileDialog (Filter = "Image Files|*.png;*.jpg;*.tif;*.tiff", Multiselect = true)
+ let dialog = OpenFileDialog (Filter = "Image Files|*.png;*.jpg;.jpeg;.bmp;*.tif;*.tiff", Multiselect = true)
let res = dialog.ShowDialog ()
if res.HasValue && res.Value then
let noSourceImage = state.SourceImages.Count () = 0
// Save.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> saveCurrentDocument ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> saveCurrentDocument ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.S, Input.ModifierKeys.Control)
)
) |> ignore
// Save as.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> saveCurrentDocumentAsNewFile ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> saveCurrentDocumentAsNewFile ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.S, Input.ModifierKeys.Control ||| Input.ModifierKeys.Shift)
)
) |> ignore
// Open.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> askLoadFile ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> askLoadFile ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.O, Input.ModifierKeys.Control)
)
) |> ignore
// New file.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> newFile ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> newFile ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.N, Input.ModifierKeys.Control)
)
) |> ignore
// Export results.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> exportResults ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> exportResults ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.E, Input.ModifierKeys.Control)
)
) |> ignore
// Import an image.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> importImage ()), (fun obj -> true)),
+ Utils.FunCommand ((fun obj -> importImage ()), (fun obj -> true)),
Input.KeyGesture (Input.Key.A, Input.ModifierKeys.Control)
)
) |> ignore
// Show analysis dialog.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand ((fun obj -> showAnalysisWindow ()), (fun obj -> state.SourceImages.Count () > 0)),
+ Utils.FunCommand ((fun obj -> showAnalysisWindow ()), (fun obj -> state.SourceImages.Count () > 0)),
Input.KeyGesture (Input.Key.Y, Input.ModifierKeys.Control)
)
) |> ignore
// Toggle RBC highlight.
win.InputBindings.Add (
Input.KeyBinding (
- ViewModule.FunCommand (
+ Utils.FunCommand (
(
fun obj ->
win.menuHightlightRBC.IsChecked <- not win.menuHightlightRBC.IsChecked