Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class FloorItemGraphicInfoEditor
	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 flooritemgroups(,) As drawlocgroup = ADGEDotNetUt.ArrayUt(Of drawlocgroup).NewArray2(3, 11)
	Public selectedgroup As Short
	Public selectedlocation As Short
	Public selecteditem As Short
	'Public selectedsublocation As Integer
	Public subchange As Boolean
	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 GLocPointer(4) As Label
    Dim GSelectBox(4) As RectangleShape
    Dim GLocRect(4) As RectangleShape
	
	'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 Short
        Dim i As Short

        'graphics.resetmodifiedcolorarray
        'CeilingGraphic.Picture = graphics.loadgraphic(77, 0)
        'Floorgraphic.Picture = graphics.loadgraphic(76, 0)

        '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)

        CGItemList.Items.Clear()

        ' Load misc item names from _Dic_MiscItem.txt, then add 85 items
        Dim c As Integer
        Dim rows As String() = DUt.Read_Dic_MiscItem()
        For c = 0 To 85 - 1
            CGItemList.Items.Add(c.ToString("00")).SubItems.Add(rows(c))
        Next

        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")

        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 Center")

        '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 10
                '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 j. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                flooritemgroups(i, j) = graphics.f558.FloorItemGroup(i, j)
            Next
        Next

        subchange = True
        'selectgroup (1)
        selectlocation((1))
        selectitem((1))
        'selectsublocation (1)
        subchange = False

        'update
    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 subchange = True Then
            Exit Sub
        End If
        subchange = True
        selectgroup((CGGroupList.FocusedItem.Index + 1))
        subchange = False
    End Sub

    Private Sub CGItemList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGItemList.SelectedIndexChanged
        If CGItemList.FocusedItem Is Nothing Then Exit Sub
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        selectitem((CGItemList.FocusedItem.Index + 1))
        subchange = False

    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 subchange = True Then
            Exit Sub
        End If
        subchange = True
        selectlocation((CGLocationList.FocusedItem.Index + 1))
        subchange = False
    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)
        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 = flooritemgroups(selectedgroup, selectedlocation).loc_Renamed(Index + 1, 1)
            savedy = flooritemgroups(selectedgroup, selectedlocation).loc_Renamed(Index + 1, 2)
        End If

    End Sub

    'Private Sub ImageA_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '
    '    If Button = 2 Then
    '        X = X * 2
    '        X = X / 3
    '        Y = Y * 2
    '        Y = Y / 3
    '
    '        If selectedlocation = 2 Or selectedlocation = 5 Or selectedlocation = 8 Or selectedlocation = 10 Then
    '            X = X + 100
    '        End If
    '        If selectedlocation = 3 Or selectedlocation = 6 Or selectedlocation = 9 Or selectedlocation = 11 Then
    '            X = X - 100
    '        End If
    '
    '        If X > 255 Then
    '            X = 255
    '        End If
    '        If X < 0 Then
    '            X = 0
    '        End If
    '        If Y > 255 Then
    '            Y = 255
    '        End If
    '        If Y < 0 Then
    '            Y = 0
    '        End If
    '
    '
    '
    '        flooritemgroups(selectedgroup, selectedlocation).setloc selectedsublocation, 1, X
    '        flooritemgroups(selectedgroup, selectedlocation).setloc selectedsublocation, 2, Y
    '
    '        update
    '        'MsgBox "x=" + Str(X) + " y=" + Str(Y)
    '    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

            flooritemgroups(selectedgroup, selectedlocation).setloc(Index + 1, 1, x2)
            flooritemgroups(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 10
                'UPGRADE_WARNING: Couldn't resolve default property of object j. 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.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                graphics.f558.setflooritemgroup(i, j, flooritemgroups(i, j))
                'Set flooritemgroups(i, j) = graphics.f558.flooritemgroup(i, j)
            Next
        Next
        App.graphics.f558.update()
        Me.Close()

    End Sub
    Public Sub selectgroup(ByVal num As Short)
        selectedgroup = num
        CGGroupList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGGroupList, num - 1, "Emerald")
        update_Renamed()
    End Sub

    Public Sub selectlocation(ByVal num As Short)
        selectedlocation = num
        CGLocationList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGLocationList, num - 1, "Topaz")
        'If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Then 'd3
        '    For i = 1 To 16
        '        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d3flooritempalette(i) / 10) + 1)
        '    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.d2flooritempalette(i) / 10) + 1)
        '    Next
        '    offset = 2
        'Else 'd1
        '    graphics.resetmodifiedcolorarray
        '    offset = 0
        'End If

        ' MonGraphicPic.Picture = graphics.loadgraphic(selectedimage, offset)
        ' For i = 0 To 4
        '     MonGraphic(i).Picture = graphics.loadgraphic(selectedimage, offset)
        ' Next
        update_Renamed()
    End Sub
    Public Sub selectitem(ByVal num As Short)
        selecteditem = num
        CGItemList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGItemList, num - 1, "BlueGem")
        selectgroup(graphics.f558.itemgraphicinfo(selecteditem).FloorItemGroup + 1)

        'selectedimage = 361 + graphics.f558.itemgraphicinfo(selecteditem).GraphicNum

        'If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Then 'd3
        '    For i = 1 To 16
        '        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d3flooritempalette(i) / 10) + 1)
        '    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.d2flooritempalette(i) / 10) + 1)
        '    Next
        '    offset = 2
        'Else 'd1
        'graphics.resetmodifiedcolorarray
        '    offset = 0
        'End If
        '
        'MonGraphicPic.Picture = graphics.loadgraphic(selectedimage, offset)
        'For i = 0 To 4
        '    MonGraphic(i).Picture = graphics.loadgraphic(selectedimage, offset)
        'Next
        update_Renamed()
    End Sub

    'Public Sub selectsublocation(ByVal num As Integer)
    '    selectedsublocation = num
    '    CGSubLocationList.ListIndex = num - 1
    '    update
    'End Sub

    '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
        Dim f As Short
        Dim l As Integer
        Dim nichenum As Integer
        Dim nichecount As Integer
        Dim nichepalette As Integer



        '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)

        '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)

            If Draw(4).CheckState = 1 Then
                If selectedlocation > 6 Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object f. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    f = 114
                    nichenum = 13
                    nichecount = 1
                    nichepalette = 0
                ElseIf selectedlocation > 3 Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object f. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    f = 111
                    nichenum = 8
                    nichecount = 3
                    nichepalette = 2
                ElseIf selectedlocation <= 3 Then
                    'UPGRADE_WARNING: Couldn't resolve default property of object f. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    f = 108
                    nichenum = 3
                    nichecount = 3
                    nichepalette = 3
                End If
                'UPGRADE_WARNING: Couldn't resolve default property of object f. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                l = f - 2

                'UPGRADE_WARNING: Couldn't resolve default property of object f. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                For i = f To l Step -1
                    graphics.stretchtransparentbmpsrc(cv, graphics.f558.graphicrect(i).displayedGraphic - 1, graphics.f558.graphicrect(i).x1 * 2, graphics.f558.graphicrect(i).y1 * 2, (graphics.f558.graphicrect(i).x2 - graphics.f558.graphicrect(i).x1 + 1) * 2, (graphics.f558.graphicrect(i).y2 - graphics.f558.graphicrect(i).y1 + 1) * 2, graphics.f558.graphicrect(i).srcx, graphics.f558.graphicrect(i).srcy, graphics.f558.graphicrect(i).x2 - graphics.f558.graphicrect(i).x1 + 1, graphics.f558.graphicrect(i).y2 - graphics.f558.graphicrect(i).y1 + 1, 10)
                Next

                If nichepalette = 2 Then
                    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"'
                        '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, graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d2walldecorationpalette(i + 1) / 10))
                    Next
                ElseIf nichepalette = 3 Then
                    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"'
                        '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, graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d3walldecorationpalette(i + 1) / 10))
                    Next
                Else
                    '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)
                End If
                '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
                For i = nichenum To nichenum + nichecount - 1
                    graphics.stretchtransparentbmp(cv, 124, graphics.f558.walldecorationinfo(2, i).x1 * 2, graphics.f558.walldecorationinfo(2, i).y1 * 2, (graphics.f558.walldecorationinfo(2, i).x2 - graphics.f558.walldecorationinfo(2, i).x1 + 1) * 2, (graphics.f558.walldecorationinfo(2, i).y2 - graphics.f558.walldecorationinfo(2, i).y1 + 1) * 2, 0, 0, 10)
                Next



                'now draw the niches?
                'd3 = 3 4 5
                'd2 = 8 9 10
                'd1 = 13
            End If

            '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
            '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 = 360 + graphics.f558.itemgraphicinfo(selecteditem).GraphicNum

            If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Then 'd3
                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"'
                    '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, graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d3flooritempalette(i + 1) / 10))
                Next
            ElseIf selectedlocation = 4 Or selectedlocation = 5 Or selectedlocation = 6 Then  'd2
                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"'
                    '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, graphics.getpalette(graphics.gPALETTE_MAIN, graphics.f558.d3flooritempalette(i + 1) / 10))
                Next
            End If

            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 = flooritemgroups(selectedgroup, selectedlocation).loc_Renamed(i + 1, 1)
                Y = flooritemgroups(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

                '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 selecteditem > 0 Then
                    '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 nh. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    nh = graphics.f558.itemgraphicinfo(selecteditem).Height
                    '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"'
                    nw = graphics.f558.itemgraphicinfo(selecteditem).Width * 2
                    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
                    'MonGraphic(i).height = nh
                    'MonGraphic(i).width = nw
                    'MonGraphic(i).Left = ImageA.Left + X - (MonGraphic(i).width / 2)
                    'MonGraphic(i).Top = ImageA.Top + Y - (MonGraphic(i).height)
                    'MonGraphic(i).Visible = Draw(i).Value

                    If Draw(i).CheckState Then
                        '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 (i = 1 Or i = 2) And graphics.f558.itemgraphicinfo(selecteditem).b4_mirrored <> 0 Then
                            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setmirrored. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            graphics.setmirrored(1)
                        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 i = 4 And graphics.f558.itemgraphicinfo(selecteditem).b4_nicheview <> 0 Then
                            'has special niche view
                            graphics.stretchtransparentbmp(cv, selectedimage + 1, X - nw / 2, Y - nh, nw, nh, 0, 0, 10)
                        Else
                            graphics.stretchtransparentbmp(cv, selectedimage, X - nw / 2, Y - nh, nw, nh, 0, 0, 10)
                        End If
                        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.setmirrored. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        graphics.setmirrored(0)
                    End If
                Else
                    'MonGraphic(i).Visible = False
                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 Short

        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.setd2flooritempalette(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.setd3flooritempalette(i, window.getd3palette(i))
        Next

        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.d2flooritempalette(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.d3flooritempalette(i))
        Next
        p.returnFloorItemGraphicInfoEditor = Me
        p.returnTo = 4
        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 subchange = True Then
			Exit Sub
		End If
		subchange = True
		flooritemgroups(selectedgroup, selectedlocation).setloc(Index + 1, 1, App.EFChange8(XCoord(Index), 0, 255))
		update_Renamed()
		subchange = False
	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 subchange = True Then
			Exit Sub
		End If
		subchange = True
		flooritemgroups(selectedgroup, selectedlocation).setloc(Index + 1, 2, App.EFChange8(YCoord(Index), 0, 255))
		update_Renamed()
		subchange = False
	End Sub

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

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

        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
    End Sub

    Private Sub FloorItemGraphicInfoEditor_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