【035】自建符号Symbol选择对话框

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

【035】自建符号Symbol选择对话框第一步:建立独立的Windows窗体:命名为:SymbologyFrmLee1.运行效果如下所示:2.全局参数:esriSymbologyStyleClasspStyleClass;//获取显示的为点类、线类还是填充类等的,赋值给symbologyControl控件,然后就显示这一类符号publicIStyleGalleryItempStyleGalleryItem;//获取选择的项ILegendClasspLegendClass;//获取传递进来的图例ILayerpLayer;boolcontextMenuMoreSymbolInitiated=false;//判断右键菜单是否已经初始化了3.给窗体添加参数:publicSymbologyFrmLee(ILegendClasstempLegendClass,ILayertempLayer){InitializeComponent();pLegendClass=tempLegendClass;//通过点击toccontrol时候可以获得要素类的LegendClass!pLayer=tempLayer;//点击的图层}4.窗体加载事件:privatevoidSymbologyFrm_Load(objectsender,EventArgse){switch(((IFeatureLayer)pLayer).FeatureClass.ShapeType)//判断图层中要素类的图形类型,不同类型显示的调节值的控件不同{caseesriGeometryType.esriGeometryPoint://点pStyleClass=esriSymbologyStyleClass.esriStyleClassMarkerSymbols;lbColor.Visible=true;lbWidth.Visible=true;lbWidth.Text=符号大小;lbAngle.Visible=true;btColor.Visible=true;nudWidth.Visible=true;cbColor.Visible=true;nudAngle.Visible=true;break;caseesriGeometryType.esriGeometryPolyline://线pStyleClass=esriSymbologyStyleClass.esriStyleClassLineSymbols;lbColor.Visible=true;lbColor.Location=System.Drawing.Point.Add(lbColor.Location,newSize(0,12));lbWidth.Visible=true;lbWidth.Location=System.Drawing.Point.Add(lbWidth.Location,newSize(0,24));lbWidth.Text=线符号粗细;btColor.Visible=true;cbColor.Visible=true;btColor.Location=System.Drawing.Point.Add(btColor.Location,newSize(0,12));cbColor.Location=System.Drawing.Point.Add(cbColor.Location,newSize(0,12));nudWidth.Visible=true;nudWidth.Location=System.Drawing.Point.Add(nudWidth.Location,newSize(0,24));break;caseesriGeometryType.esriGeometryPolygon://面pStyleClass=esriSymbologyStyleClass.esriStyleClassFillSymbols;lbColor.Visible=true;lbWidth.Visible=true;lbWidth.Text=框线宽度;lbOutlineColor.Visible=true;btColor.Visible=true;btOutlineColor.Visible=true;nudWidth.Visible=true;cbColor.Visible=true;cbOutlineColor.Visible=true;break;default:this.Close();break;}stringstrInstall=@C:\ProgramFiles(x86)\ArcGIS;//安装目录,10中可以用函数获得RuntimeManager可以获取!//ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path可以获得Engine的安装目录stringstylePath=strInstall+@\Styles\ESRI.ServerStyle;//获取ESRI.ServerStyle文件axSymbologyControl1.LoadStyleFile(stylePath);//加载此文件axSymbologyControl1.StyleClass=pStyleClass;//将上面获得的pStyleClass赋值过去,显示点、线还是面,由此决定!IStyleGalleryItempCurrentStyleGalleryItem=newStyleGalleryItem();//新建当前符号的实例pCurrentStyleGalleryItem.Name=当前符号;pCurrentStyleGalleryItem.Item=pLegendClass.Symbol;//将当前的图例symbol赋值过去ISymbologyStyleClasspSymbologyStyleClass=axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);//QI,加入这个新建项pSymbologyStyleClass.AddItem(pCurrentStyleGalleryItem,0);pSymbologyStyleClass.SelectItem(0);//同时选中}5.选择项的时候触发:privatevoidaxSymbologyControl1_OnItemSelected(objectsender,ISymbologyControlEvents_OnItemSelectedEvente){pStyleGalleryItem=e.styleGalleryItemasIStyleGalleryItem;//获取选择项PreviewPicture();//在图片框中显示if(((IFeatureLayer)pLayer).FeatureClass.ShapeType==esriGeometryType.esriGeometryPoint)//点,将属性传递到调节的控件上{IRgbColorpColor=((IMarkerSymbol)pStyleGalleryItem.Item).ColorasIRgbColor;btColor.BackColor=Color.FromArgb(pColor.Red,pColor.Green,pColor.Blue);//赋值颜色nudAngle.Value=Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).Angle);//赋值角度nudWidth.Value=Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).Size);//赋值大小}if(((IFeatureLayer)pLayer).FeatureClass.ShapeType==esriGeometryType.esriGeometryPolyline)//线{IRgbColorpColor=((ILineSymbol)pStyleGalleryItem.Item).ColorasIRgbColor;btColor.BackColor=Color.FromArgb(pColor.Red,pColor.Green,pColor.Blue);//赋值线的颜色nudWidth.Value=Convert.ToDecimal(((ILineSymbol)pStyleGalleryItem.Item).Width);//赋值线的宽度}if(((IFeatureLayer)pLayer).FeatureClass.ShapeType==esriGeometryType.esriGeometryPolygon)//面{IRgbColorpColor=((IFillSymbol)pStyleGalleryItem.Item).ColorasIRgbColor;btColor.BackColor=Color.FromArgb(pColor.Red,pColor.Green,pColor.Blue);//赋值填充的颜色nudWidth.Value=Convert.ToDecimal(((IFillSymbol)pStyleGalleryItem.Item).Outline.Width);//赋值边框宽度pColor=((IFillSymbol)pStyleGalleryItem.Item).Outline.ColorasIRgbColor;btOutlineColor.BackColor=Color.FromArgb(pColor.Red,pColor.Green,pColor.Blue);//赋值边框颜色}}6.将pStyleGalleryItem反映到picture上的方法:privatevoidPreviewPicture(){ISymbologyStyleClasspSymbologyStyle=axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);//因为其有方法PreviewStylestdole.IPictureDisppicture=pSymbologyStyle.PreviewItem(pStyleGalleryItem,pictureBox1.Width,pictureBox1.Height);//建立实例Imageimage=Image.FromHbitmap(newIntPtr(picture.Handle));//转成C#支持的Image实例pictureBox1.Image=image;//赋值过去}▲将控件的操作操作反映到picture上:7.点、线、面填充颜色传递:IRgbColorpColor=newRgbColor();//颜色实例pColor.RGB=255;tagRECTpTag=newtagRECT();//用于下面显示ColorPalette的位置pTag.left=btColor.PointToScreen(System.Drawing.Point.Empty).X;//按钮控件的左边全局横坐标pTag.bottom=btColor.PointToScreen(System.Drawing.Point.Empty).Y+btColor.Height;//按钮控件的下边全局纵坐标IColorPalettepColorPalette=newColorPalette();pColorPalette.TrackPopupMenu(refpTag,pColor,false,0);//显示ColorPalettepColor=pColorPalette.ColorasIRgbColor;//获取选中的颜色Colorcolor=Color.FromArgb(pColor.Red

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功