public static PointObservation Load(XmlReader reader, Dictionary <Observation, string> observers) { PointObservation shape = new PointObservation(); LoadPositionalData(shape, reader); shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); observers.Add(shape, reader.GetAttribute("observer")); return(shape); }
public override void Render(Graphics graphics) { if (ShouldRender) { float scale = (float)Board.ZoomFactor, x = (float)Position.X * scale, y = -(float)Position.Y * scale; // TODO: only draw a line back to the parent unit if the parent unit is functioning as a first observation int index = Parent.Children.IndexOf(this) - 1; PointObservation previousObservation = index >= 0 ? Parent.Children[index] as PointObservation : null; Shape previousShape = previousObservation != null && previousObservation.Observer == Observer ? previousObservation : Parent; float prevX = (float)previousShape.Position.X * scale, prevY = -(float)previousShape.Position.Y * scale; graphics.DrawArrow(Board.observationPen, prevX, prevY, x, y); graphics.DrawCircle(Pen, x, y, 6); RenderTime(graphics, x, y + 8); } }
public static Shape Load(XmlReader reader, Dictionary <Observation, string> observers, Dictionary <string, UnitShape> unitsById) { Shape shape; switch (reader.LocalName) { case "circle": shape = CircleShape.Load(reader); break; case "line": shape = LineShape.Load(reader); break; case "unit": shape = UnitShape.Load(reader, observers, unitsById); break; case "bearingObservation": shape = BearingObservation.Load(reader, observers); break; case "pointObservation": shape = PointObservation.Load(reader, observers); break; case "waypoint": shape = Waypoint.Load(reader); break; default: throw new System.IO.InvalidDataException("Unknown shape tag: " + reader.LocalName); } reader.Read(); return(shape); }