VERSION 5.00
Object = "{E48EFDBF-5838-4A7D-95DD-BC0EC914BD4A}#1.2#0"; "StarCEComponents.ocx"
Begin VB.Form Form1 
   Caption         =   "AddImagesSample"
   ClientHeight    =   7680
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   7680
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command6 
      Caption         =   "Refresh"
      Height          =   375
      Left            =   2160
      TabIndex        =   22
      Top             =   7200
      Width           =   1095
   End
   Begin StarCEComponents.AddImages AddImages1 
      Height          =   495
      Left            =   120
      TabIndex        =   21
      Top             =   7800
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   873
      Appearance      =   1
      BackColor       =   -2147483633
      BackStyle       =   0
      BorderStyle     =   0
      Enabled         =   -1  'True
      ShowLabels      =   0   'False
   End
   Begin VB.Frame Frame3 
      Caption         =   "Merge Image"
      Height          =   855
      Left            =   120
      TabIndex        =   19
      Top             =   6240
      Width           =   4455
      Begin VB.TextBox Text6 
         Height          =   285
         Left            =   120
         TabIndex        =   20
         Top             =   360
         Width           =   4215
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Image Lists"
      Height          =   2895
      Left            =   120
      TabIndex        =   12
      Top             =   480
      Width           =   4455
      Begin VB.CommandButton Command5 
         Caption         =   "Remove Selected"
         Height          =   255
         Left            =   2280
         TabIndex        =   18
         Top             =   2520
         Width           =   2055
      End
      Begin VB.CommandButton Command4 
         Caption         =   "Remove Selected"
         Height          =   255
         Left            =   2280
         TabIndex        =   17
         Top             =   1320
         Width           =   2055
      End
      Begin VB.ListBox List2 
         Height          =   645
         ItemData        =   "Form1.frx":0000
         Left            =   240
         List            =   "Form1.frx":0002
         TabIndex        =   16
         Top             =   1800
         Width           =   4095
      End
      Begin VB.ListBox List1 
         Height          =   645
         ItemData        =   "Form1.frx":0004
         Left            =   240
         List            =   "Form1.frx":0006
         TabIndex        =   14
         Top             =   600
         Width           =   4095
      End
      Begin VB.Label Label7 
         Caption         =   "Bottom Image List:"
         Height          =   255
         Left            =   240
         TabIndex        =   15
         Top             =   1560
         Width           =   1575
      End
      Begin VB.Label Label6 
         Caption         =   "Top Image List:"
         Height          =   255
         Left            =   240
         TabIndex        =   13
         Top             =   360
         Width           =   1695
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Add Images"
      Height          =   2655
      Left            =   120
      TabIndex        =   3
      Top             =   3480
      Width           =   4455
      Begin VB.ComboBox Combo2 
         Height          =   315
         Left            =   2280
         TabIndex        =   24
         Text            =   "Combo2"
         Top             =   1920
         Width           =   2055
      End
      Begin VB.ComboBox Combo1 
         Height          =   315
         ItemData        =   "Form1.frx":0008
         Left            =   2280
         List            =   "Form1.frx":000A
         TabIndex        =   23
         Text            =   "Combo1"
         Top             =   720
         Width           =   2055
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Add Bottom Image"
         Height          =   255
         Left            =   2280
         TabIndex        =   11
         Top             =   2280
         Width           =   2055
      End
      Begin VB.TextBox Text4 
         Height          =   285
         Left            =   2280
         TabIndex        =   10
         Top             =   1560
         Width           =   2055
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Add Top Image"
         Height          =   255
         Left            =   2280
         TabIndex        =   7
         Top             =   1080
         Width           =   2055
      End
      Begin VB.TextBox Text2 
         Height          =   285
         Left            =   2280
         TabIndex        =   5
         Top             =   360
         Width           =   2055
      End
      Begin VB.Label Label5 
         Caption         =   "Bottom Image Alignment:"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   1920
         Width           =   1815
      End
      Begin VB.Label Label4 
         Caption         =   "Bottom Image Name:"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   1560
         Width           =   1695
      End
      Begin VB.Label Label3 
         Caption         =   "Top Image Alignment:"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   720
         Width           =   1695
      End
      Begin VB.Label Label2 
         Caption         =   "Top Image Name:"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   360
         Width           =   1695
      End
   End
   Begin StarCEComponents.ConfigurationHandler ConfigurationHandler1 
      Left            =   120
      Top             =   7200
      _ExtentX        =   1931
      _ExtentY        =   873
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Save"
      Height          =   375
      Left            =   3360
      TabIndex        =   2
      Top             =   7200
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   285
      Left            =   1920
      TabIndex        =   1
      Text            =   "Star TSP100 Cutter (TSP143)"
      Top             =   120
      Width           =   2655
   End
   Begin VB.Label Label1 
      Caption         =   "Printer Queue Name:"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' This variable will let us know if a configuration file
