VERSION 5.00
Begin VB.Form frmDVDButton 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "AVStoDVD Button Generator"
   ClientHeight    =   6135
   ClientLeft      =   45
   ClientTop       =   615
   ClientWidth     =   4410
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   HelpContextID   =   82
   Icon            =   "frmDVDButton.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   6135
   ScaleWidth      =   4410
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame corColors 
      Caption         =   "Colors"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1635
      Left            =   2130
      TabIndex        =   18
      Top             =   1980
      Width           =   2175
      Begin VB.CommandButton Pls_LabelColor 
         Height          =   315
         Left            =   1200
         Style           =   1  'Graphical
         TabIndex        =   20
         Top             =   300
         Width           =   795
      End
      Begin VB.CommandButton Pls_BackColor 
         Height          =   315
         Left            =   1200
         Style           =   1  'Graphical
         TabIndex        =   22
         Top             =   720
         Width           =   795
      End
      Begin VB.CommandButton Pls_BorderColor 
         Height          =   315
         Left            =   1200
         Style           =   1  'Graphical
         TabIndex        =   24
         Top             =   1140
         Width           =   795
      End
      Begin VB.Label lblBorderColor 
         Caption         =   "Border:"
         Height          =   255
         Left            =   210
         TabIndex        =   23
         Top             =   1200
         Width           =   795
      End
      Begin VB.Label lblBackColor 
         Caption         =   "Background:"
         Height          =   255
         Left            =   210
         TabIndex        =   21
         Top             =   780
         Width           =   1005
      End
      Begin VB.Label lblLabelColor 
         Caption         =   "Label:"
         Height          =   255
         Left            =   210
         TabIndex        =   19
         Top             =   360
         Width           =   795
      End
   End
   Begin VB.Frame corDimension 
      Caption         =   "Dimensions"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1635
      Left            =   120
      TabIndex        =   9
      Top             =   1980
      Width           =   1935
      Begin VB.CheckBox int4X 
         Height          =   255
         Left            =   1560
         TabIndex        =   15
         ToolTipText     =   "Width must be multiple of 4 and Height must be multiple of 2"
         Top             =   555
         Width           =   255
      End
      Begin VB.TextBox Txt_Border 
         Height          =   315
         Left            =   840
         TabIndex        =   17
         Top             =   1140
         Width           =   495
      End
      Begin VB.TextBox Txt_Width 
         Height          =   315
         Left            =   840
         TabIndex        =   11
         Top             =   300
         Width           =   495
      End
      Begin VB.TextBox Txt_Height 
         Height          =   315
         Left            =   840
         TabIndex        =   13
         Top             =   720
         Width           =   495
      End
      Begin VB.Label lbl2x 
         Caption         =   "2x"
         Height          =   255
         Left            =   1570
         TabIndex        =   26
         Top             =   800
         Width           =   255
      End
      Begin VB.Label lbl4X 
         Caption         =   "4x"
         Height          =   255
         Left            =   1570
         TabIndex        =   14
         Top             =   360
         Width           =   255
      End
      Begin VB.Line Line3 
         X1              =   1440
         X2              =   1440
         Y1              =   480
         Y2              =   870
      End
      Begin VB.Line Line2 
         X1              =   1320
         X2              =   1440
         Y1              =   870
         Y2              =   870
      End
      Begin VB.Line Line1 
         X1              =   1320
         X2              =   1440
         Y1              =   465
         Y2              =   465
      End
      Begin VB.Label lblBorder 
         Caption         =   "Border:"
         Height          =   255
         Left            =   180
         TabIndex        =   16
         Top             =   1200
         Width           =   555
      End
      Begin VB.Label lblWidth 
         Caption         =   "Width:"
         Height          =   255
         Left            =   180
         TabIndex        =   10
         Top             =   360
         Width           =   555
      End
      Begin VB.Label lblHeight 
         Caption         =   "Height:"
         Height          =   255
         Left            =   180
         TabIndex        =   12
         Top             =   780
         Width           =   555
      End
   End
   Begin VB.Frame corText 
      Caption         =   "Text"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1815
      Left            =   120
      TabIndex        =   0
      Top             =   60
      Width           =   4155
      Begin VB.TextBox Txt_Offset 
         Height          =   315
         Left            =   2700
         TabIndex        =   8
         Top             =   1260
         Width           =   735
      End
      Begin VB.ComboBox cmbFontSize 
         Height          =   315
         Left            =   840
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   1260
         Width           =   795
      End
      Begin VB.ComboBox cmbFontName 
         Height          =   315
         Left            =   840
         Sorted          =   -1  'True
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   840
         Width           =   3135
      End
      Begin VB.TextBox Txt_Label 
         Height          =   315
         Left            =   840
         TabIndex        =   2
         Top             =   420
         Width           =   3135
      End
      Begin VB.Label lblOffset 
         Caption         =   "Offset:"
         Height          =   255
         Left            =   2040
         TabIndex        =   7
         Top             =   1320
         Width           =   555
      End
      Begin VB.Label lblFontSize 
         Caption         =   "Size:"
         Height          =   255
         Left            =   180
         TabIndex        =   5
         Top             =   1320
         Width           =   435
      End
      Begin VB.Label lblFontName 
         Caption         =   "Font:"
         Height          =   255
         Left            =   180
         TabIndex        =   3
         Top             =   900
         Width           =   555
      End
      Begin VB.Label lblLabel 
         Caption         =   "Label:"
         Height          =   255
         Left            =   180
         TabIndex        =   1
         Top             =   480
         Width           =   555
      End
   End
   Begin VB.Shape corButton 
      Height          =   1755
      Left            =   120
      Top             =   4260
      Width           =   4155
   End
   Begin VB.Label lblRefresh 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      BorderStyle     =   1  'Fixed Single
      Caption         =   "REFRESH"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   315
      Left            =   120
      TabIndex        =   25
      Top             =   3780
      Width           =   4155
   End
   Begin VB.Image imgButton 
      Height          =   1635
      Left            =   180
      Top             =   4320
      Width           =   4035
   End
   Begin VB.Menu Menu_File 
      Caption         =   "File"
      Begin VB.Menu Menu_File_Refresh 
         Caption         =   "Refresh"
         Shortcut        =   ^R
      End
      Begin VB.Menu Menu_File_Reset 
         Caption         =   "Reset"
      End
      Begin VB.Menu Menu_File_S1 
         Caption         =   "-"
      End
      Begin VB.Menu Menu_File_Save 
         Caption         =   "Save as Bitmap ..."
      End
      Begin VB.Menu Menu_File_S2 
         Caption         =   "-"
      End
      Begin VB.Menu Menu_File_Exit 
         Caption         =   "Exit"
         Shortcut        =   ^Q
      End
   End
