本文主要针对新建图层中的透明度的设置,透明度的设置是需要将记录表添加到数据库后才能设置,否则会报错:eNoDataBase;透明度值的表示方式也存在差异,在record.Transparency = new Transparency(value)中,value的取值范围是0~255,0对应图层列表中的透明度值为100,255对应图层列表中的透明度值为0,因此,需要进行转换。
public static void AddLayer(string layername)
{
Database database = HostApplicationServices.WorkingDatabase;
using (Transaction tran = database.TransactionManager.StartTransaction())
{
LayerTable table = tran.GetObject(database.LayerTableId, OpenMode.ForWrite) as LayerTable;
if (!table.Has(layername))
{
LayerTableRecord record = new LayerTableRecord();
record.Name = layername;
record.Color = Color.FromColorIndex(ColorMethod.ByColor, colorindex);
record.Description = "";
record.