Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
 public void UpdateMap(Map p)
 {
     this.Entities.SaveChanges();
 }
Ejemplo n.º 6
0
 public void DeleteMap(Map p)
 {
     this.Entities.Map.DeleteObject(p);
     this.Entities.SaveChanges();
 }
Ejemplo n.º 7
0
 public void AddMap(Map p)
 {
     this.Entities.Map.AddObject(p);
     this.Entities.SaveChanges();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Save the map to the database
 /// </summary>
 /// <param name="map"></param>
 public void Save(Map map)
 {
     new DAMap().AddMap(map);
 }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Map EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMap(Map map)
 {
     base.AddObject("Map", map);
 }