| 1 |
Public Class frmPromote |
| 2 |
|
| 3 |
Private _imageLoader As ImageLoader = ImageLoader.GetInstance |
| 4 |
|
| 5 |
Public Property isPromoted As Boolean = True |
| 6 |
|
| 7 |
Private boardBitmap As Bitmap |
| 8 |
|
| 9 |
Private promoteKomaBitmap As Bitmap |
| 10 |
|
| 11 |
Private normalKomaBitmap As Bitmap |
| 12 |
|
| 13 |
Private highlightBitmap As Bitmap |
| 14 |
|
| 15 |
Public Sub New(normalKomaValue As Byte, x As Integer, y As Integer) |
| 16 |
Me.InitializeComponent() |
| 17 |
Dim promoteKomaValue As Byte = Board.KomaUtil.PromoteKomaValue(normalKomaValue) |
| 18 |
|
| 19 |
Me.boardBitmap = _imageLoader.BoardBitmap |
| 20 |
Me.promoteKomaBitmap = _imageLoader.GetKomaImage(promoteKomaValue) |
| 21 |
Me.normalKomaBitmap = _imageLoader.GetKomaImage(normalKomaValue) |
| 22 |
Me.highlightBitmap = _imageLoader.HighLightBitmap |
| 23 |
|
| 24 |
Me.Location = New Point(x, y) |
| 25 |
End Sub |
| 26 |
|
| 27 |
Private Sub PromoteForm_Load(sender As Object, e As EventArgs) Handles Me.Load |
| 28 |
komaPictureBox.Size = New Size(highlightBitmap.Size.Width * 2, highlightBitmap.Height) |
| 29 |
Dim width As Integer = Me.komaPictureBox.Width + SystemInformation.FixedFrameBorderSize.Width * 2 |
| 30 |
Dim height As Integer = Me.komaPictureBox.Height + SystemInformation.CaptionHeight + SystemInformation.FixedFrameBorderSize.Height * 2 |
| 31 |
Me.Size = New Size(width, height) |
| 32 |
Dim p As Point = New Point(Me.komaPictureBox.Left + Me.komaPictureBox.Width \ 4, Me.komaPictureBox.Top + Me.komaPictureBox.Height \ 2) |
| 33 |
Cursor.Position = Me.komaPictureBox.PointToScreen(p) |
| 34 |
End Sub |
| 35 |
|
| 36 |
Private Sub komaPictureBox_Paint(sender As Object, e As PaintEventArgs) Handles komaPictureBox.Paint |
| 37 |
Dim rectangle As Rectangle = New Rectangle(New Point(0, 0), Me.komaPictureBox.Size) |
| 38 |
Dim rectangle2 As Rectangle = New Rectangle(New Point(-1, -1), Me.promoteKomaBitmap.Size) |
| 39 |
Dim rectangle3 As Rectangle = New Rectangle(New Point(rectangle2.Right - 2, -1), Me.normalKomaBitmap.Size) |
| 40 |
e.Graphics.DrawImage(Me.boardBitmap, rectangle, rectangle, GraphicsUnit.Pixel) |
| 41 |
e.Graphics.DrawImage(Me.highlightBitmap, If(Me.isPromoted, rectangle2, rectangle3)) |
| 42 |
e.Graphics.DrawImage(Me.promoteKomaBitmap, rectangle2) |
| 43 |
e.Graphics.DrawImage(Me.normalKomaBitmap, rectangle3) |
| 44 |
End Sub |
| 45 |
|
| 46 |
Private Sub komaPictureBox_Click(sender As Object, e As EventArgs) Handles komaPictureBox.Click |
| 47 |
If (CType(e, MouseEventArgs)).Button = MouseButtons.Left Then |
| 48 |
If (CType(e, MouseEventArgs)).X < Me.promoteKomaBitmap.Width - 2 Then |
| 49 |
Me.isPromoted = True |
| 50 |
Else |
| 51 |
Me.isPromoted = False |
| 52 |
End If |
| 53 |
Me.Close() |
| 54 |
End If |
| 55 |
End Sub |
| 56 |
End Class |