I want to create buttons depending on certain things!
So here is what I need:
fn myfunction=
(
...
for i=1 to IDcount do
(
dotnetcontrol ID_btn[i] "System.Windows.Forms.Button" width:20 height:60 pos:[27,i*153]
ID_btn[i].backcolor = (dotnetcolor 70 70 70)
ID_btn[i].flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" Flat
ID_btn[i].text="1"
ID_btn[i].foreColor = (dotnetcolor 200 200 200)
)
)
How to make it work?
Comments (71)
Comment policy
Thx Barigazy!
I use this
How to find out which s.material is used for certain button? and how to find out is this button ID btn or material?
I will use "Tag" property of dotnet object in this case button.
Simply put some information lat say materilal in button tag prop
then use findItem method for btnarray or
for i = 0 to (pn.controls.count - 1) where pn.Controls.Item[i].tag == s.material.name do print i
FINALLLY I've got it work! THANK YOUUUUUU!
But one more question!
If I add btns in dotnet panel
then how to use them?
on --<< >>??? click do
(
)
Attachments
I post already my write method.
You need to predefine locals fo button objects.
Then you nedd to define events for this buttons. Let's say you have:
on btn click arg do ... you can use only if button is dotNetControl but not dotNetObject. In mxs help you can find topics about dotNet definition
This is what I came up with
Now I can easily go on! Thank you, Barigazy! You HELPED me lot!!!
oh
ok! Thx! I will try now
My suggestion is to use "Form" instead of Rollout because you use dotnet objects.
This is the way how I write my tools, is not the perfect aproch but works for me.
Attachments
how
?
just tell me
how to define the width of the containers and if I can use just one container then let me know how to fill pn with one container. Everything else I understood how to do!
Except this
I thought to draw all buttons like you showed me in this function:
Here it is possible to put location and dimensions! In fact I need only one container where I could add buttons!
Is it possible to define just one container where I could add these buttons, or should I make a thin column on the left and one wider on the right where I could add all the buttons?
Then use simle "Panel" control for the buttons (simpliest container)
dotnetcontrol pn "Panel" pos:[5,5] width:390 height:378
I just didn't understand
where did you define the width and the height for the panel1 and panel2?
I will add controls just for the visible textures in datagrid, that's why it will be not slow!!!
I not define them in this example. But you can anywhere inside function, and if you need to be changed in some point then you need to add also arguments in fn definition like i did for width and height (w: and h:)
now it's much interesting!
I'm implementing now to my code!!!!!
Thx barigazy, I think this will do what I want!
:)
Believe me your trouble just started. :) Don't experiment too much with additional controls because your tool will become slower and slower.
Oh, yeeeeeeeeeeeeeees!!!
now I have what to work with!
Is it possible to clear pn.controlls? so that they would be empty and to recreate in case my list updates!
.net clear method
-- to remove all buttons
sp1.panel2.controls.Clear()
-- and for panel probably
pn.controls.Clear()
what is dock
in which cases it should be used?
how to add split containers iteratively?
how to fill every container with a button?
srry for all these questions, but if understand this then I know how to go on!
Thank you Barigazy, I would not be able to make it by myself!
Dock propert allow you to entirely fills the container with specified controls. Similar to align in max script. This option not work well in may last example I don't know why.
Explain better "Iteratively"?
Using for-loop collect buttons
try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
dotnetcontrol pn "MaxCustomControls.MaxUserControl" pos:[5,5] width:390 height:378
fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)
local COL1 = (defColor 80 80 80), COL2 = (defColor 150 150 150), COL3 = (defColor 65 125 88), COL4 = (defColor 125 150 80)
local sp1 = dotnetobject "SplitContainer"
local sp2 = dotnetobject "SplitContainer"
fn defineSplitCont sp mainPnl clr1 clr2 w: h: dock: spliter:2 orient:#vert ctrlsIn1st:#() ctrlsIn2st:#()=
(
sp.panel1.backColor = clr1
sp.panel2.backColor = clr2
sp.splitterWidth = spliter
case orient of
(
(#vert): sp.Orientation = sp.Orientation.Vertical
(#horiz): sp.Orientation = sp.Orientation.Horizontal
)
if dock then (sp.panel1.DockPadding.All = sp.panel2.DockPadding.All = 0 ; sp.dock = sp.dock.fill) else
(
if w != unsupplied and h != unsupplied do (sp.width = w ; sp.height = h)
sp.Location = dotNetObject "System.Drawing.Point" (mainPnl.pos.x) (mainPnl.pos.y)
)
if ctrlsIn1st.count != 0 do sp.Panel1.controls.AddRange ctrlsIn1st
if ctrlsIn2st.count != 0 do sp.Panel2.controls.AddRange ctrlsIn2st
sp
)
fn defBtn pnl txt: w:50 h:50 cnt:0 =
(
btn = dotnetobject "Button"
btn.text = txt
btn.width = 50 ; btn.height = 20
btn.Location = dotNetObject "System.Drawing.Point" 5 (-15 + (cnt*btn.height))
btn
)
on testR open do
(
pn.backcolor = pn.backcolor.black
pn.BorderStyle = pn.BorderStyle.FixedSingle
pn.width = 390 ; pn.height = 390
defineSplitCont sp2 pn COL3 COL4 dock:off spliter:2 orient:#horiz
defineSplitCont sp1 pn COL1 COL2 w:378 h:378 dock:on spliter:2 ctrlsIn1st:#(sp2) ctrlsIn2st:(for i = 1 to 10 collect (defBtn sp1.panel2 txt:("Btn_"+i as string) w:50 h:10 cnt:i))
pn.controls.add sp1
)
)
createDialog testR
THX Barigazy
I will try it when I come back! Thank you thank you thank you!!!
now as I undesrand
I should have
iside rollout
and somehow to add split containers iteratively
in such a form
just instead of this - to call splitcontainers
The MaxUserControl is one of many types of containes ei. Panels which can hold dotNet object inside. It's not important to use this type U can use simple Panel.
I play a bit maybe this can helps
try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
dotnetcontrol pn "MaxCustomControls.MaxUserControl" pos:[5,5] width:390 height:378
fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)
local COL1 = (defColor 80 80 80), COL2 = (defColor 150 150 150),COL3 = (defColor 65 125 88),COL4 = (defColor 125 150 80)
fn defineSplitCont mainPnl clr1 clr2 w: h: dock: spliter:2 orient:#vert ctrlsIn1st:#() ctrlsIn2st:#()=
(
sp = dotnetobject "SplitContainer"
sp.panel1.backColor = clr1
sp.panel2.backColor = clr2
sp.splitterWidth = spliter
case orient of
(
(#vert): sp.Orientation = sp.Orientation.Vertical
(#horiz): sp.Orientation = sp.Orientation.Horizontal
)
if dock then sp.dock = sp.dock.fill else
(
if w != unsupplied and h != unsupplied do (sp.width = w ; sp.height = h)
sp.Location = dotNetObject "System.Drawing.Point" (mainPnl.pos.x) (mainPnl.pos.y)
)
if ctrlsIn1st.count != 0 do sp.Panel1.controls.AddRange ctrlsIn1st
if ctrlsIn2st.count != 0 do sp.Panel2.controls.AddRange ctrlsIn2st
sp
)
on testR open do
(
pn.backcolor = pn.backcolor.black
pn.BorderStyle = pn.BorderStyle.FixedSingle
pn.width = 390 ; pn.height = 390
splitC2 = defineSplitCont pn COL3 COL4 dock:off spliter:2 orient:#horiz
splitC1 = defineSplitCont pn COL1 COL2 w:378 h:378 dock:on spliter:2 ctrlsIn1st:#(splitC2)
pn.controls.add splitC1
)
)
createDialog testR
and
inside rollout
I had this function previously
I took this function from here
http://3ds-max-dev.googlecode.com/svn/projects/maxtest/trunk/presenter/i…
but inside I should have buttons
I don't understand how to use it
and how to create left panel, righ panel and how to split horizontally the right panel
Look!
I still think that it's possible!!!
I've found a script with such a function
This means that split containers can be created iteratively in function!
Just help me please to create one panel on the left and one on the right and a "for" cycle to create n splitcontainers inside right panel. After this, every panel should be filled with a button!
Yup. I aranged a bit your code. Try it to see if works for you.
No need to use return in this case
function createSplitContainer =
(
--
-- splitContainer1
--
local statusStrip = createStatusStrip()
local resultDetails = createResultDetails()
local splitContainer1 = dotNetObject "SplitContainer"
splitContainer1.Dock = splitContainer1.Dock.Fill
splitContainer1.Name = "splitContainer1"
splitContainer1.Orientation = splitContainer1.Orientation.Horizontal
splitContainer1.SplitterWidth = 10
splitContainer1.SplitterDistance = 50
resultDetails.Top = 0
resultDetails.Left = 0
resultDetails.Width = splitContainer1.Panel2.Width
resultDetails.Height = splitContainer1.Panel2.Height - statusStrip.Height
splitContainer1.Panel1.Controls.Add (createResultList())
splitContainer1.Panel2.Controls.AddRange #(statusStrip, resultDetails)
splitContainer1
)
Barigazy
www.go2sleep.com
I need
like in pic from above to have blend for example which could be placed first sometimes and then multisubobject and after this again a certain material(nonmultisub) - I need it to update, that's why I would like to add splitcontainers in function depending on materialtype. How do you think, is it possible, or should I forget about that?
It's very difficult to perform. Now there's nothing I can think of. I will probably tried to add different beckcolor of DataGrid row. For example red rows will represent multimaterial, green VRayMaterial, gray Standard etc. This is just en idea.
does it mean that I need to use just 2 columns?
to receive my result?
Is it possible with using this to get this:
http://www.scriptspot.com/files/wanted.jpg ?
I not know, I've never tried something like this. You can use first column for material names and second for numbers but you know best what you need.
Barigazy
When do you sleep?
I finish some project right now. :) I can't sleep, maybe later :)
I think it's much better approach to my wish
but how to split horizontally the right panel?
and how to make each part to work as buttons?
As its name implies, these control is Container. You need to put something inside, buttons or another container.
Thank you, barigazy!!!
I will try your code a bit later, now I'm working on a 3d project a little!
Split Container
Here is en example of Split Container control.Maybe this is beter solution then FLP
try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
dotnetcontrol pn "MaxCustomControls.MaxUserControl" pos:[5,5]
on testR open do
(
pn.backcolor = pn.backcolor.black
pn.BorderStyle = pn.BorderStyle.FixedSingle
pn.width = 390 ; pn.height = 390
sp = dotnetobject "SplitContainer"
--sp.dock = sp.dock.fill
sp.width = 378 ; sp.height = 378
sp.Location = dotNetObject "System.Drawing.Point" (pn.pos.x) (pn.pos.y)
sp.splitterWidth = 2
sp.panel1.backColor = sp.panel1.backColor.DarkGray
sp.panel2.backColor = sp.panel1.backColor.LightGray
--sp.Panel1Collapsed = true
sp.Panel1MinSize = sp.width/2
--sp.SplitterDistance = 100--pn.width/2
pn.controls.add sp
)
)
createDialog testR
I've found such info
http://stackoverflow.com/questions/7741392/flowlayout-control-keeps-addi…
They said to set the WrapContents property to false
all of them give error
:)
Look better for propertie name and value which is boolean (true-false or on-off)
Not try this never again it's funny
BitmapLister.FLP.WrapContent=BitmapLister.FLP.WrapContent.false
srry
there is
There is no FlowDirection property inside FlowLayoutPanel
showproperties BitmapLister.FLP
.AccessibilityObject : , read-only
.AccessibleDefaultActionDescription :
.AccessibleDescription :
.AccessibleName :
.AccessibleRole :
.AllowDrop :
.Anchor :
.AutoScroll :
.AutoScrollMargin :
.AutoScrollMinSize :
.AutoScrollOffset :
.AutoScrollPosition :
.AutoSize :
.AutoSizeMode :
.BackColor :
.BackgroundImage :
.BackgroundImageLayout :
.BindingContext :
.BorderStyle :
.Bottom : , read-only
.Bounds :
.CanFocus : , read-only
.CanSelect : , read-only
.Capture :
.CausesValidation :
.CheckForIllegalCrossThreadCalls : , static
.ClientRectangle : , read-only
.ClientSize :
.CompanyName : , read-only
.Container : , read-only
.ContainsFocus : , read-only
.ContextMenu :
.ContextMenuStrip :
.Controls : , read-only
.Created : , read-only
.Cursor :
.DataBindings : , read-only
.DefaultBackColor : , read-only, static
.DefaultFont : , read-only, static
.DefaultForeColor : , read-only, static
.DisplayRectangle : , read-only
.Disposing : , read-only
.Dock :
.DockPadding : , read-only
.Enabled :
.FlowDirection :
.Focused : , read-only
.Font :
.ForeColor :
.Handle : , read-only
.HasChildren : , read-only
.Height :
.HorizontalScroll : , read-only
.ImeMode :
.InvokeRequired : , read-only
.IsAccessible :
.IsDisposed : , read-only
.IsHandleCreated : , read-only
.IsMirrored : , read-only
.LayoutEngine : , read-only
.Left :
.Location :
.Margin :
.MaximumSize :
.MinimumSize :
.ModifierKeys : , read-only, static
.MouseButtons : , read-only, static
.MousePosition : , read-only, static
.Name :
.Padding :
.Parent :
.PreferredSize : , read-only
.ProductName : , read-only
.ProductVersion : , read-only
.RecreatingHandle : , read-only
.Region :
.Right : , read-only
.RightToLeft :
.Site :
.Size :
.TabIndex :
.TabStop :
.Tag :
.Text :
.Top :
.TopLevelControl : , read-only
.UseWaitCursor :
.VerticalScroll : , read-only
.Visible :
.Width :
.WindowTarget :
.WrapContents :
even
doesn't change anything!
I think I'm doing smth wrong!
I not know what's wrong, but let consider this:
-- what if you have over the 1000 bitmaps or material. That will kill your tool.
Maybe is a bad idea to use numbering of maps group.
-- if you deside to continue with this then try to create two separate vertical FLP one for the material class and one for numbers.
hm
also doesn't help - the same result
from here
http://www.scriptspot.com/bobo/mxs9/dotNet/dotNetObject_System.Windows.F…
look
I noticed that whatever I use
it does not change at all! I think I'm not writing code corectly
Not change because your FLP with is too small and not allow to cange position of controls. I love to use Panel because I can manualy assigne exact location of .net control. But if your controls change size then FLP is the better choise
does not help also! exactly the same result! May be smth I do wrong!
In this case I will use dotnet Panel control and put all inside. You will lose auto alignement but who care. Just define locations of labels or buttons where you need to be inside panel control
I can use even verticalString like you said
but I still could not find a solution to align buttons like in the second picture from above
Are you try with FLP horizontal direction direction. I this not works then you need change concept
Let's say
I can use image for label with vertical text - multitexture, but I can't alight buttons
Why do you want to use map to represent simple text.Are you try to add text to button as I show you yesterday?
here is what I achieve
Attachments
But these buttons are the last thing to do with GUI
May be you have some ideas how to do this:
buttons should update accordingly to textures from datagrid which change.
Here is what I have now
and here is what I want:
Attachments
Are you try to use button name like this :
"M\nU\nL\nT\nI\nM\nA\nT\nE\nR\nR\nI\nA\nL"
--or
fn verticalString str =
(
local outStr = ""
for s in 1 to str.count do outStr += str[s]+"\n"
outStr
)
verticalString "MULTIMATERIAL"
if for btn not work then try with Label control
great idea
but if I use 2 clumns FlowLayoutPanel for the buttons then how to use labels?
or should I refuse from using FlowLayoutPanel?
And how to create labels from function, to add them depending on some parameters?
Label is not different then button. Define only properties for backcolor,forecolor,textalign,...
lbl = dotnetobject "Label"
lbl.backcolor = lbl.backcolor.dimgray
lbl.forecolor = lbl.corecolor.lightgray
lbl.TextAlign = lbl.TextAlign.MiddleCenter
lbl.BorderStyle = lbl.BorderStyle.None
lbl.width = ...
lbl.height = ...
--etc
--use for-loop to create (combine Labels and Buttons inside FLP)
-- every odd will be Label and even will be Button
--for-loop example
for i = 1 to 10 do
(
if mod i 2 != 0 then print ("Label_"+ i as string) else print ("Button_"+ i as string)
)
--Now just replace insted of print your functions for Label and Button definition
Text orientation
how to make vertical text orientation for text inside buttons?
??
??? :)
I never try this, but also I think that buttons or checkbuttons not have that property. Find another solution for for your controls placement. Not try to experiment too much, because your GUI creation process may take several months.
Trust me :)
srry, I've found! SOLVED
I had to use
still the same
But I've used
but buttons still appear the same way, at a distance of 6px!
Oh, barigazy!
You're awesome!
but how to remove padding around buton?
Attachments
adjust FLP width 2px wider then buttons width
--put theses two lines inside defCB function
dnCtrl.flatappearance.bordersize = 0
dnCtrl.margin = dotnetobject (dotnetclass "padding") margin margin 0 0
Thx Barigazy!
You're a really GREAT PERSON! I will take a look!
more infos
You know it's very smart choise to use funcions for .NET objects definition because
your code will have over 1000 lines in most cases only for UI. In free time read this thread to learn .net from masters http://forums.cgsociety.org/showthread.php?f=98&t=551473
Look at code of this tools http://www.scriptspot.com/3ds-max/scripts/hide-unhide-mtlid-faces or http://www.scriptspot.com/3ds-max/scripts/scriptrun