struct ListViewOps
(
m_dnColor = dotNetClass "System.Drawing.Color",
function MXSColor_to_dotNetColor hColor =
(
m_dnColor.fromARGB hColor.r hColor.g hColor.b
),
function dotNetColor_to_MXSColor dnColor =
(
local mxsCol = color (dnColor.r as integer) (dnColor.g as integer) (dnColor.b as integer)
mxsCol
),
function InitImageList lv stringFileArray pSize:0 =
(
--[brief] This method only adds icons and bitmaps, to an imagelist.
-- An imagelist is a structure that manages images for a control.
--[param] lv - The listview control. Must inherit from System.Windows.Forms.Control class.
--[param] stringFileArray - A maxscript array containing filenames of the images to add.
-- Must pass the string file names as a symbolic pathname:
-- i.e. "$ui/icons/mybitmap.bmp"
--[param] pSize - The size of the bitmap to add. For example 16 if the image is 16 x 16 pixels.
--[return] A System.Windows.Forms.ImageList
local hImgList = dotNetObject "System.Windows.Forms.ImageList"
local imgSize = dotNetObject "System.Drawing.Size" 16 16
if pSize == 0 then
(
hImgList.imagesize = imgSize
)else if (pSize > 2)
then
(
imgSize = dotNetObject "System.Drawing.Size" pSize pSize
hImgList.imagesize = imgSize
)
local bColor = dotNetClass "System.Drawing.Color"
if pTransparentColor != undefined and (classof pTransparentColor == color) then
(
local col = pTransparentColor --temporary
hImgList.transparentColor = bColor.fromARGB col.r col.g col.b
)
else
(
hImgList.transparentColor = bColor.fromARGB 125 125 125
)
local img = dotNetClass "System.Drawing.Image"
--获取图标名
function IsIconFile stringFileName =
(
local type = GetFileNameType stringFileName
local result = false
if type == ".ico" do ( result = true )
result
)
for file in stringFileArray do
(
fName = (symbolicPaths.expandFileName file)
if (IsIconFile fName ) then --Add icons
(
local icon = dotNetObject "System.Drawing.Icon" fName
hImgList.images.add icon
)
else --or Add bitmaps
(
local dnBitmap = dotNetObject "System.Drawing.Bitmap" fName
hImgList.images.add dnBitmap
)
)
lv.SmallImageList = hImgList
),
--给LISTVIEW添加成员
function AddLvItem lv \
pTextItems:#() \
pChecked: false \
pHashKey: "" \
pTag: undefined \
pToolTip: "" \
pInsertAt: undefined \
pImgIndex: 1 \
pIndent: 0 =
(
--[brief] This function Creates and Adds a ListViewItem to a ListView control.
--[param] pTextItems - A maxscript array that contains the strings to put in each cell
-- of the listview cells which are called ListViewSubItems
--[param] pChecked - If true displays a checkbox to the far left of the listview item
--[param] pHashKey - A string used for a hash table index
--[param] pTag