Imports System
Imports System.ComponentModel
Imports System.Collections
Imports System.Diagnostics
Imports C1.Data
Imports DataLibrary.DataObjects

' C1SchemaDef container class: main class of the data library.
' Contains the C1SchemaDef component managing the data schema. 
Public Class DataClass
    Inherits System.ComponentModel.Component

#Region " Component Designer generated code "

    ' C1SchemaDef component managing the data schema.
    ' Needs to be public in order to allow access to the library.
    Public WithEvents SchemaDef1 As C1.Data.C1SchemaDef

    Public Sub New(Container As System.ComponentModel.IContainer)
        MyClass.New()

        'Required for Windows.Forms Class Composition Designer support
        Container.Add(me)
    End Sub

    Public Sub New()
        MyBase.New()
        'This call is required by the Component Designer.
        InitializeComponent()
    End Sub

    'Component 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 Component Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(DataClass))
        Me.SchemaDef1 = New C1.Data.C1SchemaDef
        CType(Me.SchemaDef1, System.ComponentModel.ISupportInitialize).BeginInit()
        '
        'SchemaDef1
        '
        Me.SchemaDef1.DummyImage = CType(resources.GetObject("SchemaDef1.DummyImage"), System.Drawing.Bitmap)
        Me.SchemaDef1.SerializedSchemaXML = Me.SchemaDef1.GetSchemaFromResources(resources, "SchemaDef1", Me)
        Me.SchemaDef1.SerializedDesignTimeOptionsXML = Me.SchemaDef1.GetDesignTimeOptionsFromResources(resources, "SchemaDef1", Me)
        CType(Me.SchemaDef1, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub

#End Region

#Region " Switch to C1NWind.mdb database "

    Private Sub SchemaDef1_CreateSchema(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SchemaDef1.CreateSchema
        Dim dbPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + _
            "\ComponentOne Samples\Common\C1NWind.mdb"
        If System.IO.File.Exists(dbPath) Then
            Dim conn As C1.Data.SchemaObjects.Connection = SchemaDef1.Schema.Connections(0)
            conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath
        End If
    End Sub

#End Region

End Class
