Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class WallDecorationGraphicInfoEditor
	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 walldecorationgroups(,) As decorationinfo = ADGEDotNetUt.ArrayUt(Of decorationinfo).NewArray2(8, 13)
	Private walldecorationnumbers(60) As Byte
	Public selectedgroup As Short
	Public selectedlocation As Short
	Public selecteddecoration As Integer
	'Public selectedsublocation As Integer
	Public subchange As Boolean
	Public subclickchange As Boolean
	Public selectedimage As Short
	Public tracking As Boolean
	Public savedx As Short
	Public savedy As Short
	Public savedw As Short
	Public savedh As Short
	
	'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.setd2walldecorationpalette(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.setd3walldecorationpalette(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"'
	'UPGRADE_NOTE: mapfile was upgraded to mapfile_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)
        '360 to 445
        '60 and start at 121, 123, 125, etc (odds)


        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.Items.Add("03").SubItems.Add("Group 3")
        CGGroupList.Items.Add("04").SubItems.Add("Group 4")
        CGGroupList.Items.Add("05").SubItems.Add("Group 5")
        CGGroupList.Items.Add("06").SubItems.Add("Group 6")
        CGGroupList.Items.Add("07").SubItems.Add("Group 7")


        CGLocationList.Items.Clear()
        CGLocationList.Items.Add("00").SubItems.Add("D3LeftHall")
        CGLocationList.Items.Add("01").SubItems.Add("D3RightHall")
        CGLocationList.Items.Add("02").SubItems.Add("D3LeftWall")
        CGLocationList.Items.Add("03").SubItems.Add("D3CenterWall")
        CGLocationList.Items.Add("04").SubItems.Add("D3RightWall")
        CGLocationList.Items.Add("05").SubItems.Add("D2LeftHall")
        CGLocationList.Items.Add("06").SubItems.Add("D2RightHall")
        CGLocationList.Items.Add("07").SubItems.Add("D2LeftWall")
        CGLocationList.Items.Add("08").SubItems.Add("D2CenterWall")
        CGLocationList.Items.Add("09").SubItems.Add("D2RightWall")
        CGLocationList.Items.Add("10").SubItems.Add("D1LeftHall")
        CGLocationList.Items.Add("11").SubItems.Add("D1RightHall")
        CGLocationList.Items.Add("12").SubItems.Add("D1CenterWall")


        '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 8
            For j = 1 To 13
                '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"'
                walldecorationgroups(i, j).x1 = graphics.f558.walldecorationinfo(i, j).x1
                '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"'
                walldecorationgroups(i, j).x2 = graphics.f558.walldecorationinfo(i, j).x2
                '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"'
                walldecorationgroups(i, j).y1 = graphics.f558.walldecorationinfo(i, j).y1
                '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"'
                walldecorationgroups(i, j).y2 = graphics.f558.walldecorationinfo(i, j).y2
                '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"'
                walldecorationgroups(i, j).Width = graphics.f558.walldecorationinfo(i, j).Width
                '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"'
                walldecorationgroups(i, j).Height = graphics.f558.walldecorationinfo(i, j).Height
            Next
        Next

        For i = 1 To 60
            '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"'
            walldecorationnumbers(i) = graphics.f558.walldecorationnumber(i)
        Next


        CGDecorationList.Items.Clear()
        For i = 1 To 60
            CGDecorationList.Items.Add(zerostr(i - 1, 2)).SubItems.Add(mapfile.getname(120 + i * 2))
        Next
        CGDecorationList.Items(0).Focused = True

        subchange = True
        selectgroup((1))
        selectlocation((1))
        selectdecoration((1))
        'selectsublocation (1)
        subchange = False
        update_Renamed()
    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 CGDecorationList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CGDecorationList.SelectedIndexChanged
        If CGDecorationList.FocusedItem Is Nothing Then Exit Sub
        If subchange = True Then
            Exit Sub
        End If
        'left3 front3 left2 front2 left1 front1
        subchange = True
        selectdecoration((CGDecorationList.FocusedItem.Index + 1))
        subchange = False
    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 CGDecorationList.FocusedItem Is Nothing Then CGDecorationList.Items(0).Focused = True
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        selectgroup((CGGroupList.FocusedItem.Index + 1))
        walldecorationnumbers(CGDecorationList.FocusedItem.Index + 1) = CGGroupList.FocusedItem.Index
        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
	
	
	
    Private Sub GLocPointer_MouseDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As MouseEventArgs) Handles GLocPointer.MouseDown

        If eventArgs.Button And Windows.Forms.MouseButtons.Left Then
            tracking = True
            savedx = walldecorationgroups(selectedgroup, selectedlocation).x1
            savedy = walldecorationgroups(selectedgroup, selectedlocation).y1
            savedw = walldecorationgroups(selectedgroup, selectedlocation).x2 - walldecorationgroups(selectedgroup, selectedlocation).x1
            savedh = walldecorationgroups(selectedgroup, selectedlocation).y2 - walldecorationgroups(selectedgroup, selectedlocation).y1
        End If

    End Sub
	
	'Private Sub ImageA_MouseDown(walldecoration As Integer, Shift As Integer, X As Single, Y As Single)
	'
	'    If walldecoration = 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
	'
	'
	'
	'        walldecorationgroups(selectedgroup, selectedlocation).setloc selectedsublocation, 1, X
	'        walldecorationgroups(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.MouseMove
        Dim x2 As Single
        Dim y2 As Single
        If tracking = True 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 + savedw > 255 Then
                x2 = 255 - savedw
            End If

            If y2 < 0 Then
                y2 = 0
            End If
            If y2 + savedh > 255 Then
                y2 = 255 - savedh
            End If

            walldecorationgroups(selectedgroup, selectedlocation).x1 = x2
            walldecorationgroups(selectedgroup, selectedlocation).y1 = y2
            walldecorationgroups(selectedgroup, selectedlocation).x2 = walldecorationgroups(selectedgroup, selectedlocation).x1 + savedw
            walldecorationgroups(selectedgroup, selectedlocation).y2 = walldecorationgroups(selectedgroup, selectedlocation).y1 + savedh
            '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.MouseUp
        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 i As Short
        Dim j As Short

        For i = 1 To 8
            For j = 1 To 13
                graphics.f558.walldecorationinfo(i, j).x1 = walldecorationgroups(i, j).x1
                graphics.f558.walldecorationinfo(i, j).x2 = walldecorationgroups(i, j).x2
                graphics.f558.walldecorationinfo(i, j).y1 = walldecorationgroups(i, j).y1
                graphics.f558.walldecorationinfo(i, j).y2 = walldecorationgroups(i, j).y2
                graphics.f558.walldecorationinfo(i, j).Width = walldecorationgroups(i, j).Width
                graphics.f558.walldecorationinfo(i, j).Height = walldecorationgroups(i, j).Height
            Next
        Next
        For i = 1 To 60
            'UPGRADE_WARNING: Couldn't resolve default property of object i. 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.setwalldecorationnumber(i, walldecorationnumbers(i))
        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, "Topaz")
		X1Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).x1)
		X2Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).x2)
		Y1Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).y1)
		Y2Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).y2)
		GWidth.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).width)
		GHeight.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).height)
		update_Renamed()
	End Sub
	
	Public Sub selectlocation(ByVal num As Short)
		selectedlocation = num
        CGLocationList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGLocationList, num - 1, "BlueGem")
		X1Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).x1)
		X2Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).x2)
		Y1Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).y1)
		Y2Coord.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).y2)
		GWidth.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).width)
		GHeight.Text = Str(walldecorationgroups(selectedgroup, selectedlocation).height)
		
        'Dim offset As Short
		
		'If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Or selectedlocation = 4 Or selectedlocation = 5 Then 'd3
		'    For i = 1 To 16
		'        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d3walldecorationpalette(i) / 10) + 1)
		'    Next
		'    offset = 2
		'ElseIf selectedlocation = 6 Or selectedlocation = 7 Or selectedlocation = 8 Or selectedlocation = 9 Or selectedlocation = 10 Then 'd2
		'    For i = 1 To 16
		'        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d2walldecorationpalette(i) / 10) + 1)
		'    Next
		'    offset = 4
		'Else 'd1
		'    graphics.resetmodifiedcolorarray
		'    offset = 0
		'End If
		
		'WallDecorationGraphicLeft = graphics.loadgraphic(selectedimage, offset)
		'WallDecorationGraphicCenter = graphics.loadgraphic(selectedimage + 1, offset)
		'WallDecorationGraphicRight = graphics.loadgraphic(selectedimage, offset + 1)
		
		update_Renamed()
	End Sub
	
	Public Sub selectdecoration(ByVal num As Short)
		selecteddecoration = num
        CGDecorationList.Items(num - 1).Focused = True
        MyUt.CheckSel(CGDecorationList, num - 1, "Emerald")
		
		'selectedimage = 122 + ((selecteddecoration - 1) * 2)
		
		'Dim i As Integer
		'Dim j As Integer
		
		'    graphics.resetmodifiedcolorarray
		'
		'    WallDecorationGraphicLeft = graphics.loadgraphic(selectedimage, 0)
		'    WallDecorationGraphicCenter = graphics.loadgraphic(selectedimage + 1, 0)
		'    WallDecorationGraphicRight = graphics.loadgraphic(selectedimage, 1)
		
		'Dim offset As Integer
		
		'If selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 3 Or selectedlocation = 4 Or selectedlocation = 5 Then 'd3
		'    For i = 1 To 16
		'        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d3walldecorationpalette(i) / 10) + 1)
		'    Next
		'    offset = 2
		'ElseIf selectedlocation = 6 Or selectedlocation = 7 Or selectedlocation = 8 Or selectedlocation = 9 Or selectedlocation = 10 Then 'd2
		'    For i = 1 To 16
		'        graphics.setmodifiedcolor i, graphics.color((graphics.f558.d2walldecorationpalette(i) / 10) + 1)
		'    Next
		'    offset = 4
		'Else 'd1
		'    graphics.resetmodifiedcolorarray
		'    offset = 0
		'End If
		
		'WallDecorationGraphicLeft = graphics.loadgraphic(selectedimage, offset)
		'WallDecorationGraphicCenter = graphics.loadgraphic(selectedimage + 1, offset)
		'WallDecorationGraphicRight = graphics.loadgraphic(selectedimage, offset + 1)
		
		selectgroup((walldecorationnumbers(selecteddecoration) + 1))
		update_Renamed()
	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 x2, x1, y2, y1 As Short

		Dim i As Short
		
		'draw ceiling/floor
		'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 selectedlocation = 1 Or selectedlocation = 2 Or selectedlocation = 6 Or selectedlocation = 7 Or selectedlocation = 11 Or selectedlocation = 12 Then
                'draw the hallway
                graphics.drawgrect(cv, 107, -1, 10, 200) 'far back left
                graphics.drawgrect(cv, 108, -1, 10, 200) 'far back right
                graphics.drawgrect(cv, 110, -1, 10, 200) 'mid left
                graphics.drawgrect(cv, 111, -1, 10, 200) 'mid right
                graphics.drawgrect(cv, 113, -1, 10, 200) 'near left
                graphics.drawgrect(cv, 114, -1, 10, 200) 'near right
                graphics.drawgrect(cv, 116, -1, 10, 200) 'immidiate left
                graphics.drawgrect(cv, 117, -1, 10, 200) 'immidiate right

            ElseIf selectedlocation = 3 Or selectedlocation = 4 Or selectedlocation = 5 Then
                'draw d3
                graphics.drawgrect(cv, 107, -1, 10, 200)
                graphics.drawgrect(cv, 108, -1, 10, 200)
                graphics.drawgrect(cv, 106, -1, 10, 200)

            ElseIf selectedlocation = 8 Or selectedlocation = 9 Or selectedlocation = 10 Then
                'draw d2
                graphics.drawgrect(cv, 110, -1, 10, 200)
                graphics.drawgrect(cv, 111, -1, 10, 200)
                graphics.drawgrect(cv, 109, -1, 10, 200)
            Else
                'draw d1
                graphics.drawgrect(cv, 113, -1, 10, 200)
                graphics.drawgrect(cv, 114, -1, 10, 200)
                graphics.drawgrect(cv, 112, -1, 10, 200)
            End If

            'modify the palette

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

            If selectedlocation <= 5 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

            ElseIf selectedlocation <= 10 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

            End If
            'if neither case, just use the main palette
            '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

            '1,2 = hallway
            '3,4,5 = d3
            '6,7 = hallway
            '8,9,10 = d2
            '11,12 = hallway
            '13 = d1

            'If selectedlocation = 1 Or selectedlocation = 6 Or selectedlocation = 10 Then
            '    Me.WallDecorationGraphicLeft.Visible = True
            '    Me.WallDecorationGraphicRight.Visible = False
            '    Me.WallDecorationGraphicCenter.Visible = False
            'ElseIf selectedlocation = 2 Or selectedlocation = 7 Or selectedlocation = 11 Then
            '    Me.WallDecorationGraphicLeft.Visible = False
            '    Me.WallDecorationGraphicRight.Visible = True
            '    Me.WallDecorationGraphicCenter.Visible = False
            'Else
            '    Me.WallDecorationGraphicLeft.Visible = False
            '    Me.WallDecorationGraphicRight.Visible = False
            '    Me.WallDecorationGraphicCenter.Visible = True
            'End If
            '
            'If (selectedlocation <= 2) Or (selectedlocation >= 6 And selectedlocation <= 7) Or (selectedlocation >= 11 And selectedlocation <= 12) Then
            '    'hallway
            '    WallHall.Visible = True
            '    WallNear.Visible = False
            '    WallMedium.Visible = False
            '    WallFar.Visible = False
            'Else
            '    WallHall.Visible = False
            '    If selectedlocation <= 5 Then
            '        WallFar.Visible = True
            '    Else
            '        WallFar.Visible = False
            '    End If
            '    If selectedlocation <= 10 And selectedlocation > 5 Then
            '        WallMedium.Visible = True
            '    Else
            '        WallMedium.Visible = False
            '    End If
            '    If selectedlocation > 12 Then
            '        WallNear.Visible = True
            '    Else
            '        WallNear.Visible = False
            '    End If
            'End If


            'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            x1 = walldecorationgroups(selectedgroup, selectedlocation).x1
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            y1 = walldecorationgroups(selectedgroup, selectedlocation).y1
            'UPGRADE_WARNING: Couldn't resolve default property of object x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            x2 = walldecorationgroups(selectedgroup, selectedlocation).x2
            y2 = walldecorationgroups(selectedgroup, selectedlocation).y2


            'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            X1Coord.Text = Str(x1)
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            Y1Coord.Text = Str(y1)
            'UPGRADE_WARNING: Couldn't resolve default property of object x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            X2Coord.Text = Str(x2)
            Y2Coord.Text = Str(y2)

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

            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            If y2 < y1 Then
                'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                y2 = y1 + 1
            End If
            'UPGRADE_WARNING: Couldn't resolve default property of object x1. 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 x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            If x2 < x1 Then
                'UPGRADE_WARNING: Couldn't resolve default property of object x1. 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 x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                x2 = x1 + 1
            End If

            'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            x1 = x1 * 2
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            y1 = y1 * 2
            'UPGRADE_WARNING: Couldn't resolve default property of object x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            x2 = x2 * 2
            y2 = y2 * 2

            'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GLocRect.Left = x1
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GLocRect.Top = y1
            'UPGRADE_WARNING: Couldn't resolve default property of object x1. 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 x2. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GLocRect.Width = (x2 - x1) + 2
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GLocRect.Height = (y2 - y1) + 2
            'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GSelectBox.Left = x1 - 16
            'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            GSelectBox.Top = y1 - 16
            If subclickchange = False Then
                'UPGRADE_WARNING: Couldn't resolve default property of object x1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                GLocPointer.Left = x1 - 16
                'UPGRADE_WARNING: Couldn't resolve default property of object y1. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                GLocPointer.Top = y1 - 16
            End If

            GLocRect.Visible = True
            GSelectBox.Visible = True
            GLocPointer.Visible = True
            '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 Not CGDecorationList.FocusedItem Is Nothing Then

                selectedimage = 121 + 2 * (selecteddecoration - 1)
                '3,4,5,8,9,10,13 = front version
                '2,7,12 = mirrored
                If selectedlocation = 3 Or selectedlocation = 4 Or selectedlocation = 5 Or selectedlocation = 8 Or selectedlocation = 9 Or selectedlocation = 10 Or selectedlocation = 13 Then
                    selectedimage = selectedimage + 1
                End If
                If selectedlocation = 2 Or selectedlocation = 7 Or selectedlocation = 12 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
                graphics.stretchtransparentbmp(cv, selectedimage, x1, y1, (x2 - x1) + 2, (y2 - y1) + 2, 0, 0, 10)

                '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)
                'WallDecorationGraphicLeft.height = y2 - y1 + 1
                'WallDecorationGraphicLeft.width = x2 - x1 + 1
                'WallDecorationGraphicLeft.Left = ImageA.Left + x1
                'WallDecorationGraphicLeft.Top = ImageA.Top + y1
                '
                'WallDecorationGraphicRight.height = y2 - y1 + 1
                'WallDecorationGraphicRight.width = x2 - x1 + 1
                'WallDecorationGraphicRight.Left = ImageA.Left + x1
                'WallDecorationGraphicRight.Top = ImageA.Top + y1
                '
                'WallDecorationGraphicCenter.height = y2 - y1 + 1
                'WallDecorationGraphicCenter.width = x2 - x1 + 1
                'WallDecorationGraphicCenter.Left = ImageA.Left + x1
                'WallDecorationGraphicCenter.Top = ImageA.Top + y1
                '
                'If selectedlocation = 1 Or selectedlocation = 6 Or selectedlocation = 11 Then
                '    Me.WallDecorationGraphicLeft.Visible = True
                '    Me.WallDecorationGraphicRight.Visible = False
                '    Me.WallDecorationGraphicCenter.Visible = False
                'ElseIf selectedlocation = 2 Or selectedlocation = 7 Or selectedlocation = 12 Then
                '    Me.WallDecorationGraphicLeft.Visible = False
                '    Me.WallDecorationGraphicRight.Visible = True
                '    Me.WallDecorationGraphicCenter.Visible = False
                'Else
                '    Me.WallDecorationGraphicLeft.Visible = False
                '    Me.WallDecorationGraphicRight.Visible = False
                '    Me.WallDecorationGraphicCenter.Visible = True
                'End If
                'Else
                '    Me.WallDecorationGraphicLeft.Visible = False
                '    Me.WallDecorationGraphicRight.Visible = False
                '    Me.WallDecorationGraphicCenter.Visible = False
            End If

        End Using
        Graphic.BackgroundImage = offscreen
        Graphic.BackgroundImageLayout = ImageLayout.None
        Graphic.Refresh()
    End Sub
	
    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.d2walldecorationpalette(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.d3walldecorationpalette(i))
        Next
        p.returnWallDecorationGraphicInfoEditor = Me
        p.returnTo = 2
        p.Show()
        p.init()
    End Sub
	'UPGRADE_WARNING: Event X1Coord.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 X1Coord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles X1Coord.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).x1 = App.EFChange8(X1Coord, 0, 255)
		update_Renamed()
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Y1Coord.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 Y1Coord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Y1Coord.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).y1 = App.EFChange8(Y1Coord, 0, 255)
		update_Renamed()
		subchange = False
	End Sub
	
	
	
	'UPGRADE_WARNING: Event X2Coord.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 X2Coord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles X2Coord.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).x2 = App.EFChange8(X2Coord, 0, 255)
		update_Renamed()
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Y2Coord.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 Y2Coord_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Y2Coord.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).y2 = App.EFChange8(Y2Coord, 0, 255)
		update_Renamed()
		subchange = False
	End Sub
	
	
	'UPGRADE_WARNING: Event Gheight.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 Gheight_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Gheight.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).height = App.EFChange8(GHeight, 0, 255)
		subchange = False
	End Sub
	'UPGRADE_WARNING: Event Gwidth.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 Gwidth_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Gwidth.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		walldecorationgroups(selectedgroup, selectedlocation).width = App.EFChange8(GWidth, 0, 255)
		subchange = False
	End Sub

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

    Private Sub WallDecorationGraphicInfoEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CGLocationList.SmallImageList = App.JewelIL
        CGGroupList.SmallImageList = App.JewelIL
        CGDecorationList.SmallImageList = App.JewelIL
    End Sub
End Class