Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Images Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LCMS2/IT8 Reader
This example is the version from Mon, 16th Mar 2014.
Project "IT8 Reader.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub NewDocument()
dim f as FolderItem
// in debug open the file on desktop
if DebugBuild then
f = SpecialFolder.Desktop.Child("test.txt")
if f.Exists then
OpenDocument f
Return
end if
end if
// open any file
f = GetOpenFolderItem("")
if f <> nil then
OpenDocument f
end if
End EventHandler
EventHandler Sub Open()
lcms2mbs.SetLogErrorHandler self
End EventHandler
EventHandler Sub OpenDocument(item As FolderItem)
dim it8 as LCMS2IT8MBS = LCMS2IT8MBS.LoadFromFile(nil, item)
if it8<>nil then
dim mw as new MainWindow
mw.load item, it8
else
MsgBox "Failed to load "+item.Name
end if
End EventHandler
Sub Error(context as LCMS2ContextMBS, ErrorCode as UInt32, Text as string)
MsgBox "Error "+str(ErrorCode)+": "+text
End Sub
Note "Notes"
CGAT files or IT8 files must be in standard format.
For example line endings must be LF or CRLF, but not CR.
And NUMBER_OF_FIELDS entry must be before SAMPLE_ID entry.
LCMS errors if you have invalid tags defined.
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Sub load(f as FolderItem, it8 as LCMS2IT8MBS)
Title = f.DisplayName
dim TableCount as integer = it8.TableCount
List.AddRow "TableCount: "+str(TableCount)
for TableIndex as integer = 0 to TableCount-1
List.AddRow "TableIndex: "+str(TableIndex)
'dim ValidKeywords() as string = it8.ValidKeywords
'dim ValidSampleIDs() as string = it8.ValidSampleIDs
'dim headers() as string = it8.HeaderList
'dim Dic as Dictionary = it8.HeadersAsDictionary
'for each h as string in headers
'dim hdic as Dictionary = it8.HeaderSubDictionary(h)
'if hdic<>Nil then
'break
'end if
'next
'break
dim properties() as string = it8.EnumProperties
for each p as string in properties
List.AddRow p, it8.GetProperty(p)
next
// select current table
call it8.SetTable TableIndex
dim datatypes() as string = it8.EnumDataFormat
for each d as string in datatypes
List.AddRow "Data Format", d
next
dim FieldCount as integer = it8.GetPropertyAsDouble("NUMBER_OF_FIELDS")
dim SetCount as integer = it8.GetPropertyAsDouble("NUMBER_OF_SETS")
dim dw as new DataWindow
dw.top = me.top
dw.Left = me.left + me.Width + 20
dim list as listbox = dw.List
List.ColumnCount = FieldCount
for x as integer = 0 to FieldCount-1
list.Heading(x) = datatypes(x)
next
if FieldCount * 70 >dw.List.Width then
// give columns a min width if needed
dim c() as string
for i as integer = 1 to FieldCount
c.Append "70"
next
list.ColumnWidths = Join(c,",")
end if
// dummy picture and graphics to measure text width
dim p as new Picture(10,10,32)
dim g as Graphics = p.Graphics
for y as integer = 0 to SetCount-1
System.DebugLog str(y)
list.AddRow it8.GetPatchName(y)
for x as integer = 0 to FieldCount-1
System.DebugLog str(y)+" "+str(x)
dim s as string = it8.GetDataRowCol(y,x)
list.Cell(list.LastIndex,x) = s
if g.StringWidth(s)>70 then
list.CellHelpTag(list.LastIndex,x) = s
end if
next
next
next
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class DataWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
End Class
End Project
The items on this page are in the following plugins: MBS Images Plugin.