Kimberly,
You can implement this by creating your own AreaStyle. Here I generate a shape file with 4 columns (“A”, “R”, “G”, “B”) and render it based on those columns. Please have a look.
// The AreaStyle I recreated for render
class ARGBAreaStyle : AreaStyle
{
protected override void DrawCore(System.Collections.Generic.IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
{
foreach (Feature feature in features)
{
int a = int.Parse(feature.ColumnValues["A"]);
int r = int.Parse(feature.ColumnValues["R"]);
int g = int.Parse(feature.ColumnValues["G"]);
int b = int.Parse(feature.ColumnValues["B"]);
canvas.DrawArea(feature, this.OutlinePen, new GeoSolidBrush(GeoColor.FromArgb(a, r, g, b)), DrawingLevel.LevelOne, this.XOffsetInPixel, this.YOffsetInPixel, this.PenBrushDrawingOrder);
}
}
}
// Here is how to use the style
ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer("c:\testShp.shp");
ARGBAreaStyle argbAreaStyle = new ARGBAreaStyle();
argbAreaStyle.RequiredColumnNames.Add("A");
argbAreaStyle.RequiredColumnNames.Add("R");
argbAreaStyle.RequiredColumnNames.Add("G");
argbAreaStyle.RequiredColumnNames.Add("B");
layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(argbAreaStyle);
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Here is how I generate the test data
private static void CreateShapeFile(string filePath)
{
List<DbfColumn> dbfColumns = new List<DbfColumn>();
dbfColumns.Add(new DbfColumn("A", DbfColumnType.String, 10, 0));
dbfColumns.Add(new DbfColumn("R", DbfColumnType.String, 10, 0));
dbfColumns.Add(new DbfColumn("G", DbfColumnType.String, 10, 0));
dbfColumns.Add(new DbfColumn("B", DbfColumnType.String, 10, 0));
ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, filePath, dbfColumns);
Dictionary<string, string> columns1 = new Dictionary<string, string>();
columns1.Add("A", "128");
columns1.Add("R", "255");
columns1.Add("G", "0");
columns1.Add("B", "128");
Feature feature1 = new Feature(new PolygonShape("Polygon((0 0,10 0,10 10,0 10,0 0))"), columns1);
Dictionary<string, string> columns2 = new Dictionary<string, string>();
columns2.Add("A", "128");
columns2.Add("R", "0");
columns2.Add("G", "255");
columns2.Add("B", "255");
Feature feature2 = new Feature(new PolygonShape("Polygon((0 0,5 0,5 5,0 5,0 0))"), columns2);
ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(filePath, ShapeFileReadWriteMode.ReadWrite);
layer.FeatureSource.Open();
layer.FeatureSource.BeginTransaction();
layer.FeatureSource.AddFeature(feature1);
layer.FeatureSource.AddFeature(feature2);
layer.FeatureSource.CommitTransaction();
layer.FeatureSource.Close();
}
Thanks,
Ben