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];
|
}
|
}
|
}
|