private void DrawObject() { try { drawMapData.ObjectAndSection = new Bitmap(drawMapData.MapSize.Width, drawMapData.MapSize.Height); drawMapData.Graphics_ObjectAndSection = Graphics.FromImage(drawMapData.ObjectAndSection); drawMapData.Graphics_ObjectAndSection.Clear(Color.White); Point[] pointArray; int centerX; int centerY; for (int i = 0; i < localData.TheMapInfo.ObjectDataList.Count; i++) { pointArray = new Point[localData.TheMapInfo.ObjectDataList[i].PositionList.Count]; centerX = 0; centerY = 0; for (int j = 0; j < localData.TheMapInfo.ObjectDataList[i].PositionList.Count; j++) { pointArray[j] = new Point((int)drawMapData.TransferX(localData.TheMapInfo.ObjectDataList[i].PositionList[j].X), (int)drawMapData.TransferY(localData.TheMapInfo.ObjectDataList[i].PositionList[j].Y)); centerX += pointArray[j].X; centerY += pointArray[j].Y; } centerX /= localData.TheMapInfo.ObjectDataList[i].PositionList.Count; centerY /= localData.TheMapInfo.ObjectDataList[i].PositionList.Count; drawMapData.Graphics_ObjectAndSection.DrawPolygon(Pens.Black, pointArray); int size = 12; Font font = new Font("微軟正黑體", size); SizeF s = drawMapData.Graphics_ObjectAndSection.MeasureString(localData.TheMapInfo.ObjectDataList[i].Name, font); float x = centerX - s.Width / 2; float y = centerY - s.Height / 2; drawMapData.Graphics_ObjectAndSection.DrawString(localData.TheMapInfo.ObjectDataList[i].Name, font, Brushes.Black, new PointF(x, y)); } } catch (Exception ex) { mainFlow.WriteLog(3, "", String.Concat("Exception : ", ex.ToString())); } }
public void UpdateLocate(MapAGVPosition agvPosition) { if (agvPosition == null) { this.Visible = false; } else { this.Visible = true; this.Location = new Point((int)(drawMapData.TransferX(agvPosition.Position.X) - deltaX), (int)(drawMapData.TransferY(agvPosition.Position.Y) - deltaX)); } }