/// <summary> /// Draws a dot and the name of the star if a star exists in the current position. /// </summary> /// <param name="e"></param> private void DrawStar(object sender, SingleHexagonDrawEventArgs e) { Star star; int halfStar = starDotDiameter / 2; using (SectorContext db = new SectorContext()) { star = (from s in db.stars where ((s.locX == e.column) && (s.locY == e.row)) select s).FirstOrDefault(); } if (star != null) { e.gr.FillEllipse(Brushes.Black, e.hex.center.X - halfStar, e.hex.center.Y - halfStar, starDotDiameter, starDotDiameter); using (StringFormat sf = new StringFormat()) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; PointF textPoint = e.hex.center; textPoint.Y += halfStar + starTextOffset + (grid.font.Size / 2); e.gr.DrawString(star.name, grid.font, Brushes.Black, textPoint, sf); } } }
/// <summary> /// Draw labels on the hexes. /// </summary> /// <param name="e"></param> /// <remarks>This is placed in the form just to display adding code to the hex drawing</remarks> private void DrawHexLabel(object sender, SingleHexagonDrawEventArgs e) { // Label the hexagon using (StringFormat sf = new StringFormat()) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Far; string label = String.Format("0{0}0{1}", e.column, e.row); // Center + half height PointF labelPoint = e.hex.center; labelPoint.Y += e.grid.hexHeight / 2; e.gr.DrawString(label, e.grid.font, Brushes.Black, labelPoint, sf); } }