'Imports System.Text.RegularExpressions
'Imports System.ComponentModel

'Imports Stax
'Imports Stax.UI

'<ToolboxItem(False)> _
'Public Class OptionsChaptersControl
'    Inherits DialogControl

'#Region " Windows Form Designer generated code "

'    Public Sub New()
'        MyBase.New()
'        InitializeComponent()
'    End Sub

'    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 dgChapters As System.Windows.Forms.DataGrid
'    Friend WithEvents SmartTagProvider As Stax.UI.Design.SmartTagProvider
'    Friend WithEvents bOpen As System.Windows.Forms.Button
'    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'        Me.dgChapters = New System.Windows.Forms.DataGrid
'        Me.bOpen = New System.Windows.Forms.Button
'        Me.SmartTagProvider = New Stax.UI.Design.SmartTagProvider
'        CType(Me.dgChapters, System.ComponentModel.ISupportInitialize).BeginInit()
'        Me.SuspendLayout()
'        '
'        'dgChapters
'        '
'        Me.dgChapters.AllowSorting = False
'        Me.dgChapters.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
'                    Or System.Windows.Forms.AnchorStyles.Left) _
'                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'        Me.dgChapters.CaptionVisible = False
'        Me.dgChapters.DataMember = ""
'        Me.dgChapters.HeaderForeColor = System.Drawing.SystemColors.ControlText
'        Me.dgChapters.Location = New System.Drawing.Point(4, 4)
'        Me.dgChapters.Name = "dgChapters"
'        Me.dgChapters.Size = New System.Drawing.Size(225, 89)
'        Me.dgChapters.TabIndex = 6
'        '
'        'bOpen
'        '
'        Me.bOpen.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'        Me.bOpen.Location = New System.Drawing.Point(154, 99)
'        Me.bOpen.Name = "bOpen"
'        Me.bOpen.Size = New System.Drawing.Size(75, 24)
'        Me.bOpen.TabIndex = 7
'        Me.bOpen.Text = "Open..."
'        '
'        'OptionsChaptersControl
'        '
'        Me.Controls.Add(Me.dgChapters)
'        Me.Controls.Add(Me.bOpen)
'        Me.Name = "OptionsChaptersControl"
'        Me.Size = New System.Drawing.Size(232, 128)
'        CType(Me.dgChapters, System.ComponentModel.ISupportInitialize).EndInit()
'        Me.ResumeLayout(False)

'    End Sub

'#End Region

'    Private Table As New DataTable

'    Public Overrides Sub Init()
'        Table.Columns.Add(New DataColumn("Time", GetType(String)))
'        Table.Columns.Add(New DataColumn("Name", GetType(String)))

'        dgChapters.TableStyles.Add(New DataGridTableStyle)
'        Populate(p.Chapters)
'    End Sub

'    Private Sub bOpenChapters_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bOpen.Click
'        Dim d As New OpenFileDialog

'        d.Filter = FileDialogFilter.GetLinePlusAll("Text Files", "*.txt")

'        d.InitialDirectory = s.LastSourceDir
'        d.ShowDialog()

'        If d.FileName <> "" Then
'            s.LastSourceDir = Filepath.GetDir(d.FileName)
'            Populate(StringHelp.ReadFile(d.FileName))
'        End If
'    End Sub

'    Private Sub Populate(ByVal chapterFileContent As String)
'        If chapterFileContent <> "" AndAlso Not _
'            chapterFileContent.Contains("CHAPTER01NAME") Then

'            Msg.Show("Wrong format", MsgIcon.Error)

'            Exit Sub
'        End If

'        Table.Clear()

'        Dim row As DataRow = Nothing
'        Dim switch As Boolean

'        For Each i As String In StringHelp.SplitLines(chapterFileContent)
'            switch = Not switch
'            If i <> "" Then
'                If switch Then
'                    row = Table.NewRow()
'                    row(0) = StringHelp.GetRight(i, "=")
'                Else
'                    row(1) = StringHelp.GetRight(i, "=")
'                    Table.Rows.Add(row)
'                End If
'            End If
'        Next

'        dgChapters.SetDataBinding(Table, Nothing)
'    End Sub

'    Private Function GetChapters() As String
'        Dim x As Integer
'        Dim ID As String
'        Dim st As String = ""

'        For x = 0 To Table.Rows.Count - 1
'            ID = (x + 1).ToString

'            If ID.Length = 1 Then
'                ID = "0" + ID
'            End If

'            st += "CHAPTER"
'            st += ID
'            st += "="
'            st += CStr(Table.Rows(x).Item(0))
'            st += vbCrLf

'            st += "CHAPTER"
'            st += ID
'            st += "NAME"
'            st += "="
'            st += CStr(Table.Rows(x).Item(1))
'            st += vbCrLf
'        Next

'        Return st
'    End Function

'    Private Sub Chapters_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Resize
'        If Not Parent Is Nothing Then
'            If dgChapters.TableStyles.Count > 0 Then
'                dgChapters.TableStyles(0).GridColumnStyles(0).Width = dgChapters.Width \ 4 - 20
'                dgChapters.TableStyles(0).GridColumnStyles(1).Width = (dgChapters.Width \ 4) * 3 - 40
'            End If
'        End If
'    End Sub

'    Private Sub OptionsChaptersControl_FormClosingOK() Handles MyBase.FormClosingOK
'        p.Chapters = GetChapters()
'    End Sub
'End Class