private Map GenerateRoads(Map map) { map.Roads = new System.Data.Objects.DataClasses.EntityCollection<CommonLayer.Road>(); //List to save the Villages that we already created roads for List<Village> _prevCities = new List<Village>(); foreach (Village village in map.Village) { foreach (Village pV in _prevCities) { Road r = new Road(); r.ID = Guid.NewGuid(); r.VillageFrom = pV.ID; r.VillageTo = village.ID; r.VillFrom = pV; r.VillTo = village; r.Distance = (int)CalculateDistance(new Point(pV.XCoor, pV.YCoor), new Point(village.XCoor, village.YCoor)); //Add Roads to Map map.Roads.Add(r); } _prevCities.Add(village); } return map; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Session["Map"] = new CommonLayer.Map(); Session["VillageList"] = new List<Village>(); Session["RoadList"] = new List<Road>(); BindDropDown(); } }
public Map GenerateMap(int width, int height, int number) { Map map = new Map(); map.ID = Guid.NewGuid(); //Call the method to generate Villages and add them to the map map = GenerateVillages(number,map,width,height); //Call the method to generate Roads and add them to the map map = GenerateRoads(map); return map; }
public void DrawMap(Map map) { StringBuilder sb = new StringBuilder(); sb.Append("<script>"); sb.Append("var c = document.getElementById(\"myCanvas\");"); sb.Append("var ctx = c.getContext(\"2d\");"); _DrawRoads(map.Roads.ToList(), sb); DrawVillages(map.Village.ToList(), sb); sb.Append("</script>"); ClientScript.RegisterStartupScript(this.GetType(), "TestScript", sb.ToString()); }
public void UpdateMap(Map p) { this.Entities.SaveChanges(); }
public void DeleteMap(Map p) { this.Entities.Map.DeleteObject(p); this.Entities.SaveChanges(); }
public void AddMap(Map p) { this.Entities.Map.AddObject(p); this.Entities.SaveChanges(); }
/// <summary> /// Save the map to the database /// </summary> /// <param name="map"></param> public void Save(Map map) { new DAMap().AddMap(map); }
/// <summary> /// Create a new Map object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> public static Map CreateMap(global::System.Guid id, global::System.String name) { Map map = new Map(); map.ID = id; map.Name = name; return map; }
/// <summary> /// Deprecated Method for adding a new object to the Map EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMap(Map map) { base.AddObject("Map", map); }