ScriptSpot

Forum topic · General Scripting

create dotnetcontrol buttons inside function

By artrender.info · 2013-04-11

Description

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)

Thx Barigazy!

artrender.info · 2013-04-28

I use this


append btnarray #(prevh,2, w, h, (ID as string), s.material) --w= 33
append btnarray #(prevh,1, w, h, "multimaterial", s.material)--w= 33
append btnarray #(prevh,3, w, h, (classOf s.material) as string, s.material)--w= 66
But how can I detect which button is selected?

--1, 2 and 3 - is the type of material!


pn.controls.add (defBtn 0 btnarray[i][2] w:btnarray[i][3] h:h txt:btnarray[i][5])	

How to find out which s.material is used for certain button? and how to find out is this button ID btn or material?

barigazy · 2013-04-28

I will use "Tag" property of dotnet object in this case button.
Simply put some information lat say materilal in button tag prop

btn1.tag = s.material.name

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!

artrender.info · 2013-04-27

But one more question!

If I add btns in dotnet panel


pn.controls.addRange ctrlsIn2st

then how to use them?

on --<< >>??? click do
(

)

Attachments

barigazy · 2013-04-27

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:


btn = dotnetobject "Button"
btn.name = "Button1"
-- now we need a fn
fn printSomething sender arg = print sender.name
--and only you need to do next
--If you use mxs rollout dialog (example "TestRoll") then in open events put this
on testroll open do
(
    dotnet.addeventhandler btn "Click" printSomething
)

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

artrender.info · 2013-04-18


try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
	dotnetcontrol pn "Panel" 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 ctrlsIn2st=#()

	fn defBtn txt: w: h: cnt:0 =
	(
		print h
		btn = dotnetobject "Button"
		btn.text = txt
		btn.backcolor = COL2
		btn.width = w ; btn.height = h
		btn.Location = dotNetObject "System.Drawing.Point" 5 (-15 + (cnt*btn.height))
		btn
	)
	on testR open do 
	(
		pn.backcolor = COL1--pn.backcolor.blue
		pn.BorderStyle = pn.BorderStyle.FixedSingle
		pn.width = 390 ; pn.height = 390 
		for i=1 to 5 do -- add mat id buttons
		(
			append ctrlsIn2st (defBtn txt:(i as string) w:20 h:60 cnt:i)
		)
		pn.controls.addRange ctrlsIn2st
	)
)
createDialog testR

Now I can easily go on! Thank you, Barigazy! You HELPED me lot!!!

oh

artrender.info · 2013-04-18

ok! Thx! I will try now

barigazy · 2013-04-18

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

artrender.info · 2013-04-18


sp.panel1.width = 15 

?

just tell me

artrender.info · 2013-04-18

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

artrender.info · 2013-04-18

I thought to draw all buttons like you showed me in this function:


	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
	)

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?

barigazy · 2013-04-18

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

artrender.info · 2013-04-18

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!!!

barigazy · 2013-04-18

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!

artrender.info · 2013-04-18

I'm implementing now to my code!!!!!
Thx barigazy, I think this will do what I want!

:)

barigazy · 2013-04-18

Believe me your trouble just started. :) Don't experiment too much with additional controls because your tool will become slower and slower.

Oh, yeeeeeeeeeeeeeees!!!

artrender.info · 2013-04-17

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

barigazy · 2013-04-17


-- to remove all buttons
sp1.panel2.controls.Clear()
-- and for panel probably
pn.controls.Clear()

what is dock

artrender.info · 2013-04-17

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!

barigazy · 2013-04-17

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

artrender.info · 2013-04-17

I will try it when I come back! Thank you thank you thank you!!!

now as I undesrand

artrender.info · 2013-04-17

I should have


dotnetcontrol pn "MaxCustomControls.MaxUserControl" width:48 height:(table.height-24) pos:[2,153]

iside rollout

and somehow to add split containers iteratively

in such a form


defCB cb (newbitmaps.count*30-2) txt: (m as string) check:false -- 30 - the height of a datagrid row, newbitmaps.count -- count of textures inside ID

FLP.Controls.Add(cb)

just instead of this - to call splitcontainers

