Option Strict Off
Option Explicit On
Friend Class DoorEditor
	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 Doors() As Tdoor = ADGEDotNetUt.ArrayUt(Of Tdoor).NewArray1(4)
	Public selecteddoor As Short
	Public subchange As Boolean
	
    Public Sub init()
        Dim i As Short

        DoorList.Items.Clear()

        DoorList.Items.Add("00").SubItems.Add("Porticullas")
        DoorList.Items.Add("01").SubItems.Add("Wooden")
        DoorList.Items.Add("02").SubItems.Add("Iron")
        DoorList.Items.Add("03").SubItems.Add("Ra")

        For i = 1 To 4
            Doors(i).byte0 = App.graphics.f559.door(i).byte0
            Doors(i).strength = App.graphics.f559.door(i).strength

        Next

        selectdoor(1)
    End Sub
	
    Public Sub selectdoor(ByVal num As Short)
        selecteddoor = num

        DoorList.Items(selecteddoor - 1).Focused = True
        MyUt.CheckSel(DoorList, selecteddoor - 1, "BlueGem")
        Strength.Text = Str(Doors(num).strength)
        Byte0.Text = Str(Doors(num).byte0)
        MirroredRandomly.CheckState = Doors(num).mirrored
        NonMaterialsCannotPass.CheckState = Doors(num).pass_nonmaterial
        ProjectilesCanPass.CheckState = Doors(num).pass_projectile

        'graphics.resetmodifiedcolorarray
        '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
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapwidth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        Graphic.Width = 2 * graphics.getgbitmapwidth(107 + 3 * selecteddoor)
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapheight. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        Graphic.Height = 2 * graphics.getgbitmapheight(107 + 3 * selecteddoor)
        Dim offscreen As Bitmap = New Bitmap(Graphic.ClientSize.Width, Graphic.ClientSize.Height)
        Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
            graphics.stretchbmpby(cv, 107 + 3 * selecteddoor, 0, 0, 0, 0, 200, 200)
        End Using
        Graphic.Image = offscreen
        Graphic.Refresh()
        'ImageDoor.Picture = graphics.loadgraphic(108 + 3 * selecteddoor, 0)
    End Sub
	
	'UPGRADE_WARNING: Event NonMaterialsCannotPass.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 NonMaterialsCannotPass_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles NonMaterialsCannotPass.CheckStateChanged
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		Doors(selecteddoor).set_passnonmaterial((NonMaterialsCannotPass.CheckState))
		Byte0.Text = Str(Doors(selecteddoor).Byte0)
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event ProjectilesCanPass.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 ProjectilesCanPass_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ProjectilesCanPass.CheckStateChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		Doors(selecteddoor).set_passprojectile((ProjectilesCanPass.CheckState))
		Byte0.Text = Str(Doors(selecteddoor).Byte0)
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event strength.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 strength_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles strength.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		Doors(selecteddoor).Strength = App.EFChange8(Strength, 0, 255)
		subchange = False
	End Sub
	'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
		Doors(selecteddoor).Byte0 = App.EFChange8(Byte0, 0, 255)
		
		MirroredRandomly.CheckState = Doors(selecteddoor).mirrored
		NonMaterialsCannotPass.CheckState = Doors(selecteddoor).pass_nonmaterial
		ProjectilesCanPass.CheckState = Doors(selecteddoor).pass_projectile
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event MirroredRandomly.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 MirroredRandomly_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MirroredRandomly.CheckStateChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		Doors(selecteddoor).set_mirrored((MirroredRandomly.CheckState))
		Byte0.Text = Str(Doors(selecteddoor).Byte0)
		subchange = False
	End Sub
	
    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click
        Hide()

    End Sub
	
	
    Private Sub doorList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles DoorList.SelectedIndexChanged
        If DoorList.FocusedItem Is Nothing Then Exit Sub
        selectdoor(DoorList.FocusedItem.Index + 1)
    End Sub
	
	
    Private Sub Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click
        Dim i As Integer
        For i = 1 To 4
            App.graphics.f559.door(i).byte0 = Doors(i).byte0
            App.graphics.f559.door(i).strength = Doors(i).strength
        Next
        App.graphics.f559.update()
        Hide()
    End Sub

    Private Sub DoorEditor_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 DoorEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DoorList.SmallImageList = App.JewelIL
    End Sub
End Class