.NET User Interface

You can create a user interface (UI) using the .NET API and the Windows Presentation Foundation (WPF) or Windows Forms.

Creating the UI using the WPF

You can create a WPF UI in Visual Studio or another tool such as Microsoft Expression Blend. To setup 3ds Max to work with the WPF window, you need to use ManagedServices.AppSDK.GetMaxHWND and ManagedServices.AppSDK.ConfigureWindowForMax.

The following example shows how to create a floating dialog box:

// Create a new managed window to contain the WPF control
System.Windows.Window dialog = new System.Windows.Window();

// Name the window
dialog.Title = "Sample";

// Example of setup size and location
// ...
dialog.SizeToContent = System.Windows.SizeToContent.WidthAndHeight;
dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
dialog.ResizeMode = System.Windows.ResizeMode.NoResize;

// Assign the window's content to be the WPF control
dialog.Content = new CreateTeapotUserControl1();
dialog.ShowInTaskbar = false;

// Create an interop helper
System.Windows.Interop.WindowInteropHelper windowHandle =
new System.Windows.Interop.WindowInteropHelper(dialog);

// Assign the 3ds Max HWnd handle to the interop helper
windowHandle.Owner = ManagedServices.AppSDK.GetMaxHWND();

// Setup 3ds Max to handle the WPF dialog correctly
ManagedServices.AppSDK.ConfigureWindowForMax(dialog);

// Show the dialog box
dialog.Show();

Creating the UI using the Windows Forms

The .NET scene explorer feature demonstrates how to use a Windows Form in 3ds Max. There are some compatibility issues in handling window events correctly between the native 3ds Max application and any managed Windows Forms opened from it. A .NET plug-in that uses Windows Forms can host their controls in a MaxCustomControls.MaxForm window instead of the .NET Framework standard Form class.

It has been found that not all events are handled properly when using Windows Forms, therefore, it is recommended to setup and test your UI interactivity before coding to make sure that the functionality and events that you need are working properly.

Creating Dockable UI or new Extended Viewports using .NET

A .NET custom user action with a UI component can be created by inheriting from CuiDockableContentAdapter and returning a Windows control from the derived class's implementation of CreateDockableContent(). The docking style of the new control is controlled by the value returned from the DockingModes property. By returning DockStates.Dock.Viewport from DockingModes enables the control to behave as an extended viewport.

public class TestAction : CuiDockableContentAdapter 
  { 
      public override string ActionText { get { return "Test"; } } 
      public override string Category { get { return "CuiTest"; } } 
      public override Type ContentType 
      { 
        get { return typeof(TestControl);  
      } 

      public override object CreateDockableContent() 
      { 
        return new TestControl(); 
      } 

      public override DockStates.Dock DockingModes 
      { 
        get 
           { 
            return DockStates.Dock.Left | DockStates.Dock.Right | DockStates.Dock.Floating | DockStates.Dock.Viewport; 
           } 
      }
  }