Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class MissileGraphicInfoEditor
	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 missileGraphicInfos() As missilegraphicinfo = ADGEDotNetUt.ArrayUt(Of missilegraphicinfo).NewArray1(14)
	Public selectedmissilegraphicinfos As Short
	Public subchange As Boolean
	
    Public Sub init()
        Dim i As Short

        MissileGraphicInfoList.Items.Clear()

        Dim c As Integer
        Dim rows As String() = DUt.Read_Dic_Weapon()
        For c = 0 To 14 - 1
            MissileGraphicInfoList.Items.Add(c.ToString("00")).SubItems.Add(rows(c))
        Next

        For i = 1 To 14
            missileGraphicInfos(i).GraphicNum = App.graphics.f558.missilegraphicinfo(i).GraphicNum
            missileGraphicInfos(i).GraphicOffset = App.graphics.f558.missilegraphicinfo(i).GraphicOffset
            missileGraphicInfos(i).Width = App.graphics.f558.missilegraphicinfo(i).Width
            missileGraphicInfos(i).Height = App.graphics.f558.missilegraphicinfo(i).Height
            missileGraphicInfos(i).Spell_Renamed = App.graphics.f558.missilegraphicinfo(i).Spell_Renamed
            missileGraphicInfos(i).Byte5 = App.graphics.f558.missilegraphicinfo(i).Byte5
        Next
        subchange = True
        selectmissilegraphicinfo(1)
        subchange = False
    End Sub
	
	
    Public Sub load_graphics()
        Dim i As Integer
        Dim GWidth As Integer
        Dim GHeight As Integer

        graphics.curPalette = graphics.gPALETTE_MAIN
        i = missileGraphicInfos(selectedmissilegraphicinfos).GraphicNum + 316
        GWidth = missileGraphicInfos(selectedmissilegraphicinfos).Width * 2
        GHeight = missileGraphicInfos(selectedmissilegraphicinfos).Height

        If True Then
            Dim offscreen As Drawing.Bitmap = New Bitmap(GWidth, GHeight)
            Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
                graphics.stretchbmp(cv, i, 0, 0, GWidth, GHeight, 0, 0)
            End Using
            GraphicA.Image = offscreen
        End If
        GraphicA.Left = ((LineA.X2) - (LineA.X1)) / 2 + (LineA.X1) - GWidth / 2 - 2
        GraphicA.Width = GWidth + 4
        GraphicA.Height = GHeight + 4
        GraphicA.Refresh()
        i = i + 1
        If missileGraphicInfos(selectedmissilegraphicinfos).b5_frontview > 0 Then
            If True Then
                Dim offscreen As Drawing.Bitmap = New Bitmap(GWidth, GHeight)
                Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
                    graphics.stretchbmp(cv, i, 0, 0, GWidth, GHeight, 0, 0)
                End Using
                GraphicB.Image = offscreen
            End If
            GraphicB.Left = ((LineB.X2) - (LineB.X1)) / 2 + (LineB.X1) - GWidth / 2 - 2
            GraphicB.Width = GWidth + 4
            GraphicB.Height = GHeight + 4
            GraphicB.Refresh()
            i = i + 1
            GraphicB.Visible = True
        Else
            GraphicB.Visible = False
        End If
        If missileGraphicInfos(selectedmissilegraphicinfos).b5_sideview > 0 Then
            If True Then
                Dim offscreen As Drawing.Bitmap = New Bitmap(GWidth, GHeight)
                Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
                    graphics.stretchbmp(cv, i, 0, 0, GWidth, GHeight, 0, 0)
                End Using
                GraphicC.Image = offscreen
            End If
            GraphicC.Left = ((LineC.X2) - (LineC.X1)) / 2 + (LineC.X1) - GWidth / 2 - 2
            GraphicC.Width = GWidth + 4
            GraphicC.Height = GHeight + 4
            GraphicC.Refresh()
            i = i + 1
            GraphicC.Visible = True
        Else
            GraphicC.Visible = False
        End If

    End Sub
    Public Sub selectmissilegraphicinfo(ByVal num As Short)
        selectedmissilegraphicinfos = num

        MissileGraphicInfoList.Items(selectedmissilegraphicinfos - 1).Focused = True
        MyUt.CheckSel(MissileGraphicInfoList, selectedmissilegraphicinfos - 1, "BlueGem")
        GraphicNum.Text = Str(missileGraphicInfos(num).GraphicNum)
        GraphicOffset.Text = Str(missileGraphicInfos(num).GraphicOffset)
        GHeight.Text = Str(missileGraphicInfos(num).Height)
        GWidth.Text = Str(missileGraphicInfos(num).Width)
        Byte4.Text = Str(missileGraphicInfos(num).Spell_Renamed)
        Byte5.Text = Str(missileGraphicInfos(num).Byte5)

        CBAnimate.CheckState = missileGraphicInfos(num).b5_animate
        CBFrontView.CheckState = missileGraphicInfos(num).b5_frontview
        CBSideView.CheckState = missileGraphicInfos(num).b5_sideview
        CBSpell.CheckState = missileGraphicInfos(num).b4_spell

        load_graphics()
    End Sub
	
	
	'UPGRADE_WARNING: Event byte4.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 byte4_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles byte4.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).Spell_Renamed = App.EFChange8(Byte4, 0, 255)
		CBSpell.CheckState = missileGraphicInfos(selectedmissilegraphicinfos).b4_spell
		subchange = False
	End Sub
    Private Sub byte5_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Byte5.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        missileGraphicInfos(selectedmissilegraphicinfos).Byte5 = App.EFChange8(Byte5, 0, 255)
        CBAnimate.CheckState = missileGraphicInfos(selectedmissilegraphicinfos).b5_animate
        CBFrontView.CheckState = missileGraphicInfos(selectedmissilegraphicinfos).b5_frontview
        CBSideView.CheckState = missileGraphicInfos(selectedmissilegraphicinfos).b5_sideview
        subchange = False
    End Sub
	
    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click
        Hide()

    End Sub
	
	
	'UPGRADE_WARNING: Event GraphicNum.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 GraphicNum_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles GraphicNum.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).GraphicNum = App.EFChange8(GraphicNum, 0, 255)
		load_graphics()
		subchange = False
	End Sub
	'UPGRADE_WARNING: Event GraphicOffset.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 GraphicOffset_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles GraphicOffset.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).GraphicOffset = App.EFChange8(GraphicOffset, 0, 255)
		subchange = False
	End Sub
	
    Private Sub missilegraphicinfoList_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MissileGraphicInfoList.SelectedIndexChanged
        If MissileGraphicInfoList.FocusedItem Is Nothing Then Exit Sub
        If subchange = True Then
            Exit Sub
        End If
        subchange = True
        selectmissilegraphicinfo(MissileGraphicInfoList.FocusedItem.Index + 1)
        subchange = False
    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 14

            App.graphics.f558.missilegraphicinfo(i).GraphicNum = missileGraphicInfos(i).GraphicNum
            App.graphics.f558.missilegraphicinfo(i).GraphicOffset = missileGraphicInfos(i).GraphicOffset
            App.graphics.f558.missilegraphicinfo(i).Width = missileGraphicInfos(i).Width
            App.graphics.f558.missilegraphicinfo(i).Height = missileGraphicInfos(i).Height
            App.graphics.f558.missilegraphicinfo(i).Spell_Renamed = missileGraphicInfos(i).Spell_Renamed
            App.graphics.f558.missilegraphicinfo(i).Byte5 = missileGraphicInfos(i).Byte5
        Next
        App.graphics.f558.update()
        Hide()
    End Sub
	
    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
        missileGraphicInfos(selectedmissilegraphicinfos).Width = App.EFChange8(GWidth, 0, 255)
        'ImageA.width = 2 * missileGraphicInfos(selectedmissilegraphicinfos).width + 4
        ''ImageB.width = 2 * missileGraphicInfos(selectedmissilegraphicinfos).width + 4
        'ImageC.width = 2 * missileGraphicInfos(selectedmissilegraphicinfos).width + 4
        load_graphics()
        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
		missileGraphicInfos(selectedmissilegraphicinfos).height = App.EFChange8(GHeight, 0, 255)
		
		'ImageA.height = missileGraphicInfos(selectedmissilegraphicinfos).height + 4
		'ImageB.height = missileGraphicInfos(selectedmissilegraphicinfos).height + 4
		'ImageC.height = missileGraphicInfos(selectedmissilegraphicinfos).height + 4
		load_graphics()
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event CBSpell.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 CBSpell_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBSpell.CheckStateChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).setb4_spell((CBSpell.CheckState))
		Byte4.Text = Str(missileGraphicInfos(selectedmissilegraphicinfos).Spell_Renamed)
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event CBAnimate.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 CBAnimate_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBAnimate.CheckStateChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).setb5_animate((CBAnimate.CheckState))
		Byte5.Text = Str(missileGraphicInfos(selectedmissilegraphicinfos).Byte5)
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event CBsideview.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 CBsideview_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBsideview.CheckStateChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).setb5_sideview((CBSideView.CheckState))
		Byte5.Text = Str(missileGraphicInfos(selectedmissilegraphicinfos).Byte5)
		load_graphics()
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event CBfrontview.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 CBfrontview_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBfrontview.CheckStateChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		missileGraphicInfos(selectedmissilegraphicinfos).setb5_frontview((CBFrontView.CheckState))
		Byte5.Text = Str(missileGraphicInfos(selectedmissilegraphicinfos).Byte5)
		load_graphics()
		subchange = False
	End Sub

    Private Sub MissileGraphicInfoEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MissileGraphicInfoList.SmallImageList = App.JewelIL
    End Sub
End Class