Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class PaletteEditor
	Inherits System.Windows.Forms.Form
    Private palettes(91) As Integer
	Public selectedpalette As Short
	Public subchange As Boolean
	
	Public txtbox As System.Windows.Forms.TextBox

    Dim ColorList(90) As Label

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

        For i = 1 To 13
            For j = 1 To 7
                palettes((j - 1) * 13 + i) = App.graphics.f558.palette(i, j)
                '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"'
                ColorList((j - 1) * 13 + i - 1).BackColor = graphics.f558.palettetocolor(palettes((j - 1) * 13 + i))
            Next
        Next
        subchange = True
        selectpalette(1)
        subchange = False
    End Sub

    Public Sub selectpalette(ByVal num As Short)
        selectedpalette = num

        If selectedpalette = 0 Then

            SelectedBox.Visible = False
            Byte0.Visible = False
            Red.Visible = False
            Green.Visible = False
            Blue.Visible = False
            ST(0).Visible = False
            ST(1).Visible = False
            ST(2).Visible = False
            ST(18).Visible = False
        Else
            ST(0).Visible = True
            ST(1).Visible = True
            ST(2).Visible = True
            ST(18).Visible = True
            SelectedBox.Visible = True
            Byte0.Visible = True
            Red.Visible = True
            Green.Visible = True
            Blue.Visible = True
            SelectedBox.Top = ColorList(selectedpalette - 1).Top
            SelectedBox.Left = ColorList(selectedpalette - 1).Left
            Byte0.Text = Str(CShort(palettes(num) And &HF000) / &H1000)
            Red.Text = Str(CShort(palettes(num) And &HF00) / &H100)
            Green.Text = Str(CShort(palettes(num) And &HF0) / &H10)
            Blue.Text = Str(CShort(palettes(num) And &HF) / &H1)
        End If
    End Sub



    'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    'UPGRADE_WARNING: Event byte0.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 byte0_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Byte0.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        Dim b As Integer
        b = App.EFChange8(Byte0, 0, 15)
        palettes(selectedpalette) = CShort(palettes(selectedpalette) And &HFFF) + (b * &H1000)
        '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"'
        ColorList(selectedpalette - 1).BackColor = graphics.f558.palettetocolor(palettes(selectedpalette))
        '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"'
        ColorList(selectedpalette - 1).BackColor = graphics.f558.palettetocolor(palettes(selectedpalette))
        subchange = False
    End Sub


    Private Sub ColorList_MouseDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As MouseEventArgs) Handles _ColorList_90.MouseDown, _ColorList_9.MouseDown, _ColorList_89.MouseDown, _ColorList_88.MouseDown, _ColorList_87.MouseDown, _ColorList_86.MouseDown, _ColorList_85.MouseDown, _ColorList_84.MouseDown, _ColorList_83.MouseDown, _ColorList_82.MouseDown, _ColorList_81.MouseDown, _ColorList_80.MouseDown, _ColorList_8.MouseDown, _ColorList_79.MouseDown, _ColorList_78.MouseDown, _ColorList_77.MouseDown, _ColorList_76.MouseDown, _ColorList_75.MouseDown, _ColorList_74.MouseDown, _ColorList_73.MouseDown, _ColorList_72.MouseDown, _ColorList_71.MouseDown, _ColorList_70.MouseDown, _ColorList_7.MouseDown, _ColorList_69.MouseDown, _ColorList_68.MouseDown, _ColorList_67.MouseDown, _ColorList_66.MouseDown, _ColorList_65.MouseDown, _ColorList_64.MouseDown, _ColorList_63.MouseDown, _ColorList_62.MouseDown, _ColorList_61.MouseDown, _ColorList_60.MouseDown, _ColorList_6.MouseDown, _ColorList_59.MouseDown, _ColorList_58.MouseDown, _ColorList_57.MouseDown, _ColorList_56.MouseDown, _ColorList_55.MouseDown, _ColorList_54.MouseDown, _ColorList_53.MouseDown, _ColorList_52.MouseDown, _ColorList_51.MouseDown, _ColorList_50.MouseDown, _ColorList_5.MouseDown, _ColorList_49.MouseDown, _ColorList_48.MouseDown, _ColorList_47.MouseDown, _ColorList_46.MouseDown, _ColorList_45.MouseDown, _ColorList_44.MouseDown, _ColorList_43.MouseDown, _ColorList_42.MouseDown, _ColorList_41.MouseDown, _ColorList_40.MouseDown, _ColorList_4.MouseDown, _ColorList_39.MouseDown, _ColorList_38.MouseDown, _ColorList_37.MouseDown, _ColorList_36.MouseDown, _ColorList_35.MouseDown, _ColorList_34.MouseDown, _ColorList_33.MouseDown, _ColorList_32.MouseDown, _ColorList_31.MouseDown, _ColorList_30.MouseDown, _ColorList_3.MouseDown, _ColorList_29.MouseDown, _ColorList_28.MouseDown, _ColorList_27.MouseDown, _ColorList_26.MouseDown, _ColorList_25.MouseDown, _ColorList_24.MouseDown, _ColorList_23.MouseDown, _ColorList_22.MouseDown, _ColorList_21.MouseDown, _ColorList_20.MouseDown, _ColorList_2.MouseDown, _ColorList_19.MouseDown, _ColorList_18.MouseDown, _ColorList_17.MouseDown, _ColorList_16.MouseDown, _ColorList_15.MouseDown, _ColorList_14.MouseDown, _ColorList_13.MouseDown, _ColorList_12.MouseDown, _ColorList_11.MouseDown, _ColorList_10.MouseDown, _ColorList_1.MouseDown, _ColorList_0.MouseDown
        Dim Index As Short = System.Array.IndexOf(ColorList, eventSender)

        selectpalette(Index + 1)
    End Sub

    'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    'UPGRADE_WARNING: Event red.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 red_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Red.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        Dim b As Integer
        b = App.EFChange8(Red, 0, 15)
        palettes(selectedpalette) = CShort(palettes(selectedpalette) And &HF0FF) + (b * &H100)
        '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"'
        ColorList(selectedpalette - 1).BackColor = graphics.f558.palettetocolor(palettes(selectedpalette))
        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 green.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 green_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Green.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        Dim b As Integer
        b = App.EFChange8(Green, 0, 15)
        palettes(selectedpalette) = CShort(palettes(selectedpalette) And &HFF0F) + (b * &H10)
        '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"'
        ColorList(selectedpalette - 1).BackColor = graphics.f558.palettetocolor(palettes(selectedpalette))
        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 blue.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 blue_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Blue.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        Dim b As Integer
        b = App.EFChange8(Blue, 0, 15)
        palettes(selectedpalette) = CShort(palettes(selectedpalette) And &HFFF0) + (b * &H1)
        '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"'
        ColorList(selectedpalette - 1).BackColor = graphics.f558.palettetocolor(palettes(selectedpalette))
        subchange = False
    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 Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click
        Dim j As Integer
        Dim i As Integer
        For i = 1 To 13
            For j = 1 To 7
                App.graphics.f558.setpallete(i, j, palettes((j - 1) * 13 + i))
            Next
        Next
        App.graphics.f558.update()
        Dim num As Short
        num = selectedpalette
        While num > 13
            num = num - 13
        End While

        txtbox.Text = Str(num)
        Me.Close()
    End Sub




    Private Sub UseNone_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles UseNone.Click
        Dim j As Integer
        Dim i As Integer

        For i = 1 To 13
            For j = 1 To 7
                App.graphics.f558.setpallete(i, j, palettes((j - 1) * 13 + i))
            Next
        Next
        Dim num As Short
        num = 0

        txtbox.Text = Str(num)
        Me.Close()
    End Sub

    Private Sub PaletteEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ColorList(0) = _ColorList_0
        ColorList(1) = _ColorList_1
        ColorList(2) = _ColorList_2
        ColorList(3) = _ColorList_3
        ColorList(4) = _ColorList_4
        ColorList(5) = _ColorList_5
        ColorList(6) = _ColorList_6
        ColorList(7) = _ColorList_7
        ColorList(8) = _ColorList_8
        ColorList(9) = _ColorList_9
        ColorList(10) = _ColorList_10
        ColorList(11) = _ColorList_11
        ColorList(12) = _ColorList_12
        ColorList(13) = _ColorList_13
        ColorList(14) = _ColorList_14
        ColorList(15) = _ColorList_15
        ColorList(16) = _ColorList_16
        ColorList(17) = _ColorList_17
        ColorList(18) = _ColorList_18
        ColorList(19) = _ColorList_19
        ColorList(20) = _ColorList_20
        ColorList(21) = _ColorList_21
        ColorList(22) = _ColorList_22
        ColorList(23) = _ColorList_23
        ColorList(24) = _ColorList_24
        ColorList(25) = _ColorList_25
        ColorList(26) = _ColorList_26
        ColorList(27) = _ColorList_27
        ColorList(28) = _ColorList_28
        ColorList(29) = _ColorList_29
        ColorList(30) = _ColorList_30
        ColorList(31) = _ColorList_31
        ColorList(32) = _ColorList_32
        ColorList(33) = _ColorList_33
        ColorList(34) = _ColorList_34
        ColorList(35) = _ColorList_35
        ColorList(36) = _ColorList_36
        ColorList(37) = _ColorList_37
        ColorList(38) = _ColorList_38
        ColorList(39) = _ColorList_39
        ColorList(40) = _ColorList_40
        ColorList(41) = _ColorList_41
        ColorList(42) = _ColorList_42
        ColorList(43) = _ColorList_43
        ColorList(44) = _ColorList_44
        ColorList(45) = _ColorList_45
        ColorList(46) = _ColorList_46
        ColorList(47) = _ColorList_47
        ColorList(48) = _ColorList_48
        ColorList(49) = _ColorList_49
        ColorList(50) = _ColorList_50
        ColorList(51) = _ColorList_51
        ColorList(52) = _ColorList_52
        ColorList(53) = _ColorList_53
        ColorList(54) = _ColorList_54
        ColorList(55) = _ColorList_55
        ColorList(56) = _ColorList_56
        ColorList(57) = _ColorList_57
        ColorList(58) = _ColorList_58
        ColorList(59) = _ColorList_59
        ColorList(60) = _ColorList_60
        ColorList(61) = _ColorList_61
        ColorList(62) = _ColorList_62
        ColorList(63) = _ColorList_63
        ColorList(64) = _ColorList_64
        ColorList(65) = _ColorList_65
        ColorList(66) = _ColorList_66
        ColorList(67) = _ColorList_67
        ColorList(68) = _ColorList_68
        ColorList(69) = _ColorList_69
        ColorList(70) = _ColorList_70
        ColorList(71) = _ColorList_71
        ColorList(72) = _ColorList_72
        ColorList(73) = _ColorList_73
        ColorList(74) = _ColorList_74
        ColorList(75) = _ColorList_75
        ColorList(76) = _ColorList_76
        ColorList(77) = _ColorList_77
        ColorList(78) = _ColorList_78
        ColorList(79) = _ColorList_79
        ColorList(80) = _ColorList_80
        ColorList(81) = _ColorList_81
        ColorList(82) = _ColorList_82
        ColorList(83) = _ColorList_83
        ColorList(84) = _ColorList_84
        ColorList(85) = _ColorList_85
        ColorList(86) = _ColorList_86
        ColorList(87) = _ColorList_87
        ColorList(88) = _ColorList_88
        ColorList(89) = _ColorList_89
        ColorList(90) = _ColorList_90
    End Sub
End Class