/// <summary> /// 初始化SymbologyControl的StyleClass,图层如果已有符号,则把符号添加到SymbologyControl中的第一个符号,并选中 /// </summary> /// <param name="symbologyStyleClass"></param> private void SetFeatureClassStyle(esriSymbologyStyleClass symbologyStyleClass) { this.axSymbologyControl.StyleClass = symbologyStyleClass; ISymbologyStyleClass pSymbologyStyleClass = this.axSymbologyControl.GetStyleClass(symbologyStyleClass); if (this.pLegendClass != null) { IStyleGalleryItem currentStyleGalleryItem = new ServerStyleGalleryItem(); currentStyleGalleryItem.Name = "当前符号"; currentStyleGalleryItem.Item = pLegendClass.Symbol; pSymbologyStyleClass.AddItem(currentStyleGalleryItem, 0); this.pStyleGalleryItem = currentStyleGalleryItem; } pSymbologyStyleClass.SelectItem(0); }
private void PreviewImage(IStyleGalleryItem item) { ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); if (symbologyStyleClass.StyleClass == esriSymbologyStyleClass.esriStyleClassScaleBars) { stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(item, pictureBox1.Width * 2, pictureBox1.Height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); pictureBox1.Image = image; } else { stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(item, pictureBox1.Width, pictureBox1.Height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); pictureBox1.Image = image; } }
/// <summary> /// Gets the item. /// </summary> /// <param name="styleClass">The style class.</param> /// <param name="styleItem">The style item.</param> /// <returns>IStyleGalleryItem.</returns> public IStyleGalleryItem GetItem(esriSymbologyStyleClass styleClass, object styleItem) { this._styleGalleryItem = null; this.axSymbologyControl1.StyleClass = styleClass; ISymbologyStyleClass styleClass2 = this.axSymbologyControl1.GetStyleClass(styleClass); if (styleItem != null) { this._styleGalleryItem = new ServerStyleGalleryItemClass(); this._styleGalleryItem.Item = styleItem; this._styleGalleryItem.Name = frmSymbolSelector.MSG01; styleClass2.AddItem(this._styleGalleryItem, 0); styleClass2.SelectItem(0); } base.ShowDialog(); return(this._styleGalleryItem); }
//预览 private void PreviewImage() { try { //Get and set the style class ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass); //Preview an image of the symbol stdole.IPictureDisp pPicpture = symbologyStyleClass.PreviewItem(StyleGalleryItem, ImagePreview.Width, ImagePreview.Height); System.Drawing.Image pImage = System.Drawing.Image.FromHbitmap(new System.IntPtr(pPicpture.Handle)); ImagePreview.Image = pImage; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void SetFeatureClassStyle(esriSymbologyStyleClass symbologyStyleClass) { this.axSymbologyControl1.StyleClass = symbologyStyleClass; ISymbologyStyleClass pSymbologyStyleClass = this.axSymbologyControl1. GetStyleClass(symbologyStyleClass); if (this.pLegendClass != null) { IStyleGalleryItem currentStyleGalleryItem = new ServerStyleGalleryItem(); currentStyleGalleryItem.Name = "当前符号"; currentStyleGalleryItem.Item = pLegendClass.Symbol; pSymbologyStyleClass.AddItem(currentStyleGalleryItem, 0); this.pStyleGalleryItem = currentStyleGalleryItem; } pSymbologyStyleClass.SelectItem(0); }
private void axSymbologyControl_OnStyleClassChanged(object sender, ISymbologyControlEvents_OnStyleClassChangedEvent e) { object obj = e.symbologyStyleClass; ISymbologyStyleClass ssc = obj as ISymbologyStyleClass; esriSymbologyStyleClass ess = ssc.StyleClass; //switch ((esriSymbologyStyleClass)(e.symbologyStyleClass)) switch (ess) { case esriSymbologyStyleClass.esriStyleClassMarkerSymbols: this.lblAngle.Visible = true; this.nudAngle.Visible = true; this.lblSize.Visible = true; this.nudSize.Visible = true; this.lblWidth.Visible = false; this.nudWidth.Visible = false; this.lblOutlineColor.Visible = false; this.btnOutlineColor.Visible = false; break; case esriSymbologyStyleClass.esriStyleClassLineSymbols: this.lblAngle.Visible = false; this.nudAngle.Visible = false; this.lblSize.Visible = false; this.nudSize.Visible = false; this.lblWidth.Visible = true; this.nudWidth.Visible = true; this.lblOutlineColor.Visible = false; this.btnOutlineColor.Visible = false; break; case esriSymbologyStyleClass.esriStyleClassFillSymbols: this.lblAngle.Visible = false; this.nudAngle.Visible = false; this.lblSize.Visible = false; this.nudSize.Visible = false; this.lblWidth.Visible = true; this.nudWidth.Visible = true; this.lblOutlineColor.Visible = true; this.btnOutlineColor.Visible = true; break; } }
//添加GLISTBOX项 private void addListBoxItem(ISymbol symbol) { IStyleGallery styleGallery; IStyleGalleryItem styleGalleryItem; IStyleGalleryStorage styleGalleryStorge; styleGalleryItem = new ServerStyleGalleryItemClass(); styleGalleryItem.Name = this.txtSymbolName.Text; styleGalleryItem.Category = "default"; object objSymbol = symbol; styleGalleryItem.Item = objSymbol; styleGallery = new ServerStyleGalleryClass(); styleGalleryStorge = styleGallery as IStyleGalleryStorage; styleGalleryStorge.TargetFile = fileName; ISymbologyStyleClass pSymbolClass = psymbologyStyleClass; pSymbolClass.AddItem(styleGalleryItem, 0); pSymbolClass.SelectItem(0); Image image = null; if (symbol is IMarker3DSymbol) { IMarker3DSymbol mar3dsym = symbol as IMarker3DSymbol; stdole.IPicture pic = mar3dsym.Thumbnail; image = Image.FromHbitmap(new System.IntPtr(pic.Handle)); } else { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 15); image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); } GridPanel panel = supergrid.PrimaryGrid; GridRow row = new GridRow(image); panel.Rows.Add(row); psymbologyStyleClass.RemoveItem(0); imagelist.Add(image); Symbollist.Add(symbol); }
public void InitUI() { SymbologyCtrl.Clear(); string StyleFilePath = OperatePageLayout.getPath(filepath) + "\\data2\\ESRI.ServerStyle";//载入系统符号库 SymbologyCtrl.LoadStyleFile(StyleFilePath); switch (_enumMapSurType) { case Class.EnumType.EnumMapSurroundType.NorthArrow: //根据选择,载入系统指北针符号库 SymbologyCtrl.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows; pSymStyleClass = SymbologyCtrl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassNorthArrows); break; case Class.EnumType.EnumMapSurroundType.ScaleBar: //根据选择,载入系统比例尺符号库 SymbologyCtrl.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; pSymStyleClass = SymbologyCtrl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassScaleBars); break; } pSymStyleClass.UnselectItem(); }
public void InitUI() { SymbologyCtrl.Clear(); string StyleFilePath = fpath.stylepath();//载入系统符号库 SymbologyCtrl.LoadStyleFile(StyleFilePath); switch (_enumMapSurType) { case EnumMapSurroundType.NorthArrow: //根据选择,载入系统指北针符号库 SymbologyCtrl.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows; pSymStyleClass = SymbologyCtrl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassNorthArrows); break; case EnumMapSurroundType.ScaleBar: //根据选择,载入系统比例尺符号库 SymbologyCtrl.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; pSymStyleClass = SymbologyCtrl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassScaleBars); break; } pSymStyleClass.UnselectItem(); }
private void PreViewCustom(DevComponents.DotNetBar.Controls.ComboBoxEx cmb, object item, esriSymbologyStyleClass styleClass) { IStyleGalleryItem pStyleItem = new ServerStyleGalleryItemClass(); pStyleItem.Name = "Custom"; pStyleItem.Item = item; stdole.IPictureDisp picture; System.Drawing.Image image; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(styleClass); picture = symbologyStyleClass.PreviewItem(pStyleItem, cmb.Width - 80, cmb.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); DevComponents.Editors.ComboItem valueItem; valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = "Custom"; valueItem.Tag = item; valueItem.Image = image; cmb.Items.Add(valueItem); cmb.SelectedIndex = cmb.Items.Count - 1; }
//构造器选择 //int FrmIndex = 0; public FrmSymbol(string[] symbolstyle, ISymbol symbol, esriSymbologyStyleClass styleClass) { InitializeComponent(); this.EnableGlass = false; SymbolStyle = symbolstyle; pStyleClass = styleClass; pSymbol = symbol; //Add by Liuzhaoqin,2013.11.16 axSymbologyControl.StyleClass = styleClass; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(styleClass); if (symbol != null) { pStyleGalleryItem = new ServerStyleGalleryItem(); pStyleGalleryItem.Item = symbol; pStyleGalleryItem.Name = "Current"; symbologyStyleClass.AddItem(pStyleGalleryItem, 0); symbologyStyleClass.SelectItem(0); } }
public IStyleGalleryItem GetItem(esriSymbologyStyleClass styleClass, ISymbol symbol) { m_styleGalleryItem = null; //Get and set the style class axSymbologyControl1.StyleClass = styleClass; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(styleClass); //Create a new server style gallery item with its style set IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem(); styleGalleryItem.Item = symbol; styleGalleryItem.Name = "mySymbol"; //Add the item to the style class and select it symbologyStyleClass.AddItem(styleGalleryItem, 0); symbologyStyleClass.SelectItem(0); //Show the modal form this.ShowDialog(); return(m_styleGalleryItem); }
//选择样式前返回图片 public Image GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass styleClass, ISymbol symbol, int width, int height) { try { axSymbologyControl.StyleClass = styleClass; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(styleClass); IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem(); styleGalleryItem.Item = symbol; //// styleGalleryItem.Name = "DefaultSymbol"; symbologyStyleClass.AddItem(styleGalleryItem, 0); symbologyStyleClass.SelectItem(0); stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); return(image); } catch (System.Exception ex) { MessageBox.Show(ex.StackTrace); return(null); } }
private void RasterRenderer_Load(object sender, EventArgs e) { IRasterBandCollection bands = rasterLayer.Raster as IRasterBandCollection; List <string> bds = new List <string>(); for (int i = 0; i < bands.Count; i++) { bds.Add(bands.Item(i).Bandname); } cbSelectedBand.DataSource = bds; try { axSymbologyControl1.LoadStyleFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\ESRI\\ESRI.ServerStyle"); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; symbol = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); cbColorRamp.DrawMode = DrawMode.OwnerDrawFixed; cbColorRamp.DropDownStyle = ComboBoxStyle.DropDownList;//这是最关键的一步 for (int i = 0; i < symbol.get_ItemCount(symbol); i++) { stdole.IPictureDisp picture = symbol.PreviewItem(symbol.GetItem(i), cbColorRamp.Width, cbColorRamp.Height); Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); cbColorRamp.Items.Add(image); } } catch { if (lang == Language.Chinese) { MessageBox.Show("色带加载失败!"); } else if (lang == Language.English) { MessageBox.Show("Loading color ribbons failed!"); } } }
/// <summary> /// 获取要色方案集合 /// </summary> /// <param name="width">色带图片的宽度</param> /// <param name="height">色带图片的高度</param> /// <param name="category">色带的类型</param> /// <returns></returns> public List <ColorItem> GetColorScheme(int width, int height, string category) { string sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime"); if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改 { sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime"); } if (sInstall == "") { sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime"); } //added by chulili 2012-11-13 end m_SymbologyControl.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle"); ISymbologyStyleClass styleClass = m_SymbologyControl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); int count = styleClass.get_ItemCount(""); List <ColorItem> colorScheme = new List <ColorItem>(); for (int i = 0; i < count; i++) { IStyleGalleryItem pItem = styleClass.GetItem(i); if (category.Contains(pItem.Category)) { stdole.IPictureDisp picture = styleClass.PreviewItem(pItem, width, height); Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); ColorItem colorItem = new ColorItem(); colorItem.ColorImage = image; colorItem.Name = pItem.Name; colorItem.ColorRamp = pItem.Item as IColorRamp; colorScheme.Add(colorItem); } } return(colorScheme); }
//IRasterStatistics rasterStatic; private void SetRasterSymbol(IRasterLayer rasterLayer) { //获取选择的序号 int index = sBC.SelectedIndex; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); IStyleGalleryItem mStyleGalleryItem = symbologyStyleClass.GetItem(index); //获取选择的符号 IColorRamp select = (IColorRamp)mStyleGalleryItem.Item; IRasterStretchColorRampRenderer rasterStretchColorRampRenderer = new RasterStretchColorRampRendererClass(); IRasterRenderer rasterRenderer = rasterStretchColorRampRenderer as IRasterRenderer; rasterRenderer.Raster = (rasterLayer).Raster; if (checkBox1.Checked == true) { //修改像元值 线性拉伸 IRaster2 pRaster2 = rasterLayer.Raster as IRaster2; IPnt pPntBlock = new PntClass(); pPntBlock.X = 128; pPntBlock.Y = 128; IRasterCursor pRasterCursor = pRaster2.CreateCursorEx(pPntBlock); IRasterEdit pRasterEdit = pRaster2 as IRasterEdit; if (pRasterEdit.CanEdit()) { // IRasterBandCollection pBands = rasterLayer as IRasterBandCollection; IPixelBlock3 pPixelblock3 = null; int pBlockwidth = 0; int pBlockheight = 0; System.Array pixels; IPnt pPnt = null; object pValue; // long pBandCount = pBands.Count; //获取Nodata //IRasterProps pRasterPro = pRaster2 as IRasterProps; //object pNodata = pRasterPro.NoDataValue; do { pPixelblock3 = pRasterCursor.PixelBlock as IPixelBlock3; pBlockwidth = pPixelblock3.Width; pBlockheight = pPixelblock3.Height; // for (int k = 0; k < pBandCount; k++) //IRasterBandCollection bandCollection; //IRasterLayer irasterLayer = rasterLayer; //IRaster2 raster = rasterLayer.Raster as IRaster2; //IRasterDataset rd = raster.RasterDataset; //bandCollection = rd as IRasterBandCollection; //IEnumRasterBand enumband = bandCollection.Bands; //IRasterBand rasterBand = enumband.Next(); //rasterStatic = null; //if (rasterBand != null && rasterBand.Statistics != null) //{ // rasterStatic = rasterBand.Statistics; //} int pixelmax, pixelmin; { pixels = (System.Array)pPixelblock3.get_PixelData(0); pixelmax = Convert.ToInt32(pixels.GetValue(0, 0)); pixelmin = pixelmax; for (int i = 0; i < pBlockwidth; i++) { for (int j = 0; j < pBlockheight; j++) { pValue = pixels.GetValue(i, j); { // pixels.SetValue(Convert.ToByte(Convert.ToInt32(pValue) * strscale), i, j); if (Convert.ToInt32(pValue) > pixelmax) { pixelmax = Convert.ToInt32(pValue); } if (Convert.ToInt32(pValue) < pixelmin) { pixelmin = Convert.ToInt32(pValue); } } } } double strscale = ((double)pixelmax - (double)pixelmin) / 255.0; for (int i = 0; i < pBlockwidth; i++) { for (int j = 0; j < pBlockheight; j++) { pValue = pixels.GetValue(i, j); { pixels.SetValue(Convert.ToByte((Convert.ToInt32(pValue) - pixelmin) / (strscale)), i, j); } } } pPixelblock3.set_PixelData(0, pixels); } pPnt = pRasterCursor.TopLeft; pRasterEdit.Write(pPnt, (IPixelBlock)pPixelblock3); }while (pRasterCursor.Next()); System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterEdit); // MessageBox.Show("done"); } } rasterRenderer.Update(); rasterStretchColorRampRenderer.ColorRamp = select; rasterRenderer.Update(); ((IRasterLayer)rasterLayer).Renderer = rasterRenderer; }
public FrmSymbolPoint(ISymbologyStyleClass symbologyStyleClass) { InitializeComponent(); this.EnableGlass = false; psymbologyStyleClass = symbologyStyleClass; }
private void axSymbologyControl1_OnStyleClassChanged(object sender, ISymbologyControlEvents_OnStyleClassChangedEvent e) { object obj = e.symbologyStyleClass;//10.0后必须通过object对象的操作进行转换 ISymbologyStyleClass symbolClass = obj as ISymbologyStyleClass; switch (symbolClass.StyleClass) { case esriSymbologyStyleClass.esriStyleClassMarkerSymbols: lblAngle.Visible = true; nudAngle.Visible = true; lblSize.Visible = true; nudSize.Visible = true; lblWidth.Visible = false; nudWidth.Visible = false; lblOutlineColor.Visible = false; btnOutlineColor.Visible = false; break; case esriSymbologyStyleClass.esriStyleClassLineSymbols: lblAngle.Visible = false; nudAngle.Visible = false; lblSize.Visible = false; nudSize.Visible = false; lblWidth.Visible = true; nudWidth.Visible = true; lblOutlineColor.Visible = false; btnOutlineColor.Visible = false; break; case esriSymbologyStyleClass.esriStyleClassFillSymbols: lblAngle.Visible = false; nudAngle.Visible = false; lblSize.Visible = false; nudSize.Visible = false; lblWidth.Visible = true; nudWidth.Visible = true; lblOutlineColor.Visible = true; btnOutlineColor.Visible = true; break; } }
private void SymbologyForm_Load(object sender, EventArgs e) { switch (((IFeatureLayer)pLayer).FeatureClass.ShapeType) //判断图层中要素类的图形类型,不同类型显示的调节值的控件不同 { 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; } //ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path 可以获得 ArcGIS 的安装目录 //获取 ESRI.ServerStyle 文件并加载入axSymbologyControl控件 string stylePath = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path + @"Styles\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(stylePath); axSymbologyControl1.StyleClass = pStyleClass; //将上面获得的 pStyleClass 赋给axSymbologyControl控件,点线面 //新建符号实例,用当前图例的符号类型 赋值,并将其添加到axSymbologyControl中 IStyleGalleryItem pCurrentStyleGalleryItem = new StyleGalleryItem(); pCurrentStyleGalleryItem.Name = "当前符号"; pCurrentStyleGalleryItem.Item = pLegendClass.Symbol; ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); //QI,加入这个新建项 pSymbologyStyleClass.AddItem(pCurrentStyleGalleryItem, 0); pSymbologyStyleClass.SelectItem(0); //设置为选中状态 }
/// <summary> /// 初始化与拉伸相关控件 /// </summary> private void initstreach() { string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(sInstall); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); pRasterRender = pRLayer.Renderer; pRasterRenderColorRamp = pRasterRender as IRasterRendererColorRamp; //生成色度带 if (pRasterRender is IRasterStretchColorRampRenderer) { IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem(); pStyleGalleryItem.Item = pRasterRenderColorRamp.ColorRamp; pSymbolClass.AddItem(pStyleGalleryItem, 0); pSymbolClass.SelectItem(0); } for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++) { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); cmbColorRamp.Items.Add(image); } if (cmbColorRamp.Items.Count > 0) { cmbColorRamp.SelectedIndex = 0; } //判断拉伸方式和拉伸波段 if (pRasterRender is IRasterStretchColorRampRenderer) { pSCRampRender = pRasterRender as IRasterStretchColorRampRenderer; pRasterStretch = pRasterRender as IRasterStretch; int bandindex = pSCRampRender.BandIndex; cmbBand.SelectedIndex = bandindex; if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_Custom) { cmbStreach.SelectedIndex = 1; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum) { cmbStreach.SelectedIndex = 2; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations) { cmbStreach.SelectedIndex = 3; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_HistogramEqualize) { cmbStreach.SelectedIndex = 4; } else { cmbStreach.SelectedIndex = 0; } lblminstr.Text = pSCRampRender.LabelLow; lblmaxstr.Text = pSCRampRender.LabelHigh; txtmin.Text = pSCRampRender.LabelLow; txtmax.Text = pSCRampRender.LabelHigh; if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum) { txtmax.Visible = true; txtmin.Visible = false; } } else { cmbBand.SelectedIndex = 0; cmbStreach.SelectedIndex = 0; } isminmax = true; }
//................................................. //................................................. //................................................. private void LineSectionLayerSettings_Load(object sender, EventArgs e) { if (_layerDef != null) { lblLayerName.Text = _layerDef.layername; lblLayerDesc.Text = _layerDef.Description; } // Load the Color Ramps _styleFilePath = Path.ChangeExtension(Application.ExecutablePath, ".serverStyle"); if (File.Exists(_styleFilePath)) { //Load the ESRI.ServerStyle file into the SymbologyControl axSymbologyControl1.LoadStyleFile(_styleFilePath); //Set the style class axSymbologyControl1.StyleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassColorRamps; //Select the color ramp item axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).SelectItem(0); _styleFileFound = true; } else { if (rbColorRamp.Checked) { rbByLayer.Checked = true; } rbColorRamp.Enabled = false; _styleFileFound = false; lblColorRampName.Text = "Color Ramp Style File not Found!"; } //Get the Layer Info needed IGeoFeatureLayer geofeaturelayer = null; IMap map = _GISdata._activeview.FocusMap; for (int i = 0; i <= map.LayerCount - 1; i++) { if (map.get_Layer(i).Name == _layerDef.layername) { geofeaturelayer = (IGeoFeatureLayer)map.get_Layer(i); break; } } if (geofeaturelayer == null) { return; } m_featureLayer = geofeaturelayer; // Initialize Default Display Renderer m_SimpleRenderer = new SimpleRendererClass(); AssignDefaultRenderer(); // See what current settings are and set them on the form _displaymode = _GISdata._cwdata.Configuration.BPLSDisplayMode; _selectedcolorrampname = _GISdata._cwdata.Configuration.BPSavedColorRampName; if (_styleFileFound) { lblColorRampName.Text = _selectedcolorrampname; } switch (_displaymode) { case (1): rbByLayer.Checked = true; break; case (2): rbByRiskLevel.Checked = true; break; case (3): rbColorRamp.Checked = true; break; } cbRiskRankingChoices.SelectedIndex = _GISdata._cwdata.Configuration.BPRiskFieldtoUse; if ((_selectedcolorrampname.Length > 0) && (_styleFileFound)) { ISymbologyStyleClass SC = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); int i; for (i = 0; i <= SC.ItemCount - 1; i++) { if (SC.GetItem(i).Name == _selectedcolorrampname) { SC.SelectItem(i); break; } } //IStyleGalleryItem serverStyleGalleryItem = axSymbologyControl1.GetStyleClass (axSymbologyControl1.StyleClass).GetSelectedItem(); //System.Windows.Forms.MessageBox.Show(serverStyleGalleryItem.Name); } // Get Statistics to display LoadStatistics(); // Done _displayModified = false; SetControls(); }
private void btnok_Click(object sender, EventArgs e) { ////构建图片存储临时目录 //FileInfo fileInfo = new FileInfo(fileName); //string path = fileInfo.DirectoryName; //string bitmapFileName = path + @"\" + this.txtSymbolName.Text + ".bmp"; ////创建新的画图,并将底色清为白色 ////Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format24bppRgb); //Bitmap bitmap = new Bitmap(listBoxImage.ImageSize.Width - 100, listBoxImage.ImageSize.Height); //Graphics graphics = Graphics.FromImage(bitmap); //System.Drawing.Color color = System.Drawing.Color.FromArgb(0, 0, 0); //graphics.Clear(Color.White); ////将各个子样式在画图上绘制 //Bitmap image; //int startX; //int startY; //for (int i = 0; i < supergrid.PrimaryGrid.Rows.Count; i++) //{ // image = (Bitmap)imagelist[i]; // startX = picturepre.Width / 2 - (int)(imagelist[i].Size.Width * Radio) / 2; // startY = picturepre.Height / 2 - (int)(imagelist[i].Size.Height * Radio) / 2; // image.MakeTransparent(Color.Transparent); // System.Drawing.Rectangle rectangle = new Rectangle(startX-50, startY-50, (int)(imagelist[i].Size.Width * Radio), (int)(imagelist[i].Size.Height * Radio)); // graphics.DrawImage(imagelist[i], rectangle); // graphics.Save(); //} //graphics.SmoothingMode = SmoothingMode.HighQuality; //graphics.Dispose(); ////将图片保存在临时目录 //bitmap.Save(bitmapFileName, System.Drawing.Imaging.ImageFormat.Bmp); ////创建图片样式 //IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass(); //pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, bitmapFileName); //pictureMarkerSymbol.Angle = 0; //pictureMarkerSymbol.Size = 30; //pictureMarkerSymbol.XOffset = 0; //pictureMarkerSymbol.YOffset = 0; for (int i = 0; i < Symbollist.Count; i++) { pMultiLineSymbol.AddLayer(Symbollist[i] as IMarkerSymbol); } IStyleGallery styleGallery; IStyleGalleryItem styleGalleryItem; IStyleGalleryStorage styleGalleryStorge; //创建新的样式 styleGalleryItem = new ServerStyleGalleryItemClass(); styleGalleryItem.Name = this.txtSymbolName.Text; styleGalleryItem.Category = "default"; object objSymbol = pMultiLineSymbol; styleGalleryItem.Item = objSymbol; styleGallery = new ServerStyleGalleryClass(); styleGalleryStorge = styleGallery as IStyleGalleryStorage; styleGalleryStorge.TargetFile = fileName; //添加新样式 //styleGallery.AddItem(styleGalleryItem); ISymbologyStyleClass pSymbolClass = psymbologyStyleClass; pSymbolClass.AddItem(styleGalleryItem, 0); pSymbolClass.SelectItem(0); //保存新样式 //styleGallery.SaveStyle(fileName, fileInfo.Name, "marker Symbols"); this.Close(); }
private void SetUI(IElement pElement) { tabProperty.Tabs["tabFrame"].Visible = false; chkRatio.Checked = m_pBoundProp.FixedAspectRatio; if (pElement is IMarkerElement) { //panelLine.Visible = false; //panelPoly.Visible = false; panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = true; btnLine.Visible = false; btnPoint.Visible = true; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; //panelPoint.Visible = true; //panelPoint.BringToFront (); picPoint.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = false; } else if (pElement is ILineElement) { panelText.Visible = false; picLine.Visible = true; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = true; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; picLine.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = true; } else if (pElement is IFillShapeElement) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = true; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = true; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; picPoly.BringToFront(); chkRatio.Enabled = true; } else if (pElement is ITextElement) { panelText.Visible = true; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; panelText.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = false; } else if (pElement is IInkGraphic) { tabProperty.Tabs["tabArea"].Visible = false; tabProperty.Tabs["tabSymbol"].Visible = false; } if (pElement is IFrameElement) { tabProperty.Tabs["tabArea"].Visible = false; tabProperty.Tabs["tabSymbol"].Visible = false; //判断指北针,比例尺,比例文本 IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame; if (pMapSurroundFrame != null) { IMapSurround pMapSurround = pMapSurroundFrame.MapSurround; if (pMapSurround != null) { tabProperty.Tabs["tabSymbol"].Visible = true; panelText.Visible = false; if (pMapSurround is INorthArrow) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = true; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = true; btnScale.Visible = false; btnScaleText.Visible = false; picArrow.BringToFront(); chkRatio.Enabled = true; } else if (pMapSurround is IScaleBar) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = true; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = true; btnScaleText.Visible = false; picScale.BringToFront(); chkRatio.Enabled = true; } else if (pMapSurround is IScaleText) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = true; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = true; picScaleText.BringToFront(); chkRatio.Enabled = true; } } } else if (pElement is IMapFrame) { tabProperty.Tabs["tabFrame"].Visible = true; } //初始化窗体 //Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ESRI\\CoreRuntime", true); //if (rk == null) return; //string sInstall = (string)rk.GetValue("InstallDir"); string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime"); if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改 { sInstall = ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime"); } if (sInstall == "") { sInstall = ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime"); } //added by chulili 2012-11-13 end if (sInstall == "") { MessageBox.Show("系统没有安装Engine Runtime", "提示"); return; } string sPath = sInstall + "\\Styles\\ESRI.ServerStyle"; axSymbologyControl1.Clear(); axSymbologyControl1.LoadStyleFile(sPath); //添加边框符号 IStyleGalleryItem pItem; stdole.IPictureDisp picture; System.Drawing.Image image; DevComponents.Editors.ComboItem valueItem; int i = 0; axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBorders; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); int cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbBorder.Items.Clear(); cmbBorder.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbBorder.Width - 80, cmbBorder.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbBorder.Items.Add(valueItem); } //添加背景符号 axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBackgrounds; symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbBack.Items.Clear(); cmbBack.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbBack.Width - 80, cmbBack.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbBack.Items.Add(valueItem); } //添加阴影符号 axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassShadows; symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbShadow.Items.Clear(); cmbShadow.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbShadow.Width - 80, cmbShadow.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbShadow.Items.Add(valueItem); } } }