cloudflight
2023-12-26 5fa6947054206e2e781eadd4effdcdf52eda28c4
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static Hydro.MapView.MapViewEnum;
 
namespace Hydro.MapView
{
    public class Default
    {
        static string _filePath = Path.Combine(Directory.GetCurrentDirectory(), @"default.ini");
        //public static string JunctionPre = "J";
        //public static string ReservoirPre = "R";
        //public static string TankPre = "T";
        //public static string PipePre = "P";
        //public static string ValvePre = "V";
        //public static string MeterPre = "M";
        //public static string RepeaterPre = "Repeater";
        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];
        }
    }
}