[Closed] reserved names and dot net
Here is a bit of an issue. I’m working with a button and trying to set the flatstyles.
testButton.flatStyle=dotNetObject "System.Windows.Forms.FlatStyle" system
testButton.flatStyle=dotNetObject "System.Windows.Forms.FlatStyle" standard
Both are reserved words in Max script, any way to get around this sort of thing if it happens in more important commands?
I don’t think that those key words being reserved is the issue.
I may be mistaken, but I think you are trying to treat the dotnet constructor as a function of sorts? Passing the style you wish as a parameter?
dotNET doesn’t quite work that way. You essentially want to get the constructed value out of the flat style class directly. E.g.:
myButton.flatStyle = (dotNetClass "System.Windows.Forms.FlatStyle").system
myButton.flatStyle = (dotNetClass "System.Windows.Forms.FlatStyle").standard
myButton.flatStyle = (dotNetClass "System.Windows.Forms.FlatStyle").flat
-- where the following is the class to derive from
dotNetClass "System.Windows.Forms.FlatStyle"
dotNetClass:System.Windows.Forms.FlatStyle
-- where the following is the actual value (object)
(dotNetClass "System.Windows.Forms.FlatStyle").system
dotNetObject:System.Windows.Forms.FlatStyle
Interesting as it does work. Well Flat works any ways but popup doesn’t look like it is doing anything different. I will try your method and see what I get. I think my problem was I started with dotNetObject and not dotNetClass. Thanks
Yep that worked. System is what I was looking for as I figured it would be the same as what is in Max.
Richard, I have added you as one of the dotNet pros on my main dotnet page. I don’t have a home page ofr you so I have linked you to http://www.splutterfish.com/sf/WebContent/Index
Is this OK with you?
For buttons, there’s a very faint change in the button’s outline between popup and flat on my machine – probably dependent on the windows UI settings. Should be visible (look closely, though) when changing it using the latter method.
Interesting, so doing it they way I did worked for flat but didn’t work for popup or the others as I see a difference now. I see what I would expect with a setting called popup:)
Hey that is simple.
And thanks Pete, I will have a look over that when I get a chance.
Hi Paul,
The original dotnetobject method seems to work when building a dedicated dotnet UI. this example is a snippet of a larger script but has some extras like using an imagelist to specify a button with a transparent background. I just made a function to set the button’s appearance and passed the dotnet button and the properties in the arguments. Once the classes are defined you should be able to do the same to the dotnetcontrol.property method in the same way as rich suggested. hope it helps!
dotNet.loadAssembly "MaxCustomControls.dll"
global TCBform
fn BuildDotNetButton btn btntext size font style mobg mdbg x y =
(
btn.text = btntext
btn.font = font
btn.size = size
btn.location = dotNetObject "System.Drawing.Point" x y
btn.flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" style
btn.FlatAppearance.MouseOverBackColor = mobg
btn.FlatAppearance.MouseDownBackColor = mdbg
TCBForm.controls.add btn
)
fn DotNetUI =
(
try(TCBForm.close())catch()
-- class objects
-- colours, size,layout and font class libraries
cTCBColor = dotNetClass "System.Drawing.Color"
cgroupbox = dotnetclass "System.Windows.Forms.Groupbox"
csize = dotNetclass "System.Drawing.Size"
cButton = dotNetclass "System.Windows.Forms.Button"
cLabel = dotNetclass "System.Windows.Forms.Label"
cfontStyle = dotNetClass "System.Drawing.FontStyle"
cFont = dotNetObject "System.Drawing.Font" "System" 7 cfontStyle.regular
cFontbold = dotNetObject "System.Drawing.Font" "System" 7 cfontStyle.bold
cFontLargeit = dotNetObject "System.Drawing.Font" "System" 9 cfontStyle.italic
cFontboldLarge = dotNetObject "System.Drawing.Font" "System" 9 cfontStyle.bold
calign = dotnetclass "System.Drawing.ContentAlignment"
--DotNetForm Declarations
TCBForm = dotNetObject "MaxCustomControls.MaxForm"
TCBForm.ClientSize = dotNetObject "System.Drawing.Size" 118 156
TCBForm.text = ".Net"
TCBForm.font = cfontLarge
TCBForm.topmost = true
oFormBorderStyle = dotNetClass "System.Windows.Forms.FormBorderStyle"
TCBForm.FormBorderStyle = oFormBorderStyle.FixedToolWindow
TCBForm.ShowInTaskbar = true
TCBForm.MinimizeBox = false
TCBForm.MaximizeBox = false
--convert 3ds max UI colors to dotnet color classes
maxBackColor = colorMan.getColor #background
maxForeColor = colorMan.getColor #text
maxButtonColor = colorMan.getColor #pressedButton
TCBForm.BackColor = cTCBColor.FromArgb (maxBackColor[1] * 255.0f) (maxBackColor[2] * 255.0f) (maxBackColor[3] * 255.0f)
TCBForm.ForeColor = cTCBColor.FromArgb (maxForeColor[1] * 255.0f) (maxForeColor[2] * 255.0f) (maxForeColor[3] * 255.0f)
MBColorDotNet = cTCBColor.FromArgb (maxButtonColor[1] * 255.0f) (maxButtonColor[2] * 255.0f) (maxButtonColor[3] * 255.0f)
-- using an image list to load a transparent image color onto the button
-- load the dotnet image
-- imageclass = dotNetclass "System.Drawing.image"
-- IListimage1 = imageclass.fromfile (LRUIdir+"TCB.bmp")
-- construct the imagelist
-- imglist = dotnetobject "System.Windows.Forms.ImageList"
-- imglist.imagesize = dotnetobject "System.Drawing.Size" 106 62
-- imglist.images.add ilistimage1
-- imglist.TransparentColor = CTCBColor.white
-- object Size class instances
oBtnSize1 = dotNetObject cSize 28 18
oBtnSize2 = dotNetObject csize 38 38
oBtnSize3 = dotNetObject csize 110 25
oBtnSize4 = dotNetObject csize 100 20
oBtnSize5= dotNetObject csize 110 62
groupSize1 = dotNetObject csize 110 60
groupSize2 = dotNetObject csize 110 185
--dotnet controls
groupeaseto = dotnetobject cGroupBox
groupeaseto.text = "Ease To "
groupeaseto.font = cfont
groupeaseto.size = groupsize1
groupeaseto.location = dotNetObject "System.Drawing.Point" 5 95
---- BUTTONS
TCBReset = dotnetobject cbutton
BuildDotNetButton TCBReset "Reset TCB" obtnSize5 cfontBoldLarge Flat MBColorDotNet cTCBcolor.crimson 5 6
-- position the image on the button
-- TCBReset.ImageIndex = 0
-- TCBReset.ImageList = ImgList
TCBReset.TextAlign = cAlign.bottomCenter
btnkey = dotNetObject cButton
BuildDotNetButton btnkey "Add Key" obtnSize3 cfontLarge Flat MBColorDotNet cTCBcolor.crimson 5 70
btnEaseTo0 = dotNetObject cButton
BuildDotNetButton btnEaseTo0 "0" obtnSize2 cfontboldlarge Flat MBColorDotNet cTCBcolor.crimson 10 110
btnEaseTo10 = dotNetObject cButton
BuildDotNetButton btnEaseTo10 "10" obtnSize1 cfont Flat MBColorDotNet cTCBcolor.crimson 50 110
btnEaseTo25 = dotNetObject cButton
BuildDotNetButton btnEaseTo25 "25" obtnSize1 cfont Flat MBColorDotNet cTCBcolor.crimson 50 130
btnEaseTo40 = dotNetObject cButton
BuildDotNetButton btnEaseTo40 "40" obtnSize1 cfont Flat MBColorDotNet cTCBcolor.crimson 80 110
btnEaseTo50 = dotNetObject cButton
BuildDotNetButton btnEaseTo50 "50" obtnSize1 cfont Flat MBColorDotNet cTCBcolor.crimson 80 130
-- add the groups last so they are arranged behind the buttons
TCBForm.controls.add groupeaseto
TCBForm.show()
)
DotNetUI()