[APBeta] Script help
Jeff Young
jey at adobe.com
Sat Jul 9 07:18:06 PDT 2011
Inge,
The sorting doesn't destroy the usefulness of the script (it just means M2 sorts after M19), so I went ahead and cleaned it up a bit (and added editing of image height and width in case anyone uses those) and published it.
(It's under Other / Images in the By Category section.)
Let me know if you find any issues.
Cheers,
Jeff.
From: apbeta-bounces at lists.astroplanner.net [mailto:apbeta-bounces at lists.astroplanner.net] On Behalf Of I.R. van de Stadt
Sent: Saturday, July 09, 2011 1:56 AM
To: apbeta at lists.astroplanner.net
Subject: Re: [APBeta] Script help
I sincerely hope that Paul will help you out.
A really useful script-idea and I'm looking forward to that one.
Inge
________________________________
From: jey at adobe.com
To: APBeta at lists.astroplanner.net
Date: Sat, 9 Jul 2011 01:12:02 +0100
Subject: [APBeta] Script help
Paul,
I've written the following script to allow editing of user image descriptions (and some of the flags). The first dialog shows a list of user images. Double-clicking one of them brings up an edit dialog which allows you to edit the description and two of the flags.
The first dialog list is doing a string-sort instead of an ID-sort, though. Is there a way to return ID for the MultiFieldObject's ColumnType so the list will sort correctly?
Thanks,
Jeff.
function EditImage(img as Image) as boolean
dim editor as Dialog, imgCanvas as Canvas
editor = new Dialog
imgCanvas = Dialog.NewCanvas(500, 500)
imgCanvas.DrawImage(img, 0, 0, 500)
editor.CanvasParameter(imgCanvas)
editor.StringParameter("Description", img.Description)
editor.BooleanParameter("Color", img.IsColor)
editor.BooleanParameter("Black on White", img.IsBlackOnWhite)
if editor.show("Edit User Image for " + img.ID) then
img.Description = editor.StringParameter("Description")
img.IsColor = editor.BooleanParameter("Color")
img.IsBlackOnWhite = editor.BooleanParameter("Black on White")
return true
end if
return false
end function
function toStr(b as boolean) as string
if b then
return "true"
else
return "false"
end if
end function
class ImageMetaData
implements MultiFieldObject
ID as string
Desc as string
isColor as boolean
isBlackOnWhite as boolean
index as integer
function ColumnName(idx as integer) as string
if idx = 1 then
return "ID"
elseif idx = 2 then
return "Description"
elseif idx = 3 then
return "Color"
elseif idx = 4 then
return "Black on White"
elseif idx = 5 then
return "Index"
end if
end function
function ColumnType(idx as integer) as integer
if idx = 1 then
return vtype_String
elseif idx = 2 then
return vtype_String
elseif idx = 3 then
return vtype_Boolean
elseif idx = 4 then
return vtype_Boolean
elseif idx = 5 then
return vtype_Integer
end if
end function
function ColumnValue(idx as integer) as string
if idx = 1 then
return ID
elseif idx = 2 then
return Desc
elseif idx = 3 then
return toStr(isColor)
elseif idx = 4 then
return toStr(isBlackOnWhite)
elseif idx = 5 then
return Str(index)
end if
return "undefined column (" + Str(idx) + ")"
end function
function nColumns() as integer
return 5
end function
end class
function getImageMetaData(img as Image, idx as integer) as ImageMetaData
dim metadata as ImageMetaData
metadata = new ImageMetaData
metadata.ID = img.ID
metadata.Desc = img.Description
metadata.isColor = img.IsColor
metadata.isBlackOnWhite = img.IsBlackOnWhite
metadata.index = idx
return metadata
end function
sub main()
try
dim imageData(1000) as ImageMetaData
dim i, idx as integer, img as Image
i = 0
for idx = 1 to Image.Count
img = Image.Get(idx)
if img.IsUser then
imageData(i) = getImageMetaData(img, idx)
i = i + 1
end if
next
redim imageData(i-1)
dim browser as Dialog
while true
browser = new Dialog
browser.ListChoiceParameter("User Images", 0, imageData, true, 50, true)
browser.ParameterWindowNoCancel()
browser.ParameterWindowOKCaption("Done")
if browser.show("User Image Browser") then
if browser.DoubleClickedList() = "User Images" then
i = browser.ListChoiceParameter("User Images")
idx = imageData(i).index
img = Image.Get(idx)
if EditImage(img) then
imageData(i) = getImageMetaData(img, idx)
end if
else
return
end if
else
return
end if
wend
catch
print "My bad. Image Browser script generated an exception."
end try
end sub
_______________________________________________ APBeta mailing list APBeta at lists.astroplanner.net http://lists.astroplanner.net/listinfo.cgi/apbeta-astroplanner.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.astroplanner.net/pipermail/apbeta-astroplanner.net/attachments/20110709/5086f4e4/attachment-0003.htm>
More information about the APBeta
mailing list