Imports AxSftTreeLib70
Imports SftTreeLib70
Imports Softelvdm.OLEConvert

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 label1 As System.Windows.Forms.Label
Friend WithEvents closeButton As System.Windows.Forms.Button
Friend WithEvents AxSftTree1 As AxSftTreeLib70.AxSftTree
Friend WithEvents SftHelperComponent1 As Softelvdm.OCXHelper.SftHelperComponent
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.label1 = New System.Windows.Forms.Label()
Me.closeButton = New System.Windows.Forms.Button()
Me.AxSftTree1 = New AxSftTreeLib70.AxSftTree()
Me.SftHelperComponent1 = New Softelvdm.OCXHelper.SftHelperComponent(Me.components)
CType(Me.AxSftTree1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'label1
'
Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label1.Location = New System.Drawing.Point(384, 143)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(88, 152)
Me.label1.TabIndex = 5
Me.label1.Text = "Click on the SftTree/OCX control and hit F1 to access online help for SftTree/OCX" & _
" 6.0"
Me.label1.Visible = False
'
'closeButton
'
Me.closeButton.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.closeButton.Location = New System.Drawing.Point(384, 7)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(88, 24)
Me.closeButton.TabIndex = 4
Me.closeButton.Text = "Close"
'
'AxSftTree1
'
Me.AxSftTree1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right)
Me.AxSftTree1.Location = New System.Drawing.Point(8, 7)
Me.AxSftTree1.Name = "AxSftTree1"
Me.AxSftTree1.OcxState = CType(resources.GetObject("AxSftTree1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftTree1.Size = New System.Drawing.Size(368, 328)
Me.AxSftTree1.TabIndex = 3
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.closeButton
Me.ClientSize = New System.Drawing.Size(480, 342)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.label1, Me.closeButton, Me.AxSftTree1})
Me.Name = "Form1"
Me.Text = "Softel vdm, Inc. - ListFont Sample"
CType(Me.AxSftTree1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

    End Sub

#End Region
    '--locate-marker--

    Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
        Application.Exit()
    End Sub

    Private Sub AxSftTree1_ItemDblClick(ByVal sender As Object, ByVal e As AxSftTreeLib70._DSftTreeEvents_ItemDblClickEvent) Handles AxSftTree1.ItemDblClick
        If e.areaType = SftTreeAreaTypeConstants.constSftTreeColumnRes Then
            AxSftTree1.get_Column(e.colIndex).MakeOptimal()
            AxSftTree1.Items.RecalcHorizontalExtent()
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AxSftTree1.BulkUpdate = True

        ' Add all screen fonts to the tree control
        Dim ScreenIndex As Integer
        ScreenIndex = AxSftTree1.Items.Add("Fonts")
        AxSftTree1.get_Item(ScreenIndex).Level = 0

        ' display fonts
        Dim Counter As Integer = 0
        Dim ff As FontFamily
        For Each ff In System.Drawing.FontFamily.Families
            ' add font name
            Dim newFont As Font
            Try
                newFont = New Font(ff.Name, 8)
            Catch
                newFont = Nothing
            End Try
            If Not newFont Is Nothing Then
                Counter = Counter + 1
                If Counter > 50 Then ' only add up to 50
                    Exit For
                End If
                Dim ItemIndex As Integer
                ItemIndex = AxSftTree1.Items.Add(ff.Name)
                AxSftTree1.get_Item(ItemIndex).Level = 1
                ' set the font
                AxSftTree1.get_Cell(ItemIndex, 0).Font = OLECvt.ToIFontDisp(newFont)
                ' set the font name in column 1
                AxSftTree1.get_Cell(ItemIndex, 1).Text = ff.Name
            End If
        Next

        AxSftTree1.BulkUpdate = False
        ' make column widths optimal
        AxSftTree1.ColumnsObj.MakeOptimal()
        ' allow horizontal scrolling
        AxSftTree1.Items.RecalcHorizontalExtent()
    End Sub

End Class