/// <summary> /// 栅格分级渲染(注意选中字段唯一值个数不能小于设置的唯一值个数) /// </summary> /// <param name="rasterClassRenderer">分级渲染设置</param> /// <param name="pStyleGalleryItem">颜色带样式</param> public void ClassRenderer(IRasterClassifyColorRampRenderer rasterClassRenderer, IStyleGalleryItem pStyleGalleryItem) { if (pStyleGalleryItem == null) { MessageBox.Show(@"Color ramp cannot be empty"); return; } IRasterRenderer rasterRend = (IRasterRenderer)rasterClassRenderer; rasterRend.Raster = rasterLayer.Raster; rasterRend.Update(); IEnumColors enumColors = RenderHelper.GetColorRamp(pStyleGalleryItem, rasterClassRenderer.ClassCount).Colors; enumColors.Reset(); IFillSymbol fillSymbol = new SimpleFillSymbolClass(); for (int i = 0; i < rasterClassRenderer.ClassCount; i++) { fillSymbol.Color = enumColors.Next(); rasterClassRenderer.set_Symbol(i, (ISymbol)fillSymbol); string label = Math.Round(rasterClassRenderer.Break[i], 2) + "-" + Math.Round(rasterClassRenderer.Break[i + 1], 2); rasterClassRenderer.set_Label(i, label); } rasterLayer.Renderer = rasterRend; }
private void LegendPropertyPage_Load(object sender, EventArgs e) { if (this.istyleGallery_0 != null) { IStyleGalleryItem item = null; IEnumStyleGalleryItem item2 = this.istyleGallery_0.get_Items("Line Patches", "", ""); item2.Reset(); for (item = item2.Next(); item != null; item = item2.Next()) { this.cboLinePatches.Add(item); } if (this.cboLinePatches.Items.Count > 0) { this.cboLinePatches.SelectedIndex = 0; } item2 = this.istyleGallery_0.get_Items("Area Patches", "", ""); item2.Reset(); for (item = item2.Next(); item != null; item = item2.Next()) { this.cboAreaPatches.Add(item); } if (this.cboAreaPatches.Items.Count > 0) { this.cboAreaPatches.SelectedIndex = 0; } } this.method_0(); this.bool_0 = true; this.lvcolumnHeader_0.ColumnStyle = ListViewColumnStyle.ReadOnly; this.lvcolumnHeader_1.ColumnStyle = ListViewColumnStyle.EditBox; }
//axSymbologyControl空间SymbolItem选中事件相应函数 private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //获取选择项 PreviewPicture(); //在图片框中显示 //点,将属性传递到调节的控件上 if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { { IRgbColor pColor = ((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor; 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) { IRgbColor pColor = ((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor; 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) { IRgbColor pColor = ((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor; btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //填充色 nudWidth.Value = Convert.ToDecimal(((IFillSymbol)pStyleGalleryItem.Item).Outline.Width); //边框宽度 pColor = ((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor; btOutlineColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //边框颜色 } }
protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { if (arg.Button == MouseButtons.Left) { GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y); SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem); PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference); IStyleGalleryItem styleGalleryItem = StyleGallerySelection.GetStyleGalleryItem(); if (styleGalleryItem != null) { StyleElement styleElement = new StyleElement(pointGeometry.Geometry, StyleElementSize, styleGalleryItem); TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe); if (!tableOfContents.LayerExists(GraphicsLayerName)) { tableOfContents.ConstructLayer(GraphicsLayerName); } Layer layer = new Layer(tableOfContents[GraphicsLayerName]); layer.AddElement(styleElement.Element, styleElement.ElementProperties); ArcGlobe.Globe.GlobeDisplay.RefreshViewers(); } } }
private void SetDefaultSymbol(ILineElement elem) { ILineSymbol defaultLineSym = null; String esriStylePath; IStyleGallery styleGallery = new StyleGalleryClass(); IStyleGalleryStorage styleStor = (IStyleGalleryStorage)styleGallery; esriStylePath = styleStor.DefaultStylePath + "ESRI.style"; IEnumStyleGalleryItem styleItems = styleGallery.get_Items("Line Symbols", esriStylePath, "Dashed"); styleItems.Reset(); IStyleGalleryItem styleGalleryItem = styleItems.Next(); while (!(styleGalleryItem == null)) { if (styleGalleryItem.Name == "Dashed 4:4") { defaultLineSym = (ILineSymbol)styleGalleryItem.Item; defaultLineSym.Width = 1.50; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Blue = 0; rgbColor.Green = 0; rgbColor.Transparency = 50; defaultLineSym.Color = rgbColor; break; } else { styleGalleryItem = styleItems.Next(); } } elem.Symbol = defaultLineSym; }
private void StyleComboBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (this.iarray_0.Count != 0) { e.DrawBackground(); try { IStyleGalleryItem styleGalleryItem = this.iarray_0.get_Element(e.Index) as IStyleGalleryItem; if (styleGalleryItem != null) { System.IntPtr hdc = e.Graphics.GetHdc(); IStyleDraw styleDraw = StyleDrawFactory.CreateStyleDraw(styleGalleryItem.Item); if (styleDraw != null) { e.Bounds.Inflate(-2, -4); styleDraw.Draw(hdc.ToInt32(), e.Bounds, 72.0, 1.0); } e.Graphics.ReleaseHdc(hdc); } else { Brush brush = new SolidBrush(e.ForeColor); e.Graphics.DrawString(base.Items[e.Index].ToString(), e.Font, brush, (float)(e.Bounds.Left + 3), (float)(e.Bounds.Top + 3)); } } catch { } } }
/// <summary> /// Handles the Click event of the btnChangeOutlineStyle control. /// </summary> /// <param name="obj">The source of the event.</param> /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnChangeOutlineStyle_Click(object obj, EventArgs eventArgs) { if (this._styleGalleryItem != null) { this._fillSymble = (this._styleGalleryItem.Item as IFillSymbol); if (this._fillSymble != null) { ILineSymbol lineSymbol = this._fillSymble.Outline; frmSymbolSelector frmSymbolSelect = new frmSymbolSelector(); IStyleGalleryItem item = frmSymbolSelect.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, lineSymbol as ISymbol); if (item != null) { lineSymbol = (item.Item as ILineSymbol); if (lineSymbol.Color != null) { this.cmbFillLineColor.Color = ColorTranslator.FromOle(lineSymbol.Color.RGB); } else { this.cmbFillLineColor.Color = Color.Empty; } this.cmbFillWidth.Value = Convert.ToDecimal(lineSymbol.Width); this._fillSymble.Outline = lineSymbol; this.ViewSymble(); } } } }
private void DrawColorRamp() { string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path; string styleFilePath = sInstall + "\\Styles\\ESRI.ServerStyle"; IStyleGallery styleGallery = new ServerStyleGalleryClass(); IStyleGalleryItem styleGalleryItem = null; IStyleGalleryStorage styleGalleryStorage = styleGallery as IStyleGalleryStorage; styleGalleryStorage.AddFile(styleFilePath); IEnumStyleGalleryItem enumStyleGalleryItem = styleGallery.get_Items("Color Ramps", styleFilePath, ""); enumStyleGalleryItem.Reset(); styleGalleryItem = enumStyleGalleryItem.Next(); while (styleGalleryItem != null) { m_ColorRamp = (IColorRamp)styleGalleryItem.Item; EnumStyleItem.Add(m_ColorRamp); m_FillSymbol = new GradientFillSymbol(); m_FillSymbol.GradientAngle = 0; m_FillSymbol.ColorRamp = m_ColorRamp; pictureBox1.Image = SymbolToBitmap(m_FillSymbol, 0, pictureBox1.Width, pictureBox1.Height); imageList1.Images.Add(pictureBox1.Image); comboBoxColor.Items.Add(pictureBox1.Image); styleGalleryItem = enumStyleGalleryItem.Next(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(enumStyleGalleryItem); }
private ISymbol GetSymbolByControl(ISymbol symbolType) { ISymbol symbol = null; IStyleGalleryItem styleGalleryItem = null; esriSymbologyStyleClass styleClass = esriSymbologyStyleClass. esriStyleClassMarkerSymbols; if (symbolType is IMarkerSymbol) { styleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols; } if (symbolType is ILineSymbol) { styleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols; } if (symbolType is IFillSymbol) { styleClass = esriSymbologyStyleClass.esriStyleClassFillSymbols; } GetSymbol symbolForm = new GetSymbol(styleClass); symbolForm.ShowDialog(); styleGalleryItem = symbolForm.m_styleGalleryItem; if (styleGalleryItem == null) { return(null); } symbol = styleGalleryItem.Item as ISymbol; symbolForm.Dispose(); this.Activate(); return(symbol); }
private void listLegendLayers_SelectedIndexChanged(object sender, EventArgs e) { this.bool_0 = false; this.ilegendItem_0 = (this.listLegendLayers.Items[this.listLegendLayers.SelectedIndex] as LegendItemWrap).LegendItem; if (this.ilegendItem_0 != null) { ILegendClassFormat legendClassFormat = this.ilegendItem_0.LegendClassFormat; if (legendClassFormat.AreaPatch == null) { ILegendFormat format = this.ilegend_0.Format; legendClassFormat.AreaPatch = format.DefaultAreaPatch; legendClassFormat.LinePatch = format.DefaultLinePatch; legendClassFormat.PatchWidth = format.DefaultPatchWidth; legendClassFormat.PatchHeight = format.DefaultPatchHeight; } if (this.定制 == null) { this.定制 = new ServerStyleGalleryItemClass(); this.定制.Name = "定制"; this.定制.Item = legendClassFormat.LinePatch; } if (this.定制_1 == null) { this.定制_1 = new ServerStyleGalleryItemClass(); this.定制_1.Name = "定制"; this.定制_1.Item = legendClassFormat.AreaPatch; } this.cboLinePatches.SelectStyleGalleryItem(this.定制); this.cboAreaPatches.SelectStyleGalleryItem(this.定制_1); this.txtWidth.Text = legendClassFormat.PatchWidth.ToString("#.##"); this.txtHeight.Text = legendClassFormat.PatchHeight.ToString("#.##"); this.bool_0 = true; } }
//插入指北针 public void InsertNorthArrow() { SetCurrentTool(); AddNorthArrowForm addNorthArrow = new AddNorthArrowForm(); if (addNorthArrow.ShowDialog() == DialogResult.OK) { IStyleGalleryItem pStyleGalleryItemTemp = addNorthArrow.m_pStyleGalleryItem; if (pStyleGalleryItemTemp == null) { return; } IMapFrame pMapframe = m_pageLayoutControl.ActiveView.GraphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap) as IMapFrame; IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass(); pMapSurroundFrame.MapFrame = pMapframe; pMapSurroundFrame.MapSurround = (IMapSurround)pStyleGalleryItemTemp.Item; //在pageLayout中根据名称查要Element,找到之后删除已经存在的指北针 IElement pElement = m_pageLayoutControl.FindElementByName("NorthArrows"); if (pElement != null) { m_pageLayoutControl.ActiveView.GraphicsContainer.DeleteElement(pElement); //删除已经存在的指北针 } IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(16, 24, 20, 28); pElement = (IElement)pMapSurroundFrame; pElement.Geometry = (IGeometry)pEnvelope; m_pageLayoutControl.ActiveView.GraphicsContainer.AddElement(pElement, 0); m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
private void LegendSetupUserControl_Load(object sender, EventArgs e) { if (this.istyleGallery_0 != null) { IStyleGalleryItem item = null; IEnumStyleGalleryItem item2 = this.istyleGallery_0.get_Items("Line Patches", "", ""); item2.Reset(); for (item = item2.Next(); item != null; item = item2.Next()) { this.cboLinePatches.Add(item); } if (this.cboLinePatches.Items.Count > 0) { this.cboLinePatches.SelectedIndex = 0; } item2 = this.istyleGallery_0.get_Items("Area Patches", "", ""); item2.Reset(); for (item = item2.Next(); item != null; item = item2.Next()) { this.cboAreaPatches.Add(item); } if (this.cboAreaPatches.Items.Count > 0) { this.cboAreaPatches.SelectedIndex = 0; } } this.method_0(); this.bool_0 = true; }
/// <summary> /// 浮点类型图层的唯一值渲染 /// </summary> /// <param name="pStyleGalleryItem">颜色带样式</param> public void FloatRasterUniqueRenderer(IStyleGalleryItem pStyleGalleryItem) { if (pStyleGalleryItem == null) { MessageBox.Show(@"Color ramp cannot be empty"); return; } IRasterUniqueValueRenderer uniqueValueRenderer = new RasterUniqueValueRendererClass(); IRasterRenderer pRasterRenderer = uniqueValueRenderer as IRasterRenderer; pRasterRenderer.Raster = rasterLayer.Raster; pRasterRenderer.Update(); //必须设置栅格渲染的唯一值,不然只能渲染0值 SetRasterUniqueValue(uniqueValueRenderer); //获取排好序的唯一值 List <object> uniqueValue = GetFloatSortedUniqueValue(); int uniqueCount = uniqueValue.Count; if (uniqueCount == 0) { MessageBox.Show(@"The count of unique value cannot be zero"); return; } uniqueValueRenderer.set_ClassCount(0, uniqueCount); IEnumColors enumColors = RenderHelper.GetEnumColors(pStyleGalleryItem, uniqueCount); enumColors.Reset(); //添加唯一值和设置标注符号 AddValueAndSetLabelSymbol(uniqueValueRenderer, uniqueValue, enumColors); rasterLayer.Renderer = pRasterRenderer; }
/// <summary> /// 唯一值渲染(注意字段类型要一致) /// </summary> /// <param name="uniqueValue">唯一值列表</param> /// <param name="uniqueFiled">字段</param> /// <param name="pStyleGalleryItem">颜色带样式</param> public void UniqueRenderer <T>(List <T> uniqueValue, string uniqueFiled, IStyleGalleryItem pStyleGalleryItem) { if (pStyleGalleryItem == null) { MessageBox.Show(@"Color ramp cannot be empty"); return; } IRasterUniqueValueRenderer uniqueValueRenderer = new RasterUniqueValueRendererClass(); IRasterRenderer pRasterRenderer = uniqueValueRenderer as IRasterRenderer; pRasterRenderer.Raster = rasterLayer.Raster; pRasterRenderer.Update(); int uniqueCount = uniqueValue.Count; if (uniqueCount == 0) { MessageBox.Show(@"The count of unique value cannot be zero"); return; } //设置唯一值渲染属性 SetUniqueRendererProperty(uniqueValueRenderer, uniqueFiled, uniqueCount); IEnumColors enumColors = RenderHelper.GetEnumColors(pStyleGalleryItem, uniqueCount); enumColors.Reset(); //添加唯一值和设置标注符号 AddValueAndSetLabelSymbol(uniqueValueRenderer, uniqueValue, enumColors); rasterLayer.Renderer = pRasterRenderer; }
// 从符号 public static ISymbol FetchSymbol(string name) { string strStartPath = System.Windows.Forms.Application.StartupPath; IStyleGallery pStyleGallery = new ServerStyleGalleryClass(); IStyleGalleryStorage pStyleGalleryStorage = pStyleGallery as IStyleGalleryStorage; pStyleGalleryStorage.AddFile(strStartPath + "\\mlb.ServerStyle"); IEnumStyleGalleryItem pEnumStyleGalleryItem = pStyleGallery.get_Items("Marker Symbols", strStartPath + "\\mlb.ServerStyle", null); ISymbol pSymbol = null; pEnumStyleGalleryItem.Reset(); IStyleGalleryItem pStyleGalleryItem = pEnumStyleGalleryItem.Next(); while (pStyleGalleryItem != null) { if (pStyleGalleryItem.Name == name) { //获取符号 pSymbol = pStyleGalleryItem.Item as ISymbol; System.Runtime.InteropServices.Marshal.ReleaseComObject(pEnumStyleGalleryItem); break; } pStyleGalleryItem = pEnumStyleGalleryItem.Next(); } return(pSymbol); }
public FrmEditLine(string [] symbolstyle, IStyleGalleryItem stylegalleryitem) { InitializeComponent(); this.EnableGlass = false; SymbolStyle = symbolstyle; pStyleGalleryItem = stylegalleryitem; }
public int SelectStyleGalleryItem(IStyleGalleryItem istyleGalleryItem_0) { int result; for (int i = 0; i < this.iarray_0.Count; i++) { IStyleGalleryItem styleGalleryItem = this.iarray_0.get_Element(i) as IStyleGalleryItem; if (styleGalleryItem != null && istyleGalleryItem_0 != null) { if (istyleGalleryItem_0.Name == (this.iarray_0.get_Element(i) as IStyleGalleryItem).Name) { this.SelectedIndex = i; result = i; return(result); } } else if (styleGalleryItem == istyleGalleryItem_0) { this.SelectedIndex = i; result = i; return(result); } } this.Add(istyleGalleryItem_0); this.SelectedIndex = this.iarray_0.Count - 1; result = this.SelectedIndex; return(result); }
private void LoadChildren() { if (m_childrenLoaded) { return; } //Our children are GxContainer objects that represent the actual style items //of a certain type. IEnumStyleGalleryItem pEnumItems = null; pEnumItems = m_pParent.StyleGallery.get_Items(m_pClass.Name, "ESRI.style", ""); IStyleGalleryItem pItem = null; pItem = pEnumItems.Next(); while (pItem != null) { clsGxStyleGalleryItem pGxItem = null; pGxItem = new clsGxStyleGalleryItem(); pGxItem.StyleGalleryItem = pItem; IGxObject pGxObject = null; pGxObject = pGxItem; pGxObject.Attach(this, m_pCatalog); m_pChildren.Insert(-1, pGxObject); pItem = pEnumItems.Next(); } m_childrenLoaded = true; }
//选择样式,图片框中预览 private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //object objSymbol = pStyleGallery.Item; //SympleToView((ISymbol)styleGallery.Item); PreviewImage(); }
private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; Color color; switch (this.axSymbologyControl.StyleClass) { case esriSymbologyStyleClass.esriStyleClassMarkerSymbols: color = this.ConvertIRgbColorToColor(((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor); break; case esriSymbologyStyleClass.esriStyleClassLineSymbols: color = this.ConvertIRgbColorToColor(((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor); break; case esriSymbologyStyleClass.esriStyleClassFillSymbols: color = this.ConvertIRgbColorToColor(((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor); this.btnOutlineColor.BackColor = this.ConvertIRgbColorToColor(((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor); break; default: color = Color.Black; break; } this.btnColor.BackColor = color; this.PreviewImage(); }
private void btnCancel_Click(object sender, EventArgs e) { _size = Convert.ToDouble(cmbxSymbolSize.Text); m_styleGalleryItem = null; //hide the form this.Hide(); }
public static IStyleGalleryItem FindStyleGalleryItem(string string_0, IStyleGallery istyleGallery_0, string string_1, string string_2, string string_3) { IStyleGalleryItem result; if (istyleGallery_0 == null) { result = null; } else { try { IEnumStyleGalleryItem enumStyleGalleryItem = istyleGallery_0.get_Items(string_2, string_1, string_3); enumStyleGalleryItem.Reset(); for (IStyleGalleryItem styleGalleryItem = enumStyleGalleryItem.Next(); styleGalleryItem != null; styleGalleryItem = enumStyleGalleryItem.Next()) { if (styleGalleryItem.Name.ToUpper() == string_0.ToUpper()) { result = styleGalleryItem; return(result); } } } catch { } System.GC.Collect(); result = null; } return(result); }
//样式选择 private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { //选择样式 StyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; PreviewImage(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add AddScaleBar.OnMouseDown implementation if (Button == 1) { IEnvelope pEnv; pEnv = pPageLayoutControl.TrackRectangle(); GetSymbol symbolForm = new GetSymbol(esriSymbologyStyleClass. esriStyleClassScaleBars); symbolForm.Text = "Choose Scale Bar"; IStyleGalleryItem styleGalleryItem = symbolForm.GetItem (esriSymbologyStyleClass.esriStyleClassNorthArrows); symbolForm.Dispose(); if (styleGalleryItem == null) { return; } IMapFrame mapFrame = (IMapFrame)m_hookHelper.ActiveView.GraphicsContainer. FindFrame(m_hookHelper.ActiveView.FocusMap); IMapSurroundFrame mapSurroundFrame = new MapSurroundFrameClass(); mapSurroundFrame.MapFrame = mapFrame; mapSurroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item; IElement element = (IElement)mapSurroundFrame; element.Geometry = pEnv; m_hookHelper.ActiveView.GraphicsContainer.AddElement ((IElement)mapSurroundFrame, 0); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, mapSurroundFrame, null); } }
//样式选择 private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { //选择样式 pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; //将选择的样式与设计的样式大小、颜色等属性结合 if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassMarkerSymbols) { IMarkerSymbol pMarkerSymbol = pStyleGalleryItem.Item as IMarkerSymbol; double pMarkerSize = pMarkerSymbol.Size; PointSize.Text = pMarkerSize.ToString(); double pMarkerAngle = pMarkerSymbol.Angle; PointAngle.Text = pMarkerAngle.ToString(); colorPoint.SelectedColor = ClsGDBDataCommon.IColorToColor(pMarkerSymbol.Color); } else if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassLineSymbols) { ILineSymbol pLineSymbol = pStyleGalleryItem.Item as ILineSymbol; double pLineWidth = pLineSymbol.Width; LineSize.Text = pLineWidth.ToString(); colorLine.SelectedColor = ClsGDBDataCommon.IColorToColor(pLineSymbol.Color); } else if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassFillSymbols) { IFillSymbol pFillSymbol = pStyleGalleryItem.Item as IFillSymbol; PolygonSize.Text = pFillSymbol.Outline.Width.ToString(); colorPolygon.SelectedColor = ClsGDBDataCommon.IColorToColor(pFillSymbol.Color); colorOutLine.SelectedColor = ClsGDBDataCommon.IColorToColor(pFillSymbol.Outline.Color); } PreviewImage(); }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; if (styleGalleryItem.Item is IMarkerSymbol) { //Set the default marker symbol m_graphicProperties.MarkerSymbol = (IMarkerSymbol)styleGalleryItem.Item; } else if (styleGalleryItem.Item is ILineSymbol) { //Set the default line symbol m_graphicProperties.LineSymbol = (ILineSymbol)styleGalleryItem.Item; } else if (styleGalleryItem.Item is IFillSymbol) { //Set the default fill symbol m_graphicProperties.FillSymbol = (IFillSymbol)styleGalleryItem.Item; } else if (styleGalleryItem.Item is ITextSymbol) { //Set the default text symbol m_graphicProperties.TextSymbol = (ITextSymbol)styleGalleryItem.Item; } }
/// <summary> /// 获取枚举色带 /// </summary> /// <param name="styleGalleryItem"></param> /// <param name="fieldCount"></param> /// <returns></returns> public static List <IColor> GetColors(int fieldCount, IStyleGalleryItem styleGalleryItem = null) { //获取默认颜色带 return(styleGalleryItem == null ? GetDefaultColors(fieldCount) : EnumColorsToList(GetEnumColors(styleGalleryItem, fieldCount))); }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { //Get the selected item m_styleGalleryItem = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).GetSelectedItem(); //enable ok button button1.Enabled = true; }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; //Get the frame containing the focus map IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap); if (styleGalleryItem.Item is IBackground) { //Set the frame's background frameProperties.Background = (IBackground)styleGalleryItem.Item; } else if (styleGalleryItem.Item is IBorder) { //Set the frame's border frameProperties.Border = (IBorder)styleGalleryItem.Item; } else if (styleGalleryItem.Item is IShadow) { //Set the frame's shadow frameProperties.Shadow = (IShadow)styleGalleryItem.Item; } //Refresh the PageLayoutControl axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null); }
//插入比例尺 public void InsertScale() { this.SetCurrentTool(); AddScaleForm scaleForm = new AddScaleForm(); if (scaleForm.ShowDialog() == DialogResult.OK) { IStyleGalleryItem pStyleGalleryItem = scaleForm.m_pStyleGalleryItem; IMapFrame pMapframe = m_pageLayoutControl.ActiveView.GraphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap) as IMapFrame; IMapSurroundFrame pSurroundFrame = new MapSurroundFrameClass(); pSurroundFrame.MapFrame = pMapframe; pSurroundFrame.MapSurround = (IMapSurround)pStyleGalleryItem.Item; //在pageLayout中根据名称查要Element,找到之后删除已经存在的比例尺 IElement pelement = m_pageLayoutControl.FindElementByName("ScaleBars"); if (pelement != null) { m_pageLayoutControl.ActiveView.GraphicsContainer.DeleteElement(pelement); //删除已经存在的指北针 } IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(12, 2, 20, 3); pelement = (IElement)pSurroundFrame; pelement.Geometry = (IGeometry)pEnvelope; m_pageLayoutControl.ActiveView.GraphicsContainer.AddElement(pelement, 0); m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
public IStyleGalleryItem GetItem(esriSymbologyStyleClass styleClass) { m_styleGalleryItem = null; axSymbologyControl.StyleClass = styleClass; axSymbologyControl.GetStyleClass(styleClass).UnselectItem(); this.ShowDialog(); return m_styleGalleryItem; }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { m_styleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //预览被选择的样式项 PreviewImage(); //更新大小属性控件的值 this.symbolSize.Value = Convert.ToDecimal(GetSizeFromSymbol(m_styleGalleryItem.Item as ISymbol)); //更新颜色控件的颜色 }
public void PreviewItem(IStyleGalleryItem pItem, int hDC, tagRECT r) { //Draw a representation of the item to the given DC. try { m_pClass.Preview(pItem.Item, hDC, ref r); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass) { pStyleGalleryItem = null; //Set the style class of SymbologyControl1 axSymbologyControl1.StyleClass = styleClass; //Change cursor this.Cursor = Cursors.Default; //Show the modal form this.ShowDialog(); //return the label style that has been selected from the SymbologyControl return pStyleGalleryItem; }
private IElement GetElement(IGeometry geometry, double size, IStyleGalleryItem styleGalleryItem) { IElement element; IMarkerElement markerElement = new MarkerElementClass(); element = markerElement as IElement; IMarkerSymbol markerSymbol = styleGalleryItem.Item as IMarkerSymbol; markerSymbol.Size = size; element.Geometry = geometry; markerElement.Symbol = markerSymbol; return element; }
public static Bitmap StyleGalleryItemToBmp(int pWidth, int pHeight, IStyleGalleryClass pStyleGalleryClass, IStyleGalleryItem pStyleGalleryItem) { /// 通过符号库中的IStyleGalleryItem 和 IStyleGalleryClass类别生成图片预览 Bitmap bitmap = new Bitmap(pWidth, pHeight); System.Drawing.Graphics pGraphics = System.Drawing.Graphics.FromImage(bitmap); tagRECT rect = new tagRECT(); rect.right = bitmap.Width; rect.bottom = bitmap.Height; //生成预览 IntPtr hdc = new IntPtr(); hdc = pGraphics.GetHdc(); pStyleGalleryClass.Preview(pStyleGalleryItem.Item, hdc.ToInt32(), ref rect); pGraphics.ReleaseHdc(hdc); pGraphics.Dispose(); return bitmap; }
public IStyleGalleryItem GetItem(esriSymbologyStyleClass styleClass, ISymbol symbol) { this._styleGalleryItem = null; //Get and set the style class this._axSymCtrl.StyleClass = styleClass; ISymbologyStyleClass symbologyStyleClass = this._axSymCtrl.GetStyleClass(styleClass); //Create a new server style gallery item with its style set IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem(); styleGalleryItem.Item = symbol; styleGalleryItem.Name = "Current"; //Add the item to the style class and select it symbologyStyleClass.AddItem(styleGalleryItem, 0); symbologyStyleClass.SelectItem(0); //Show the modal form this.ShowDialog(); return this._styleGalleryItem; }
private void axSymCtrl_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { this._styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; ShowPreviewImage(); }
private void CancelBtn_Click(object sender, RoutedEventArgs e) { this._styleGalleryItem = null; this.Hide(); }
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { m_styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; PreviewImage(); }
public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass) { m_StyleGalleryItem = null; //Disable ok button button1.Enabled = false; //Set the style class axSymbologyControl1.StyleClass = styleClass; //Unselect any selected item in the current style class axSymbologyControl1.GetStyleClass(styleClass).UnselectItem(); //Show the modal form this.ShowDialog(); //Return the selected label style return m_StyleGalleryItem; }
private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { this.pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; this.PreviewImage(); }
private void OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { //Preview the selected item m_styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; PreviewImage(); //set the dirty flag if (!IsPageActivating) PageIsDirty = true; }
private void UpdateSymbol(IStyleGalleryItem styleGalleryItem) { //Get IPage interface IPage page = axPageLayoutControl1.Page; //Apply the symbol as a property to the page if (optIPropertySupport.Checked) { //Query interface for IPropertySupport IPropertySupport propertySupport = page as IPropertySupport; //If the symbol can be applied if (propertySupport.CanApply(styleGalleryItem.Item)) //Apply the object propertySupport.Apply(styleGalleryItem.Item); else MessageBox.Show("Unable to apply this symbol!"); } //Apply the symbol as an IFrameProperties property if (optIFrameProperties.Checked) { //Query interface for IFrameProperties IFrameProperties frameProperties = page as IFrameProperties; if (styleGalleryItem.Item is IBorder) //Set the frame's border frameProperties.Border = styleGalleryItem.Item as IBorder ; else if (styleGalleryItem.Item is IBackground) //Set the frame's background frameProperties.Background = styleGalleryItem.Item as IBackground; else if (styleGalleryItem.Item is IColor) MessageBox.Show("There is no color property on IFrameProperties!"); else if (styleGalleryItem.Item is IShadow) //Set the frame's shadow frameProperties.Shadow = styleGalleryItem.Item as IShadow; } //Apply the symbol as an IPage property if (optIPage.Checked) { if (styleGalleryItem.Item is IBorder) //Set the frame's border page.Border = styleGalleryItem.Item as IBorder; else if (styleGalleryItem.Item is IBackground) //Set the frame's background page.Background = styleGalleryItem.Item as IBackground; else if (styleGalleryItem.Item is IColor) //Set the frame's background color page.BackgroundColor = styleGalleryItem.Item as IColor; else if (styleGalleryItem.Item is IShadow) MessageBox.Show("There is no shadow property on IPage!"); } //Refresh axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null); }
public Bitmap StyleGalleryItemToBmp(int iWidth, int iHeight, IStyleGalleryClass mStyleGlyCs, IStyleGalleryItem mStyleGlyItem) { //建立符合规格的内存图片 Bitmap bmp = new Bitmap(iWidth, iHeight); Graphics gImage = Graphics.FromImage(bmp); //建立对应的符号显示范围 tagRECT rect = new tagRECT(); rect.right = bmp.Width; rect.bottom = bmp.Height; //生成预览 System.IntPtr hdc = new IntPtr(); hdc = gImage.GetHdc(); //在图片上绘制符号 mStyleGlyCs.Preview(mStyleGlyItem.Item, hdc.ToInt32(), ref rect); gImage.ReleaseHdc(hdc); gImage.Dispose(); return bmp; }
public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass) { //Retrieve the selected area/line patch style from the SymbologyControl m_styleGalleryItem = null; //disable ok button button1.Enabled = false; //Set the style class of SymbologyControl1 axSymbologyControl1.StyleClass = styleClass; //Unselect any selected item in the current style class axSymbologyControl1.GetStyleClass(styleClass).UnselectItem(); //Show the modal form this.ShowDialog(); //return the label style that has been selected from the SymbologyControl return m_styleGalleryItem; }
public StyleElement(IGeometry geometry, double size, IStyleGalleryItem styleGalleryItem) { _element = GetElement(geometry, size, styleGalleryItem); _elementProperties = GetElementProperties(); }
private void btnCancel_Click(object sender, EventArgs e) { m_styleGalleryItem = null; this.Hide(); }
//axSymbologyControl空间SymbolItem选中事件相应函数 private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = e.styleGalleryItem as IStyleGalleryItem; //获取选择项 PreviewPicture(); //在图片框中显示 //点,将属性传递到调节的控件上 if (((IFeatureLayer)pLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { IRgbColor pColor = ((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor; //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) { IRgbColor pColor = ((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor; //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) { IRgbColor pColor = ((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor; //btColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //填充色 cbColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //填充色 nudWidth.Value = Convert.ToDecimal(((IFillSymbol)pStyleGalleryItem.Item).Outline.Width); //边框宽度 pColor = ((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor; //btOutlineColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //边框颜色 cbOutlineColor.BackColor = Color.FromArgb(pColor.Red, pColor.Green, pColor.Blue); //边框颜色 } }
private esriSymbologyStyleClass _symbolStyle; //符号样式的类型:点、线、面 #endregion Fields #region Constructors public SymbolForm(ISimpleRenderer currentSimpleRender) { InitializeComponent(); m_styleGalleryItem = new ServerStyleGalleryItemClass(); m_styleGalleryItem.Item = (object)currentSimpleRender.Symbol;//窗体初始加载时显示当前图层的当前样式图标 }
private void SetFeatureClassStyle(esriSymbologyStyleClass styleClass, ISymbol symbol) { m_styleGalleryItem = null; //Get and set the style class m_axSymbologyControl.StyleClass = styleClass; ISymbologyStyleClass symbologyStyleClass = m_axSymbologyControl.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); }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { //Get the selected item m_styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; }
public static void SetStyleGalleryItem(IStyleGalleryItem styleGalleryItem) { _styleGalleryItem = styleGalleryItem; }
private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { //Get the selected item m_StyleGalleryItem = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).GetSelectedItem(); //Enable ok button button1.Enabled = true; }
private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; Color color; switch (this.axSymbologyControl.StyleClass) { //点符号 case esriSymbologyStyleClass.esriStyleClassMarkerSymbols: color = this.ConvertIRgbColorToColor(((IMarkerSymbol)pStyleGalleryItem.Item).Color as IRgbColor); //设置点符号角度和大小初始值 this.nudAngle.Value = (decimal)((IMarkerSymbol)this.pStyleGalleryItem.Item).Angle; this.nudSize.Value = (decimal)((IMarkerSymbol)this.pStyleGalleryItem.Item).Size; break; //线符号 case esriSymbologyStyleClass.esriStyleClassLineSymbols: color = this.ConvertIRgbColorToColor(((ILineSymbol)pStyleGalleryItem.Item).Color as IRgbColor); //设置线宽初始值 this.nudWidth.Value = (decimal)((ILineSymbol)this.pStyleGalleryItem.Item).Width; break; //面符号 case esriSymbologyStyleClass.esriStyleClassFillSymbols: color = this.ConvertIRgbColorToColor(((IFillSymbol)pStyleGalleryItem.Item).Color as IRgbColor); this.btnOutlineColor.BackColor = this.ConvertIRgbColorToColor(((IFillSymbol)pStyleGalleryItem.Item).Outline.Color as IRgbColor); //设置外框线宽度初始值 this.nudWidth.Value = (decimal)((IFillSymbol)this.pStyleGalleryItem.Item).Outline.Width; break; default: color = Color.Black; break; } //设置按钮背景色 this.btnColor.BackColor = color; //预览符号 this.PreviewImage(); }
private void button2_Click(object sender, System.EventArgs e) { m_styleGalleryItem = null; //hide the form this.Hide(); }
/// <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 btnCancle_Click(object sender, EventArgs e) { pStyleGalleryItem = null; this.Close(); }
//关闭按钮 private void SymbologyForm_FormClosing(object sender, FormClosingEventArgs e) { if (!change) { IStyleGalleryItem pCurrentStyleGalleryItem = new StyleGalleryItem(); pCurrentStyleGalleryItem.Name = "当前符号"; pCurrentStyleGalleryItem.Item = pLegendClass.Symbol; pStyleGalleryItem = pCurrentStyleGalleryItem; } }
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; this.PreviewImage(); // i = pStyleGalleryItem.ID; }