问题是用代码设定图层的风格后,打开工作空间,图层并没有相应的风格,资源库中存在,图层已选定所需的风格,但是风格没有刷新。需要手动打开填充符号编辑器,选中一次填充符号,点击确定,再点击填充符号选择器的应用,图层风格才真正刷新。是否我的代码缺少一步刷新的操作?
代码大致是这个样子,有些获取数据库图层的地方省略了。
SymbolFill symbolFill = new SymbolFill();
SymbolFillBase symbolFillBase = new SymbolFillBase();
SymbolFillMarker pSimpleSymbolFillMarker = new SymbolFillMarker();
double angle = (45 * (Math.PI)) / 180;
double halfWidthOrHeight = 50 * Math.Tan(angle);
point2Ds.Add(new Point2D(0, 50 - halfWidthOrHeight));
point2Ds.Add(new Point2D(100, 50 + halfWidthOrHeight));
double Width = 10;
double Height = 10 * Math.Tan(angle);
GeoLine geoLine = new GeoLine(point2Ds);
SymbolMarker marker = new SymbolMarker();
marker.FromGeometry(geoLine, new Rectangle2D(new Point2D(0, 0), new Point2D(100, 100)));
marker.Origin = new Point(50, 50);
SymbolMarkerStroke symbolMarkerStroke = marker[0];
symbolMarkerStroke.LineWidth = 1;
marker.Size = 100;
string guid_8 = Guid.NewGuid().ToString().Replace("-", "").Remove(8);
marker.Name = guid_8 + "esri";
int SymbolFillMarkerID = supermapResource.MarkerLibrary.Add(marker);
pSimpleSymbolFillMarker.MarkerID = SymbolFillMarkerID;
pSimpleSymbolFillMarker.MarkerSize = 100;
pSimpleSymbolFillMarker.MarkerPoints = new Point[1] { new Point() { X = Convert.ToInt32(Width * 0.5), Y = Convert.ToInt32(Height * 0.5) } };
pSimpleSymbolFillMarker.Width = Convert.ToInt32(Width);
pSimpleSymbolFillMarker.Height = Convert.ToInt32(Height);
symbolFillBase.SetFillMarker(pSimpleSymbolFillMarker);
symbolFillBase.ForeColor = ConvertColor.ConvertWJColorToSystemColor(pWJLineFillSymbol.Color);
symbolFill.Add(symbolFillBase);
int id = supermapResource.FillLibrary.Add(symbolFill);
supermapGeoStyle.FillBackOpaque = false;
supermapGeoStyle.FillSymbolID = id;
supermapGeoStyle.LineSymbolID = 0;
supermapLayersettingVector.Style = supermapGeoStyle;
map.Layers.Add(pDatasetVector, supermapLayersettingVector, false);
工作空间第一次打开后:第一个是点符号正常,第二个是渐变填充符号正常,后面三个都不正常显示。