Hiii,In my code,I am able to access the layer and I want to change the layer color to the color which is being picked through the colorpicker.The default color in colorpicker is white.The problem is whenever i pick any of the color from colorpicker,the layer color always changes to white.
Also,when I select any color other than white,error is:System.drawing.color cannot be converted to int32.
Anyone,Please,solve my problem
Thanks in advance.
This is my code
protected void ColorPicker1_ColorPicked(object sender, System.Drawing.Color chosenColor)
{
IRgbColor rgbColor = new RgbColorClass();
rgbColor.Red = chosenColor.R;
rgbColor.Blue = chosenColor.B;
rgbColor.Green = chosenColor.G;
//rgbColor.RGB = ColorPicker1.ChosenColor.ToArgb();
//Response.Write(chosenColor.Name.ToString());
if (!MapResourceManager1.Initialized)
MapResourceManager1.Initialize();
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal mrl = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)MapResourceManager1.GetResource(0);
IMapServer ms = (IMapServer)mrl.ServerContextInfo.ServerContext.ServerObject;
IMapServerObjects2 mso = (IMapServerObjects2)ms;
IMap map = mso.get_Map(ms.DefaultMapName);
IFeatureLayer2 layer = (IFeatureLayer2)map.get_Layer(0);
IFeatureLayer layer1 = (IFeatureLayer)layer;
IGeoFeatureLayer glayer = (IGeoFeatureLayer)layer1;
ILineSymbol linesymbol = new SimpleLineSymbolClass();
linesymbol.Width = 1.0;
linesymbol.Color = (IColor)rgbColor;
ISimpleFillSymbol fillsymbol = new SimpleFillSymbolClass();
fillsymbol.Outline = linesymbol;
fillsymbol.Color = (IColor)rgbColor;
//Here is my error
//renderer.symbol threw an exception of type 'System.UnauthorizedException'
//Access is denied:(Exception from HRESULT:0x70080005(E_ACCESSDENIED))}
ISimpleRenderer renderer = (ISimpleRenderer)glayer.Renderer;
renderer.Symbol = (ISymbol)fillsymbol;
glayer.Renderer = (IFeatureRenderer)renderer;
mrl.RefreshServerObjects();
Map1.Refresh();
Toc1.Refresh();
}