' has been loaded into the ConfigurationHandler object
Dim ConfigurationLoaded As Boolean

Private Sub Command1_Click()
    ' Save all changes to the configuration file
    ' The merge image text box setting will have to be modified here,
    ' since there is no button on the form for it
    AddImages1.MergeImage = Text6.Text
    
    ' Save the configuration to the file that the specified printer queue is using
    ConfigurationHandler1.SaveConfigurationToQueue Text1.Text
    
    RefreshLists
End Sub

Private Sub Command2_Click()
    ' Add an image to the top image list
    If Text2.Text = "" Then
        ' Use this function to allow the user to select an image from the list
        AddImages1.AddTopImageDialog
    Else
        ' Use this function to specify which image to use
        AddImages1.AddTopImage Text2.Text, Combo1.ListIndex
    End If
End Sub

Private Sub Command3_Click()
    ' Add an image to the bottom image list
    If Text4.Text = "" Then
        ' Use this function to allow the user to select an image from the list
        AddImages1.AddBottomImageDialog
    Else
        ' Use this function to specify which image to use
        AddImages1.AddBottomImage Text4.Text, Combo2.ListIndex
    End If
End Sub

Private Sub Command4_Click()
    ' Remove selected image in the Top Image List
    AddImages1.DeleteTopImage List1.Text
End Sub

Private Sub Command5_Click()
    ' Remove selected image in the Bottom Image List
    AddImages1.DeleteBottomImage List2.Text
End Sub

Private Sub Command6_Click()
    ' "Refresh" button
    RefreshLists
End Sub

Private Sub Form_Load()
    ' The configuration is not loaded by default
    ConfigurationLoaded = False
    
    Combo1.AddItem "Left"
    Combo1.AddItem "Centre"
    Combo1.AddItem "Right"
    
    Combo1.ListIndex = 1
    
    Combo2.AddItem "Left"
    Combo2.AddItem "Centre"
    Combo2.AddItem "Right"
    
    Combo2.ListIndex = 1
End Sub

Private Sub LoadConfiguration()
    ' This function will load the a configuration file into the ConfigurationHandler control
    ' The file loaded is the file used by the printer queue specified in Text1
    If Not ConfigurationLoaded Then
        If ConfigurationHandler1.LoadConfigurationFromQueue(Text1.Text) Then
            ConfigurationLoaded = True
        Else
            MsgBox "Error loading configuration. Please enter a valid printer queue name.", vbExclamation Or vbOKOnly, "Error"
        End If
    End If
End Sub

Private Sub RefreshLists()
    Dim i As Integer
    LoadConfiguration
    
    ' Load the ConfigurationHandler control into the AddImages control
    ' From this point on, all functions and properties used by this control
    ' will affect the configuration file that was loaded into this
    ' ConfigruationHandler
    AddImages1.SetConfigurationHandler ConfigurationHandler1
    
    ' Load all top image names from this control into List1
    For i = 0 To AddImages1.TopImageListCount
        List1.AddItem AddImages1.GetTopImageName(i)
    Next i
    
    ' Load all bottom image names from this control into List2
    For i = 0 To AddImages1.BottomImageListCount
        List1.AddItem AddImages1.GetBottomImageName(i)
    Next i
End Sub