barigazy · 2013-04-17

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

artrender.info · 2013-04-17


dotNetControl FLP "FlowLayoutPanel" width:48 height:(table.height-24) pos:[2,153]

inside rollout

I had this function previously

artrender.info · 2013-04-17



	fn dotnetcolor r g b = 
	(
		(dotNetClass "System.Drawing.Color").fromARGB r g b
	)
 
	fn defCB  dnCtrl btnheight txt: check: =
	(
		dnCtrl.Appearance = dnCtrl.Appearance.Button
		dnCtrl.flatappearance.bordersize = 0
		dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 1)
		dnCtrl.width = 20 
		dnCtrl.height = btnheight
		dnCtrl.backcolor = (dotnetcolor 84 84 84) 
		dnCtrl.forecolor = (dotnetcolor 200 200 200)
		dnCtrl.Cursor = (dotNetClass "Cursors").Hand
		dnCtrl.FlatStyle = dnCtrl.FlatStyle.Flat
		dnCtrl.TextAlign = dnCtrl.TextAlign.MiddleCenter
		dnCtrl.text = txt ; dnCtrl.checked = check
	)
--...
dotNetControl MtlFLP "FlowLayoutPanel" width:22 height:(table.height-24) pos:[5,153]--column for materials buttons
dotNetControl FLP "FlowLayoutPanel" width:30 height:(table.height-24) pos:[18,153]--column for mat IDs
--...
 if classof s.material == multimaterial then
(...
	cb = dotNetobject "checkbox"
	defCB cb (newbitmaps.count*30-2) txt: (m as string) check:false -- 30 - the height of a datagrid row, newbitmaps.count -- count of textures inside ID
	FLP.Controls.Add(cb)
)

I don't understand how to use it

artrender.info · 2013-04-17

and how to create left panel, righ panel and how to split horizontally the right panel

Look!

artrender.info · 2013-04-17

I still think that it's possible!!!

I've found a script with such a function


		function createSplitContainer =
		(
			-- 
			-- splitContainer1
			-- 
			local splitContainer1 = dotNetObject "System.Windows.Forms.SplitContainer"
			splitContainer1.Dock = splitContainer1.Dock.Fill
			splitContainer1.Name = "splitContainer1"
			splitContainer1.Orientation = splitContainer1.Orientation.Horizontal
			splitContainer1.SplitterWidth = 10
			splitContainer1.SplitterDistance = 50
			
			splitContainer1.Panel1.Controls.Add (createResultList())
			
			local statusStrip = createStatusStrip()
			splitContainer1.Panel2.Controls.Add statusStrip
			
			local resultDetails = createResultDetails()
			resultDetails.Top = 0
			resultDetails.Left = 0
			resultDetails.Width = splitContainer1.Panel2.Width
			resultDetails.Height = splitContainer1.Panel2.Height - statusStrip.Height
			splitContainer1.Panel2.Controls.Add resultDetails
			
			return splitContainer1
		),

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!

barigazy · 2013-04-17

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
)

I need

artrender.info · 2013-04-16

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?

barigazy · 2013-04-16

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.

barigazy · 2013-04-16

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

artrender.info · 2013-04-16

When do you sleep?

barigazy · 2013-04-16

I finish some project right now. :) I can't sleep, maybe later :)

I think it's much better approach to my wish

artrender.info · 2013-04-16

