我正在尝试为我正在编写的记事本 ++ 插件设置 Markerbackgrounds,以便可以突出显示某些行。颜色存储为从 Color.ToArgb() 转换的整数:
int colour = Convert.ToInt32(Color.LightSkyBlue.ToArgb())
根据我对 Scintillia 文档的了解,它只接受 RGB 颜色,因此我使用以下函数去除颜色的 Alpha 部分。这确实设置了一种颜色,但不是蓝色,而是橙色而不是蓝色。这是设置标记背景颜色的正确方法吗?
private static void DefineColor(int type, int colour)
{
string hexValue = colour.ToString("X");
hexValue = hexValue.Remove(0, 2);
//hexValue = "0x" + hexValue
int decValue = Convert.ToInt32(ColorTranslator.FromHtml(hexValue));
//int decValue = int.Parse("FF", System.Globalization.NumberStyles.AllowHexSpecifier);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERDEFINE, type, (int)SciMsg.SC_MARK_BACKGROUND);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETBACK, type, decValue);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETFORE, type, 0);
}