Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class CreatureGraphicInfoEditor
	Inherits System.Windows.Forms.Form
	
	'UPGRADE_WARNING: Arrays can't be declared with New. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC9D3AE5-6B95-4B43-91C7-28276302A5E8"'
    Private creaturegroups(3, 11) As drawlocgroup
	Private creaturegroupnums(27) As Short
	Public selectedgroup As Short
	Public selectedlocation As Short
	Public selectedmonster As Short
	Public selectedview As Short
	'Public selectedsublocation As Integer
    'Public subchange As Boolean
    Protected selchanging As Integer
	Public subclickchange As Boolean
	Public selectedimage As Short
	Public tracking As Boolean
	Public tracked As Short
	Public savedx As Short
	Public savedy As Short
	Dim mon As Short
	Dim oldviewstring As String

    Dim GSelectBox(4) As RectangleShape
    Dim GLocRect(4) As RectangleShape
    Dim GLocPointer(4) As Label
	
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Public Sub init()
        Dim j As Integer
        Dim i As Integer

        'graphics.resetmodifiedcolorarray

        'CeilingGraphic.Picture = graphics.loadgraphic(77, 0)
        'Floorgraphic.Picture = graphics.loadgraphic(76, 0)
        '446 to 532

        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.curPalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_MAIN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        graphics.curPalette = graphics.gPALETTE_MAIN
        Dim offscreen As Bitmap = New Bitmap(Graphic.ClientSize.Width, Graphic.ClientSize.Height)
        Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
            graphics.fill(cv, 0, 0, Graphic.Width, Graphic.Height, System.Drawing.Color.Black)
            graphics.stretchbmpby(cv, 76, 0, 0, 0, 0, 200, 200)
            graphics.stretchbmpby(cv, 75, 0, 132, 0, 0, 200, 200)
        End Using
        Graphic.BackgroundImage = offscreen
        Graphic.BackgroundImageLayout = ImageLayout.None
        Graphic.Refresh()

        'for ease of use, i decided to put in a few lines to give refernce to tiles
        HLine1.X1 = 0
        HLine1.X2 = (Graphic.Width - 4)
        HLine1.Y1 = (graphics.f558.graphicrect(106).y2 * 2) 'corresponds to walls
        HLine1.Y2 = (graphics.f558.graphicrect(106).y2 * 2) 'corresponds to walls
        HLine2.X1 = 0
        HLine2.X2 = (Graphic.Width - 4)
        HLine2.Y1 = (graphics.f558.graphicrect(109).y2 * 2) 'corresponds to walls
        HLine2.Y2 = (graphics.f558.graphicrect(109).y2 * 2) 'corresponds to walls
        HLine3.X1 = 0
        HLine3.X2 = (Graphic.Width - 4)
        HLine3.Y1 = (graphics.f558.graphicrect(112).y2 * 2) 'corresponds to walls
        HLine3.Y2 = (graphics.f558.graphicrect(112).y2 * 2) 'corresponds to walls

        VLine1.X1 = 0
        VLine1.X2 = (graphics.f558.graphicrect(106).x1 * 2)
        VLine1.Y1 = (Graphic.Height - 4)
        VLine1.Y2 = (graphics.f558.graphicrect(106).y2 * 2)
        ' add 25% more distance
        VLine1.X2 = ((VLine1.X1) + ((VLine1.X2) - (VLine1.X1)) * 5 / 4)
        VLine1.Y2 = ((VLine1.Y1) + ((VLine1.Y2) - (VLine1.Y1)) * 5 / 4)

        VLine2.X1 = (Graphic.Width - 4)
        VLine2.X2 = (graphics.f558.graphicrect(106).x2 * 2)
        VLine2.Y1 = (Graphic.Height - 4)
        VLine2.Y2 = (graphics.f558.graphicrect(106).y2 * 2)
        ' add 25% more distance
        VLine2.X2 = ((VLine2.X1) + ((VLine2.X2) - (VLine2.X1)) * 5 / 4)
        VLine2.Y2 = ((VLine2.Y1) + ((VLine2.Y2) - (VLine2.Y1)) * 5 / 4)

        CGViewList.Items.Clear()


        CGGroupList.Items.Clear()
        CGGroupList.Items.Add("00").SubItems.Add("Group 0")
        CGGroupList.Items.Add("01").SubItems.Add("Group 1")
        CGGroupList.Items.Add("02").SubItems.Add("Group 2")

        CGGroupList.Font = CGLocationList.Font
        CGLocationList.Items.Clear()
        CGLocationList.Items.Add("00").SubItems.Add("D3 Center")
        CGLocationList.Items.Add("01").SubItems.Add("D3 Left")
        CGLocationList.Items.Add("02").SubItems.Add("D3 Right")
        CGLocationList.Items.Add("03").SubItems.Add("D2 Center")
        CGLocationList.Items.Add("04").SubItems.Add("D2 Left")
        CGLocationList.Items.Add("05").SubItems.Add("D2 Right")
        CGLocationList.Items.Add("06").SubItems.Add("D1 Center")
        CGLocationList.Items.Add("07").SubItems.Add("D1 Left")
        CGLocationList.Items.Add("08").SubItems.Add("D1 Right")
        CGLocationList.Items.Add("09").SubItems.Add("D0 Left")
        CGLocationList.Items.Add("10").SubItems.Add("D0 Right")

        CGMonsterList.Items.Clear()
        CGMonsterList.Items.Add("00").SubItems.Add("Scorpion")
        CGMonsterList.Items.Add("01").SubItems.Add("Slime Devil")
        CGMonsterList.Items.Add("02").SubItems.Add("Giggler")
        CGMonsterList.Items.Add("03").SubItems.Add("Flying Eye")
        CGMonsterList.Items.Add("04").SubItems.Add("Hellhound")
        CGMonsterList.Items.Add("05").SubItems.Add("Ruster")
        CGMonsterList.Items.Add("06").SubItems.Add("Screamer")
        CGMonsterList.Items.Add("07").SubItems.Add("Rock Pile")
        CGMonsterList.Items.Add("08").SubItems.Add("Rive")
        CGMonsterList.Items.Add("09").SubItems.Add("Stone Golem")
        CGMonsterList.Items.Add("10").SubItems.Add("Mummy")
        CGMonsterList.Items.Add("11").SubItems.Add("Black Flame")
        CGMonsterList.Items.Add("12").SubItems.Add("Skeleton")
        CGMonsterList.Items.Add("13").SubItems.Add("Couatl")
        CGMonsterList.Items.Add("14").SubItems.Add("Vexirk")
        CGMonsterList.Items.Add("15").SubItems.Add("Worm")
        CGMonsterList.Items.Add("16").SubItems.Add("Ant Man")
        CGMonsterList.Items.Add("17").SubItems.Add("Muncher")
        CGMonsterList.Items.Add("18").SubItems.Add("Deth Knight")
        CGMonsterList.Items.Add("19").SubItems.Add("Zytaz")
        CGMonsterList.Items.Add("20").SubItems.Add("Water Elemental")
        CGMonsterList.Items.Add("21").SubItems.Add("Oitu")
        CGMonsterList.Items.Add("22").SubItems.Add("Demon")
        CGMonsterList.Items.Add("23").SubItems.Add("Lord Chaos")
        CGMonsterList.Items.Add("24").SubItems.Add("Dragon")
        CGMonsterList.Items.Add("25").SubItems.Add("Unrecognized Type")
        CGMonsterList.Items.Add("26").SubItems.Add("Grey Lord")

        'CGSubLocationList.Clear
        'CGSubLocationList.AddItem
        'CGSubLocationList.List(0, 0) = "00"
        'CGSubLocationList.List(0, 1) = "Far Left"
        'CGSubLocationList.AddItem
        'CGSubLocationList.List(1, 0) = "01"
        'CGSubLocationList.List(1, 1) = "Far Right"
        'CGSubLocationList.AddItem
        'CGSubLocationList.List(2, 0) = "02"
        'CGSubLocationList.List(2, 1) = "Near Right"
        'CGSubLocationList.AddItem
        'CGSubLocationList.List(3, 0) = "03"
        'CGSubLocationList.List(3, 1) = "Near Left"
        'CGSubLocationList.AddItem
        'CGSubLocationList.List(4, 0) = "04"
        'CGSubLocationList.List(4, 1) = "Center"

        For i = 1 To 3
            For j = 1 To 11
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                creaturegroups(i, j) = graphics.f558.creaturegroup(i, j)
            Next
        Next

        For i = 1 To 27
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            creaturegroupnums(i) = graphics.f558.monstergraphicinfo(i).graphicgroup
        Next
        selchanging = selchanging Or 1
        'selectgroup (1)
        selectmonster((1))
        selectlocation((1))
        'selectview (1)
        'selectsublocation (1)
        update_Renamed()
        selchanging = selchanging And Not 1

    End Sub
	
    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub
	
    Private Sub CGGroupList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGGroupList.SelectedIndexChanged
        If CGGroupList.FocusedItem Is Nothing Then Exit Sub
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 2
        selectgroup((CGGroupList.FocusedItem.Index + 1))
        update_Renamed()
        selchanging = selchanging And Not 2
    End Sub
	
    Private Sub CGLocationList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGLocationList.SelectedIndexChanged
        If CGLocationList.FocusedItem Is Nothing Then Exit Sub
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 4
        selectlocation((CGLocationList.FocusedItem.Index + 1))
        update_Renamed()
        selchanging = selchanging And Not 4
    End Sub
    Private Sub CGMonsterList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGMonsterList.SelectedIndexChanged
        If CGMonsterList.FocusedItem Is Nothing Then Exit Sub
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 8
        selectmonster((CGMonsterList.FocusedItem.Index + 1))
        update_Renamed()
        selchanging = selchanging And Not 8
    End Sub
    Private Sub CGViewList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGViewList.SelectedIndexChanged
        If CGViewList.FocusedItem Is Nothing Then Exit Sub
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 16
        selectview((CGViewList.FocusedItem.Index + 1))
        'UPGRADE_WARNING: Couldn't resolve default property of object CGViewList.List(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        oldviewstring = CGViewList.Items(CGViewList.FocusedItem.Index).SubItems(1).Text
        update_Renamed()
        selchanging = selchanging And Not 16
    End Sub
	
	'Private Sub CGSubLocationList_Click()
	'
	'    If subchange = True Then
	'        Exit Sub
	'    End If
	'    subchange = True
	'    selectsublocation (CGSubLocationList.ListIndex + 1)
	'    subchange = False
	'End Sub
	
	
	
	'UPGRADE_WARNING: Event Draw.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Draw_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Draw.CheckStateChanged
		Dim Index As Short = Draw.GetIndex(eventSender)
        If selchanging <> 0 Then
            Exit Sub
        End If
		update_Renamed()
	End Sub
	
	
    Private Sub GLocPointer_MouseDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As MouseEventArgs) Handles _GLocPointer_0.MouseDown, _GLocPointer_1.MouseDown, _GLocPointer_2.MouseDown, _GLocPointer_3.MouseDown, _GLocPointer_4.MouseDown
        Dim Index As Short = Array.IndexOf(GLocPointer, eventSender)

        If eventArgs.Button And Windows.Forms.MouseButtons.Left Then
            tracking = True
            tracked = Index
            savedx = creaturegroups(selectedgroup, selectedlocation).loc_Renamed(Index + 1, 1)
            savedy = creaturegroups(selectedgroup, selectedlocation).loc_Renamed(Index + 1, 2)
        End If

    End Sub
	
    Private Sub GLocPointer_MouseMoveEvent(ByVal eventSender As System.Object, ByVal eventArgs As MouseEventArgs) Handles _GLocPointer_0.MouseMove, _GLocPointer_1.MouseMove, _GLocPointer_2.MouseMove, _GLocPointer_3.MouseMove, _GLocPointer_4.MouseMove
        Dim Index As Short = Array.IndexOf(GLocPointer, eventSender)
        Dim x2 As Single
        Dim y2 As Single
        If tracking = True And tracked = Index Then
            subclickchange = True
