#Region "LICENSE"
'Copyright 2009 by Codemonkey85
'
'This library is free software: you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation, either version 3 of the License, or
'(at your option) any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details.
'
'You should have received a copy of the GNU General Public License
'along with this program.  If not, see <http://www.gnu.org/licenses/>.
#End Region

#Region "Imports Region"
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Threading
Imports System.Net
Imports System
Imports System.Collections.Generic
Imports PokemonDSLib
Imports PokemonDSLib.PokemonLib
Imports System.Windows.Forms
Imports System.Drawing

#End Region

Public Class PKMViewer

    ''' <summary>
    ''' The variable declaration section.
    ''' </summary>
    ''' <remarks></remarks>
#Region "Variable Declarations"

    Public PKM As New Pokemon
    Public PKMArray() As Pokemon
    Public PKMIndex As Integer = 0

#End Region

#Region "TO-DO LIST"

    'TODO: THE TO-DO LIST
    'TODO: Pokémon contest move descriptions / appeals
    '
    'Egg trainer memo
    'Use location met/egg info/hometown to elaborate (Egg/Pal Park/Event)
    '
    'Things my program will (eventually!) let you change in .PKM files:
    '
    'In party / in storage (if Trainer saved at Pokémon Center)
    'Location in storage (if Trainer saved at Pokémon Center)
    'Location in party
    'Nickname (if Trainer ID and Secret ID match PKM)
    'Held Item
    'Markings
    '
    'http://www.upokecenter.com/games/dp/guides/
    '
    'http://www.upokecenter.com/games/rs/guides/id.html
    '
    'http://www.smogon.com/forums/showthread.php?t=45230
    '
    'http://www.pokemonelite2000.com/sprites.html
