Option Strict Off
Option Explicit On
Friend Class CustomPaletteEditor
	Inherits System.Windows.Forms.Form
	Private d2palette(16) As Byte
	Private d3palette(16) As Byte
	Public selectedpalette As Short
	Public subchange As Boolean
	
	Public returnDoorDecorationGraphicInfoEditor As DoorDecorationGraphicInfoEditor
	Public returnWallDecorationGraphicInfoEditor As WallDecorationGraphicInfoEditor
	Public returnCreatureGraphicInfoEditor As CreatureGraphicInfoEditor
	Public returnFloorItemGraphicInfoEditor As FloorItemGraphicInfoEditor
    Public returnTo As Short

    Dim MasterColorButton(15) As Label
    Dim D2ColorButton(15) As Label
    Dim D3ColorButton(15) As Label
    Dim D2Color(15) As TextBox
    Dim D3Color(15) As TextBox
	
	'UPGRADE_NOTE: val was upgraded to val_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Sub setd2palette(ByVal num As Short, ByVal val_Renamed As Byte)
        d2palette(num) = val_Renamed
    End Sub
	Function getd2palette(ByVal num As Short) As Byte
		getd2palette = d2palette(num)
	End Function
	'UPGRADE_NOTE: val was upgraded to val_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Sub setd3palette(ByVal num As Short, ByVal val_Renamed As Byte)
        d3palette(num) = val_Renamed
    End Sub
	Function getd3palette(ByVal num As Short) As Byte
		getd3palette = d3palette(num)
	End Function
	
	'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 i As Short

        For i = 0 To 15
            'MasterColorButton(i - 1).ForeColor = graphics.color(i)
            'MasterColorButton(i - 1).BackColor = graphics.color(i)
            'D2ColorButton(i - 1).ForeColor = graphics.color((d2palette(i) / 10) + 1)
            'D2ColorButton(i - 1).BackColor = graphics.color((d2palette(i) / 10) + 1)
            MasterColorButton(i).ForeColor = graphics.getpalette(graphics.gPALETTE_MAIN, i)
            MasterColorButton(i).BackColor = graphics.getpalette(graphics.gPALETTE_MAIN, i)
            D2ColorButton(i).ForeColor = graphics.getpalette(graphics.gPALETTE_MAIN, d2palette(i + 1) / 10)
            D2ColorButton(i).BackColor = graphics.getpalette(graphics.gPALETTE_MAIN, d2palette(i + 1) / 10)
            D2Color(i).Text = Str(d2palette(i + 1))
            D3ColorButton(i).ForeColor = graphics.getpalette(graphics.gPALETTE_MAIN, d2palette(i + 1) / 10)
            D3ColorButton(i).BackColor = graphics.getpalette(graphics.gPALETTE_MAIN, d3palette(i + 1) / 10)
            D3Color(i).Text = Str(d3palette(i + 1))
        Next
    End Sub
	
    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click
        Me.Close()

    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_WARNING: Event D2Color.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 D2Color_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles _D2Color_0.TextChanged, _D2Color_1.TextChanged, _D2Color_2.TextChanged, _D2Color_3.TextChanged, _D2Color_4.TextChanged, _D2Color_5.TextChanged, _D2Color_6.TextChanged, _D2Color_7.TextChanged, _D2Color_8.TextChanged, _D2Color_9.TextChanged, _D2Color_10.TextChanged, _D2Color_12.TextChanged, _D2Color_13.TextChanged, _D2Color_14.TextChanged, _D2Color_15.TextChanged
        Dim Index As Short = Array.IndexOf(D2Color, eventSender)
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        d2palette(Index + 1) = App.EFChange8(D2Color(Index), 0, 159)
        'D2ColorButton(Index).ForeColor = graphics.color((d2palette(Index + 1) / 10) + 1)
        'D2ColorButton(Index).BackColor = graphics.color((d2palette(Index + 1) / 10) + 1)
        D2ColorButton(Index).ForeColor = graphics.getpalette(graphics.gPALETTE_MAIN, d2palette(Index + 1) / 10)
        D2ColorButton(Index).BackColor = graphics.getpalette(graphics.gPALETTE_MAIN, d2palette(Index + 1) / 10)

        subchange = False
    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_WARNING: Event d3Color.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 d3Color_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles _D3Color_0.TextChanged, _D3Color_1.TextChanged, _D3Color_2.TextChanged, _D3Color_3.TextChanged, _D3Color_4.TextChanged, _D3Color_5.TextChanged, _D3Color_6.TextChanged, _D3Color_7.TextChanged, _D3Color_8.TextChanged, _D3Color_9.TextChanged, _D3Color_10.TextChanged, _D3Color_11.TextChanged, _D3Color_12.TextChanged, _D3Color_13.TextChanged, _D3Color_14.TextChanged, _D3Color_15.TextChanged
        Dim Index As Short = Array.IndexOf(D3Color, eventSender)
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        d3palette(Index + 1) = App.EFChange8(D3Color(Index), 0, 159)
        'D3ColorButton(Index).ForeColor = graphics.color((d3palette(Index + 1) / 10) + 1)
        'D3ColorButton(Index).BackColor = graphics.color((d3palette(Index + 1) / 10) + 1)

        '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"'
        D3ColorButton(Index).ForeColor = graphics.getpalette(graphics.gPALETTE_MAIN, d3palette(Index + 1) / 10)
        '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"'
        D3ColorButton(Index).BackColor = graphics.getpalette(graphics.gPALETTE_MAIN, d3palette(Index + 1) / 10)
        subchange = False
    End Sub
	
    Private Sub Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click

        If returnTo = 1 Then
            returnDoorDecorationGraphicInfoEditor.returnCustomPaletteEditor(Me)
        ElseIf returnTo = 2 Then
            returnWallDecorationGraphicInfoEditor.returnCustomPaletteEditor(Me)
        ElseIf returnTo = 3 Then
            returnCreatureGraphicInfoEditor.returnCustomPaletteEditor(Me)
        ElseIf returnTo = 4 Then
            returnFloorItemGraphicInfoEditor.returnCustomPaletteEditor(Me)
        End If
        Me.Close()
    End Sub

    Private Sub CustomPaletteEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MasterColorButton(0) = _MasterColorButton_0
        MasterColorButton(1) = _MasterColorButton_1
        MasterColorButton(2) = _MasterColorButton_2
        MasterColorButton(3) = _MasterColorButton_3
        MasterColorButton(4) = _MasterColorButton_4
        MasterColorButton(5) = _MasterColorButton_5
        MasterColorButton(6) = _MasterColorButton_6
        MasterColorButton(7) = _MasterColorButton_7
        MasterColorButton(8) = _MasterColorButton_8
        MasterColorButton(9) = _MasterColorButton_9
        MasterColorButton(10) = _MasterColorButton_10
        MasterColorButton(11) = _MasterColorButton_11
        MasterColorButton(12) = _MasterColorButton_12
        MasterColorButton(13) = _MasterColorButton_13
        MasterColorButton(14) = _MasterColorButton_14
        MasterColorButton(15) = _MasterColorButton_15

        D2ColorButton(0) = _D2ColorButton_0
        D2ColorButton(1) = _D2ColorButton_1
        D2ColorButton(2) = _D2ColorButton_2
        D2ColorButton(3) = _D2ColorButton_3
        D2ColorButton(4) = _D2ColorButton_4
        D2ColorButton(5) = _D2ColorButton_5
        D2ColorButton(6) = _D2ColorButton_6
        D2ColorButton(7) = _D2ColorButton_7
        D2ColorButton(8) = _D2ColorButton_8
        D2ColorButton(9) = _D2ColorButton_9
        D2ColorButton(10) = _D2ColorButton_10
        D2ColorButton(11) = _D2ColorButton_11
        D2ColorButton(12) = _D2ColorButton_12
        D2ColorButton(13) = _D2ColorButton_13
        D2ColorButton(14) = _D2ColorButton_14
        D2ColorButton(15) = _D2ColorButton_15

        D3ColorButton(0) = _D3ColorButton_0
        D3ColorButton(1) = _D3ColorButton_1
        D3ColorButton(2) = _D3ColorButton_2
        D3ColorButton(3) = _D3ColorButton_3
        D3ColorButton(4) = _D3ColorButton_4
        D3ColorButton(5) = _D3ColorButton_5
        D3ColorButton(6) = _D3ColorButton_6
        D3ColorButton(7) = _D3ColorButton_7
        D3ColorButton(8) = _D3ColorButton_8
        D3ColorButton(9) = _D3ColorButton_9
        D3ColorButton(10) = _D3ColorButton_10
        D3ColorButton(11) = _D3ColorButton_11
        D3ColorButton(12) = _D3ColorButton_12
        D3ColorButton(13) = _D3ColorButton_13
        D3ColorButton(14) = _D3ColorButton_14
        D3ColorButton(15) = _D3ColorButton_15

        D3Color(0) = _D3Color_0
        D3Color(1) = _D3Color_1
        D3Color(2) = _D3Color_2
        D3Color(3) = _D3Color_3
        D3Color(4) = _D3Color_4
        D3Color(5) = _D3Color_5
        D3Color(6) = _D3Color_6
        D3Color(7) = _D3Color_7
        D3Color(8) = _D3Color_8
        D3Color(9) = _D3Color_9
        D3Color(10) = _D3Color_10
        D3Color(11) = _D3Color_11
        D3Color(12) = _D3Color_12
        D3Color(13) = _D3Color_13
        D3Color(14) = _D3Color_14
        D3Color(15) = _D3Color_15

        D2Color(0) = _D2Color_0
        D2Color(1) = _D2Color_1
        D2Color(2) = _D2Color_2
        D2Color(3) = _D2Color_3
        D2Color(4) = _D2Color_4
        D2Color(5) = _D2Color_5
        D2Color(6) = _D2Color_6
        D2Color(7) = _D2Color_7
        D2Color(8) = _D2Color_8
        D2Color(9) = _D2Color_9
        D2Color(10) = _D2Color_10
        D2Color(11) = _D2Color_11
        D2Color(12) = _D2Color_12
        D2Color(13) = _D2Color_13
        D2Color(14) = _D2Color_14
        D2Color(15) = _D2Color_15
    End Sub
End Class