Public Class MainForm
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ButtonAbout As System.Windows.Forms.Button
    Friend WithEvents ButtonOrder As System.Windows.Forms.Button
    Friend WithEvents ButtonCallActionScriptFunction As System.Windows.Forms.Button
    Friend WithEvents f_in_box__control1 As f_in_box__lib.f_in_box__control
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ButtonCallActionScriptFunction = New System.Windows.Forms.Button
        Me.ButtonAbout = New System.Windows.Forms.Button
        Me.ButtonOrder = New System.Windows.Forms.Button
        Me.F_in_box__control1 = New f_in_box__lib.f_in_box__control
        Me.SuspendLayout()
        '
        'ButtonCallActionScriptFunction
        '
        Me.ButtonCallActionScriptFunction.Location = New System.Drawing.Point(8, 376)
        Me.ButtonCallActionScriptFunction.Name = "ButtonCallActionScriptFunction"
        Me.ButtonCallActionScriptFunction.Size = New System.Drawing.Size(224, 56)
        Me.ButtonCallActionScriptFunction.TabIndex = 3
        Me.ButtonCallActionScriptFunction.Text = "Call ActionScript function"
        '
        'ButtonAbout
        '
        Me.ButtonAbout.Location = New System.Drawing.Point(448, 376)
        Me.ButtonAbout.Name = "ButtonAbout"
        Me.ButtonAbout.Size = New System.Drawing.Size(176, 23)
        Me.ButtonAbout.TabIndex = 5
        Me.ButtonAbout.Text = "More about F-IN-BOX"
        '
        'ButtonOrder
        '
        Me.ButtonOrder.Location = New System.Drawing.Point(448, 408)
        Me.ButtonOrder.Name = "ButtonOrder"
        Me.ButtonOrder.Size = New System.Drawing.Size(176, 23)
        Me.ButtonOrder.TabIndex = 6
        Me.ButtonOrder.Text = "Buy license"
        '
        'f_in_box__control1
        '
        Me.F_in_box__control1.FlashProperty_AlignMode = 0
        Me.F_in_box__control1.FlashProperty_AllowScriptAccess = ""
        Me.F_in_box__control1.FlashProperty_BackgroundColor = -1
        Me.F_in_box__control1.FlashProperty_Base = ""
        Me.F_in_box__control1.FlashProperty_BGColor = ""
        Me.F_in_box__control1.FlashProperty_DeviceFont = False
        Me.F_in_box__control1.FlashProperty_EmbedMovie = False
        Me.F_in_box__control1.FlashProperty_FlashVars = ""
        Me.F_in_box__control1.FlashProperty_FrameNum = -1
        Me.F_in_box__control1.FlashProperty_Loop = True
        Me.F_in_box__control1.FlashProperty_Menu = True
        Me.F_in_box__control1.FlashProperty_Movie = ""
        Me.F_in_box__control1.FlashProperty_MovieData = ""
        Me.F_in_box__control1.FlashProperty_Playing = True
        Me.F_in_box__control1.FlashProperty_Quality = 1
        Me.F_in_box__control1.FlashProperty_Quality2 = "High"
        Me.F_in_box__control1.FlashProperty_SAlign = ""
        Me.F_in_box__control1.FlashProperty_Scale = "ShowAll"
        Me.F_in_box__control1.FlashProperty_ScaleMode = 0
        Me.F_in_box__control1.FlashProperty_Stacking = ""
        Me.F_in_box__control1.FlashProperty_SWRemote = ""
        Me.F_in_box__control1.FlashProperty_WMode = "Window"
        Me.F_in_box__control1.Location = New System.Drawing.Point(8, 8)
        Me.F_in_box__control1.Name = "f_in_box__control1"
        Me.F_in_box__control1.Size = New System.Drawing.Size(616, 360)
        Me.F_in_box__control1.StandardMenu = False
        Me.F_in_box__control1.TabIndex = 7
        Me.F_in_box__control1.Text = "f_in_box__control1"
        '
        'MainForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(632, 446)
        Me.Controls.Add(Me.F_in_box__control1)
        Me.Controls.Add(Me.ButtonOrder)
        Me.Controls.Add(Me.ButtonAbout)
        Me.Controls.Add(Me.ButtonCallActionScriptFunction)
        Me.MaximizeBox = False
        Me.Name = "MainForm"
        Me.Text = "Sample 7 - Flash 8 External API"
        Me.ResumeLayout(False)

    End Sub

#End Region

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

        If Not f_in_box__lib.[Global].IsFlashInstalled Then
            System.Windows.Forms.MessageBox.Show("Flash is not installed!")
            Close()
        End If

        Dim FlashVersion As f_in_box__lib.Version = f_in_box__control1.AxCode.Version

        If FlashVersion.MajorPart < 8 Then
            System.Windows.Forms.MessageBox.Show("The application needs Flash 8 or higher\nCurrent version is: " + FlashVersion.ToString())
            Close()
        End If

        f_in_box__control1.PutMovieFromStream(Me.GetType().Assembly.GetManifestResourceStream("Sample07_ExternalInterface.externalinterface.swf"))
        f_in_box__control1.FlashMethod_Play()
    End Sub

    Private Sub ButtonCallActionScriptFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCallActionScriptFunction.Click
        Dim Response As String = f_in_box__control1.FlashMethod_CallFunction("<invoke name=" + """" + "CallMeFromApplication" + """" + " returntype=" + """" + "xml" + """" + "><arguments><string>Some text for F-IN-BOX .NET</string></arguments></invoke>")
        MsgBox("The function returned: '" + Response + "'")
    End Sub

    Private Sub f_in_box__control1_OnFlashCall(ByVal sender As Object, ByVal request As String) Handles f_in_box__control1.OnFlashCall
        f_in_box__control1.FlashMethod_SetReturnValue("<string>Current time is: " + System.DateTime.Now.ToString() + "</string>")
    End Sub

    Private Sub ButtonAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAbout.Click
        System.Diagnostics.Process.Start("http://www.f-in-box.com/dotnet/")
    End Sub

    Private Sub ButtonOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOrder.Click
        System.Diagnostics.Process.Start("http://www.f-in-box.com/dotnet/order.html")
    End Sub

    Private Sub f_in_box__control1_OnIsInputKey(ByVal sender As Object, ByVal keyData As System.Windows.Forms.Keys, ByRef InputKey As Boolean) Handles f_in_box__control1.OnIsInputKey
        If keyData = Keys.Tab Or keyData = Keys.Enter Or keyData = Keys.Left Or keyData = Keys.Right Or keyData = Keys.Up Or keyData = Keys.Down Then
            InputKey = True
        End If
    End Sub
End Class