#End Region

    ''' <summary>
    ''' Set the form controls' text to "" and images to nothing.
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub BlankStuff()

        lblPokdexNo.ForeColor = Color.Black
        lblName.ForeColor = Color.Black

        lblIDNo.Text = ""
        lblPokdexNo.Text = ""
        lblOT.Text = ""
        pbBall.Image = Nothing

        pbTNL.Maximum = 10
        pbTNL.Minimum = 0
        pbTNL.Value = 0

        pbHP.Maximum = 10
        pbHP.Minimum = 0
        pbHP.Value = 0

        lblHeldItem.Text = ""

        pbStatus.Image = Nothing
        pbShiny.Image = Nothing

        pbItem.Image = Nothing
        pbSprite.Image = Nothing

        lblCMove1Name.Text = ""
        lblCMove2Name.Text = ""
        lblCMove3Name.Text = ""
        lblCMove4Name.Text = ""

        For i As Integer = 1 To 80
            TryCast(GetControlByName("pbRib" & (i).ToString), PictureBox).Image = Nothing
        Next

        pbRib1.Tag = ""
        pbRib2.Tag = ""
        pbRib3.Tag = ""
        pbRib4.Tag = ""
        pbRib5.Tag = ""
        pbRib6.Tag = ""
        pbRib7.Tag = ""
        pbRib8.Tag = ""
        pbRib9.Tag = ""
        pbRib10.Tag = ""
        pbRib11.Tag = ""
        pbRib12.Tag = ""
        pbRib13.Tag = ""
        pbRib14.Tag = ""
        pbRib15.Tag = ""
        pbRib16.Tag = ""
        pbRib17.Tag = ""
        pbRib18.Tag = ""
        pbRib19.Tag = ""
        pbRib20.Tag = ""
        pbRib21.Tag = ""
        pbRib22.Tag = ""
        pbRib23.Tag = ""
        pbRib24.Tag = ""
        pbRib25.Tag = ""
        pbRib26.Tag = ""
        pbRib27.Tag = ""
        pbRib28.Tag = ""
        pbRib29.Tag = ""
        pbRib30.Tag = ""
        pbRib31.Tag = ""
        pbRib32.Tag = ""
        pbRib33.Tag = ""
        pbRib34.Tag = ""
        pbRib35.Tag = ""
        pbRib36.Tag = ""
        pbRib37.Tag = ""
        pbRib38.Tag = ""
        pbRib39.Tag = ""
        pbRib40.Tag = ""
        pbRib41.Tag = ""
        pbRib42.Tag = ""
        pbRib43.Tag = ""
        pbRib44.Tag = ""
        pbRib45.Tag = ""
        pbRib46.Tag = ""
        pbRib47.Tag = ""
        pbRib48.Tag = ""
        pbRib49.Tag = ""
        pbRib50.Tag = ""
        pbRib51.Tag = ""
        pbRib52.Tag = ""
        pbRib53.Tag = ""
        pbRib54.Tag = ""
        pbRib55.Tag = ""
        pbRib56.Tag = ""
        pbRib57.Tag = ""
        pbRib58.Tag = ""
        pbRib59.Tag = ""
        pbRib60.Tag = ""
        pbRib61.Tag = ""
        pbRib62.Tag = ""
        pbRib63.Tag = ""
        pbRib64.Tag = ""
        pbRib65.Tag = ""
        pbRib66.Tag = ""
        pbRib67.Tag = ""
        pbRib68.Tag = ""
        pbRib69.Tag = ""
        pbRib70.Tag = ""
        pbRib71.Tag = ""
        pbRib72.Tag = ""
        pbRib73.Tag = ""
        pbRib74.Tag = ""
        pbRib75.Tag = ""
        pbRib76.Tag = ""
        pbRib77.Tag = ""
        pbRib78.Tag = ""
        pbRib79.Tag = ""
        pbRib80.Tag = ""

        lblRibCount.Text = ""

        lblAbility.Text = ""
        lblAttack.Text = ""
        lblContestMoves1.Text = ""
        lblContestMoves2.Text = ""
        lblContestMoves3.Text = ""
        lblContestMoves4.Text = ""
        lblDefense.Text = ""
        lblHP.Text = ""
        pbCircle.Image = Nothing
        pbDiamond.Image = Nothing
        pbHeart.Image = Nothing
        pbStar.Image = Nothing
        pbSquare.Image = Nothing
        pbTriangle.Image = Nothing

        lblMoves1.Text = ""
        lblMoves2.Text = ""
        lblMoves3.Text = ""
        lblMoves4.Text = ""

        lblMove1Name.Text = ""
        lblMove1Pwr.Text = ""
        lblMove1Acc.Text = ""
        pbMove1Type.Image = Nothing

        lblMove2Name.Text = ""
        lblMove2Pwr.Text = ""
        lblMove2Acc.Text = ""
        pbMove2Type.Image = Nothing

        lblMove3Name.Text = ""
        lblMove3Pwr.Text = ""
        lblMove3Acc.Text = ""
        pbMove3Type.Image = Nothing

        lblMove4Name.Text = ""
        lblMove4Pwr.Text = ""
        lblMove4Acc.Text = ""
        pbMove4Type.Image = Nothing


        lblName.Text = ""
        lblNickName.Text = ""
        lblOT.ForeColor = Color.Black
        'lblRibbons.Text = ""
        lblSpAtk.Text = ""
        lblSpDef.Text = ""
        lblSpeed.Text = ""
        lblTrainerMemo.Text = ""
        pbType1.Image = Nothing
        pbType2.Image = Nothing
        pbBeauty.Value = 0
        pbCool.Value = 0
        pbCute.Value = 0
        pbGender.Image = Nothing
        pbPKRS.Image = Nothing
        pbSheen.Value = 0
        pbShiny.Image = Nothing
        pbSmart.Value = 0
        pbTough.Value = 0
        lblLevel.Text = ""
        lblEXP.Text = ""
        lblTNL.Text = ""
        lblBeauty.Text = ""
        lblCool.Text = ""
        lblCute.Text = ""
        lblTough.Text = ""
        lblSmart.Text = ""
        lblSheen.Text = ""

        pbMove1Var.ImageLocation = Nothing
        pbMove2Var.ImageLocation = Nothing
        pbMove3Var.ImageLocation = Nothing
        pbMove4Var.ImageLocation = Nothing

        lblMove1PP.Text = ""
        lblMove2PP.Text = ""
        lblMove3PP.Text = ""
        lblMove4PP.Text = ""

        lblAtkIV.Text = ""
        lblAtkEV.Text = ""
        lblHPIV.Text = ""
        lblHPEV.Text = ""
        lblDefIV.Text = ""
        lblDefEV.Text = ""
        lblSpdEV.Text = ""
        lblSpdIV.Text = ""
        lblSpAtkEV.Text = ""
        lblSpAtkIV.Text = ""
        lblSpDefIV.Text = ""
        lblSpDefEV.Text = ""

        lblHometown.Text = ""
        lblHiddenPowerPower.Text = ""
        lblHiddenPowerType.Text = ""
        lblWurmpleEvo.Text = ""
        lblFriendship.Text = ""
        pbHiddenPowerType.Image = Nothing
        lblCountry.Text = ""
        lblPID.Text = ""
        lblSecretID.Text = ""

        lblLocation.Text = ""

        pbMove1Var.Image = Nothing
        pbMove2Var.Image = Nothing
        pbMove3Var.Image = Nothing
        pbMove4Var.Image = Nothing

    End Sub

    Public Sub PKM_Read()
        'Try

        BlankStuff()

        PokemonLib.InitializeDictionaries()

        pbSprite.Image = PKM.Sprite
        lblCountry.Text = PKM.Origins.Country.Name
        lblHometown.Text = PKM.Origins.Hometown.Name
        pbPKRS.Image = Nothing

        If PKM.IsEgg Then

        Else

            With PKM.BattleStats.Current
                If .CurrentHP > 999 Or .MaxHP > 999 Or .Attack > 999 Or .Defense > 999 Or .Speed > 999 Or .SpAttack > 999 Or .SpDefense > 999 Or _
               .CurrentHP < 0 Or .MaxHP <= 0 Or .Attack <= 0 Or .Defense <= 0 Or .Speed <= 0 Or .SpAttack <= 0 Or .SpDefense <= 0 Then
                    PKM = PC_to_Party(PKM)
                End If
            End With

            pbGender.Image = PKM.Gender.Image
            Dim ShinyIMG As Bitmap
            If PKM.Shiny Then
                ShinyIMG = ShinyStar
                ShinyIMG.MakeTransparent(Color.White)
                pbShiny.Image = ShinyIMG
                lblPokdexNo.ForeColor = Color.Red
                lblName.ForeColor = Color.Red
            End If

            If PKM.Level = 100 Then
                pbTNL.Value = 0
            Else
                pbTNL.Maximum = PKM.TNL + PKM.EXP
                pbTNL.Minimum = 0
                pbTNL.Value = pbTNL.Maximum - (PKM.TNLPercent * pbTNL.Maximum)
            End If

            lblIDNo.Text = PKM.Trainer.ID.ToString("00000")
            lblPokdexNo.Text = UInt16.Parse(PKM.Species.ID).ToString("000")

            pbHP.Maximum = PKM.BattleStats.Current.MaxHP
            pbHP.Value = PKM.BattleStats.Current.CurrentHP

            If PKM.Item.Value > 0 Then
                lblHeldItem.Text = PKM.Item.Name
                pbItem.Image = PKM.Item.Image
            Else
                lblHeldItem.Text = "No Item"
            End If

            pbBall.Image = PKM.Ball.Image

            If PKM.Moves(0).Value > 0 Then _
            lblCMove1Name.Text = PKM.Moves(0).Name
            If PKM.Moves(1).Value > 0 Then _
            lblCMove2Name.Text = PKM.Moves(1).Name
            If PKM.Moves(2).Value > 0 Then _
            lblCMove3Name.Text = PKM.Moves(2).Name
            If PKM.Moves(3).Value > 0 Then _
            lblCMove4Name.Text = PKM.Moves(3).Name

            lblAbility.Text = PKM.Ability.Name & vbNewLine & vbNewLine & PKM.Ability.Description
            lblAttack.Text = PKM.BattleStats.Current.Attack
            lblContestMoves1.Text = ""
            lblContestMoves2.Text = ""
            lblContestMoves3.Text = ""
            lblContestMoves4.Text = ""
            lblDefense.Text = PKM.BattleStats.Current.Defense
            lblHP.Text = PKM.BattleStats.Current.CurrentHP & " / " & PKM.BattleStats.Current.MaxHP

            If PKM.Moves(0).Value > 0 Then _
            lblMoves1.Text = PKM.Moves(0).Description
            If PKM.Moves(1).Value > 0 Then _
            lblMoves2.Text = PKM.Moves(1).Description
            If PKM.Moves(2).Value > 0 Then _
            lblMoves3.Text = PKM.Moves(2).Description
            If PKM.Moves(3).Value > 0 Then _
            lblMoves4.Text = PKM.Moves(3).Description

            If PKM.Moves(0).Value > 0 Then
                lblMove1Name.Text = PKM.Moves(0).Name
                If PKM.Moves(0).Power = 1 Or PKM.Moves(0).Power = 0 Then
                    lblMove1Pwr.Text = "Power: -"
                Else
                    lblMove1Pwr.Text = "Power: " & PKM.Moves(0).Power
                End If
                If PKM.Moves(0).Accuracy = 0 Then
                    lblMove1Acc.Text = "Accuracy: -"
                Else
                    lblMove1Acc.Text = "Accuracy: " & (PKM.Moves(0).Accuracy / 100).ToString("p0")
                End If
                pbMove1Type.Image = PKM.Moves(0).Type.Image
            End If

            If PKM.Moves(1).Value > 0 Then
                lblMove2Name.Text = PKM.Moves(1).Name
                If PKM.Moves(1).Power = 1 Or PKM.Moves(1).Power = 0 Then
                    lblMove2Pwr.Text = "Power: -"
                Else
                    lblMove2Pwr.Text = "Power: " & PKM.Moves(1).Power
                End If
                If PKM.Moves(1).Accuracy = 0 Then
                    lblMove2Acc.Text = "Accuracy: -"
                Else
                    lblMove2Acc.Text = "Accuracy: " & (PKM.Moves(1).Accuracy / 100).ToString("p0")
                End If
                pbMove2Type.Image = PKM.Moves(1).Type.Image
            End If

            If PKM.Moves(2).Value > 0 Then
                lblMove3Name.Text = PKM.Moves(2).Name
                If PKM.Moves(1).Power = 1 Or PKM.Moves(1).Power = 0 Then
                    lblMove3Pwr.Text = "Power: -"
                Else
                    lblMove3Pwr.Text = "Power: " & PKM.Moves(1).Power
                End If
                If PKM.Moves(2).Accuracy = 0 Then
                    lblMove3Acc.Text = "Accuracy: -"
                Else
                    lblMove3Acc.Text = "Accuracy: " & (PKM.Moves(2).Accuracy / 100).ToString("p0")
                End If
                pbMove3Type.Image = PKM.Moves(2).Type.Image
            End If

            If PKM.Moves(3).Value > 0 Then
                lblMove4Name.Text = PKM.Moves(3).Name
                If PKM.Moves(3).Power = 1 Or PKM.Moves(3).Power = 0 Then
                    lblMove4Pwr.Text = "Power: -"
                Else
                    lblMove4Pwr.Text = "Power: " & PKM.Moves(3).Power
                End If
                If PKM.Moves(3).Accuracy = 0 Then
                    lblMove4Acc.Text = "Accuracy: -"
                Else
                    lblMove4Acc.Text = "Accuracy: " & (PKM.Moves(3).Accuracy / 100).ToString("p0")
                End If
                pbMove4Type.Image = PKM.Moves(3).Type.Image
            End If

            lblName.Text = UCase(PKM.Species.Name)
            lblNickName.Text = PKM.Nickname
            If PKM.Trainer.Gender.Value = Genders.Female Then
                lblOT.ForeColor = Color.Red
            Else
                lblOT.ForeColor = Color.Blue
            End If
            lblOT.Text = PKM.Trainer.Name

            For i As Integer = 0 To PKM.Ribbons.Names.Count - 1
                TryCast(GetControlByName("pbRib" & (i + 1).ToString), PictureBox).Image = PKM.Ribbons.Images(i)
                TryCast(GetControlByName("pbRib" & (i + 1).ToString), PictureBox).Tag = PKM.Ribbons.Names(i)
            Next

            lblRibCount.Text = PKM.Ribbons.Names.Count

            lblSpAtk.Text = PKM.BattleStats.Current.SpAttack
            lblSpDef.Text = PKM.BattleStats.Current.SpDefense
            lblSpeed.Text = PKM.BattleStats.Current.Speed
            pbType1.Image = PKM.BaseStats.Type(0).Image
            If PKM.BaseStats.Type(1).Value <> PKM.BaseStats.Type(0).Value Then _
                pbType2.Image = PKM.BaseStats.Type(1).Image
            pbBeauty.Value = PKM.Condition.Beauty
            pbCool.Value = PKM.Condition.Cool
            pbCute.Value = PKM.Condition.Cute
            pbSheen.Value = PKM.Condition.Sheen
            pbSmart.Value = PKM.Condition.Smart
            pbTough.Value = PKM.Condition.Tough
            lblLevel.Text = "Lv. " & PKM.Level
            lblEXP.Text = PKM.EXP
            lblTNL.Text = PKM.TNL
            lblBeauty.Text = (PKM.Condition.Beauty / 255).ToString("p0")
            lblCool.Text = (PKM.Condition.Cool / 255).ToString("p0")
            lblCute.Text = (PKM.Condition.Cute / 255).ToString("p0")
            lblTough.Text = (PKM.Condition.Tough / 255).ToString("p0")
            lblSmart.Text = (PKM.Condition.Smart / 255).ToString("p0")
            lblSheen.Text = (PKM.Condition.Sheen / 255).ToString("p0")

            If PKM.Moves(0).Value > 0 Then _
            pbMove1Var.Image = PKM.Moves(0).BattleCategory.Image
            If PKM.Moves(1).Value > 0 Then _
            pbMove2Var.Image = PKM.Moves(1).BattleCategory.Image
            If PKM.Moves(2).Value > 0 Then _
            pbMove3Var.Image = PKM.Moves(2).BattleCategory.Image
            If PKM.Moves(3).Value > 0 Then _
            pbMove4Var.Image = PKM.Moves(3).BattleCategory.Image

            If PKM.Moves(0).Value > 0 Then _
            lblMove1PP.Text = PKM.Moves(0).CurrentPP & " / " & PKM.Moves(0).TotalPP
            If PKM.Moves(1).Value > 0 Then _
            lblMove2PP.Text = PKM.Moves(1).CurrentPP & " / " & PKM.Moves(1).TotalPP
            If PKM.Moves(2).Value > 0 Then _
            lblMove3PP.Text = PKM.Moves(2).CurrentPP & " / " & PKM.Moves(2).TotalPP
            If PKM.Moves(3).Value > 0 Then _
            lblMove4PP.Text = PKM.Moves(3).CurrentPP & " / " & PKM.Moves(3).TotalPP

            lblAtkIV.Text = PKM.IVs.Attack
            lblAtkEV.Text = PKM.EVs.Attack
            lblHPIV.Text = PKM.IVs.HP
            lblHPEV.Text = PKM.EVs.HP
            lblDefIV.Text = PKM.IVs.Defense
            lblDefEV.Text = PKM.EVs.Defense
            lblSpdEV.Text = PKM.EVs.Speed
            lblSpdIV.Text = PKM.IVs.Speed
            lblSpAtkEV.Text = PKM.EVs.SpAttack
            lblSpAtkIV.Text = PKM.IVs.SpAttack
            lblSpDefIV.Text = PKM.IVs.SpDefense
            lblSpDefEV.Text = PKM.EVs.SpDefense

            lblHiddenPowerPower.Text = "Power: " & PKM.HiddenPower.Power
            lblHiddenPowerType.Text = "Type: "
            lblWurmpleEvo.Text = ""
            lblFriendship.Text = (PKM.Tameness / 255).ToString("p0")
            pbHiddenPowerType.Image = PKM.HiddenPower.Type.Image
            lblPID.Text = PKM.PID & vbNewLine & Hex(PKM.PID)
            lblSecretID.Text = PKM.Trainer.SID.ToString("00000")

            lblLocation.Text = ""

            With PKM.Markings(Color.Black, Color.Gray)
                pbCircle.Image = .Circle.Image
                pbSquare.Image = .Square.Image
                pbTriangle.Image = .Triangle.Image
                pbHeart.Image = .Heart.Image
                pbDiamond.Image = .Diamond.Image
                pbStar.Image = .Star.Image
            End With

            pbStatus.Image = PKM.Status.Image

        End If

        lblTrainerMemo.Text = PKM.TrainerMemo

        'Catch ex As Exception
        '    MessageBox.Show(ex.Message, "Error " & Err.Number & ":", MessageBoxButtons.OK, MessageBoxIcon.Error)
        'End Try
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.Escape
                Me.Close()
            Case Keys.Up
                If PKMArray Is Nothing Then Exit Sub
                If PKMArray.Count = 0 Or PKMArray.Count = 1 Then Exit Sub
                Dim iC As Integer = 0
                PKMIndex -= 1
                If PKMIndex < 0 Then PKMIndex = PKMArray.Count - 1
                Do Until PKMArray(PKMIndex).Species.ID <> Species.NOTHING Or iC = PKMArray.Count
                    PKMIndex -= 1
                    If PKMIndex < 0 Then PKMIndex = PKMArray.Count - 1
                    iC += 1
                Loop
                Me.PKM = PKMArray(PKMIndex)
                PKM_Read()
            Case Keys.Down
                If PKMArray Is Nothing Then Exit Sub
                If PKMArray.Count = 0 Or PKMArray.Count = 1 Then Exit Sub
                Dim iC As Integer = 0
                PKMIndex += 1
                If PKMIndex > PKMArray.Count - 1 Then PKMIndex = 0
                Do Until PKMArray(PKMIndex).Species.ID <> Species.NOTHING Or iC = PKMArray.Count
                    PKMIndex += 1
                    If PKMIndex > PKMArray.Count - 1 Then PKMIndex = 0
                    iC += 1
                Loop
                Me.PKM = PKMArray(PKMIndex)
                PKM_Read()
            Case Else
                Select Case TabControl1.SelectedIndex
                    Case 0
                        If e.KeyCode = Keys.Left Then
                            TabControl1.SelectedIndex = TabControl1.TabCount - 1
                            e.SuppressKeyPress = True
                            Exit Sub
                        End If
                    Case TabControl1.TabCount - 1
                        If e.KeyCode = Keys.Right Then
                            TabControl1.SelectedIndex = 0
                            e.SuppressKeyPress = True
                            Exit Sub
                        End If
                    Case Else
                        If e.KeyCode = Keys.Left Then
                            TabControl1.SelectedIndex -= 1
                            e.SuppressKeyPress = True
                            Exit Sub
                        End If
                        If e.KeyCode = Keys.Right Then
                            TabControl1.SelectedIndex += 1
                            e.SuppressKeyPress = True
                            Exit Sub
                        End If
                End Select
        End Select

    End Sub

    Private Sub TabControl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

        If TabControl1.SelectedIndex = 0 And e.KeyCode = Keys.Left Then
            TabControl1.SelectedIndex = 6
            e.SuppressKeyPress = True
        End If

        If TabControl1.SelectedIndex = 6 And e.KeyCode = Keys.Right Then
            TabControl1.SelectedIndex = 0
            e.SuppressKeyPress = True
        End If

    End Sub

    Private Sub PKMViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.MinimumSize = Me.Size

    End Sub

    Public Function GetControlByName(ByVal Name As String) As Control

        'now, why would I put a "_" in front of the name?
        Dim info As System.Reflection.FieldInfo = Me.GetType().GetField("_" & Name, _
        System.Reflection.BindingFlags.NonPublic Or _
        System.Reflection.BindingFlags.Instance Or _
        System.Reflection.BindingFlags.Public Or _
        System.Reflection.BindingFlags.IgnoreCase)

        If info Is Nothing Then Return Nothing
        Dim o As Object = info.GetValue(Me)
        Return o

    End Function

    Private Sub pbRib_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles pbRib1.MouseHover, pbRib2.MouseHover, pbRib3.MouseHover, pbRib4.MouseHover, pbRib5.MouseHover, pbRib6.MouseHover, pbRib7.MouseHover, pbRib8.MouseHover, pbRib9.MouseHover, pbRib10.MouseHover, pbRib11.MouseHover, pbRib12.MouseHover, pbRib13.MouseHover, pbRib14.MouseHover, pbRib15.MouseHover, pbRib16.MouseHover, pbRib17.MouseHover, pbRib18.MouseHover, pbRib19.MouseHover, pbRib20.MouseHover, pbRib21.MouseHover, pbRib22.MouseHover, pbRib23.MouseHover, pbRib24.MouseHover, pbRib25.MouseHover, pbRib26.MouseHover, pbRib27.MouseHover, pbRib28.MouseHover, pbRib29.MouseHover, pbRib30.MouseHover, pbRib31.MouseHover, pbRib32.MouseHover, pbRib33.MouseHover, pbRib34.MouseHover, pbRib35.MouseHover, pbRib36.MouseHover, pbRib37.MouseHover, pbRib38.MouseHover, pbRib39.MouseHover, pbRib40.MouseHover, pbRib41.MouseHover, pbRib42.MouseHover, pbRib43.MouseHover, pbRib44.MouseHover, pbRib45.MouseHover, pbRib46.MouseHover, pbRib47.MouseHover, pbRib48.MouseHover, pbRib49.MouseHover, pbRib50.MouseHover, pbRib51.MouseHover, pbRib52.MouseHover, pbRib53.MouseHover, pbRib54.MouseHover, pbRib55.MouseHover, pbRib56.MouseHover, pbRib57.MouseHover, pbRib58.MouseHover, pbRib59.MouseHover, pbRib60.MouseHover, pbRib61.MouseHover, pbRib62.MouseHover, pbRib63.MouseHover, pbRib64.MouseHover, pbRib65.MouseHover, pbRib66.MouseHover, pbRib67.MouseHover, pbRib68.MouseHover, pbRib69.MouseHover, pbRib70.MouseHover, pbRib71.MouseHover, pbRib72.MouseHover, pbRib73.MouseHover, pbRib74.MouseHover, pbRib75.MouseHover, pbRib76.MouseHover, pbRib77.MouseHover, pbRib78.MouseHover, pbRib79.MouseHover, pbRib80.MouseHover
        Try
            If sender.tag <> "" And sender.image <> Nothing Then _
            toolTipInfo.Show(sender.tag, sender, 5000)
        Catch ex As Exception
        End Try
    End Sub

    Private Sub pbRib_MouseClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles pbRib1.MouseClick, pbRib2.MouseClick, pbRib3.MouseClick, pbRib4.MouseClick, pbRib5.MouseClick, pbRib6.MouseClick, pbRib7.MouseClick, pbRib8.MouseClick, pbRib9.MouseClick, pbRib10.MouseClick, pbRib11.MouseClick, pbRib12.MouseClick, pbRib13.MouseClick, pbRib14.MouseClick, pbRib15.MouseClick, pbRib16.MouseClick, pbRib17.MouseClick, pbRib18.MouseClick, pbRib19.MouseClick, pbRib20.MouseClick, pbRib21.MouseClick, pbRib22.MouseClick, pbRib23.MouseClick, pbRib24.MouseClick, pbRib25.MouseClick, pbRib26.MouseClick, pbRib27.MouseClick, pbRib28.MouseClick, pbRib29.MouseClick, pbRib30.MouseClick, pbRib31.MouseClick, pbRib32.MouseClick, pbRib33.MouseClick, pbRib34.MouseClick, pbRib35.MouseClick, pbRib36.MouseClick, pbRib37.MouseClick, pbRib38.MouseClick, pbRib39.MouseClick, pbRib40.MouseClick, pbRib41.MouseClick, pbRib42.MouseClick, pbRib43.MouseClick, pbRib44.MouseClick, pbRib45.MouseClick, pbRib46.MouseClick, pbRib47.MouseClick, pbRib48.MouseClick, pbRib49.MouseClick, pbRib50.MouseClick, pbRib51.MouseClick, pbRib52.MouseClick, pbRib53.MouseClick, pbRib54.MouseClick, pbRib55.MouseClick, pbRib56.MouseClick, pbRib57.MouseClick, pbRib58.MouseClick, pbRib59.MouseClick, pbRib60.MouseClick, pbRib61.MouseClick, pbRib62.MouseClick, pbRib63.MouseClick, pbRib64.MouseClick, pbRib65.MouseClick, pbRib66.MouseClick, pbRib67.MouseClick, pbRib68.MouseClick, pbRib69.MouseClick, pbRib70.MouseClick, pbRib71.MouseClick, pbRib72.MouseClick, pbRib73.MouseClick, pbRib74.MouseClick, pbRib75.MouseClick, pbRib76.MouseClick, pbRib77.MouseClick, pbRib78.MouseClick, pbRib79.MouseClick, pbRib80.MouseClick
        Try
            If sender.tag <> "" Then _
            toolTipInfo.Show(sender.tag, sender, 5000)
        Catch ex As Exception
        End Try
    End Sub

    Public Sub New(ByVal _PKM As Pokemon)
        InitializeComponent()
        InitializeDictionaries()
        Me.PKM = _PKM
    End Sub

    Public Sub New()
        InitializeComponent()
        InitializeDictionaries()
    End Sub

    Public Sub New(ByVal _PKM As Pokemon(), Optional ByVal StartingIndex As Integer = 0)
        InitializeComponent()
        InitializeDictionaries()
        PKMArray = _PKM
        PKMIndex = StartingIndex
        Me.PKM = PKMArray(PKMIndex)
    End Sub

End Class