End
Attribute VB_Name = "frmDVDButton"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' -------------------------------------------------------------------------------
'
'   AVStoDVD - by MrC
'   File: frmDVDButton.frm
'   Purpose: AVStoDVD DVD Menu Button Generation form
'
' -------------------------------------------------------------------------------


Option Explicit
Option Compare Binary
Option Base 0


Private Sub Form_Load()

    Dim jj As Integer
    
    On Error Resume Next
    
    ' Load Skin Font settings
    Call modMain.Load_Skin_Font(Me)
    
    ' Load Language
    Call Populate_Form_Language

    On Error GoTo Err_Handling
    
    ' Populate form controls
    Me.Txt_Label.Text = "Play All"
    modDialog.MakeFontsList Me.cmbFontName
    Me.cmbFontName.Text = "Tahoma"
    With Me.cmbFontSize
        .Clear
        For jj = 6 To 20
            .AddItem jj
        Next jj
        For jj = 22 To 40 Step 2
            .AddItem jj
        Next jj
        .Text = 20
    End With
    Me.Txt_Offset.Text = 5
    Me.Txt_Width.Text = 104
    Me.Txt_Height.Text = 32
    Me.int4X.value = 1
    Me.Txt_Border.Text = 1
    Me.Pls_LabelColor.BackColor = RGB(0, 0, 0)
    Me.Pls_BackColor.BackColor = RGB(255, 255, 255)
    Me.Pls_BorderColor.BackColor = RGB(0, 0, 0)
    
    Call lblRefresh_Click
    
    Exit Sub
    
Err_Handling:
Select Case Err.Number
Case 9999
    Resume
Case Else
    MsgBox "Error " & Err.Number & vbCrLf & vbCrLf & Err.Description, vbCritical, App.Title
End Select

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    modFS.DeleteIfExist Preferences.TempPath & "\Button.avs"
    modFS.DeleteIfExist Preferences.TempPath & "\Button.bmp"

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Me.lblRefresh.FontBold = False
    
End Sub

Private Sub Menu_File_Refresh_Click()

    Call lblRefresh_Click
    
End Sub

Private Sub Menu_File_Reset_Click()

    Call Form_Load

End Sub

