[Closed] WPF styles for 3dsMax themes
Does anyone know if there are any available styles for WPF controls that make them blend in nicely with the rest of the 3dsMax interface? I’m thinking there must be, since Autodesk made some dialogs using WPF, like the “Manage Workspaces”.
Is it really? Well that must be why I could not find any styles for it then, hehe.
How about the ribbon then, that must be WPF surely?
You can find many of the controls in AdWindows.dll. I asked about this some time ago and the answer I got was that the controls had no official support so you would have to digg through them yourself. But since the ribbon and AdWindows.dll can be found in almost all of the autodesk products maybe you can find some tutorials on how to use it and apply that back to max.
Are the styles in there too? I would assume that there’s some kind of commonly applicable style for the dark and light themes?
Look in the Autodesk.Internal.Windows namespace in AdWindows.dll. There you find some theme-classes that holds different variations of brushes.
The nice thing about the controls found in that assembly is they will automatically change their theme when you switch the theme in max. Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Autodesk.Windows; //AdWindows.dll
using MaxWpfContent; //MaxWpfContent.dll
namespace Flamespace
{
public static class Example
{
class SimpleCommandHandler<T> : System.Windows.Input.ICommand
{
readonly Action<T> execute;
public SimpleCommandHandler(Action<T> execute) { this.execute = execute; }
public bool CanExecute(object parameter) { return true; }
public void Execute(object parameter) { execute((T)parameter); }
public event EventHandler CanExecuteChanged
{
add { System.Windows.Input.CommandManager.RequerySuggested += value; }
remove { System.Windows.Input.CommandManager.RequerySuggested -= value; }
}
}
public static void Create()
{
Window window = new Window();
window.ShowInTaskbar = false;
window.SizeToContent = SizeToContent.WidthAndHeight;
window.Title = "AdWindowsTest";
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
RibbonControl ribbonControl = new RibbonControl();//ComponentManager.Ribbon; Use the component manager in someway to add the tab to max's ribbon.
ribbonControl.BeginInit();
RibbonTab tab = new RibbonTab();
tab.Title = "Mytab";
RibbonPanel panel = new RibbonPanel();
RibbonPanelSource panelSource = new RibbonPanelSource();
panelSource.Title = "~ø/ *-.";
RibbonToggleButton button = new RibbonToggleButton();
button.Text = "Switch theme";
button.ShowText = true;
button.CommandHandler = new SimpleCommandHandler<object>(i =>
{
MaxWpfContent.ThemeColorSelectorCommand themeCommand;
if (button.IsChecked)
themeCommand = new MaxWpfContent.DarkThemeSelectorCommand();
else
themeCommand = new MaxWpfContent.LightThemeSelectorCommand();
themeCommand.Execute(null);
});
panelSource.Items.Add(button);
panel.Source = panelSource;
tab.Panels.Add(panel);
ribbonControl.Tabs.Add(tab);
ribbonControl.EndInit();
window.Content = ribbonControl;
System.Windows.Interop.WindowInteropHelper windowHandle =
new System.Windows.Interop.WindowInteropHelper(window);
windowHandle.Owner = ManagedServices.AppSDK.GetMaxHWND();
ManagedServices.AppSDK.ConfigureWindowForMax(window);
window.Show();
}
}
}
I’m looking at AdWindows.dll, and I’m getting the feeling that a lot of things are happening through “code behind” instead of through xaml. I wonder why they decided to do this…
And I also wonder how we could leverage the themes for regular WPF controls like buttons, textblocks, simple treeviews and so on.