好吧,我找到了一些列表,但我不知道如何迭代。它似乎按名称(和我不知道的名称)返回项目,从该链接中,我选择一个来看看这是否有效。Dim coll=Autodesk.AutoCAD.ApplicationServices.Application.UIBindings.ColorSettings。
dim c1=col.Item(“命令行背景”)但是,huiz,你是说(属性pallete)只有可能是暗的还是亮的吗?如果是这样,比这可能对我有用。那么剩下的唯一一件事就是找出运行的autocad版本,因为2013,2014年与2015年有不同的颜色(也是我唯一需要的最后3个)。
//Using Jetbrains DotPeek on AdUiPalettes was able to identify and pull the PaletteThemeDefaults
//Then converting color to a brush
MyPaletteCtrl = new MyPalette();
//Check theme to set the initial color and the reactors
CheckTheme();
//Set Palette background color
MyPaletteCtrl.Background = backgroundColor;
//Add the palette
base.AddVisual("MyPalette", MyPaletteCtrl, true);
Application.SystemVariableChanged += new Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventHandler(variableChanged);
}
catch (Exception ex)
{
//Error loading palette
}
}
protected override void OnPaletteSetClosed()
{
Application.SystemVariableChanged -= new Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventHandler(variableChanged);
}
public static void PaletteSetItemCommand()
{
instance = new PaletteSetItem();
instance.Visible = true;
}
private void variableChanged(object o, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
{
if (e.Name == @"COLORTHEME" && e.Changed)
CheckTheme();
//Set Palette background color
MyPaletteCtrl.Background = backgroundColor;
}
private void CheckTheme()
{
if (Application.Version.Major > 19)
{
//Background color is set based on the theme color
if (System.Convert.ToInt32(Application.GetSystemVariable(@"COLORTHEME")) == 1)
{
Autodesk.Windows.Palettes.PaletteTheme pt = new Autodesk.Windows.Palettes.PaletteTheme(Autodesk.Windows.Palettes.PaletteThemeDefaults.LightOverallColor);
backgroundColor = new SolidColorBrush(pt.PaletteTabBackgroundColor);
}
else
{
Autodesk.Windows.Palettes.PaletteTheme pt = new Autodesk.Windows.Palettes.PaletteTheme(Autodesk.Windows.Palettes.PaletteThemeDefaults.DarkOverallColor);
backgroundColor = new SolidColorBrush(pt.PaletteTabBackgroundColor);
}
}
else
{
//Sets a default gray color just so there's something