During the AutoCAD team’s efforts to introduce the dark theme in the 2015 version, work was done to more easily support additional themes. A lot of work was needed to create the underlying mechanism but now it’s really easy to add your own themes.
To test the mechanism, the AutoCAD team has created a sample theme that turns AutoCAD into various shades of pink. It works programmatically by adjusting the various UI elements, so you really don’t need much code of your own to implement it.
My 5-year old daughter absolutely loves it – she’s extremely interested in what I do for work, all of a sudden. I wouldn’t go as far as saying it’s a way to increase female representation in STEM fields – there are lots of women who detest pink just as there are plenty of men who like it – but I dare say it won’t hurt.
To make it really easy to install this new theme on your system, we’ve added it to the Exchange Apps Store (it may take a day or two to appear up there – we have a backlog of 2015-compatible apps to publish, it seems).
If you can’t wait for the app to be posted, here’s the C# code that implements it. Once compiled and NETLOADed, simply run the PRETTYINPINK command to enable the new theme.
It should be simple enough to take this code and adjust the various parameters to support a different colour, should you want to see AutoCAD in red or blue, for instance.
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
namespace ThemeChange
{
public class AdjustTheme : Form
{
const int bdrPrc = 20;
string _message = "";
Brush _brush = null;
public AdjustTheme(Brush brush, string message)
{
_brush = brush;
_message = message;
TopMost = true;
ShowInTaskbar = false;
FormBorderStyle = FormBorderStyle.None;
BackColor = Color.Plum;
TransparencyKey = Color.Plum;
Width = Screen.PrimaryScreen.Bounds.Width;
Height = Screen.PrimaryScreen.Bounds.Height;
Paint +=
(s, e) =>
{
int bdrWid = Height * bdrPrc / 100;
var border = new Rectangle(0, 0, Width, Height);
e.Graphics.DrawRectangle(new Pen(_brush, bdrWid), border);
var f = new Font("Arial", bdrWid / 2.5f);
var sz = e.Graphics.MeasureString(_message, f);
int wid = (int)sz.Width;
int hgt = (int)sz.Height;
var rect =
new Rectangle(
(Width - wid) / 2, (Height - hgt) / 2,
(int)(wid * 1.2), hgt
);
e.Graphics.DrawString(_message, f, _brush, rect);
};
}
}
public class ThemeChanger
{
private static AdjustTheme _form = null;
private static Timer _timer = null;
private static int _times = 0;
private static int _maxTimes = 0;
public static void ChangeTheme(
Brush brush, string message, int times, double secs
)
{
_form = new AdjustTheme(brush, message);
_form.Show();
_maxTimes = (times * 2) - 1;
_timer = new Timer()
{
Interval = (int)(secs * 1000),
Enabled = true
};
_timer.Tick +=
(s, e) =>
{
if (_times++ >= _maxTimes)
{
_form.Hide();
_form.Dispose();
_form = null;
_timer.Stop();
_timer.Dispose();
_timer = null;
_times = 0;
}
else
{
if (_form.Visible)
_form.Hide();
else
_form.Show();
}
};
}
public class Commands
{
[CommandMethod("PRETTYINPINK")]
public void PinkTheme()
{
ThemeChanger.ChangeTheme(
Brushes.HotPink,
new string(
new double[]{
17.25,27.5,26.5,27.75,30.25,8,16.25,28,28.5,26.25,27,
8,17.5,27.75,27.75,27,28.75,36.5,8,17,24.25,30.25,8.25
}.Select<double,char>(x =>(char)(int)(x*4)).
ToArray<char>()), 4, 2
);
}
}
}
}
Enjoy! :-)
Update:
Now that my favourite blogging day of the year has passed: for those of you unable (or understandably unwilling) to run the above code, here’s what happens when you do. Did anyone fall for it long enough to run it?