but how to split horizontally the right panel?


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.backcolor = (dotNetClass "System.Drawing.Color").fromARGB (((colorMan.getColor #background) * 255)[1] as integer) (((colorMan.getColor #background) * 255)[2] as integer) (((colorMan.getColor #background) * 255)[3] as integer)
		--pn.BorderStyle = pn.BorderStyle.FixedSingle
		pn.width = 390 ; pn.height = 390 
		sp = dotnetobject "SplitContainer" 
		sph = dotnetobject "SplitContainer" 
		--sp.dock = sp.dock.fill
		sp.width = 378 ; sp.height = 378
		sph.width = 185 ; sph.height = 378
		sp.Location = dotNetObject "System.Drawing.Point" (pn.pos.x) (pn.pos.y)
		sph.Location = dotNetObject "System.Drawing.Point" (pn.pos.x+185) (pn.pos.y)
		--sp.splitterWidth = 2
		sp.panel1.backColor = sp.panel1.backColor.DarkGray
		--sp.panel2.backColor = sp.panel1.backColor.LightGray
		sph.panel1.backColor = sph.panel1.backColor.Darkblue
		--sp.Panel1Collapsed = true
		sp.Panel1MinSize = sp.width/2
		sph.Panel1MinSize = sph.height/2
		sph.Orientation = sph.Orientation.Horizontal
		--sp.SplitterDistance = 100--pn.width/2
		pn.controls.add sp
                pn.controls.add sph
	)
)
createDialog testR

and how to make each part to work as buttons?

barigazy · 2013-04-16

As its name implies, these control is Container. You need to put something inside, buttons or another container.

Thank you, barigazy!!!

artrender.info · 2013-04-16

I will try your code a bit later, now I'm working on a 3d project a little!

Split Container

barigazy · 2013-04-16

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

artrender.info · 2013-04-16

http://stackoverflow.com/questions/7741392/flowlayout-control-keeps-addi…

They said to set the WrapContents property to false


BitmapLister.FLP.WrapContent=false
BitmapLister.FLP.WrapContent.false
BitmapLister.FLP.WrapContent=BitmapLister.FLP.WrapContent.false
BitmapLister.FLP.WrapContent=FLP.WrapContent.false

all of them give error

:)

barigazy · 2013-04-16

Look better for propertie name and value which is boolean (true-false or on-off)


BitmapLister.FLP.WrapContents = off

Not try this never again it's funny

BitmapLister.FLP.WrapContent=BitmapLister.FLP.WrapContent.false

srry

artrender.info · 2013-04-16

there is

There is no FlowDirection property inside FlowLayoutPanel

artrender.info · 2013-04-16

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

artrender.info · 2013-04-16



BitmapLister.FLP.FlowDirection.BottomUp

doesn't change anything!
I think I'm doing smth wrong!

barigazy · 2013-04-16

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

artrender.info · 2013-04-16



BitmapLister.FLP.FlowDirection=(dotNetObject "System.Windows.Forms.FlowDirection" LeftToRight)

and 

BitmapLister.FLP.FlowDirection=(dotNetObject "System.Windows.Forms.FlowDirection" TopDown)

also doesn't help - the same result

look

artrender.info · 2013-04-16

I noticed that whatever I use


BitmapLister.FLP.FlowDirection.TopDown
or
BitmapLister.FLP.FlowDirection.LeftToRight

it does not change at all! I think I'm not writing code corectly

barigazy · 2013-04-16

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

artrender.info · 2013-04-16


BitmapLister.FLP.FlowDirection.LeftToRight 

does not help also! exactly the same result! May be smth I do wrong!

barigazy · 2013-04-16

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

artrender.info · 2013-04-16

but I still could not find a solution to align buttons like in the second picture from above

barigazy · 2013-04-16

Are you try with FLP horizontal direction direction. I this not works then you need change concept

Let's say

artrender.info · 2013-04-16

I can use image for label with vertical text - multitexture, but I can't alight buttons

barigazy · 2013-04-16

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

artrender.info · 2013-04-16


	fn defCB  dnCtrl btntype btnwidth btnheight txt: =
	(
		dnCtrl.backcolor = (dotnetcolor 84 84 84)
		dnCtrl.forecolor = (dotnetcolor 200 200 200)
		dnCtrl.TextAlign = dnCtrl.TextAlign.MiddleCenter
		dnCtrl.BorderStyle = dnCtrl.BorderStyle.None
		dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 1)
		dnCtrl.width = btnwidth
		dnCtrl.height = btnheight
		dnCtrl.text = txt
		dnCtrl.Cursor = (dotNetClass "Cursors").Hand
         )



mt = dotnetobject "Label"
defCB mt 20 (IDTextureCount*30-2) txt: ((classOf s.material) as string) 
BitmapLister.FLP.Controls.Add(mt)

