45025366d91c3eb4d78533cb5ac35b3f49b6bf1d
[master-thesis.git] / Parasitemia / Parasitemia / GUI / State.fs
1 module Parasitemia.GUI.State
2
3 open System.Collections.Generic
4
5 open Emgu.CV
6 open Emgu.CV.Structure
7
8 open Types
9
10 type State () =
11 let sourceImages = List<SourceImage>()
12 let mutable currentImage = -1
13
14 member val FilePath: string = "" with get, set
15 member val PatientID: string = "" with get, set
16
17 member this.Save () =
18 let data = { Pia.sources = List.ofSeq sourceImages; Pia.patientID = this.PatientID }
19 Pia.save this.FilePath data
20
21 member this.Load () =
22 let data = Pia.load this.FilePath
23 this.PatientID <- data.patientID
24 sourceImages.Clear()
25 sourceImages.InsertRange(0, data.sources)
26
27 member this.AddSourceImage (filePath: string) : SourceImage =
28 let srcImg = { num = sourceImages.Count + 1; rbcs = []; img = new Image<Bgr, byte>(filePath) }
29 sourceImages.Add(srcImg)
30 if sourceImages.Count = 1
31 then
32 currentImage <- 1
33 srcImg
34
35 member x.SourceImages : SourceImage seq =
36 sourceImages :> SourceImage seq
37
38 member this.Reset () =
39 this.PatientID <- ""
40 sourceImages.Clear()