Akram Parvez Technical Artist


Posted on

I have been learning and using dot-net in 3ds max a lot recently. I think its time i show some of my learnings in Dot-net GDI . Here is an example of using a dot-net label as progress bar with GDI. I tried to replicate the look of pre-max9 polygon counter as asked in tech-artist.org forum(here).

global _dupPolyCounter
try (destroyDialog _dupPolyCounter) catch()

rollout _dupPolyCounter "Duplicate Polycounter" width:250
	local _min = 100,_max =200
	group "Progress Test"
		label _bdgt "Budget:" pos:[20,25]
		spinner spn_max "" pos:[65,25] range:[100,1000,_max] width:55 type:#integer
		label _crnt "Current:" pos:[140,25]
		spinner spn_val "" pos:[185,25] range:[1,spn_max.value,_min] width:55 type:#integer
		dotnetcontrol lbl "label" height:10 width:200 pos:[25,50]
	local acolor = dotnetclass "system.drawing.color"
	mapped fn dispose gdiobj =
	on lbl Paint args do
		local margin = 2
		graphics = args.graphics
		width = ((lbl.clientRectangle.width)/40)
		_val = ((float(_min)/_max)*40)
		X = lbl.clientRectangle.X+margin
		Y = lbl.clientRectangle.Y+margin
		for i = 1 to _val do
			rect = dotnetobject "System.Drawing.Rectangle" X Y (width-1) (lbl.clientRectangle.Height-2*margin)
			_col = acolor.green
			if i > 35  then _col = acolor.red else (if i>27 then _col = acolor.yellow else _col = acolor.green)
			foreBrush=dotnetobject "System.Drawing.SolidBrush" _col
			graphics.FillRectangle foreBrush rect
			X += width
			dispose #(foreBrush)
	on spn_val changed val do
		_min = val
	on spn_max changed val do
		_max = val
		spn_val.range = [1,spn_max.value,_min]
 	on _dupPolyCounter open do
		lbl.backColor = lbl.backColor.Black

createDialog _dupPolyCounter

I hope to post more snippets in future..

Filed under: Scripts Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a Reply

No trackbacks yet.

%d bloggers like this: