[Closed] 3dsMax-Style .NET Button DLL ?
I was wondering if someone had made a .NET dll with a button exactly matching the design of the 3dsMax GUI Button (light bevel&emboss, pushing down effect on click,…) ?
this doesn’t have the backcolor change onpressed like max buttons do. I think that’s what feranti is getting at
he says ‘pusing down effect’ i take that to be a typo of ‘pushing down effect’ which in my mind includes the change in backcolor on-pressed
Yes you’re right ! I have edited the first post for better understanding of the thread.
For sure it is not a big stuff. I was just emitting the idea that it would be cool to share a .NET control (if someone already did it) which will be the exact same look as maxscript to be used in pure .NET gui. It would keep the look of the max rollouts tool.
If I take time to do it, I’ll post it there.
I have a series of max look-a-like controls. I will try to find time to clean up the code and post it.
I wrote something like this a while ago when I was learning dotnet.
My stance on this has changed somewhat. I totally get the notion of dotnetcontrols like the flowlayout panel, the datagridview, labels etc and use them daily to enhance my scripted systems. They can be integrated well into max without any issue and they substantially increase the functionality of a UI. But buttons? I don’t see really what they bring to the party? (aside mayyyybe image/text combinations and double click functionality).
It seems you are fighting to style them when all they want to do is declare their independence to the rest of the max UI. Yes it’s nice when you see buttons that have text and images, but does this ever look right with max’s (admittedly long in the tooth) interface?
This is not meant to detract from what feranti is attempting to do which is perfectly valid, and as you all know I’m a massive advocate of dotnet in max but I just draw the line at buttons.
Thanks, LoneRobot, for the sharing !
Just as I am right now :).
The annoying thing with max classic controls are their lack of properties. First thing which comes to my mind for the button is the height or width so that you can place another element close to or under it, without putting voodoo constants in your placement script :). Am I wrong on that point ?
Hi Antoine, I’m not sure I get what you mean by voodoo constants, can you explain what it is you can’t do with max control layout that you can with dotnet?
Alright, I wish I had time clean this up and provide a more complete example, but this is an exmaple of the framework I used to immitate max controls:
public class MaxButton : Button
{
public bool FrameOnMouseOverOnly;
private bool mouseOver;
private MaxColorsProvider provider;
public MaxColorsProvider ColorProvider
{
get { return provider; }
set
{
provider = value;
UpdateColors();
}
}
public MaxButton()
{
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.UseVisualStyleBackColor = false;
if (DesignMode) return;
}
public void UpdateColors()
{
if (provider == null) return;
this.BackColor = provider.BackColor;
this.ForeColor = provider.ForeColor;
this.FlatAppearance.CheckedBackColor = provider.CheckedColor;
this.FlatAppearance.MouseOverBackColor = provider.BackColor;
this.FlatAppearance.BorderColor = provider.BackColor;
this.FlatAppearance.BorderSize = 0;
}
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
if (DesignMode || provider == null) return;
if (FrameOnMouseOverOnly && !mouseOver) return;
//draw the frame
pevent.Graphics.DrawLines(provider.FrameLowPen, new Point[] {
new Point(0, Height),
new Point(0, 0),
new Point(Width, 0)});
pevent.Graphics.DrawLines(provider.FrameHighPen, new Point[] {
new Point(0, Height - 1),
new Point(Width - 1, Height - 1),
new Point(Width - 1, 0)});
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
mouseOver = true;
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
mouseOver = false;
}
protected override bool ShowFocusCues
{
get
{
return false;
}
}
}
This is a generic button, which also has the option to draw the frame all the time, or only when the mouse if over it (like the 3dsmax main toolbar buttons).
For your project, you also need a class that acts as the 3dsmax UI colors provider, and contains colors and GDI+ objects that represent the 3dsmax UI colors. This is usually initialized using MAXScript with the correct colors.
One might wonder why I didn’t just reference the 3dsmax managed assemblies, and the reason for that is only backwards compatibility.
This code is missing the inverted frame on mouse down, I was sure I added that, maybe in a different file.
Sorry, I’ll really try to find the time to rearrange this better, and also give examples of the CheckButton and Spinner I did.
Do not be sorry ! It is a great start point for anyone (including me) learning .NET controls programming. Thanks
One might wonder why I didn’t just reference the 3dsmax managed assemblies, and the reason for that is only backwards compatibility.
Yes I was about to ask, btw. Which max versions would be incompatible with 3dsmax managed assemblies ?