.NET 的System.Drawing.Color
转为 ArcEngine 的IColor
// 方法1
public IColor ConvertColorFromNETtoArc(System.Drawing.Color netColor)
{
IColor arcColor = new RgbColorClass();
arcColor.RGB = netColor.B * 65536 + netColor.G * 256 + netColor.R;
return arcColor;
}
// 方法2
IColor arcColor = new RgbColorClass();
arcColor.RGB = ColorTranslator.ToOle(System.Drawing.Color.RoyalBlue);
// 方法3
IColor arcColor = ESRI.ArcGIS.ADF.Converter.ToRGBColor(colorDialog.Color);
ArcEngine 的IColor
转为 .NET 的System.Drawing.Color
// 方法1
System.Drawing.Color netColor = ColorTranslator.FromOle(arcColor)
// 方法2
System.Drawing.Color netColor = ESRI.ArcGIS.ADF.Converter.FromRGBColor(arcColor)
举例 "从 .NET 调色板取色,转为 ArcEngine 的 IColor "
ColorDialog colorDialog = new ColorDialog();
colorDialog.AllowFullOpen = true;
colorDialog.FullOpen = true;
colorDialog.ShowHelp = true;
colorDialog.Color = System.Drawing.Color.DarkBlue;
IColor arcColor;
if(colorDialog.ShowDialog()!=DialogResult.Cancel)
{
arcColor = ESRI.ArcGIS.ADF.Converter.ToRGBColor(colorDialog.Color);
}