Imports System.Windows.Forms

Public Class Form1
    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 PlaySWFFromFileButton As System.Windows.Forms.Button
    Friend WithEvents MoreAboutComponentButton As System.Windows.Forms.Button
    Friend WithEvents OrderButton As System.Windows.Forms.Button
    Friend WithEvents OpenSWFFileDialog As System.Windows.Forms.OpenFileDialog
    Friend WithEvents SaveFrameButton As System.Windows.Forms.Button
    Friend WithEvents SaveBMPFileDialog As System.Windows.Forms.SaveFileDialog
    Friend WithEvents f_in_box__control1 As f_in_box__lib.f_in_box__control
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.PlaySWFFromFileButton = New System.Windows.Forms.Button
        Me.MoreAboutComponentButton = New System.Windows.Forms.Button
        Me.OrderButton = New System.Windows.Forms.Button
        Me.OpenSWFFileDialog = New System.Windows.Forms.OpenFileDialog
        Me.SaveFrameButton = New System.Windows.Forms.Button
        Me.SaveBMPFileDialog = New System.Windows.Forms.SaveFileDialog
        Me.f_in_box__control1 = New f_in_box__lib.f_in_box__control
        Me.SuspendLayout()
        '
        'PlaySWFFromFileButton
        '
        Me.PlaySWFFromFileButton.Location = New System.Drawing.Point(8, 376)
        Me.PlaySWFFromFileButton.Name = "PlaySWFFromFileButton"
        Me.PlaySWFFromFileButton.Size = New System.Drawing.Size(128, 24)
        Me.PlaySWFFromFileButton.TabIndex = 3
        Me.PlaySWFFromFileButton.Text = "Play SWF from file..."
        '
        'MoreAboutComponentButton
        '
        Me.MoreAboutComponentButton.Location = New System.Drawing.Point(272, 408)
        Me.MoreAboutComponentButton.Name = "MoreAboutComponentButton"
        Me.MoreAboutComponentButton.Size = New System.Drawing.Size(176, 24)
        Me.MoreAboutComponentButton.TabIndex = 3
        Me.MoreAboutComponentButton.Text = "More about F-IN-BOX"
        '
        'OrderButton
        '
        Me.OrderButton.Location = New System.Drawing.Point(456, 408)
        Me.OrderButton.Name = "OrderButton"
        Me.OrderButton.Size = New System.Drawing.Size(168, 24)
        Me.OrderButton.TabIndex = 3
        Me.OrderButton.Text = "Buy license"
        '
        'OpenSWFFileDialog
        '
        Me.OpenSWFFileDialog.Filter = "Flash Movies (*.swf)|*.swf|All Files (*.*)|*.*"
        '
        'SaveFrameButton
        '
        Me.SaveFrameButton.Location = New System.Drawing.Point(144, 376)
        Me.SaveFrameButton.Name = "SaveFrameButton"
        Me.SaveFrameButton.Size = New System.Drawing.Size(184, 24)
        Me.SaveFrameButton.TabIndex = 3
        Me.SaveFrameButton.Text = "Save frame as bitmap..."
        '
        'SaveBMPFileDialog
        '
        Me.SaveBMPFileDialog.Filter = "Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*"
        '
        'f_in_box__control1
        '
        Me.f_in_box__control1.Context = Nothing
        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 = 4
        Me.f_in_box__control1.Text = "f_in_box__control1"
        Me.f_in_box__control1.TransparentMode = False
        '
        'Form1
        '
        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.PlaySWFFromFileButton)
        Me.Controls.Add(Me.MoreAboutComponentButton)
        Me.Controls.Add(Me.OrderButton)
        Me.Controls.Add(Me.SaveFrameButton)
        Me.MaximizeBox = False
        Me.Name = "Form1"
        Me.Text = "Sample 5 - Saving Frame As Bitmap"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OpenSWFFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(Application.ExecutablePath())
        SaveBMPFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(Application.ExecutablePath())

        f_in_box__control1.PutMovieFromStream(Me.GetType().Assembly.GetManifestResourceStream("Sample05_SWF2Bitmap.movie.swf"))
        f_in_box__control1.FlashMethod_Play()
    End Sub

    Private Sub PlaySWFFromFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlaySWFFromFileButton.Click
        If OpenSWFFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            f_in_box__control1.FlashProperty_Movie = OpenSWFFileDialog.FileName
        End If
    End Sub

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

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

    Private Sub SaveFrameButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveFrameButton.Click
        Dim FrameBitmap As Bitmap = f_in_box__control1.GetBitmap()

        If SaveBMPFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            FrameBitmap.Save(SaveBMPFileDialog.FileName, System.Drawing.Imaging.ImageFormat.Bmp)

            If System.Windows.Forms.DialogResult.Yes = MessageBox.Show("Would you like to open saved image?", "Question", MessageBoxButtons.YesNo) Then
                System.Diagnostics.Process.Start(SaveBMPFileDialog.FileName)
            End If
        End If
    End Sub
End Class