for m in mIDList do
(
     lbl = dotnetobject "Label"
     defCB lbl 20 (newbitmaps.count*30-2) txt: (m as string)
     BitmapLister.FLP.Controls.Add(lbl)
     BitmapLister.FLP.FlowDirection.TopDown
)

Attachments

But these buttons are the last thing to do with GUI

artrender.info · 2013-04-15

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


	fn dotnetcolor r g b = 
	(
		(dotNetClass "System.Drawing.Color").fromARGB r g b
	)
 
	fn defCB  dnCtrl btnheight txt: check: =
	(
		dnCtrl.Appearance = dnCtrl.Appearance.Button
		dnCtrl.flatappearance.bordersize = 0
		dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 1)
		dnCtrl.width = 20 
		dnCtrl.height = btnheight
		dnCtrl.backcolor = (dotnetcolor 84 84 84) 
		dnCtrl.forecolor = (dotnetcolor 200 200 200)
		dnCtrl.Cursor = (dotNetClass "Cursors").Hand
		dnCtrl.FlatStyle = dnCtrl.FlatStyle.Flat
		dnCtrl.TextAlign = dnCtrl.TextAlign.MiddleCenter
		dnCtrl.text = txt ; dnCtrl.checked = check
	)
--...
dotNetControl MtlFLP "FlowLayoutPanel" width:22 height:(table.height-24) pos:[5,153]--column for materials buttons
dotNetControl FLP "FlowLayoutPanel" width:30 height:(table.height-24) pos:[18,153]--column for mat IDs
--...
 if classof s.material == multimaterial then
(...
	cb = dotNetobject "checkbox"
	defCB cb (newbitmaps.count*30-2) txt: (m as string) check:false -- 30 - the height of a datagrid row, newbitmaps.count -- count of textures inside ID
	FLP.Controls.Add(cb)
)
else
						mt = dotNetobject "checkbox"
						defCB mt (multimatTCount*30-2) txt: ((classOf s.material) as string) check:false
						BitmapLister.MtlFLP.Controls.Add(mt)

and here is what I want:

Attachments

barigazy · 2013-04-15

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"

barigazy · 2013-04-15

if for btn not work then try with Label control

great idea

artrender.info · 2013-04-15

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?

barigazy · 2013-04-15

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

artrender.info · 2013-04-15

how to make vertical text orientation for text inside buttons?


dnCtrl.Orientation = (dotNetClass "System.Windows.Forms.Orientation").Vertical

??

??? :)

barigazy · 2013-04-15

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

artrender.info · 2013-04-15

I had to use


dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 0)

still the same

artrender.info · 2013-04-15


dnCtrl.margin = dotnetobject (dotnetclass "padding") margin margin 0 0 --gives error

But I've used


dnCtrl.padding = (dotNetObject "system.windows.forms.padding" 0)

but buttons still appear the same way, at a distance of 6px!

Oh, barigazy!

artrender.info · 2013-04-15

You're awesome!

but how to remove padding around buton?

artrender.info · 2013-04-14


	fn dotnetcolor r g b = 
	(
		(dotNetClass "System.Drawing.Color").fromARGB r g b
	)

	fn defCB dnCtrl txt: check: =
	(
		dnCtrl.Appearance = dnCtrl.Appearance.Button
		dnCtrl.width = dnCtrl.height = 25 ; 
		dnCtrl.backcolor = (dotnetcolor 70 70 70) 
		dnCtrl.forecolor = (dotnetcolor 200 200 200)
		dnCtrl.Cursor = (dotNetClass "Cursors").Hand
		dnCtrl.FlatStyle = dnCtrl.FlatStyle.Flat
		dnCtrl.TextAlign = dnCtrl.TextAlign.MiddleCenter
		dnCtrl.text = txt ; dnCtrl.checked = check
	)
--...
dotNetControl FLP "FlowLayoutPanel" width:30 height:(table.height-24) pos:[18,153]
--...

	cb = dotNetobject "checkbox"
	defCB cb txt: "1" check:false
	FLP.Controls.Add(cb)
Attachments

barigazy · 2013-04-14

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!

artrender.info · 2013-04-11

You're a really GREAT PERSON! I will take a look!

more infos

barigazy · 2013-04-11

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