[Closed] DotNet controls Picture Box
Hi
Im trying to remake my old Asset Browser and use dotNet forms.
But when Im searched in the internet to learn more about this stuff…
I realize what most of people create their own dll files.
And using dotnet.loadAssembly
to load them in to max.
This is very good! But not for me ,because I dont know any of C++ or VB , Pascal
. languages
Is there any way to avoid this and create a simple browser with already existing functions in DotNet?
so… I started to create an array of images
imgPaths = getFiles “C:\Temp\Images\*.jpg”
and after, load them in to picture boxes and add in form
(
local imgPaths = getFiles "C:\\Temp\\Images\\*.jpg"
local colors = dotNetClass "System.Drawing.Color"
local dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
--collect images
local imgArray = #()
for i=1 to imgPaths.count do
(
local pic = dotNetObject "System.Windows.Forms.PictureBox"
pic.width = 160
pic.height = 120
pic.Padding = dotNetObject "System.Windows.Forms.Padding" 4
--pic.Cursor = dotNetObject "System.Windows.Forms.Cursor" "C:\ emp\\images\\hnwse.cur"
pic.AllowDrop = true
imgArray[i] = pic
imgArray[i].image = (dotNetclass "System.Drawing.Image").fromfile imgPaths[i]
)
--add images to form
local dotForm = (dotNetObject "System.Windows.Forms.Form")
for i=1 to imgPaths.count do dotForm.Controls.add imgArray[i]
dotForm.Text = " Picture Box Test 1"
dotForm.topmost = true
dotForm.show()
)
Something is not right here , all the pictures is on same place.
I cant find a command to put them right.
Im tried also dotNetObject "System.Windows.Forms.ImageList" , but there Im lost completely ...
I dont know why this is not working???
– LargeIconEach item appears as a full-sized icon with a label below it.
lv.View = (dotNetClass “System.Windows.Forms.View”). LargeIcon
[ http://msdn.microsoft.com/en-us/library/system.windows.forms.view.aspx ]( http://msdn.microsoft.com/en-us/library/system.windows.forms.view.aspx)
rollout mc2Gallery2Dialog "3DsMax Gallery II" width:592 height:692
(
--> Local
local jpg_images_dir = "E:\\3DGallery\\Weapons\\Swords"
--< Local
dotNetControl lv "System.Windows.Forms.ListView" pos:[84,38] width:504 height:650
dropdownList ddl1 "" pos:[84,8] width:228 height:21 items:#("Class")
dropdownList ddl2 "" pos:[360,8] width:228 height:21 items:#("Type")
--> Functions
fn myCallback = ( return false )
fn fillTagsWith images =
(
fn callback_abort = ( dotnetObject "System.Drawing.Image+GetThumbnailImageAbort" myCallback())
local ptr_callback_abort = dotNetClass "System.IntPtr"
image_list = dotNetObject "System.Windows.Forms.ImageList"
image_list.ColorDepth = image_list.ColorDepth.Depth24Bit
image_list.ImageSize = dotNetObject "System.Drawing.Size" 160 120
for i in images do
(
local thumb = dotNetObject "System.Drawing.Bitmap" i
image_list.images.add thumb
)
return image_list
)
fn inicialitzaListView lv =
(
lv.View = (dotNetClass "System.Windows.Forms.View").List -- LargeIcon --X--
lv.showitemtooltips = true
)
fn fillListView lv image_list =
(
lv.Clear()
lv.SmallImageList = fillTagsWith image_list
for i = 1 to image_list.count do
(
tag = image_list[i]
ListViewOps.AddLvItem lv pTextItems:#("",(getFilenameFile tag)) pImgIndex:(i-1)
)
)
--< Functions
on mc2Gallery2Dialog open do
(
inicialitzaListView lv
--load images
if doesFileExist jpg_images_dir do
(
jpg_images = getFiles (jpg_images_dir + "\\*.jpg")
fillListView lv jpg_images
)
)
)
createDialog mc2Gallery2Dialog style:#(#style_titlebar,
#style_sysmenu, #style_minimizebox, #style_maximizebox, #style_sunkenedge, #style_resizing)
if anybody knows, please let me know... thanks
Here is a pic of my old browser...
[img] http://mithrillgate.wgz.cz/image/14781902 [/img]
Browser Usage:
1)add /store scene models (snap model to surface if exist)
2)paint models in to surface (setup random count, pos ,rotation, for each model in the set)
3)add/store scene materials
4)add/store textures
Browser Property:
1)Resizable with automatic thumbnails sorting
2)Add, delete or rename items
2)Remember user settings: thumb size, random params in set, dialog position, dialog scale, dropdown list selection
.
4) drag and drop method for models and materials + ctrl alt shift hotkeys for rotation and scale
hi PEN thanks for the advice
:wavey:
but there is another problem.. it seems the [font="][color=Cyan][b]XtraTreeList[/b] [/color]has no property
[/font]
[font=Verdana]maybe is because Im using 3DsMax 9[/font]
rollout tltest "XtraTreeList Test" width: 300 height: 200
(
dotNetControl tl "DevExpress.XtraTreeList.TreeList" width: 274 height: 180
fn getInfo itm =
(
try ( format "show:%
" (show itm) ) catch (print "undefined")
try ( format "interface:%
" (showinterface itm) ) catch (print "undefined")
try ( format "methods:%
" (showmethods itm) ) catch (print "undefined")
try ( format "prop:%
" (showproperties itm) ) catch (print "undefined")
)
on tltest open do getInfo tl
)
createdialog tltest
Result in Listener:
Rollout:tltest
show:false
“undefined”
methods:false
prop:false
true
OK
You could also create a flowLayoutPanel, and add labels or imageboxes or whatever to it’s “controls” property. The flowLayoutPanel will take care of the sorting which is pretty nice.
I found some references about flowlayoutpanel from LoneRobot site.
Im already made some basic functions, but Im worry with it is to difficult for me…
rollout mc2TestGalleryDilog "3DsMax 9 Gallery II" width:556 height:597
(
--> Local
local jpg_images_dir = "E:\\3DGallery\\Weapons\\Swords"
local colorclass = dotnetclass "system.drawing.color"
--< Local
-->Interface
dotNetControl flp "flowlayoutpanel" pos:[5,52] width:543 height:531
dotNetControl legend "textbox" pos:[5,4] width:543 height:20
--<Interface
-->functions
fn Btn_Pressed sender eventargs =
(
local stringdata
legend.forecolor = sender.forecolor
legend.backcolor = if sender.text == "Transparent" then colorclass.white else sender.backcolor
--higlight thumbnails
if sender.backcolor == colorclass.yellow
then
(
stringdata = "pressed 1"--sender.tag
sender.backcolor = colorclass.cadetblue
)
else
(
stringdata = "pressed 2"--sender.text
sender.backcolor = colorclass.yellow --not working too
)
--mouse up
--btndragdrop.backcolor = (dotnetclass "System.Drawing.Color").yellow
--mouse down
--btndragdrop.backcolor = (dotnetclass "System.Drawing.Color").orangered
legend.text = stringdata
--showmethods eventargs
show eventargs
--show eventargs.Clicks
--changing cursor --not works
/*
-- sender.clientrectangle.contains args.x args.y --cant implement
if (eventargs.x !=0 and eventargs.y != 0) then
(
setsyscur #arrow
)
else
(
setSysCur #select
)
*/
)
--<functions
-->Actions
on mc2TestGalleryDilog open do
(
local singleborder = (dotNetClass "System.Windows.Forms.BorderStyle").fixedsingle
local dnfont = dotNetObject "System.Drawing.Font" "Verdana" 6.5 ((dotNetClass "System.Drawing.FontStyle").bold)
local dnfontlarge = dotNetObject "System.Drawing.Font" "Verdana" 8.5 ((dotNetClass "System.Drawing.FontStyle").bold)
local dnMXSlarge = dotNetObject "System.Drawing.Font" "System" 8.5 ((dotNetClass "System.Drawing.FontStyle").bold)
flp.autoscroll = true
flp.padding = dotnetobject "system.windows.forms.padding" 2
local dnobjarray = #()
Images_Array = getFiles (jpg_images_dir + "\\*.jpg")
for i in Images_Array do
(
btndragdrop = dotnetobject "button"
btndragdrop.size = dotnetobject "system.drawing.size" 160 120
--btndragdrop.backcolor = colorclass.yellow --cadetblue -- tag color
btndragdrop.forecolor = colorclass.ivory --text color
btndragdrop.margin = dotnetobject "system.windows.forms.padding" 2 -- thumbs distance
btndragdrop.flatstyle = (dotNetclass "System.Windows.Forms.FlatStyle").flat
btndragdrop.font= dnfont
btndragdrop.text = getFilenameFile i
btndragdrop.textalign = (dotnetclass "System.Drawing.ContentAlignment").BottomCenter
--btndragdrop.BackgroundImage = (dotnetclass "System.Drawing.Image").FromFile i
--btndragdrop.Image = (dotnetclass "System.Drawing.Image").FromFile i
btndragdrop.Image = dotNetObject "System.Drawing.Bitmap" i
--btndragdrop.AllowDrop = true
-----btndragdrop.AutoSize = true -- autosize thumbnail to image
--btndragdrop.DisplayRectangle
--.BorderStyle : <System.Windows.Forms.BorderStyle>
--.AllowDrop
--.Bounds : <System.Drawing.Rectangle>
dotNet.addEventHandler btndragdrop "click" Btn_Pressed
append dnobjarray btndragdrop
btndragdrop = nothing
)
--> Title of gallery type
colorlabel = dotnetobject "label"
colorlabel.borderstyle = singleborder
colorlabel.margin = dotnetobject "system.windows.forms.padding" 2
colorlabel.backcolor = colorclass.cadetblue
colorlabel.font= dnfontlarge
colorlabel.text = "3D Models"
colorlabel.size = dotnetobject "system.drawing.size" 516 24
colorlabel.textalign = (dotnetclass "System.Drawing.ContentAlignment").MiddleCenter
--show colorlabel
--< Title of gallery type
flp.controls.add colorlabel
flp.controls.addrange dnobjarray
)
--<Actions
)-- end rollout
createDialog mc2TestGalleryDilog style:#(#style_titlebar,
#style_sysmenu, #style_minimizebox, #style_maximizebox, #style_sunkenedge, #style_resizing)
thanks MacroBruneta for you tip
thanks to you LoneRobot, DotNetClass Color Chart is very cool. (much stuff to learn…)
I actually started experimenting with it a few weeks ago and it seems extremely useful. Sure wish there was a .net for dummies guide somewhere online.