1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| using Newtonsoft.Json;
|
| namespace HydroUI
| {
| [Serializable]
| public class Default
| {
| static string _filePath = Path.Combine(Directory.GetCurrentDirectory(), @"default.ini");
| public NodeViewModel junction;
| public ReservoirViewModel reservoir;
| public TankViewModel tank;
| public MeterViewModel meter;
| public NozzleViewModel nozzle;
| public LinkViewModel pipe;
| public ValveViewModel valve;
| public RepeaterViewModel repeater;
| public PumpViewModel pump;
| public static Default GetfaultINI()
| {
| StreamReader sr = new StreamReader(_filePath);
| string json = sr.ReadToEnd();
| sr.Close();
| return JsonConvert.DeserializeObject<Default>(json);
|
| }
| public void SaveFile()
| {
| StreamWriter sw = new StreamWriter(_filePath);
| sw.WriteLine(JsonConvert.SerializeObject(this));
| sw.Close();
| }
|
| public static Dictionary<MapObjectType, string> PreName = new Dictionary<MapObjectType, string>()
| {
| {MapObjectType.节点,"J" },
| {MapObjectType.水库,"R" },
| {MapObjectType.水池,"T" },
| {MapObjectType.水表,"M" },
| {MapObjectType.喷头,"N" },
| {MapObjectType.管线,"P" },
| {MapObjectType.阀门,"V" },
| {MapObjectType.重复器,"Rp" },
| {MapObjectType.水泵,"Pump" },
| {MapObjectType.阀门点,"Vn" },
| };
| public static string GetPreString(IBaseViewModel obj)
| {
| return PreName[obj.Type];
| }
| }
| }
|
|