【035】自建符号Symbol选择对话框
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{ IRgbColor pColor =
((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor;
btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值颜色
pictureBox1.Image = image; //赋值过去 }
▲ 将控件的操作操作反映到 picture 上:
7. 点、线、面填充颜色传递:
IRgbColor pColor = new RgbColor(); //颜色实例 pColor.RGB = 255; tagRECT pTag = new tagRECT(); //用于下面显示 ColorPalette 的位置 pTag.left = btColor.PointToScreen(System.Drawing.Point.Empty).X; 按钮控件的左边全局横坐标 pTag.bottom = btColor.PointToScreen(System.Drawing.Point.Empty).Y + btColor.Height; //按钮控件的下边全局纵坐标 IColorPalette pColorPalette = new ColorPalette(); pColorPalette.TrackPopupMenu(ref pTag, pColor, false, 0); //显示 ColorPalette pColor = pColorPalette.Color as IRgbColor; //获取选中的颜色
4. 窗ቤተ መጻሕፍቲ ባይዱ加载事件:
private void SymbologyFrm_Load(object sender, EventArgs e) {
switch(((IFeatureLayer)pLayer).FeatureClass.ShapeType) // 判断图层中要素类的图形类型,不同类型显示的调节值的控件不同
axSymbologyControl1.LoadStyleFile(stylePath); //加 载此文件
axSymbologyControl1.StyleClass = pStyleClass; //将上面获得的 pStyleClass 赋值过去,显示 点、线还是面,由此决定!
IStyleGalleryItem pCurrentStyleGalleryItem = new StyleGalleryItem(); //新建当前符号的实例
stdole.IPictureDisp picture = pSymbologyStyle.PreviewItem(pStyleGalleryItem, pictureBox1.Width, pictureBox1.Height); //建立实例
Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); //转成 C# 支持的 Image 实例
} }
6. 将 pStyleGalleryItem 反映到 picture 上的方法:
private void PreviewPicture() {
ISymbologyStyleClass pSymbologyStyle = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleCl 因为其有方法 PreviewStyle
3. 给窗体添加参数:
public SymbologyFrmLee(ILegendClass tempLegendClass, ILayer tempLayer) {
InitializeComponent(); pLegendClass = tempLegendClass; //通过点击 toccontrol 时候可以获得要素类的 LegendClass! pLayer = tempLayer; //点击的图层 }
pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //获取选择项
PreviewPicture(); //在图片框中显示
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) //点,将属性传递 到调节的控件上
Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值填充的颜色
nudWidth.Value = Convert.ToDecimal(((IFillSymbol)pStyleGalleryItem.Item).Outli 赋值边框宽度
pSymbologyStyleClass.AddItem(pCurrentStyleGalleryItem, 0);
pSymbologyStyleClass.SelectItem(0); //同时 选中 }
5. 选择项的时候触发:
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) {
btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值线的颜色
nudWidth.Value = Convert.ToDecimal(((ILineSymbol)pStyleGalleryItem.Item).Width 赋值线的宽度
pCurrentStyleGalleryItem.Name = "当前符号"; pCurrentStyleGalleryItem.Item = pLegendClass.Symbol; //将当前的图例 symbol 赋值过去 ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleCl 加入这个新建项
nudAngle.Value = Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).An 赋值角度
nudWidth.Value = Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).Si 赋值大小
【035】自建符号Symbol选择对话框
第一步:建立独立的 Windows 窗体: 命名为:SymbologyFrmLee
1. 运行效果如下所示:
2. 全局参数: esriSymbologyStyleClass pStyleClass; //获取显示的为 点类、线类还是填充类等的,赋值给 symbologyControl 控件,然 后就显示这一类符号 public IStyleGalleryItem pStyleGalleryItem; //获取 选择的项 ILegendClass pLegendClass; //获取传递进来的图例 ILayer pLayer; bool contextMenuMoreSymbolInitiated = false; //判断右键菜 单是否已经初始化了
pColor = ((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor;
btOutlineColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值边框颜色
}
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) //线
{ IRgbColor pColor =
((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor;
{ case
esriGeometryType.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; case esriGeometryType.esriGeometryPolyline: //线 pStyleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols; lbColor.Visible = true; lbColor.Location = System.Drawing.Point.Add(lbColor.Location, new Size(0, 12)); lbWidth.Visible = true; lbWidth.Location = System.Drawing.Point.Add(lbWidth.Location, new Size(0, 24)); lbWidth.Text = "线符号粗细"; btColor.Visible = true; cbColor.Visible = true; btColor.Location = System.Drawing.Point.Add(btColor.Location, new Size(0, 12)); cbColor.Location = System.Drawing.Point.Add(cbColor.Location, new Size(0, 12)); nudWidth.Visible = true; nudWidth.Location = System.Drawing.Point.Add(nudWidth.Location, new Size(0, 24)); break; case esriGeometryType.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; } string strInstall = @"C:\Program Files (x86)\ArcGIS"; //安装目录,10中可以用函数获得 RuntimeManager 可以获取! //ESRI.ArcGIS. 可以获得 Engine 的安装目录 string stylePath = strInstall + @"\Styles\ESRI.ServerStyle"; //获取 ESRI.ServerStyle 文件
}
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) //面
{ IRgbColor pColor =
((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor; btColor.BackColor =
((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor;
btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值颜色
pictureBox1.Image = image; //赋值过去 }
▲ 将控件的操作操作反映到 picture 上:
7. 点、线、面填充颜色传递:
IRgbColor pColor = new RgbColor(); //颜色实例 pColor.RGB = 255; tagRECT pTag = new tagRECT(); //用于下面显示 ColorPalette 的位置 pTag.left = btColor.PointToScreen(System.Drawing.Point.Empty).X; 按钮控件的左边全局横坐标 pTag.bottom = btColor.PointToScreen(System.Drawing.Point.Empty).Y + btColor.Height; //按钮控件的下边全局纵坐标 IColorPalette pColorPalette = new ColorPalette(); pColorPalette.TrackPopupMenu(ref pTag, pColor, false, 0); //显示 ColorPalette pColor = pColorPalette.Color as IRgbColor; //获取选中的颜色
4. 窗ቤተ መጻሕፍቲ ባይዱ加载事件:
private void SymbologyFrm_Load(object sender, EventArgs e) {
switch(((IFeatureLayer)pLayer).FeatureClass.ShapeType) // 判断图层中要素类的图形类型,不同类型显示的调节值的控件不同
axSymbologyControl1.LoadStyleFile(stylePath); //加 载此文件
axSymbologyControl1.StyleClass = pStyleClass; //将上面获得的 pStyleClass 赋值过去,显示 点、线还是面,由此决定!
IStyleGalleryItem pCurrentStyleGalleryItem = new StyleGalleryItem(); //新建当前符号的实例
stdole.IPictureDisp picture = pSymbologyStyle.PreviewItem(pStyleGalleryItem, pictureBox1.Width, pictureBox1.Height); //建立实例
Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); //转成 C# 支持的 Image 实例
} }
6. 将 pStyleGalleryItem 反映到 picture 上的方法:
private void PreviewPicture() {
ISymbologyStyleClass pSymbologyStyle = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleCl 因为其有方法 PreviewStyle
3. 给窗体添加参数:
public SymbologyFrmLee(ILegendClass tempLegendClass, ILayer tempLayer) {
InitializeComponent(); pLegendClass = tempLegendClass; //通过点击 toccontrol 时候可以获得要素类的 LegendClass! pLayer = tempLayer; //点击的图层 }
pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //获取选择项
PreviewPicture(); //在图片框中显示
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) //点,将属性传递 到调节的控件上
Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值填充的颜色
nudWidth.Value = Convert.ToDecimal(((IFillSymbol)pStyleGalleryItem.Item).Outli 赋值边框宽度
pSymbologyStyleClass.AddItem(pCurrentStyleGalleryItem, 0);
pSymbologyStyleClass.SelectItem(0); //同时 选中 }
5. 选择项的时候触发:
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) {
btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值线的颜色
nudWidth.Value = Convert.ToDecimal(((ILineSymbol)pStyleGalleryItem.Item).Width 赋值线的宽度
pCurrentStyleGalleryItem.Name = "当前符号"; pCurrentStyleGalleryItem.Item = pLegendClass.Symbol; //将当前的图例 symbol 赋值过去 ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleCl 加入这个新建项
nudAngle.Value = Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).An 赋值角度
nudWidth.Value = Convert.ToDecimal(((IMarkerSymbol)pStyleGalleryItem.Item).Si 赋值大小
【035】自建符号Symbol选择对话框
第一步:建立独立的 Windows 窗体: 命名为:SymbologyFrmLee
1. 运行效果如下所示:
2. 全局参数: esriSymbologyStyleClass pStyleClass; //获取显示的为 点类、线类还是填充类等的,赋值给 symbologyControl 控件,然 后就显示这一类符号 public IStyleGalleryItem pStyleGalleryItem; //获取 选择的项 ILegendClass pLegendClass; //获取传递进来的图例 ILayer pLayer; bool contextMenuMoreSymbolInitiated = false; //判断右键菜 单是否已经初始化了
pColor = ((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor;
btOutlineColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //赋值边框颜色
}
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) //线
{ IRgbColor pColor =
((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor;
{ case
esriGeometryType.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; case esriGeometryType.esriGeometryPolyline: //线 pStyleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols; lbColor.Visible = true; lbColor.Location = System.Drawing.Point.Add(lbColor.Location, new Size(0, 12)); lbWidth.Visible = true; lbWidth.Location = System.Drawing.Point.Add(lbWidth.Location, new Size(0, 24)); lbWidth.Text = "线符号粗细"; btColor.Visible = true; cbColor.Visible = true; btColor.Location = System.Drawing.Point.Add(btColor.Location, new Size(0, 12)); cbColor.Location = System.Drawing.Point.Add(cbColor.Location, new Size(0, 12)); nudWidth.Visible = true; nudWidth.Location = System.Drawing.Point.Add(nudWidth.Location, new Size(0, 24)); break; case esriGeometryType.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; } string strInstall = @"C:\Program Files (x86)\ArcGIS"; //安装目录,10中可以用函数获得 RuntimeManager 可以获取! //ESRI.ArcGIS. 可以获得 Engine 的安装目录 string stylePath = strInstall + @"\Styles\ESRI.ServerStyle"; //获取 ESRI.ServerStyle 文件
}
if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) //面
{ IRgbColor pColor =
((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor; btColor.BackColor =