/// <summary> /// Creating a new document using the specified map, route, laps, initial transformation matrix, projection origin and document settings, and adding one new session with the specified route and laps. /// </summary> /// <param name="map"></param> /// <param name="route"></param> /// <param name="laps"></param> /// <param name="initialTransformationMatrix"></param> /// <param name="projectionOrigin"></param> /// <param name="settings"></param> public Document(Map map, Route route, LapCollection laps, GeneralMatrix initialTransformationMatrix, LongLat projectionOrigin, DocumentSettings settings) { Map = map; sessions.Add(new Session(route, laps, map.Image.Size, initialTransformationMatrix, projectionOrigin, settings.DefaultSessionSettings)); this.settings = settings; UpdateDocumentToCurrentVersion(this); }
/// <summary> /// Creates a shallow copy. /// </summary> /// <returns></returns> public SessionCollection Copy() { var copy = new SessionCollection(); foreach (var s in sessions) { copy.Add(s); } return(copy); }
private static SessionCollection ReadSessions(BinaryReader reader) { var sessions = new SessionCollection(); var sessionCount = reader.ReadUInt32(); for (int i = 0; i < sessionCount; i++) { var tag = (Tags)reader.ReadByte(); var tagLength = Convert.ToInt32(reader.ReadUInt32()); switch (tag) { case Tags.Session: sessions.Add(ReadSession(reader, tagLength)); break; default: reader.BaseStream.Position += tagLength; break; } } return(sessions); }
// todo: skip showRouteLine parameter, use RouteDrawingMode instead public Bitmap CreateMapAndRouteImage(bool showRouteLine, double zoomValue, Session sessionToDraw, List <int> legsToDraw, double frameWidth, WaypointAttribute colorCodingAttribute, WaypointAttribute?secondaryColorCodingAttribute, RouteDrawingMode mode, SessionSettings sessionSettings) { RectangleD frame = GetFrame(zoomValue, sessionToDraw, legsToDraw, frameWidth, colorCodingAttribute, mode); var sc = new SessionCollection(); sc.Add(sessionToDraw); var wholeImage = CreateMapAndRouteImage(true, zoomValue, sc, colorCodingAttribute, secondaryColorCodingAttribute, mode, sessionSettings); AdjustFrameToImage(frame, wholeImage); var croppedImage = new Bitmap( Convert.ToInt32(Math.Ceiling(frame.Right) - Math.Floor(frame.Left)), Convert.ToInt32(Math.Ceiling(frame.Bottom) - Math.Floor(frame.Top))); var croppedImageGraphics = Graphics.FromImage(croppedImage); croppedImageGraphics.DrawImage( wholeImage, -Convert.ToInt32(Math.Floor(frame.Left)), -Convert.ToInt32(Math.Floor(frame.Top))); croppedImageGraphics.Dispose(); wholeImage.Dispose(); return(croppedImage); }