#If False Then
            x2 = eventArgs.X * 4
            x2 = x2 / 3
            y2 = eventArgs.Y * 4
            y2 = y2 / 3
#Else
            x2 = eventArgs.X
            y2 = eventArgs.Y
#End If

            x2 = x2 - 4
            y2 = y2 - 4
            x2 = x2 / 2
            y2 = y2 / 2

            x2 = x2 + savedx
            y2 = y2 + savedy
            If x2 < 0 Then
                x2 = 0
            End If
            If x2 > 255 Then
                x2 = 255
            End If

            If y2 < 0 Then
                y2 = 0
            End If
            If y2 > 255 Then
                y2 = 255
            End If

            creaturegroups(selectedgroup, selectedlocation).setloc(Index + 1, 1, x2)
            creaturegroups(selectedgroup, selectedlocation).setloc(Index + 1, 2, y2)
            'XCoord.Text = Str(x2)
            'YCoord.Text = Str(y2)

            update_Renamed()
            subclickchange = False
        End If

    End Sub
    Private Sub GLocPointer_MouseUpEvent(ByVal eventSender As System.Object, ByVal eventArgs As MouseEventArgs) Handles _GLocPointer_0.MouseUp, _GLocPointer_1.MouseUp, _GLocPointer_2.MouseUp, _GLocPointer_3.MouseUp, _GLocPointer_4.MouseUp
        Dim Index As Short = Array.IndexOf(GLocPointer, eventSender)
        tracking = False
        'MsgBox "aasdf"
        update_Renamed()
    End Sub
	
	
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Private Sub Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click
        Dim j As Short
        Dim i As Short

        For i = 1 To 3
            For j = 1 To 11
                'Set creaturegroups(i, j) = graphics.f558.creaturegroup(i, j)
                graphics.f558.setcreaturegroup(i, j, creaturegroups(i, j))
            Next
        Next
        For i = 1 To 27
            graphics.f558.monstergraphicinfo(i).setgraphicgroup(creaturegroupnums(i))
        Next
        graphics.f558.update()
        Me.Close()

    End Sub
	Public Sub selectmonster(ByVal num As Short)
		selectedmonster = num
        CGMonsterList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGMonsterList, num - 1, "BlueGem")
		selectgroup((creaturegroupnums(selectedmonster) + 1))
		Dim i As Short
		Dim newview As Short
		
		newview = 0
        CGViewList.Items.Clear()
		i = 0
        CGViewList.Items.Add(zerostr(i, 2)).SubItems.Add("Front")
        If oldviewstring = "Front" Then
            newview = i
        End If
		i = i + 1
		
        If graphics.f559.monster(selectedmonster).w4_sideimage > 0 Then
            CGViewList.Items.Add(zerostr(i, 2)).SubItems.Add("Side")
            If oldviewstring = "Side" Then
                newview = i
            End If
            i = i + 1
        End If
        If graphics.f559.monster(selectedmonster).w4_backimage > 0 Then
            CGViewList.Items.Add(zerostr(i, 2)).SubItems.Add("Back")
            If oldviewstring = "Back" Then
                newview = i
            End If
            i = i + 1
        End If
        If graphics.f559.monster(selectedmonster).w4_attackimage > 0 Then
            CGViewList.Items.Add(zerostr(i, 2)).SubItems.Add("Attack")
            If oldviewstring = "Attack" Then
                newview = i
            End If
            i = i + 1
        End If

		selectview((newview + 1))
	End Sub
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Sub selectview(ByVal num As Short)
        Dim fromside As Boolean
		'UPGRADE_NOTE: Space was upgraded to Space_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
		Dim Space_Renamed As Short
		
		selectedview = num
        CGViewList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGViewList, num - 1, "EyeOfTime")
		'UPGRADE_WARNING: Couldn't resolve default property of object CGViewList.List(num - 1, 1). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        If CGViewList.Items(num - 1).SubItems(1).Text = "Side" Then
            fromside = True
        Else
            fromside = False
        End If
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f559. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Space_Renamed = graphics.f559.monster(selectedmonster).w2_space
		If Space_Renamed = 2 Then
			Draw(0).CheckState = System.Windows.Forms.CheckState.UnChecked
			Draw(1).CheckState = System.Windows.Forms.CheckState.UnChecked
			Draw(2).CheckState = System.Windows.Forms.CheckState.UnChecked
			Draw(3).CheckState = System.Windows.Forms.CheckState.UnChecked
			Draw(4).CheckState = System.Windows.Forms.CheckState.Checked
		ElseIf Space_Renamed = 1 Then 
			If fromside = True Then
				Draw(0).CheckState = System.Windows.Forms.CheckState.UnChecked
				Draw(1).CheckState = System.Windows.Forms.CheckState.UnChecked
				Draw(2).CheckState = System.Windows.Forms.CheckState.Checked
				Draw(3).CheckState = System.Windows.Forms.CheckState.Checked
				Draw(4).CheckState = System.Windows.Forms.CheckState.UnChecked
			Else
				Draw(0).CheckState = System.Windows.Forms.CheckState.Checked
				Draw(1).CheckState = System.Windows.Forms.CheckState.Checked
				Draw(2).CheckState = System.Windows.Forms.CheckState.UnChecked
				Draw(3).CheckState = System.Windows.Forms.CheckState.UnChecked
				Draw(4).CheckState = System.Windows.Forms.CheckState.UnChecked
			End If
		Else
			Draw(0).CheckState = System.Windows.Forms.CheckState.Checked
			Draw(1).CheckState = System.Windows.Forms.CheckState.Checked
			Draw(2).CheckState = System.Windows.Forms.CheckState.Checked
			Draw(3).CheckState = System.Windows.Forms.CheckState.Checked
			Draw(4).CheckState = System.Windows.Forms.CheckState.UnChecked
		End If
		
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		selectedimage = 446 + graphics.f558.monstergraphicinfo(selectedmonster).GraphicNum + selectedview - 1
		
		updatemonster()
	End Sub
	Public Sub selectgroup(ByVal num As Short)
		selectedgroup = num
		creaturegroupnums(selectedmonster) = selectedgroup - 1
        CGGroupList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGGroupList, num - 1, "Emerald")
	End Sub
	
	Public Sub selectlocation(ByVal num As Short)
		selectedlocation = num
        CGLocationList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGLocationList, num - 1, "Topaz")
		
		updatemonster()
		
        If selchanging = 0 Then
            update_Renamed()
        End If
	End Sub
	
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Sub updatemonster()
        Dim offset As Short
        Dim newcolor As Drawing.Color
        Dim i As Integer

		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.curPalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		graphics.curPalette = graphics.gPALETTE_CUSTOM
		If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Then 'd3
			'For i = 1 To 16
			'    graphics.setmodifiedcolor i, graphics.color((graphics.f558.d3monsterpalette(i) / 10) + 1)
			'Next
			For i = 0 To 15
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_MAIN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                newcolor = graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d3monsterpalette(i + 1) / 10)
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                graphics.setpalette(graphics.gPALETTE_CUSTOM, i, newcolor)
			Next 
            offset = 4
		ElseIf selectedlocation = 4 Or selectedlocation = 5 Or selectedlocation = 6 Then  'd2
			'For i = 1 To 16
			'    graphics.setmodifiedcolor i, graphics.color((graphics.f558.d2monsterpalette(i) / 10) + 1)
			'Next
			For i = 0 To 15
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_MAIN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                newcolor = graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d2monsterpalette(i + 1) / 10)
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				graphics.setpalette(graphics.gPALETTE_CUSTOM, i, newcolor)
			Next 
            offset = 2
		Else 'd1
			'graphics.resetmodifiedcolorarray
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_MAIN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.copypalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			graphics.copypalette(graphics.gPALETTE_MAIN, graphics.gPALETTE_CUSTOM)
            offset = 0
		End If
		
		
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		If graphics.f558.monstergraphicinfo(selectedmonster).ColorA > 0 Then
			'graphics.setmodifiedcolor 11, graphics.f558.palettetocolor(graphics.f558.palette(graphics.f558.monstergraphicinfo(selectedmonster).ColorA, 1 + (offset / 2)))
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			graphics.setpalette(graphics.gPALETTE_CUSTOM, 10, graphics.f558.palettetocolor(graphics.f558.palette(graphics.f558.monstergraphicinfo(selectedmonster).ColorA, 1 + (offset / 2))))
		End If
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		If graphics.f558.monstergraphicinfo(selectedmonster).ColorB > 0 Then
			'graphics.setmodifiedcolor 10, graphics.f558.palettetocolor(graphics.f558.palette(graphics.f558.monstergraphicinfo(selectedmonster).ColorB, 1 + (offset / 2)))
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setpalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            graphics.setpalette(graphics.gPALETTE_CUSTOM, 9, graphics.f558.palettetocolor(graphics.f558.palette(graphics.f558.monstergraphicinfo(selectedmonster).colorb, 1 + (offset / 2))))
		End If
		
	End Sub
	
	'Public Sub selectsublocation(ByVal num As Integer)
	'    selectedsublocation = num
	'    CGSubLocationList.ListIndex = num - 1
	'    update
	'End Sub
	
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	'UPGRADE_NOTE: update was upgraded to update_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Sub update_Renamed()
        Dim X As Short
		Dim Y As Short
		Dim i As Short
		
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.curPalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_MAIN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        graphics.curPalette = graphics.gPALETTE_MAIN
        Dim offscreen As Bitmap = New Bitmap(Graphic.ClientSize.Width, Graphic.ClientSize.Height)
        Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
            graphics.fill(cv, 0, 0, Graphic.Width, Graphic.Height, System.Drawing.Color.Black)
            graphics.stretchbmpby(cv, 76, 0, 0, 0, 0, 200, 200)
            graphics.stretchbmpby(cv, 75, 0, 132, 0, 0, 200, 200)

            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.curPalette. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.gPALETTE_CUSTOM. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            graphics.curPalette = graphics.gPALETTE_CUSTOM
            Dim nh As Short
            Dim nw As Short
            For i = 0 To 4
                'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                X = creaturegroups(selectedgroup, selectedlocation).loc_Renamed(i + 1, 1)
                Y = creaturegroups(selectedgroup, selectedlocation).loc_Renamed(i + 1, 2)


                'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                XCoord(i).Text = Str(X)
                YCoord(i).Text = Str(Y)

                'If X > 0 Or Y > 0 Or subclickchange = True Then

                If selectedlocation = 2 Or selectedlocation = 5 Or selectedlocation = 8 Or selectedlocation = 10 Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    X = X - 100
                End If
                If selectedlocation = 3 Or selectedlocation = 6 Or selectedlocation = 9 Or selectedlocation = 11 Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    X = X + 100
                End If
                'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                X = X * 2
                Y = Y * 2

                'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                GSelectBox(i).Left = X - 4
                GSelectBox(i).Top = Y - 4
                If subclickchange = False Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    GLocPointer(i).Left = X - 4
                    GLocPointer(i).Top = Y - 4
                End If

                GLocRect(i).Visible = Draw(i).CheckState
                GSelectBox(i).Visible = Draw(i).CheckState
                GLocPointer(i).Visible = Draw(i).CheckState
                'Else
                '    HLine.Visible = False
                '    VLine.Visible = False
                '    SelectBox.Visible = False
                '    LocPointer.Visible = False
                'End If
                '164 close, 103 medium, 84 long
                'so at medium, the height is 62% of the normal
                'at long, the height is 50% of the normal
                'If (x > 0 Or y > 0) And selectedimage > 0 Then
                If selectedimage > 0 Then

                    'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapheight. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    'UPGRADE_WARNING: Couldn't resolve default property of object nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    nh = graphics.getgbitmapheight(selectedimage)
                    'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapwidth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    nw = graphics.getgbitmapwidth(selectedimage)

                    If selectedlocation <= 3 Then
                        'draw 50% of normal size (100% since its doubled)
                        'nh = MonGraphicPic.height
                        'nw = MonGraphicPic.width
                    ElseIf selectedlocation <= 6 Then
                        'draw 63.3% of normal size (133.3% since its doubled)
                        'nh = MonGraphicPic.height * 4 / 3
                        'nw = MonGraphicPic.width * 4 / 3
                        'UPGRADE_WARNING: Couldn't resolve default property of object nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        nh = nh * 4 / 3
                        nw = nw * 4 / 3
                    Else
                        'draw normal size (200% since its doubled)
                        'nh = MonGraphicPic.height * 2
                        'nw = MonGraphicPic.width * 2
                        'UPGRADE_WARNING: Couldn't resolve default property of object nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        nh = nh * 2
                        nw = nw * 2
                    End If


                    'UPGRADE_WARNING: Couldn't resolve default property of object X. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    GLocRect(i).Left = X - nw / 2
                    'UPGRADE_WARNING: Couldn't resolve default property of object nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    GLocRect(i).Top = Y - nh
                    GLocRect(i).Width = nw
                    'UPGRADE_WARNING: Couldn't resolve default property of object nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    GLocRect(i).Height = nh

                    If Draw(i).CheckState Then
                        graphics.stretchtransparentbmp(cv, selectedimage, X - nw / 2, Y - nh, nw, nh, 0, 0, graphics.f558.monstergraphicinfo(selectedmonster).transparentpixel)
                    End If
                End If
            Next
        End Using
        Graphic.BackgroundImage = offscreen
        Graphic.BackgroundImageLayout = ImageLayout.None
        Graphic.Refresh()
	End Sub
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Public Sub returnCustomPaletteEditor(ByRef window As CustomPaletteEditor)
        Dim i As Integer

        For i = 1 To 16
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            graphics.f558.setd2monsterpalette(i, window.getd2palette(i))
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            graphics.f558.setd3monsterpalette(i, window.getd3palette(i))
        Next

        updatemonster()
        update_Renamed()
    End Sub
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Private Sub PaletteInfo_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles PaletteInfo.Click
        Dim i As Short
        Dim p As CustomPaletteEditor
        p = New CustomPaletteEditor
        For i = 1 To 16
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            p.setd2palette(i, graphics.f558.d2monsterpalette(i))
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            p.setd3palette(i, graphics.f558.d3monsterpalette(i))
        Next
        p.returnCreatureGraphicInfoEditor = Me
        p.returnTo = 3
        p.Show()
        p.init()
    End Sub
	
	'UPGRADE_WARNING: Event XCoord.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub XCoord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles XCoord.TextChanged
		Dim Index As Short = XCoord.GetIndex(eventSender)
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 32
		creaturegroups(selectedgroup, selectedlocation).setloc(Index + 1, 1, App.EFChange8(XCoord(Index), 0, 255))
		update_Renamed()
        selchanging = selchanging And Not 32
	End Sub
	
	'UPGRADE_WARNING: Event YCoord.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub YCoord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YCoord.TextChanged
		Dim Index As Short = YCoord.GetIndex(eventSender)
        If selchanging <> 0 Then
            Exit Sub
        End If
        selchanging = selchanging Or 64
		creaturegroups(selectedgroup, selectedlocation).setloc(Index + 1, 2, App.EFChange8(YCoord(Index), 0, 255))
		update_Renamed()
        selchanging = selchanging And Not 64
	End Sub

    Private Sub CreatureGraphicInfoEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CGMonsterList.SmallImageList = App.JewelIL
        CGLocationList.SmallImageList = App.JewelIL
        CGGroupList.SmallImageList = App.JewelIL
        CGViewList.SmallImageList = App.JewelIL

        GSelectBox(0) = _GSelectBox_0
        GSelectBox(1) = _GSelectBox_1
        GSelectBox(2) = _GSelectBox_2
        GSelectBox(3) = _GSelectBox_3
        GSelectBox(4) = _GSelectBox_4

        GLocRect(0) = _GLocRect_0
        GLocRect(1) = _GLocRect_1
        GLocRect(2) = _GLocRect_2
        GLocRect(3) = _GLocRect_3
        GLocRect(4) = _GLocRect_4

        GLocPointer(0) = _GLocPointer_0
        GLocPointer(1) = _GLocPointer_1
        GLocPointer(2) = _GLocPointer_2
        GLocPointer(3) = _GLocPointer_3
        GLocPointer(4) = _GLocPointer_4
    End Sub

    Private Sub CreatureGraphicInfoEditor_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If e.CloseReason = CloseReason.UserClosing Then
            e.Cancel = True
            Hide()
        End If
    End Sub
End Class