获取autocad UI当前颜色
我找不到当前autocad UI颜色列表的位置我想做的是根据当前的颜色(例如acad属性pallete),改变我自己的pallete背景。这很容易,但我就是找不到那个列表在哪里。
我最接近谷歌的是http://adndevblog.typepad.com/autocad/2013/05/wpf-databinding-to-the-commandline-colors.html但是
**** Hidden Message ***** 2015年,有一个系统变量。您可以设置一个事件来查看它何时发生变化。
在2015年之前,您需要阅读注册表(当前配置文件)以了解亮暗主题是否有效。 好吧,我找到了一些列表,但我不知道如何迭代。它似乎按名称(和我不知道的名称)返回项目,从该链接中,我选择一个来看看这是否有效。Dim coll=Autodesk.AutoCAD.ApplicationServices.Application.UIBindings.ColorSettings。
dim c1=col.Item(“命令行背景”)但是,huiz,你是说(属性pallete)只有可能是暗的还是亮的吗?如果是这样,比这可能对我有用。那么剩下的唯一一件事就是找出运行的autocad版本,因为2013,2014年与2015年有不同的颜色(也是我唯一需要的最后3个)。
啊,你需要调色板的颜色!
AutoCAD只显示浅色或深色主题设置。自2015年以来,您可以使用设置为0或1的系统变量GetSystemVariable(“COlorTHEME”)来做到这一点。在以前的版本中,您需要从注册表中读取当前配置文件。
HKEY_CURRENT_USER\Software\欧特克\AutoCAD\R19.1\ACAD-D001:409\Profiles
然后在该配置文件下,如果用户使用浅色主题或深色主题,您可以在某个地方找到设置。
您不会得到真正的颜色,但您可以通过屏幕截图找到并使用Photoshop或其他东西来获取对话框颜色。
有关更多信息,您可以访问http://through-the-interface.typepad.com/through_the_interface/2014/04/supporting-autocad-2015s-dark-theme.html
我也玩了一会儿,但发现
1。改变所有的对话框、调色板和其他东西需要大量的编程工作。2015年的深色主题颜色与2014年的深色主题颜色不同
3。有些窗口窗体对象,如Groupboxes,背景很暗,很难看。有些颜色像绿色真的很丑(而且我的应用主色是绿色)
5。AutoCAD和Civil3D在它们的对话框中不使用深色,只使用属性调色板和图层调色板(和一些其他的)
所以,我只是保持简单,根本不检查深色主题设置。
我仍然在了解这个问题,但它都在安装DLL(
duh
)中,特别是
AcWindows.dll和
tt class=“bbc_tt”>AdUiPalettes.dll
- 你可以从
Acmgd.dll跟踪链
,加载它并遵循参考。在这种情况下,我们正在寻找
Dll
内部的资源 这里是
AdUiPalettes.dll
...
查看最后两个主题 - 就是这样。如果你
DIFF
它们,它开始有意义,以一种HSBColor的方式。
我发现
最好的
(免费)反编译器是dnSpy - 您可以下载预构建的版本或自己构建。Jetbrains dotpeek和Telerik Decompile也都很好。您应该在相同的代码上尝试所有3个并查看差异,它们在变化的地方非常有趣,特别是在C#6,反应式扩展,事件(有些只是将代码反编译为委托)之类的事情上。
在关于“黑客”等的恐慌上街之前,请注意,反编译这些DLL是ADN正式批准的,不 - 鼓励...http://adndevblog.typepad.com/autocad/2012/08/a-rich-source-of-autocad-net-sample-code.html &http://through-the-interface.typepad.com/through_the_interface/2010/02/debugging-into-autocads-net-api-layer-using-reflector-part-1.html
在你反编译它并复制粘贴XAML(erm,道德上可疑)之前,请注意,它已经提到它的颜色在2014年至2015年间发生了变化。因此,也许使用该 DLL 中的资源是一个更好的主意(当然,具有回退位置)。请参阅下面的链接,让球在其中滚动。
好吧,我必须回去工作...
为我提供研究笔记(当我手头上有更多的时间时),以及其他任何感兴趣的人......
http://stackoverflow.com/a/2771208/492
https://www.google.com.au/search?safe=active&q=.net+ResourceManager+baml
https://msdn.microsoft.com/en-us/library/system.resources.resourcemanager(v=vs.110).aspx
https://books.google.com.au/books?id=b1n3mOfdsBoC&pg=PA60&lpg=PA60&dq=.net+ResourceManager+baml&source=bl&ots=AfaJ4o1Rgn&sig=EmU8-WxZZVKRwH4BHEm77QokB5U&hl=en&sa=X&ved=0ahUKEwjAy6LMmprLAhVDmJQKHU5ICiMQ6AEIHDAA#v=onepage&q=.net%20ResourceManager%20baml&f=false 看看这个 https://github.com/ADN-DevTech/AutoCAD-Slide-Library-Manager,看看如何使用
嵌入在DLL中的主题,在这种情况下,它是一个玛雅主题,但原理是相同的。
另请参见 https://github.com/ADN-DevTech/Maya-Net-Wpf-DarkScheme 。请注意,如果现有 DLL 与可执行文件/ AutoCAD / 丢失的袜子不在同一个 palce 中,则链接到该 DLL 以获取主题可能不起作用。我还没有测试过任何这些。 感谢大家在此上的帖子,我能够找出一个动态到应用程序主题颜色(浅色或深色)的工作解决方案。
最终,我的问题是使用WPF,即使用户控件背景是透明的,它也没有在调色板中正确显示。
当使用AddVisual(“MyPalette”,Palette,true)时,它实际上是黑色的。
然后我遇到了这个博客,说我们应该用ElementHost托管WPF,以使其正确运行。这进来了,但没有根据主题改变颜色。
https://through-the-interface.typepad.com/through_the_interface/2009/08/hosting-wpf-content-inside-an-autocad-palette.html
这让我想到了一个动态解决方案,该解决方案适用于各种版本(2015年及以后的版本),并采用主题颜色。要使用此解决方案,您只需添加对 AdUiPalettes 的引用.dll。感谢@CADBLOKE使用DotPeek来研究这些程序集的想法,我能够确定Autodesk.Windows.Palettes.PaletteThemeDefaults.DarkOverallColor将返回Dark主题颜色,Autodesk.Windows.Palettes.PaletteThemeDefaults.LightOverallColor将返回浅色主题。感谢@nekitip,因为我使用了转换为C#的部分代码。
public class PaletteSetItem : PaletteSet
{
static PaletteSetItem instance = null;
static Guid guid = new Guid("{f9fead11-f73b-48b3-84c2-bd93b02df9bc}");
const string showCommand = "MyPalette";
private SolidColorBrush backgroundColor; //this is used to store the palette background color if needed
public static MyPalette MyPaletteCtrl { get; set; }
public PaletteSetItem()
: base(showCommand, showCommand, guid)
{
try
{
//Add the icon to the palette
base.Icon = MyIcon;
//Set the Palette size.
base.Size = new Size(400, 800);
//Changing background color based on System variable
//Following ideas here: https://www.theswamp.org/index.php?topic=47877.0
//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
backgroundColor = (SolidColorBrush)new BrushConverter().ConvertFrom(@"#808080");
}
}
}
当然,你可以设置它来绑定到 WPF 用户控件,但我选择不走这条路,因为我认为这更支持 WinForms 和 WPF。
希望这也有助于其他人。
我不知道这是否符合目标。
我不得不用lisp改变一堆调色板。以下是我的做法。
我最终找到了我想用它改变的东西。
(vlax-dump-object (vla-get-display (vla-get-preferences (vlax-get-Acad-object)))
然后我整理出我想要改变的颜色。
作为另一个侧面。
(vlax-dump-object (vla-get-preferences (vlax-get-Acad-object)) T)
将为您提供选项选项卡名称,以便向下钻取并找到所需的内容。
我最终得到了这个,因为我需要改变什么。
(setq acadobject (vlax-get-acad-object))
(setq acadpref (vlax-get-property acadobject 'preferences))
(setq acaddisp (vlax-get-property acadpref 'display))
(vlax-put-property acaddisp 'GraphicsWinmodelBackgrndColor 65986) ;;Model space background
(vlax-put-property acaddisp 'GraphicsWinLayoutBackgrndColor63434) ;;command area
(vlax-put-property acaddisp 'ModelCrosshairColor 865785);; crosshairs
(vlax-put-property acaddisp 'TextWinBackgrndColor 3687) ;;command area
页:
[1]