VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmProfileManagement 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Profile Management"
   ClientHeight    =   3615
   ClientLeft      =   45
   ClientTop       =   405
   ClientWidth     =   3375
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmWelcome.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3615
   ScaleWidth      =   3375
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdContinue 
      Caption         =   "Continue..."
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1920
      TabIndex        =   2
      Top             =   3120
      Width           =   1335
   End
   Begin VB.CommandButton cmdCreate 
      Caption         =   "Create..."
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   3120
      Width           =   975
   End
   Begin MSComctlLib.ListView lv 
      Height          =   2175
      Left            =   120
      TabIndex        =   0
      Top             =   840
      Width           =   3135
      _ExtentX        =   5530
      _ExtentY        =   3836
      View            =   2
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      Checkboxes      =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   0
   End
   Begin VB.Label Label1 
      Caption         =   "Tick each profile you want imported then Continue.  If you wish to configure a new profile click Create."
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   855
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   3135
   End
End
Attribute VB_Name = "frmProfileManagement"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Continue As Boolean

Public Sub Reload()
    Form_Load
End Sub

Private Sub cmdContinue_Click()
    On Error GoTo hErr
    Continue = True
    Dim I As Integer, ticked As Integer
    For I = 1 To lv.ListItems.Count
        If (lv.ListItems(I).Checked) Then
            ticked = ticked + 1
        End If
    Next
    If (ticked > 0) Then
        For I = 1 To lv.ListItems.Count
            If (lv.ListItems(I).Checked) Then
                LoadProfile lv.ListItems(I).text
                DoEvents
            End If
        Next
        ChatFont = ReadIni(AppData & "Settings.ini", "Settings", "ChatFont")
        ListFont = ReadIni(AppData & "Settings.ini", "Settings", "ListFont")
        ChatFontSize = Val(ReadIni(AppData & "Settings.ini", "Settings", "ChatFontSize"))
        ListFontSize = Val(ReadIni(AppData & "Settings.ini", "Settings", "ListFontSize"))
        If LenB(ChatFont) = 0 Then ChatFont = "Courier New"
        If LenB(ListFont) = 0 Then ListFont = "Courier New"
        If ChatFontSize < 6 Or ChatFontSize > 16 Then ChatFontSize = 9
        If ListFontSize < 6 Or ListFontSize > 16 Then ListFontSize = 9
        frmBot.ChangeChatFont ChatFont, ChatFontSize, True
        frmBot.ChangeListFont ListFont, ListFontSize
        frmBot.Show
        Unload Me
    Else
        MsgBox "None were ticked, cannot continue!"
    End If
    Exit Sub
hErr:
    MsgBox "An error occurred when trying to load profile(s): " & vbNewLine & Err.Description, vbCritical, "Load Profile(s)"
    Unload Me
End Sub

Private Sub cmdCreate_Click()
    On Error GoTo hErr
    Dim str As String
    str = InputBox("Enter name for new profile:", "Create Profile")
    str = FixFilename(str)
    If LenB(str) > 0 Then
        Open AppData & "Profiles\" & str & ".ini" For Append As #1
        Close #1
        frmConfigure.ProfileManager = True
        frmConfigure.Show
        frmConfigure.ShowProfile str
    End If
    Exit Sub
hErr:
    MsgBox "An error occurred when trying to create a profile: " & vbNewLine & Err.Description, vbCritical, "Create Profile"
End Sub

Private Sub Form_Load()
    On Error GoTo hErr
    Continue = False
    If fso.FolderExists(AppData & "Profiles\") = False Then fso.CreateFolder (AppData & "Profiles\")
    lv.ListItems.Clear
    Dim strProfiles() As String, I As Integer
    strProfiles = FileList(AppData & "Profiles\*.ini")
    If ArrayInit(Not strProfiles) Then
        For I = 0 To UBound(strProfiles)
            If LenB(strProfiles(I)) > 0 Then
                Dim Profile As String
                Profile = Left$(strProfiles(I), InStrRev(strProfiles(I), ".") - 1)
                If frmBot.tbsProfile.Tabs.Count > 0 Then
                    Dim F As Integer
                    For F = 1 To frmBot.tbsProfile.Tabs.Count
                        If LCase$(frmBot.tbsProfile.Tabs(F).Caption) = LCase$(Profile) Then
                            GoTo SkipProfile:
                        End If
                    Next F
                    lv.ListItems.Add(, , Profile).Checked = True
SkipProfile:
                Else
                    lv.ListItems.Add(, , Profile).Checked = True
                End If
            End If
        Next
    End If
    cmdCreate.Enabled = True
    cmdContinue.Enabled = (lv.ListItems.Count > 0)
    Exit Sub
hErr:
    MsgBox "An error occurred when trying to get list of profiles: " & vbNewLine & Err.Description, vbCritical, "List Profiles"
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Cancel = 0
    If Not Continue Then
        Dim F As Form
        For Each F In Forms
            If F.Name <> Me.Name Then Unload F
            Set F = Nothing
        Next F
    End If
End Sub