Private Sub Menu_File_Save_Click()

    Dim PathName As String
    
    On Error GoTo Err_Handling
    
    If modFS.EsisteFile(Preferences.TempPath & "\Button.bmp") = False Then
        Call lblRefresh_Click
    End If
    Do
        PathName = modDialog.SaveFile(Me.hwnd, modStr.DefaultStr(Language("719001"), "Create Button Image"), "Image File (*.bmp)|*.bmp|All Files (*.*)|*.*", Preferences.InputPath, "", cdlOFNFileMustExist + cdlOFNExplorer + cdlOFNLongNames + cdlOFNHideReadOnly)
        If PathName <> "" Then
            If UCase(modFS.ExtOf(PathName)) <> "BMP" Then
                PathName = PathName & ".bmp"
            End If
        Else
            Exit Sub
        End If
        If modFS.EsisteFile(PathName) = True Then
            If MsgBox(Msgs.FileExistsOverwrite, vbQuestion + vbYesNo, App.Title) = vbYes Then Exit Do
        End If
    Loop Until modFS.EsisteFile(PathName) = False
    FileCopy Preferences.TempPath & "\Button.bmp", PathName
    If modFS.EsisteFile(PathName) = True Then
        MsgBox Msgs.CreateSuccess & vbCrLf & vbCrLf & "'" & PathName & "'", vbInformation, App.Title
        If modUtil.FormIsLoad("frmDVDMenu") = True Then
            If MsgBox(modStr.DefaultStr(Language("719002"), "Do you want to use the current button as DVD Menu 'Play All' button image?"), vbQuestion + vbYesNo, App.Title) = vbYes Then
                DVDMenu.PlayAllButtonPicturePath = PathName
                frmDVDMenu.ImgPlayAll.Tag = ""
            End If
        End If
    End If

    Exit Sub
    
Err_Handling:
MsgBox "Error " & Err.Number & vbCrLf & vbCrLf & Err.Description, vbCritical, App.Title

End Sub

Private Sub Menu_File_Exit_Click()

    Unload Me
    
End Sub

Private Sub Pls_LabelColor_Click()

    Dim NewColor As Long
    
    NewColor = modDialog.ShowColor(Me.Pls_LabelColor.BackColor, Me)
    If NewColor <> -1 Then
        Me.Pls_LabelColor.BackColor = NewColor
    End If

End Sub

Private Sub Pls_BackColor_Click()

    Dim NewColor As Long
    
    NewColor = modDialog.ShowColor(Me.Pls_BackColor.BackColor, Me)
    If NewColor <> -1 Then
        Me.Pls_BackColor.BackColor = NewColor
    End If

End Sub

Private Sub Pls_BorderColor_Click()

    Dim NewColor As Long
    
    NewColor = modDialog.ShowColor(Me.Pls_BorderColor.BackColor, Me)
    If NewColor <> -1 Then
        Me.Pls_BorderColor.BackColor = NewColor
    End If

End Sub

Private Sub Txt_Offset_Validate(Cancel As Boolean)

    Dim Flag As Boolean
    
    If IsNumeric(Me.Txt_Offset.Text) = True Then
        If Val(Me.Txt_Offset.Text) > 0 Then
            Flag = True
        End If
    End If
    If Flag = False Then
        MsgBox Msgs.InvalidValue, vbExclamation, App.Title
        Cancel = True
    End If
    
End Sub

Private Sub Txt_Width_Validate(Cancel As Boolean)
    
    Dim Flag As Boolean
    
    If IsNumeric(Me.Txt_Width.Text) = True Then
        If Val(Me.Txt_Width.Text) > 0 Then
            Flag = True
        End If
    End If
    If Flag = False Then
        MsgBox Msgs.InvalidValue, vbExclamation, App.Title
        Cancel = True
    Else
        If Me.int4X.value = 1 Then
            Me.Txt_Width.Text = Round(Val(Me.Txt_Width.Text) / 4) * 4
        End If
    End If
    
End Sub

Private Sub Txt_Height_Validate(Cancel As Boolean)
    
    Dim Flag As Boolean
    
    If IsNumeric(Me.Txt_Height.Text) = True Then
        If Val(Me.Txt_Height.Text) > 0 Then
            Flag = True
        End If
    End If
    If Flag = False Then
        MsgBox Msgs.InvalidValue, vbExclamation, App.Title
        Cancel = True
    Else
        If Me.int4X.value = 1 Then
            Me.Txt_Height.Text = Round(Val(Me.Txt_Height.Text) / 2) * 2
        End If
    End If
    
End Sub

Private Sub int4X_Click()

    If Me.int4X.value = 1 Then
        Me.Txt_Width.Text = Round(Val(Me.Txt_Width.Text) / 4) * 4
        Me.Txt_Height.Text = Round(Val(Me.Txt_Height.Text) / 2) * 2
    End If

End Sub

Private Sub Txt_Border_Validate(Cancel As Boolean)
    
    Dim Flag As Boolean
    
    If IsNumeric(Me.Txt_Border.Text) = True Then
        If Val(Me.Txt_Border.Text) > 0 Then
            Flag = True
        End If
    End If
    If Flag = False Then
        MsgBox Msgs.InvalidValue, vbExclamation, App.Title
        Cancel = True
    End If
    
End Sub

Private Sub corButton_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Me.lblRefresh.FontBold = False
    
End Sub

Private Sub lblRefresh_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Me.lblRefresh.FontBold = True
    
End Sub

