| | |
| | | using static Hydro.Core.ObjectEnum; |
| | | using Hydro.MapView.Common; |
| | | using static Hydro.MapView.MapViewEnum; |
| | | using Hydro.CommonBase; |
| | | using CommonBase; |
| | | |
| | | namespace Hydro.MapView |
| | | { |
| | | public class MapViewNetWork : NetWork |
| | | public partial class MapViewNetWork : NetWork |
| | | { |
| | | bool use_old = false; |
| | | public string Name; |
| | | public NodeViewModel StartPoint { get; set; } |
| | | |
| | |
| | | /// <summary> |
| | | /// 核心承载字段 |
| | | /// </summary> |
| | | public new List<NodeViewModel> Nodes = new List<NodeViewModel>(); |
| | | //public new List<NodeViewModel> Nodes = new List<NodeViewModel>(); |
| | | |
| | | /// <summary> |
| | | /// 核心承载字段 |
| | | /// </summary> |
| | | public new List<LinkViewModel> Links = new List<LinkViewModel>(); |
| | | //public new List<LinkViewModel> Links = new List<LinkViewModel>(); |
| | | |
| | | public Dictionary<string, Dataset> dict_dataset;// = new Dictionary<string, Dataset>(); |
| | | public HashSet<string> Hash_ID; |
| | |
| | | public List<PumpNodeViewModel> Deserialized_pumpNodes { get; set; } |
| | | |
| | | public List<AreaViewModel> areas = new List<AreaViewModel>(); |
| | | |
| | | public bool ReadFromJson(string json) |
| | | { |
| | | var net = JsonConvert.DeserializeObject<MapViewNetWork>(json); |
| | | //net.junctions.Clear(); |
| | | //net.Nodes.Clear(); |
| | | junctions = net.Deserialized_junctions; |
| | | tanks = net.Deserialized_tanks; |
| | | reservoirs = net.Deserialized_reservoirs; |
| | | meters = net.Deserialized_meters; |
| | | nozzles = net.Deserialized_nozzles; |
| | | pipes = net.Deserialized_pipes; |
| | | valves = net.Deserialized_valves; |
| | | valveNodes = net.Deserialized_valveNodes; |
| | | repeaters = net.Deserialized_repeaters; |
| | | pumps = net.Deserialized_pumps; |
| | | pumpNodes = net.Deserialized_pumpNodes; |
| | | StartPoint = net.StartPoint; |
| | | EndPoint = net.EndPoint; |
| | | |
| | | return true; |
| | | } |
| | | public string WriteToJson() |
| | | { |
| | | var net = new MapViewNetWork(); |
| | | net.Deserialized_junctions = junctions; |
| | | net.Deserialized_tanks = tanks; |
| | | net.Deserialized_reservoirs = reservoirs; |
| | | net.Deserialized_meters = meters; |
| | | net.Deserialized_nozzles = nozzles; |
| | | net.Deserialized_pipes = pipes; |
| | | net.Deserialized_valves = valves; |
| | | //net.Deserialized_valveNodes = valveNodes; |
| | | net.Deserialized_repeaters = repeaters; |
| | | net.Deserialized_pumps = pumps; |
| | | net.StartPoint = StartPoint; |
| | | net.EndPoint = EndPoint; |
| | | //net.Deserialized_pumpNodes = pumpNodes; |
| | | string json = JsonConvert.SerializeObject(net); |
| | | return json; |
| | | } |
| | | |
| | | |
| | | public JunctionViewModel AddJunction(string ID, PointF position, float z = 0) |
| | | { |
| | |
| | | string DefaultString = Default.GetPreString(obj); |
| | | int i = 0; |
| | | string ID = obj.ID; |
| | | List<IBaseViewModel> objs; |
| | | //List<IBaseViewModel> objs; |
| | | ID = $"{DefaultString}{i}"; |
| | | //while ((objs = MapObjects.FindAll(p0 => p0.ID == ID)).Count>1 && objs[0]!=obj) |
| | | while (Hash_ID.Contains(ID)) |
| | |
| | | { |
| | | get |
| | | { |
| | | List<IBaseViewModel> objects = new List<IBaseViewModel>(); |
| | | List<BaseModel> objects = new List<BaseModel>(); |
| | | objects.AddRange(Nodes); |
| | | objects.AddRange(Links); |
| | | return objects; |
| | | return objects.Select(o=>(IBaseViewModel)o).ToList(); |
| | | } |
| | | } |
| | | public void Rename() |
| | |
| | | k1++; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |