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.
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