3 edited tags
| link
2 Indented code
source | link

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint Dim mDestRect As Rectangle

Dim mX As Int32 = 0 Dim mY As Int32 = 0

Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point) Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black)) For row As Int32 = 0 To 9 For column As Int32 = 0 To 9

  If (row Mod 2) = 1 Then
    mX = (column * mTileWidth) + 32
  Else
      mX = column * mTileWidth
  End If

  mY = (row * mTileHeight) - (row * 16)


  mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
  e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)


 Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
 e.Graphics.FillEllipse(mBrush, mREct)

 TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

 Next column
Next row

End Using End Using End Sub

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
  Dim mDestRect As Rectangle

  Dim mX As Int32 = 0
  Dim mY As Int32 = 0

  Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point)
   Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black))
    For row As Int32 = 0 To 9
     For column As Int32 = 0 To 9

      If (row Mod 2) = 1 Then
        mX = (column * mTileWidth) + 32
      Else
          mX = column * mTileWidth
      End If

      mY = (row * mTileHeight) - (row * 16)


      mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
      e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)


     Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
     e.Graphics.FillEllipse(mBrush, mREct)

     TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

     Next column
    Next row
   End Using
  End Using
 End Sub

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint Dim mDestRect As Rectangle

Dim mX As Int32 = 0 Dim mY As Int32 = 0

Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point) Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black)) For row As Int32 = 0 To 9 For column As Int32 = 0 To 9

  If (row Mod 2) = 1 Then
    mX = (column * mTileWidth) + 32
  Else
      mX = column * mTileWidth
  End If

  mY = (row * mTileHeight) - (row * 16)


  mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
  e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)


 Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
 e.Graphics.FillEllipse(mBrush, mREct)

 TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

 Next column
Next row

End Using End Using End Sub

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
  Dim mDestRect As Rectangle

  Dim mX As Int32 = 0
  Dim mY As Int32 = 0

  Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point)
   Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black))
    For row As Int32 = 0 To 9
     For column As Int32 = 0 To 9

      If (row Mod 2) = 1 Then
        mX = (column * mTileWidth) + 32
      Else
          mX = column * mTileWidth
      End If

      mY = (row * mTileHeight) - (row * 16)


      mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
      e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)


     Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
     e.Graphics.FillEllipse(mBrush, mREct)

     TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

     Next column
    Next row
   End Using
  End Using
 End Sub
1
source | link

hexagonal grid Mouse over

enter image description here

I've been trying to workout the code that calculates the correct row and column in the mouse is over event the following is the code I'm using to draw the grid Tile are 64x64.

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint Dim mDestRect As Rectangle

Dim mX As Int32 = 0 Dim mY As Int32 = 0

Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point) Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black)) For row As Int32 = 0 To 9 For column As Int32 = 0 To 9

  If (row Mod 2) = 1 Then
    mX = (column * mTileWidth) + 32
  Else
      mX = column * mTileWidth
  End If

  mY = (row * mTileHeight) - (row * 16)


  mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
  e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)


 Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
 e.Graphics.FillEllipse(mBrush, mREct)

 TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

 Next column
Next row

End Using End Using End Sub

can anybody help please