public static void SaveMapPath(MapPath path, string filename) { using (StreamWriter w = new StreamWriter(filename)) { XmlSerializer s = new XmlSerializer(typeof(MapPath)); s.Serialize(w, path); } }
private void LoadMapPaths(Map map) { currentMapPaths.Clear(); foreach (string pathId in map.PathIds.ToArray()) { MapPath path = LoadSave.LoadMapPath(Globals.MapPathsDir + pathId); if (path != null) { currentMapPaths.Add(path); if (Globals.IsDebugMode) { DrawPath(path, bluePen); } } else { throw new Exception("MapPath returned is null. This should ne ver happen. Please contact administrator."); } } // Load navigator paths in the current map currentNavigatorPaths.Clear(); foreach (string pathId in map.PathIds.ToArray()) { foreach (NavigatorPath path in Globals.NavigatorPlace.Paths) { if (path.Id == pathId) { currentNavigatorPaths.Add(pathId, path); break; } } } }
private void DrawPath(MapPath mapPath, Pen pen) { // Draw map path points foreach (MapPoint point in mapPath.Points) { float x = point.X * ((float)(pbMap.Width + (zoomIndex * zoomIncrement)) / actualMapImage.Width); float y = point.Y * ((float)(pbMap.Height + (zoomIndex * zoomIncrement)) / actualMapImage.Height); DrawPoint(x, y, pen); } pbMap.Refresh(); }
public static MapPath LoadMapPath(string filename) { MapPath path = null; if (File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) { using (XmlTextReader xr = new XmlTextReader(sr)) { XmlSerializer xs = new XmlSerializer(typeof(MapPath)); if (xs.CanDeserialize(xr)) { path = (MapPath)xs.Deserialize(xr); } } } } return(path); }