View Full Version : MAXScript dotNetController font help please
GrahamArthur 05-21-2009, 10:41 PM Hi I got a button all set-up in max and i was wondering is there a way to set the size and colour of my font???
I'm sure there is, but the size is a read-only... so I'm wondering how to get around this..
I'm very new to dotNet... In fact this is my first attempt at a simple button.
try(destroyDialog testRoll)catch()
rollout testRoll "Test"
(
dotNetControl testButton "system.windows.forms.button" height:50
on testRoll open do
(
testButton.text="testButton"
)
)
createDialog testRoll
I get this out of properties
.Size : <System.Single>, read-only
::EDIT::
i solved the font colour
testButton.ForeColor was the solution
after some searching i found that i most likely need to create a new font object.. then apply or clone it to the current font of the button
|
|
ZeBoxx2
05-22-2009, 12:12 AM
testroll.testbutton.font = dotNetObject "System.Drawing.Font" "Times New Roman" 24
-- or with some font styling
dnFontStyle = dotNetClass "System.Drawing.FontStyle"
myFontStyle = dotnet.combineenums dnFontStyle.bold dnFontStyle.italic
testroll.testbutton.font = dotNetObject "System.Drawing.Font" "Times New Roman" 24 myFontStyle
( oh the hilarity! )
GrahamArthur
05-22-2009, 04:00 AM
awesome.
wow... i missunderstood "fontFamily" when you build the font...
.... i kept getting that wrong type error... but never really caught on to what was causing it.
thanks a bunch.. i was so close :)
MarcoBrunetta
05-22-2009, 05:02 AM
Does anybody else get the impression that parts of .NET where created while on drugs?:hmm:
Marco, it is a far cry from active X where the're on drugs but they were also alcoholic schizophrenics with a touch of ADD.
Do you mind if I add this to my Dotnet button page Richard?
ZeBoxx2
05-22-2009, 01:57 PM
Paul: of course not :) ( though maybe use a label other than testButton ;) )
Marco: true, but can't the same be said for most languages, really?
Even MaxScript has some horrible inconsistencies, idosyncracies, etc.
Take for example the matchPattern functionality.
matchPattern string pattern:"<pattern>"
Practically everywhere where it's important, a keyword parameter is optional; if it weren't optional, you'd use a positional parameter. Yet, matchPattern absolutely -requires- you to specify the pattern, but to do so you use the keyword parameter.
I can think of similar oddities in half a dozen other scripting languages I've worked with or encountered :)
Thanks Richard
Funny the example that you gave is one that I have to look up every time I use it, I always forget the parameter keyword as I know there is no defaut that is used and it has to be passed.
Here it is, I just left it in the button help, at some point I should do separate pages on things like this. This was quick and dirty but gets the point across.
http://paulneale.com/tutorials/dotNet/button/button.htm#fontStyling
MarcoBrunetta
05-22-2009, 02:55 PM
@PEN:
Hehe, luckily I skipped the activeX era =D. Nice going with the reference btw.
@ZeBoxx2:
Probably yes, I was just venting my frustration after the latest "OH MY GOD WHAT THE HELL WHERE THEY THINKING" moment with .NET. Things like this changing fonts or setting up colors (fromARGB?!) just seem so pointlessly contrived.
LoneRobot
05-22-2009, 03:24 PM
Here it is, I just left it in the button help, at some point I should do separate pages on things like this. This was quick and dirty but gets the point across.
http://paulneale.com/tutorials/dotNet/button/button.htm#fontStyling
just an extra bit while we are on the subject of buttons - when using the flat styling property, you don't have to use the mouseover and mousedown handlers to change button color states, there is a flatappearance property that can do this for you -
try(destroyDialog testR)catch()
rollout testR "Test"
(
local Ccolor = dotnetclass "system.drawing.color"
dotNetControl testButton "system.windows.forms.button" height:50
on testR open do
(
testButton.flatStyle=testButton.flatStyle.flat
testButton.text="Test Button"
testButton.TextAlign= (dotNetClass "System.Drawing.ContentAlignment").BottomRight
testButton.backColor=testButton.backColor.lightBlue
testButton.flatappearance.mouseoverbackcolor = Ccolor.green
testButton.flatappearance.mousedownbackcolor = Ccolor.red
testButton.flatappearance.bordercolor = Ccolor.yellow
)
)
createDialog testR green
LoneRobot
05-22-2009, 03:27 PM
Interesting Pete, mind if I add that as well?
not at all! :cool:
Interesting Pete, mind if I add that as well?
Your better then I thought Pete, you managed to answer three minutes before I asked:)
LoneRobot
05-22-2009, 03:47 PM
it's weird, sometimes I get these flashes and I swear that I can see what is going on in your head. What those unicycling elephants and breakdancing monkeys are doing there I don't know.
There ya go.
http://paulneale.com/tutorials/dotNet/button/button.htm#fontStyling
I'm not surprised that you can read my thoughts or that you saw the monkeys and elephants, I just surprised you thought they were more notable then the belly dancing pigmys wearing slippers, fez hats and nothing else.
GrahamArthur
05-22-2009, 06:50 PM
i have to agree with marco in some sense
picking up dotNet.. for me is not as simple as i thought it would be...
but its good to know that there is help here if i need it.. thank you all again
MarcoBrunetta
05-22-2009, 06:57 PM
It gets easier as you start to understand some of the logic behind it. It's the same as everything, if you've grown accustomed to one kind of logic, it's hard to get the hags of a different one. Happens to me every time I try to learn a new 3D app.
Time to start making it into my office more often Arthur;)
drdubosc
05-24-2009, 01:08 AM
I have, humbly, to hop to the defense of Microsoft. (And that hasn't always been my natural instinct).
.net is almost completely consistent, and rigorous. The seemingly convoluted and verbose ways of doing some things are there for good reasons, the result of careful design. On the whole, they are typical object-oriented strategies for avoiding code dependencies. They separate interface from implementation, facilitate re-use and economy with resources, and let you rewrite or extend sections of large applications with less chance of screwing up existing code, or introducing untraceable bugs.
Those strategies are, admittedly, a bit much for small programs, and scripting. And the bridge to MXS introduces some peculiarities. But they weren't stoned when they wrote it!
The logic that makes it easier to get your head round it can be found in lots of references out there to OO design, or design patterns.
CGTalk Moderation
05-24-2009, 01:08 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.