Public Class Bytes20194Editor
    Dim clrs(16) As Drawing.Color

    Public Sub init()
        graphics.curPalette = graphics.gPALETTE_MAIN

        Dim i As Integer
        For i = 0 To 15
            clrs(i) = graphics.getpalette(graphics.curPalette, i)
        Next

        NumericUpDown0.Value = App.graphics.f560.byte20194(1) : NumericUpDown0_ValueChanged(NumericUpDown0, New EventArgs())
        NumericUpDown1.Value = App.graphics.f560.byte20194(2) : NumericUpDown0_ValueChanged(NumericUpDown1, New EventArgs())
        NumericUpDown2.Value = App.graphics.f560.byte20194(3) : NumericUpDown0_ValueChanged(NumericUpDown2, New EventArgs())
        NumericUpDown3.Value = App.graphics.f560.byte20194(4) : NumericUpDown0_ValueChanged(NumericUpDown3, New EventArgs())
        NumericUpDown4.Value = App.graphics.f560.byte20194(5) : NumericUpDown0_ValueChanged(NumericUpDown4, New EventArgs())
        NumericUpDown5.Value = App.graphics.f560.byte20194(6) : NumericUpDown0_ValueChanged(NumericUpDown5, New EventArgs())
        NumericUpDown6.Value = App.graphics.f560.byte20194(7) : NumericUpDown0_ValueChanged(NumericUpDown6, New EventArgs())
        NumericUpDown7.Value = App.graphics.f560.byte20194(8) : NumericUpDown0_ValueChanged(NumericUpDown7, New EventArgs())
        NumericUpDown8.Value = App.graphics.f560.byte20194(9) : NumericUpDown0_ValueChanged(NumericUpDown8, New EventArgs())
        NumericUpDown9.Value = App.graphics.f560.byte20194(10) : NumericUpDown0_ValueChanged(NumericUpDown9, New EventArgs())
        NumericUpDown10.Value = App.graphics.f560.byte20194(11) : NumericUpDown0_ValueChanged(NumericUpDown10, New EventArgs())
        NumericUpDown11.Value = App.graphics.f560.byte20194(12) : NumericUpDown0_ValueChanged(NumericUpDown11, New EventArgs())
        NumericUpDown12.Value = App.graphics.f560.byte20194(13) : NumericUpDown0_ValueChanged(NumericUpDown12, New EventArgs())
        NumericUpDown13.Value = App.graphics.f560.byte20194(14) : NumericUpDown0_ValueChanged(NumericUpDown13, New EventArgs())
        NumericUpDown14.Value = App.graphics.f560.byte20194(15) : NumericUpDown0_ValueChanged(NumericUpDown14, New EventArgs())
        NumericUpDown15.Value = App.graphics.f560.byte20194(16) : NumericUpDown0_ValueChanged(NumericUpDown15, New EventArgs())
    End Sub

    Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
        App.graphics.f560.setbyte20194(1, CByte(NumericUpDown0.Value))
        App.graphics.f560.setbyte20194(2, CByte(NumericUpDown1.Value))
        App.graphics.f560.setbyte20194(3, CByte(NumericUpDown2.Value))
        App.graphics.f560.setbyte20194(4, CByte(NumericUpDown3.Value))
        App.graphics.f560.setbyte20194(5, CByte(NumericUpDown4.Value))
        App.graphics.f560.setbyte20194(6, CByte(NumericUpDown5.Value))
        App.graphics.f560.setbyte20194(7, CByte(NumericUpDown6.Value))
        App.graphics.f560.setbyte20194(8, CByte(NumericUpDown7.Value))
        App.graphics.f560.setbyte20194(9, CByte(NumericUpDown8.Value))
        App.graphics.f560.setbyte20194(10, CByte(NumericUpDown9.Value))
        App.graphics.f560.setbyte20194(11, CByte(NumericUpDown10.Value))
        App.graphics.f560.setbyte20194(12, CByte(NumericUpDown11.Value))
        App.graphics.f560.setbyte20194(13, CByte(NumericUpDown12.Value))
        App.graphics.f560.setbyte20194(14, CByte(NumericUpDown13.Value))
        App.graphics.f560.setbyte20194(15, CByte(NumericUpDown14.Value))
        App.graphics.f560.setbyte20194(16, CByte(NumericUpDown15.Value))
        App.graphics.f560.update()
        Hide()
    End Sub

    Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCancel.Click
        Hide()
    End Sub

    Private Sub Bytes20194Editor_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Select Case e.CloseReason
            Case CloseReason.UserClosing
                e.Cancel = True
                Hide()
        End Select
    End Sub

    Private Sub Bytes20194Editor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub NumericUpDown0_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
        NumericUpDown0.ValueChanged, _
        NumericUpDown1.ValueChanged, _
        NumericUpDown2.ValueChanged, _
        NumericUpDown3.ValueChanged, _
        NumericUpDown4.ValueChanged, _
        NumericUpDown5.ValueChanged, _
        NumericUpDown6.ValueChanged, _
        NumericUpDown7.ValueChanged, _
        NumericUpDown8.ValueChanged, _
        NumericUpDown9.ValueChanged, _
        NumericUpDown10.ValueChanged, _
        NumericUpDown11.ValueChanged, _
        NumericUpDown12.ValueChanged, _
        NumericUpDown13.ValueChanged, _
        NumericUpDown14.ValueChanged, _
        NumericUpDown15.ValueChanged

        Dim c As Byte
        c = CByte(CType(sender, NumericUpDown).Value)
        Dim clr As Drawing.Color = Me.BackColor
        If c <= &H9F Then clr = clrs(Int(c / 10))

        If Object.ReferenceEquals(sender, NumericUpDown0) Then Label0.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown1) Then Label1.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown2) Then Label2.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown3) Then Label3.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown4) Then Label4.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown5) Then Label5.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown6) Then Label6.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown7) Then Label7.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown8) Then Label8.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown9) Then Label9.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown10) Then Label10.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown11) Then Label11.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown12) Then Label12.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown13) Then Label13.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown14) Then Label14.BackColor = clr
        If Object.ReferenceEquals(sender, NumericUpDown15) Then Label15.BackColor = clr
    End Sub
End Class