ArcEngine唯一值着色再开发!

  有些工作看似简单,其实真正做起来还是需要很花一些功夫的!别人开发了唯一值着色程序,本想拿来用无奈做的实在没有办法满足要求,所以只好自己开发。不多言,先上截图:

ArcEngine唯一值着色再开发!

  这里做了一个颜色显示控件ColorRampComboBox,主要可以返回色带的起始颜色FromColor和ToColor。还定义了一个事件和属性SelectedIndex;

ColorRampComboBox
 1 using System;

 2 using System.Drawing;

 3 using System.Windows.Forms;

 4 using System.Drawing.Drawing2D;

 5 

 6 namespace GeoLibert

 7 {

 8     public partial class ColorRampComboBox : UserControl

 9     {

10         public ColorRampComboBox()

11         {

12             InitializeComponent();

13             PersonalizeComponent();

14         }

15         private Color _FromColor;

16         private Color _ToColor;

17         public Color FromColor

18         {

19 

20             get { return _FromColor; }

21             set { _FromColor = value; }

22         }

23         public Color ToColor

24         {

25            get { return _ToColor; }

26 

27             set { _ToColor = value; }

28 

29         }

30         int selectIndex = -1;

31 

32         public int SelectedIndex

33         {

34             get { return selectIndex; }

35             set 

36             { 

37                 selectIndex = value;

38                 comboBox1.SelectedIndex = selectIndex;

39             }

40         }

41 

42         public event EventHandler SelectColorChanged;

43         //预定义的渐变色

44         private static string[] colorList =

45         {

46             "Black|White","White|Black","Red|Blue",

47             "Red|Green","Blue|Green",

48             "Aqua|Aquamarine","Azure|Beige",

49             "Bisque|Black","BlanchedAlmond|Blue","BlueViolet|Brown",

50             "BurlyWood|CadetBlue","Chartreuse|Chocolate",

51             "CornflowerBlue|Cornsilk","Crimson|Cyan","DarkBlue|DarkCyan",

52             "DarkGoldenrod|DarkGray","DarkGreen|DarkKhaki",

53             "DarkMagenta|DarkOliveGreen","DarkOrange|DarkOrchid"

54 

55         };

56         private void PersonalizeComponent()

57 

58         {

59             this.comboBox1.DrawMode = DrawMode.OwnerDrawFixed;

60             this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

61             this.comboBox1.ItemHeight = 18;

62             this.comboBox1.BeginUpdate();

63             this.comboBox1.Items.Clear();

64             foreach (string oneColor in colorList)

65             {

66                 this.comboBox1.Items.Add(oneColor);

67             }

68            this.comboBox1.EndUpdate();

69 

70         }

71         private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)

72         {

73             if (e.Index < 0)

74                 return;

75             Rectangle rect = e.Bounds;

76             //读取起始、终止颜色值

77             string fColorName = comboBox1.Items[e.Index].ToString().Split('|')[0];

78             string tColorName = comboBox1.Items[e.Index].ToString().Split('|')[1];

79             _FromColor = Color.FromName(fColorName);

80             _ToColor = Color.FromName(tColorName);

81             //选择线性渐变刷子

82             LinearGradientBrush brush = new LinearGradientBrush(rect, _FromColor, _ToColor, 0, false);

83             rect.Inflate(-1, -1);

84             // 填充颜色

85             e.Graphics.FillRectangle(brush, rect);

86             // 绘制边框

87             e.Graphics.DrawRectangle(Pens.Black, rect);

88         }

89         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

90         {

91             selectIndex = comboBox1.SelectedIndex;

92             if (SelectColorChanged != null)

93             {

94                 SelectColorChanged(this, e);

95             }

96         }

97 

98     }

99 }

  下面是部分唯一值着色程序代码,

  程序逻辑:选择图层,选择字段,选择色带,获取唯一值时根据字段和色带创建Bitmap,添加相应的ListView项;

       根据已有的字段(UniqueRenderer),改变色带是,修改其符号颜色。

