Update coding style.
[master-thesis.git] / Parasitemia / ParasitemiaUI / PiaZ.fs
index 0215254..92ebbe0 100644 (file)
@@ -56,26 +56,26 @@ let currentFileVersion = 2
 /// <param name="data"></param>
 /// <exception cref="System.IOException">If the file cannot be written</exception>
 let save (filePath : string) (data : DocumentData) =
-    use file = ZipFile.Open(filePath, ZipArchiveMode.Update)
+    use file = ZipFile.Open (filePath, ZipArchiveMode.Update)
 
     for e in List.ofSeq file.Entries do // 'ofSeq' to not iterate a collection currently modified.
-        e.Delete()
+        e.Delete ()
 
     // Main JSON file.
-    let mainEntry = file.CreateEntry(mainEntryName, CompressionLevel.Fastest)
-    use mainEntryWriter = new StreamWriter(mainEntry.Open())
-    mainEntryWriter.Write(JsonConvert.SerializeObject({ patientID = data.patientID; fileVersion = currentFileVersion }))
+    let mainEntry = file.CreateEntry (mainEntryName, CompressionLevel.Fastest)
+    use mainEntryWriter = new StreamWriter (mainEntry.Open ())
+    mainEntryWriter.Write (JsonConvert.SerializeObject ({ patientID = data.patientID; fileVersion = currentFileVersion }))
 
     // Write each images and the associated information.
     for srcImg in data.images do
         let imgFilename = (string srcImg.num) + imageExtension
-        let imgEntry = file.CreateEntry(imgFilename, CompressionLevel.NoCompression) // FIXME: It seems a compression is applied to this file despite of the 'NoCompression' flag.
-        srcImg.img.ToBitmap().Save(imgEntry.Open(), System.Drawing.Imaging.ImageFormat.Tiff)
+        let imgEntry = file.CreateEntry (imgFilename, CompressionLevel.NoCompression) // FIXME: It seems a compression is applied to this file despite of the 'NoCompression' flag.
+        srcImg.img.ToBitmap().Save (imgEntry.Open (), System.Drawing.Imaging.ImageFormat.Tiff)
 
-        let imgJSONEntry = file.CreateEntry(imgFilename + ".json", CompressionLevel.Fastest)
-        use imgJSONFileWriter = new StreamWriter(imgJSONEntry.Open())
-        imgJSONFileWriter.Write(
-            JsonConvert.SerializeObject(
+        let imgJSONEntry = file.CreateEntry (imgFilename + ".json", CompressionLevel.Fastest)
+        use imgJSONFileWriter = new StreamWriter (imgJSONEntry.Open ())
+        imgJSONFileWriter.Write (
+            JsonConvert.SerializeObject (
                 {
                     num = srcImg.num
                     name = srcImg.name
@@ -103,11 +103,11 @@ let updateDocumentData (fromVersion : int) (toVersion : int) (data : DocumentDat
 /// <param name="filePath"></param>
 /// <exception cref="System.IOException">If the file cannot be read</exception>
 let load (filePath : string) (defaultConfig : ParasitemiaCore.Config.Config) : DocumentData =
-    use file = ZipFile.Open(filePath, ZipArchiveMode.Read)
+    use file = ZipFile.Open (filePath, ZipArchiveMode.Read)
 
-    let mainEntry = file.GetEntry(mainEntryName)
-    use mainEntryReader = new StreamReader(mainEntry.Open())
-    let info = JsonConvert.DeserializeObject<JSONInformation>(mainEntryReader.ReadToEnd())
+    let mainEntry = file.GetEntry (mainEntryName)
+    use mainEntryReader = new StreamReader (mainEntry.Open ())
+    let info = JsonConvert.DeserializeObject<JSONInformation> (mainEntryReader.ReadToEnd ())
 
     updateDocumentData info.fileVersion currentFileVersion
         {
@@ -116,15 +116,15 @@ let load (filePath : string) (defaultConfig : ParasitemiaCore.Config.Config) : D
                 [
                     let mutable imgNum = 0
                     for imgEntry in file.Entries do
-                        if imgEntry.Name.EndsWith(imageExtension) then
-                            use bitmap = new System.Drawing.Bitmap(imgEntry.Open(), false)
-                            let img = new Image<Bgr, byte>(bitmap)
+                        if imgEntry.Name.EndsWith (imageExtension) then
+                            use bitmap = new System.Drawing.Bitmap (imgEntry.Open (), false)
+                            let img = new Image<Bgr, byte> (bitmap)
                             imgNum <- imgNum + 1
-                            let imgJSONEntry = file.GetEntry(imgEntry.Name + ".json")
-                            use imgJSONFileReader = new StreamReader(imgJSONEntry.Open())
-                            let imgInfo = JsonConvert.DeserializeObject<JSONSourceImage>(imgJSONFileReader.ReadToEnd())
+                            let imgJSONEntry = file.GetEntry (imgEntry.Name + ".json")
+                            use imgJSONFileReader = new StreamReader (imgJSONEntry.Open ())
+                            let imgInfo = JsonConvert.DeserializeObject<JSONSourceImage> (imgJSONFileReader.ReadToEnd ())
 
-                            let config = defaultConfig.Copy()
+                            let config = defaultConfig.Copy ()
                             config.Parameters <-
                                 {
                                     ParasitemiaCore.Config.defaultParameters with