Private Sub lblRefresh_Click()

    Dim sAVS As String
    
    On Error GoTo Err_Handling
    
    Screen.MousePointer = vbHourglass
    sAVS = "BlankClip(length=1, width=" & Me.Txt_Width.Text & "-2*" & Me.Txt_Border.Text & ", height=" & Me.Txt_Height.Text & "-2*" & Me.Txt_Border.Text & ", color=$" & modStr.CHex(Me.Pls_BackColor.BackColor) & ")" & vbCrLf & _
           "AddBorders(" & Me.Txt_Border.Text & ", " & Me.Txt_Border.Text & ", " & Me.Txt_Border.Text & ", " & Me.Txt_Border.Text & ", color=$" & modStr.CHex(Me.Pls_BorderColor.BackColor) & ")" & vbCrLf & _
           "Subtitle(""" & Me.Txt_Label.Text & """, x=-1, y=" & Me.Txt_Height.Text & "-" & Me.Txt_Border.Text & "-" & Me.Txt_Offset.Text & ", font=""" & Me.cmbFontName.Text & """, size=" & Me.cmbFontSize.Text & ", text_color=$" & modStr.CHex(Me.Pls_LabelColor.BackColor) & ", halo_color=$" & modStr.CHex(Me.Pls_BackColor.BackColor) & ")" & vbCrLf & _
           "ImageWriter(""" & Preferences.TempPath & "\Button""" & ",type=""bmp"")"
    modStr.STRtoANSIFile sAVS, Preferences.TempPath & "\Button.avs"
    modShellEx.Execute App.Path & "\FFmpeg\ffmpeg.exe", "-i """ & Preferences.TempPath & "\Button.avs""" & " -f rawvideo -y NUL", SW_HIDE, True
    modFS.ReName Preferences.TempPath & "\Button000000.bmp", Preferences.TempPath & "\Button.bmp", True
    Me.imgButton.ZOrder 0
    Me.imgButton.Picture = LoadPicture(Preferences.TempPath & "\Button.bmp")
    Me.imgButton.Left = Me.corButton.Left + Int((Me.corButton.Width - Me.imgButton.Width) / 2)
    Me.imgButton.Top = Me.corButton.Top + Int((Me.corButton.Height - Me.imgButton.Height) / 2)
    Screen.MousePointer = vbDefault
    
    Exit Sub
    
Err_Handling:
MsgBox "Error " & Err.Number & vbCrLf & vbCrLf & Err.Description, vbCritical, App.Title

End Sub

Private Sub Populate_Form_Language()

    On Error Resume Next
    
    If Language.Count > 0 Then
        With Me
            ' Form
            .Caption = modStr.DefaultStr(Language("710000"), .Caption)
            .Menu_File.Caption = modStr.DefaultStr(Language("710100"), .Menu_File.Caption)
            .Menu_File_Refresh.Caption = modStr.DefaultStr(Language("710110"), .Menu_File_Refresh.Caption)
            .Menu_File_Reset.Caption = modStr.DefaultStr(Language("710120"), .Menu_File_Reset.Caption)
            .Menu_File_Save.Caption = modStr.DefaultStr(Language("710130"), .Menu_File_Save.Caption)
            .Menu_File_Exit.Caption = modStr.DefaultStr(Language("710140"), .Menu_File_Exit.Caption)
            .corText.Caption = modStr.DefaultStr(Language("710200"), .corText.Caption)
            .lblLabel.Caption = modStr.DefaultStr(Language("710210"), .lblLabel.Caption)
            .lblFontName.Caption = modStr.DefaultStr(Language("710220"), .lblFontName.Caption)
            .lblFontSize.Caption = modStr.DefaultStr(Language("710230"), .lblFontSize.Caption)
            .lblOffset.Caption = modStr.DefaultStr(Language("710240"), .lblOffset.Caption)
            .corDimension.Caption = modStr.DefaultStr(Language("710300"), .corDimension.Caption)
            .lblWidth.Caption = modStr.DefaultStr(Language("710310"), .lblWidth.Caption)
            .lblHeight.Caption = modStr.DefaultStr(Language("710320"), .lblHeight.Caption)
            .lblBorder.Caption = modStr.DefaultStr(Language("710330"), .lblBorder.Caption)
            .corColors.Caption = modStr.DefaultStr(Language("710400"), .corColors.Caption)
            .lblLabelColor.Caption = modStr.DefaultStr(Language("710410"), .lblLabelColor.Caption)
            .lblBackColor.Caption = modStr.DefaultStr(Language("710420"), .lblBackColor.Caption)
            .lblBorderColor.Caption = modStr.DefaultStr(Language("710430"), .lblBorderColor.Caption)
            .lblRefresh.Caption = modStr.DefaultStr(Language("710500"), .lblRefresh.Caption)
        End With
    End If
 
 End Sub