View Code
  1 namespace GeoLibert

  2 {

  3     public partial class frmUniqueRenderer : Form

  4     {

  5         public frmUniqueRenderer()

  6         {

  7             InitializeComponent();

  8         }

  9         ISceneControl m_SceneCtrl = null;

 10         public ISceneControl SceneCtrl

 11         {

 12             get { return m_SceneCtrl; }

 13             set { m_SceneCtrl = value; }

 14         }

 15         IFeatureLayer pCurrentLyr = null;//当前图层

 16         IUniqueValueRenderer pUniqueValueR = null;

 17         IStyleGalleryClass pStyleGalleryClass = null;

 18         esriGeometryType m_strShapeType;//当前图层类型

 19         private void frmUniqueRenderer_Load(object sender, EventArgs e)

 20         {

 21             //加载图层

 22             if (m_SceneCtrl == null)

 23             {return;}

 24             ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();

 25             uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}";

 26             IScene map = m_SceneCtrl.Scene;

 27             if (map.LayerCount == 0) { return; }

 28             IEnumLayer enumLyr = map.get_Layers((ESRI.ArcGIS.esriSystem.UID)uid, true);

 29             enumLyr.Reset();

 30             ILayer layer = enumLyr.Next();

 31             while (layer != null)

 32             {

 33                 IFeatureLayer featlyr = layer as IFeatureLayer;

 34                 cmbChooseLayer.Items.Add(featlyr.Name);

 35                 layer = enumLyr.Next();

 36             }

 37             colorRampComboBox1.SelectedIndex = 0;//选择第一个色带

 38             cmbChooseLayer.SelectedIndex = 0;//默认选择第一个图层

 39             listView1.SmallImageList = imageList2;

 40             listView1.LargeImageList = imageList2;

 41             listView1.View = View.Details;

 42             //InitServerStyleFile(styleFilename);

 43             int columnWidth = listView1.Width / 4;

 44             listView1.Columns.Add("符号", columnWidth, HorizontalAlignment.Left);

 45             listView1.Columns.Add("字段值", columnWidth, HorizontalAlignment.Left);

 46             listView1.Columns.Add("标注", columnWidth, HorizontalAlignment.Left);

 47             

 48         }

 49         private void cmbChooseLayer_SelectedIndexChanged(object sender, EventArgs e)

 50         {

 51             pCurrentLyr = GetFeatureLayerFromMapLyr(cmbChooseLayer.SelectedIndex);

 52             m_strShapeType = pCurrentLyr.FeatureClass.ShapeType;//

 53             IFeatureClass featcls = pCurrentLyr.FeatureClass;

 54             IFields pFields = featcls.Fields;

 55             for (int i = 0; i < pFields.FieldCount;i++ )

 56             {

 57                 IField pfield=pFields.get_Field(i);

 58                 if (pfield.Type!=esriFieldType.esriFieldTypeGeometry)

 59                 {

 60                     combFields.Items.Add(pfield.Name);

 61                 }              

 62             }

 63             IGeoFeatureLayer pGeoFeatureLayer = pCurrentLyr as IGeoFeatureLayer;

 64             IFeatureRenderer  pFeatureRenderer = pGeoFeatureLayer.Renderer;          

 65             //判断当前图层类型,构建IStyleGalleryClass

 66             switch (featcls.ShapeType)

 67             {

 68                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:

 69                     pStyleGalleryClass = new MarkerSymbolStyleGalleryClassClass();

 70                     break;

 71                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:

 72                     pStyleGalleryClass = new LineSymbolStyleGalleryClassClass();

 73                     break;

 74                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:

 75                     pStyleGalleryClass = new FillSymbolStyleGalleryClassClass();

 76                     break;

 77                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch:

 78                     pStyleGalleryClass = new FillSymbolStyleGalleryClassClass();

 79                     break;

 80                 default:

 81                     break;

 82             }

 83             listView1.Items.Clear();

 84             imageList2.Images.Clear();

 85             if (pFeatureRenderer is ISimpleRenderer)

 86             {

 87                 ISimpleRenderer pSimpleRenderer = pFeatureRenderer as ISimpleRenderer;

 88                 ISymbol pSymbol = pSimpleRenderer.Symbol;

 89                 Bitmap bitmap = PreviewSymbol(pStyleGalleryClass, pSymbol, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

 90                 imageList2.Images.Add(bitmap as Image);

 91                 ListViewItem listviewitem1 = new ListViewItem(new string[] { " ", "默认值","默认值" }, 0);

 92                 listView1.Items.Add(listviewitem1);

 93             }

 94             else if (pFeatureRenderer is IUniqueValueRenderer)

 95             {

 96                 pUniqueValueR = new UniqueValueRendererClass();//构建新的唯一值着色类

 97                 IUniqueValueRenderer pUnique = pFeatureRenderer as IUniqueValueRenderer;

 98 

 99                 IObjectCopy objCopy = new ObjectCopyClass();

100                 object copiedUniqueVR = objCopy.Copy(pUnique);

101                 object toUniqueVR = pUniqueValueR;

102                 objCopy.Overwrite(copiedUniqueVR, ref toUniqueVR);

103                 ISymbol pSymbolDefault = pUniqueValueR.DefaultSymbol;

104                 if (pSymbolDefault!=null)

105                 {

106                     Bitmap bitmap = PreviewSymbol(pStyleGalleryClass, pSymbolDefault, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

107                     imageList2.Images.Add(bitmap as Image);

108                     ListViewItem listviewitem0 = new ListViewItem();

109                     listviewitem0.SubItems.Add("默认值");

110                     listviewitem0.SubItems.Add("默认值");

111                     listviewitem0.ImageIndex = 0;

112                     listView1.Items.Add(listviewitem0);

113                 }

114                 string strfield = pUniqueValueR.get_Field(0);

115                 IFeatureClass pCurrentFeatCls = pCurrentLyr.FeatureClass;

116                 int idx = -1;

117                 for (int i = 0; i < pFields.FieldCount; i++)

118                 {

119                     IField pfield = pFields.get_Field(i);

120                     if (pfield.Type != esriFieldType.esriFieldTypeGeometry)

121                     {

122                         idx++;

123                         if (pfield.Name==strfield)

124                         {

125                             combFields.SelectedIndex = idx;

126                         }                    

127                     }

128                 }

129                 if (idx!=-1)

130                 {

131                     isGetAllValue = true;

132                     recordNum = pUniqueValueR.ValueCount;

133                 }             

134                 for (int i = 0; i < pUniqueValueR.ValueCount; i++)

135                 {

136                     string strValue = pUniqueValueR.get_Value(i);

137                     ISymbol pSymbol1 = pUniqueValueR.get_Symbol(strValue);

138                     

139                     Bitmap bitmap1 = PreviewSymbol(pStyleGalleryClass, pSymbol1, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

140                     imageList2.Images.Add(bitmap1 as Image);

141                     ListViewItem listviewitem1 = new ListViewItem();

142                     listviewitem1.SubItems.Add(strValue);

143                     listviewitem1.SubItems.Add(strValue);

144                     listviewitem1.ImageIndex = i + 1;

145                     listView1.Items.Add(listviewitem1);

146                 }             

147 

148             }

149         }

150         Bitmap PreviewSymbol(IStyleGalleryClass pStyleGalleryClass, object galleryItem, int imgWidth, int imgHeight)

151         {

152             Bitmap bitmap = new Bitmap(imgWidth, imgHeight);

153             Graphics graphics = Graphics.FromImage(bitmap);

154             tagRECT rect = new tagRECT();

155             rect.right = bitmap.Width;

156             rect.bottom = bitmap.Height;

157             System.IntPtr hdc = graphics.GetHdc();

158 

159             pStyleGalleryClass.Preview(galleryItem, hdc.ToInt32(), ref rect);

160             graphics.ReleaseHdc(hdc);

161             graphics.Dispose();

162             return bitmap;

163         }

164         //从地图图层中获得特征类数据图层

165         private IFeatureLayer GetFeatureLayerFromMapLyr(int selectidx)

166         {

167             //AxSceneControl axScene= pMainFrm.axSceneControl1;

168             IFeatureLayer featlyr = null;

169 

170             ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();

171             uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}";

172             IScene scene = m_SceneCtrl.Scene;

173             IEnumLayer enumLyr = scene.get_Layers((ESRI.ArcGIS.esriSystem.UID)uid, true);

174             enumLyr.Reset();

175             ILayer layer = enumLyr.Next();

176             int i = 0;

177             while (layer != null)

178             {

179                 

180                 if (i == selectidx)

181                 {

182                     featlyr = layer as IFeatureLayer;

183                     break;

184                 }

185                 i++;

186                 layer = enumLyr.Next();

187             }

188             return featlyr;

189         }

190    

191         //书写颜色转换函数,从.NET颜色转换为esri的颜色

192         private IColor ConvertColorToColor(Color color)

193         {

194             IRgbColor pColor = new RgbColorClass();

195             pColor.RGB = color.B * 65536 + color.G * 256 + color.R;

196             return pColor;

197         }

198 

199         private void colorRampComboBox1_SelectColorChanged(object sender, EventArgs e)

200         {

201             

202             if (isGetAllValue && recordNum > 0)

203             {

204                 Color fromColor = colorRampComboBox1.FromColor;

205                 Color toColor = colorRampComboBox1.ToColor;

206                 IColorRamp pColorRamp = null;

207                 IAlgorithmicColorRamp pAlgorithmColorRamp = new AlgorithmicColorRamp();

208                 pAlgorithmColorRamp.ToColor = this.ConvertColorToColor(toColor);

209                 pAlgorithmColorRamp.FromColor = this.ConvertColorToColor(fromColor);

210                 //设置梯度类型

211                 pAlgorithmColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;

212                 //设置颜色带颜色数量

213                 //////任意产生recordNum个颜色,recordNum就是要素的数目

214                 pAlgorithmColorRamp.Size = recordNum+1;

215                 //创建颜色带

216                 bool bTrue = true;

217                 pAlgorithmColorRamp.CreateRamp(out bTrue);

218                 pColorRamp = pAlgorithmColorRamp as IColorRamp;

219 

220                 listView1.Items.Clear();

221                 imageList2.Images.Clear();

222                 ISymbol pSymbol0 = pUniqueValueR.DefaultSymbol;

223                 Bitmap bitmap0 = PreviewSymbol(pStyleGalleryClass, pSymbol0, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

224                 Image image0 = bitmap0;

225                 imageList2.Images.Add(image0);

226                 ListViewItem lv0 = new ListViewItem(new string[] { " ", "默认值", "默认值"}, 0);

227                 listView1.Items.Add(lv0);

228                 IEnumColors pEnumRamp = pColorRamp.Colors;

229                 for (int i = 0; i < pUniqueValueR.ValueCount; i++)

230                 {

231                     

232                     IColor pNextUniqueColor = null;

233                     //获得随机颜色带中的任意一种颜色

234                     pNextUniqueColor = pEnumRamp.Next();

235                     if (pNextUniqueColor == null)

236                     {

237                         pEnumRamp.Reset();

238                         pNextUniqueColor = pEnumRamp.Next();

239                     }

240                     ISymbol addSymbol = GetSymbolByShpType(m_strShapeType, pNextUniqueColor);

241                     string strValue = pUniqueValueR.get_Value(i);

242                     pUniqueValueR.set_Symbol(strValue, addSymbol);

243                     Bitmap bitmap = PreviewSymbol(pStyleGalleryClass, addSymbol, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

244                     Image image = bitmap;

245                     imageList2.Images.Add(image);

246                     listView1.SmallImageList = imageList2;

247                     ListViewItem lv = new ListViewItem(new string[] { " ", strValue, strValue}, i+1);

248                     listView1.Items.Add(lv);

249 

250                 }

251             }

252 

253         }

254         

255         private void btnOK_Click(object sender, EventArgs e)

256         {

257             IGeoFeatureLayer m_pGeoFeatureL = (IGeoFeatureLayer)pCurrentLyr;

258             m_pGeoFeatureL.Renderer = (IFeatureRenderer)pUniqueValueR;

259             m_SceneCtrl.SceneGraph.Invalidate(pCurrentLyr, true, false);

260             m_SceneCtrl.SceneViewer.Redraw(true);

261             m_SceneCtrl.SceneGraph.RefreshViewers();

262             this.DialogResult = DialogResult.OK;

263             

264         }

265         private void btnCancel_Click(object sender, EventArgs e)

266         {

267             this.DialogResult = DialogResult.Cancel;

268         }

269         bool isGetAllValue = false;

270         int recordNum = 0;//找出该图层的记录数

271         private void btnGetUniqueValue_Click(object sender, EventArgs e)

272         {

273             if (isGetAllValue == false)

274             {

275                 isGetAllValue = true;

276                 IGeoFeatureLayer m_pGeoFeatureL = (IGeoFeatureLayer)pCurrentLyr;

277                 

278                 string LayerFieldName = combFields.Text;

279                 pUniqueValueR = new UniqueValueRendererClass();

280                 IColor colr = GetRGB(238,223,155);

281                 pUniqueValueR.DefaultSymbol = GetSymbolByShpType(m_strShapeType, colr); 

282                 pUniqueValueR.UseDefaultSymbol = false;            

283                 ITable pTable = (ITable)m_pGeoFeatureL;

284                 ////////找出LayerFieldName在字段中的编号

285                 int lfieldNumber = pTable.FindField(combFields.Text);

286                 if (lfieldNumber == -1)

287                 {

288                     MessageBox.Show("无法找到字段" + LayerFieldName);

289                     return;

290                 }

291                 /////只用一个字段进行单值着色

292                 pUniqueValueR.FieldCount = 1;

293                 /////用于区分着色的字段

294                 pUniqueValueR.set_Field(0, LayerFieldName);

295                 //产生查询过滤器

296                 IQueryFilter pQueryFilter = new QueryFilterClass();

297                 pQueryFilter.AddField(LayerFieldName);

298                 ////依据某个字段在表中找出指向所有行的游标对象

299                 ICursor pNumCursor = pTable.Search(pQueryFilter, true);

300                   

301                 System.Collections.IEnumerator enumerator;

302                 IDataStatistics DS = new DataStatisticsClass();

303                 DS.Field = LayerFieldName;//设置唯一值字段

304                 DS.Cursor = pNumCursor;//数据来源

305                 enumerator = DS.UniqueValues;//得到唯一值

306                 recordNum = DS.UniqueValueCount;

307                 //ZS = Convert.ToString(DS.UniqueValueCount);

308                 enumerator.Reset();//从新指向第一个值

309 

310                 Color fromColor = colorRampComboBox1.FromColor;

311                 Color toColor = colorRampComboBox1.ToColor;

312                 IColorRamp pColorRamp = null;

313                 IAlgorithmicColorRamp pAlgorithmColorRamp = new AlgorithmicColorRamp();

314                 pAlgorithmColorRamp.ToColor = this.ConvertColorToColor(toColor);

315                 pAlgorithmColorRamp.FromColor = this.ConvertColorToColor(fromColor);

316                 //设置梯度类型

317                 pAlgorithmColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;

318                 //设置颜色带颜色数量

319                 //////任意产生recordNum个颜色,recordNum就是要素的数目

320                 pAlgorithmColorRamp.Size = recordNum+1;

321                 //创建颜色带

322                 bool bTrue = true;

323                 pAlgorithmColorRamp.CreateRamp(out bTrue);

324                 pColorRamp = pAlgorithmColorRamp as IColorRamp;

325                 IEnumColors pEnumRamp = pColorRamp.Colors;

326                 IColor pNextUniqueColor = null;

327 

328                 /////遍历所有的要素

329                while (enumerator.MoveNext())//pNextRow!=null

330                {

331                    object fieldValue;

332                    fieldValue = enumerator.Current;

333                    string codeValue = fieldValue.ToString();

334                    //获得随机颜色带中的任意一种颜色

335                    pNextUniqueColor = pEnumRamp.Next();

336                    if (pNextUniqueColor == null)

337                    {

338                        pEnumRamp.Reset();

339                        pNextUniqueColor = pEnumRamp.Next();

340                    }

341                    ISymbol addSymbol = GetSymbolByShpType(m_strShapeType, pNextUniqueColor);

342                    pUniqueValueR.AddValue(codeValue, LayerFieldName, addSymbol);

343                }

344                 listView1.Items.Clear();

345                 imageList2.Images.Clear();

346                 ISymbol pSymbol0 = pUniqueValueR.DefaultSymbol;

347                 Bitmap bitmap0 = PreviewSymbol(pStyleGalleryClass, pSymbol0, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

348                 Image image0 = bitmap0;

349                 imageList2.Images.Add(image0);

350                 ListViewItem lv0 = new ListViewItem(new string[] { " ", "默认值", "默认值" }, 0);

351                 listView1.Items.Add(lv0);

352                 for (int i = 0; i < pUniqueValueR.ValueCount; i++)

353                 {

354                     string strValue = pUniqueValueR.get_Value(i);

355                     ISymbol pSymbol = pUniqueValueR.get_Symbol(strValue);

356                     Bitmap bitmap = PreviewSymbol(pStyleGalleryClass, pSymbol, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

357                     Image image = bitmap;

358                     imageList2.Images.Add(image);

359                     listView1.SmallImageList = imageList2;

360                     ListViewItem lv = new ListViewItem(new string[] { " ", strValue, strValue}, i+1);

361                     listView1.Items.Add(lv);

362 

363                 }

364             }

365           

366         }

367         public ISymbol GetSymbolByShpType(esriGeometryType strShpType, IColor fillColor)

368         {

369             ISymbol returnSyb = null;

370             IFillSymbol pFillSymbol;

371             ILineSymbol pLineSymbol;

372             //设置背景符号

373             if (strShpType == esriGeometryType.esriGeometryPolygon)

374             {

375                 pFillSymbol = new SimpleFillSymbolClass();

376                 pFillSymbol.Color = fillColor;

377                 pLineSymbol = new SimpleLineSymbolClass();

378                 pLineSymbol.Color =ConvertColorToColor(Color.Black);

379                 pLineSymbol.Width = 1;//outLineWid;

380                 pFillSymbol.Outline = pLineSymbol;

381                 returnSyb = (ISymbol)pFillSymbol;

382             }

383             if (strShpType == esriGeometryType.esriGeometryPolyline)

384             {

385                 ILineSymbol pLineBaseSymbol;

386                 pLineBaseSymbol = new SimpleLineSymbolClass();

387                 pLineBaseSymbol.Color = fillColor;

388                 returnSyb = (ISymbol)pLineBaseSymbol;

389             }

390             if (strShpType == esriGeometryType.esriGeometryPoint)

391             {

392                 IMarkerSymbol pMarkerBaseSymbol;

393                 pMarkerBaseSymbol = new SimpleMarkerSymbolClass();

394                 pMarkerBaseSymbol.Color = fillColor;

395                 pMarkerBaseSymbol.Size = 4;

396                 returnSyb = (ISymbol)pMarkerBaseSymbol;

397             }

398             if (strShpType == esriGeometryType.esriGeometryMultiPatch)

399             {

400                 pFillSymbol = new SimpleFillSymbolClass();

401                 pFillSymbol.Color = fillColor;

402                 pLineSymbol = new SimpleLineSymbolClass();

403                 pLineSymbol.Color = ConvertColorToColor(Color.Black);

404                 pLineSymbol.Width = 1;//outLineWid;

405                 pFillSymbol.Outline = pLineSymbol;

406                 returnSyb = (ISymbol)pFillSymbol;

407             }

408             return returnSyb;

409         }

410 

411         private IColor GetRGB(int r, int g, int b)

412         {

413             IRgbColor pColor;

414             pColor = new RgbColorClass();

415             pColor.Red = r;

416             pColor.Green = g;

417             pColor.Blue = b;

418             return pColor;

419         }

420 

421         private void btnRemoveAllValue_Click(object sender, EventArgs e)

422         {

423             pUniqueValueR.RemoveAllValues();

424             isGetAllValue = false;

425             listView1.Items.Clear();

426             imageList2.Images.Clear();

427             ISymbol pSymbol0 = pUniqueValueR.DefaultSymbol;

428             Bitmap bitmap0 = PreviewSymbol(pStyleGalleryClass, pSymbol0, imageList2.ImageSize.Width, imageList2.ImageSize.Height);

429             Image image0 = bitmap0;

430             imageList2.Images.Add(image0);

431             ListViewItem lv0 = new ListViewItem(new string[] { " ", "默认值", "默认值" }, 0);

432             listView1.Items.Add(lv0);

433         }

434 

435         private void combFields_SelectedIndexChanged(object sender, EventArgs e)

436         {

437             isGetAllValue = false;

438         }

439     }

440  

441 }

  该程序还没有实现双击改变某一个符号的功能,不过应该不难,只需要修改pUniqueRenderer,Set_Symbol(I)就行了!

参考文献:1.自定义ComboBox显示色带:http://blog.sina.com.cn/s/blog_86d10dc7010166i7.html

你可能感兴趣的:(ArcEngine)