//支持6中element,点,线,面,注记,Inkgraphic,MapFrame private bool GetProperty(IDisplay pDisplay, IElement pElement) { try { //获得FrameELEment的属性 if (pElement is IFrameElement) { IFrameProperties pFrameProperty = (IFrameProperties)pElement; IFrameDecoration pFrameDecoration = null; IClone pClone; int i; bool bExist = false; //得到地图边框属性 if (pFrameProperty.Border != null) { pFrameDecoration = (IFrameDecoration)pFrameProperty.Border; //判断和列表框中的符号是否相同 bExist = false; for (i = 0; i < cmbBorder.Items.Count; i++) { pClone = (IClone)pFrameProperty.Border; DevComponents.Editors.ComboItem item = cmbBorder.Items[i] as DevComponents.Editors.ComboItem; if (item == null) { continue; } if (pClone.Equals(item.Tag)) { bExist = true; break; } } if (bExist) { cmbBorder.SelectedIndex = i; } else { PreViewCustom(cmbBorder, pFrameProperty.Border, esriSymbologyStyleClass.esriStyleClassBorders); } GetDecorationColor(pFrameDecoration, btnBorderColor); numBorderGapX.Value = (decimal)pFrameDecoration.HorizontalSpacing; numBorderGapY.Value = (decimal)pFrameDecoration.VerticalSpacing; numBorderRound.Value = (decimal)pFrameDecoration.CornerRounding; } //得到地图背景属性 if (pFrameProperty.Background != null) { pFrameDecoration = (IFrameDecoration)((IFrameElement)pElement).Background; //判断和列表框中的符号是否相同 bExist = false; for (i = 0; i < cmbBack.Items.Count; i++) { pClone = (IClone)pFrameProperty.Background; DevComponents.Editors.ComboItem item = cmbBack.Items[i] as DevComponents.Editors.ComboItem; if (item == null) { continue; } if (pClone.Equals(item.Tag)) { bExist = true; break; } } if (bExist) { cmbBack.SelectedIndex = i; } else { PreViewCustom(cmbBack, pFrameProperty.Background, esriSymbologyStyleClass.esriStyleClassBackgrounds); } GetDecorationColor(pFrameDecoration, btnBackColor); numBackGapX.Value = (decimal)pFrameDecoration.HorizontalSpacing; numBackGapY.Value = (decimal)pFrameDecoration.VerticalSpacing; numBackRound.Value = (decimal)pFrameDecoration.CornerRounding; } //得到地图阴影属性 if (pFrameProperty.Shadow != null) { pFrameDecoration = (IFrameDecoration)pFrameProperty.Shadow; //判断和列表框中的符号是否相同 bExist = false; for (i = 0; i < cmbShadow.Items.Count; i++) { pClone = (IClone)pFrameProperty.Shadow; DevComponents.Editors.ComboItem item = cmbShadow.Items[i] as DevComponents.Editors.ComboItem; if (item == null) { continue; } if (pClone.Equals(item.Tag)) { bExist = true; break; } } if (bExist) { cmbShadow.SelectedIndex = i; } else { PreViewCustom(cmbShadow, pFrameProperty.Shadow, esriSymbologyStyleClass.esriStyleClassShadows); } GetDecorationColor(pFrameDecoration, btnShadowColor); numShadowGapX.Value = (decimal)pFrameDecoration.HorizontalSpacing; numShadowGapY.Value = (decimal)pFrameDecoration.VerticalSpacing; numShadowRound.Value = (decimal)pFrameDecoration.CornerRounding; } } IElementProperties3 pElementProp = pElement as IElementProperties3; txtName.Text = pElementProp.Name; IEnvelope pBounds = new EnvelopeClass(); pElement.QueryBounds(pDisplay, pBounds); IArea pArea = (IArea)pBounds; numCenterX.Text = pArea.Centroid.X.ToString("f4"); numCenterY.Text = pArea.Centroid.Y.ToString("f4"); numHeight.Text = pBounds.Height.ToString("f4"); numWidth.Text = pBounds.Width.ToString("f4"); numLowerLeftX.Text = pBounds.LowerLeft.X.ToString("f4"); numLowerLeftY.Text = pBounds.LowerLeft.Y.ToString("f4"); if (pElement is IMarkerElement) { IMarkerElement pMrkElement = pElement as IMarkerElement; picPoint.Tag = pMrkElement.Symbol; PreViewSymbol((ISymbol)picPoint.Tag, ref picPoint); } else if (pElement is ILineElement) { ILineElement pLinElement = pElement as ILineElement; picLine.Tag = pLinElement.Symbol; PreViewSymbol((ISymbol)picLine.Tag, ref picLine); } else if (pElement is IFillShapeElement) { IFillShapeElement pFillElement = pElement as IFillShapeElement; picPoly.Tag = pFillElement.Symbol; PreViewSymbol((ISymbol)picPoly.Tag, ref picPoly); //得到面积 pArea = (IArea)pElement.Geometry; numArea.Text = pArea.Area.ToString("0.00"); //得到周长 IPolygon pPolygon = new PolygonClass(); pElement.QueryOutline(m_pDisplay, pPolygon); IRing pOutRing = new RingClass(); pPolygon.QueryExteriorRings(ref pOutRing); numLength.Text = pOutRing.Length.ToString("0.00"); } else if (pElement is ITextElement) { ITextElement pTxtElement = pElement as ITextElement; txtText.Text = pTxtElement.Text; picText.Tag = pTxtElement.Symbol; PreViewSymbol((ISymbol)picText.Tag, ref picText); } if (pElement is IFrameElement) { //判断指北针,比例尺,比例文本 IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame; if (pMapSurroundFrame != null) { IMapSurround pMapSurround = pMapSurroundFrame.MapSurround; if (pMapSurround != null) { if (pMapSurround is INorthArrow) { picArrow.Tag = pMapSurround; PreViewSymbol(pMapSurround, ref picArrow); } else if (pMapSurround is IScaleBar) { picScale.Tag = pMapSurround; PreViewSymbol(pMapSurround, ref picScale); } else if (pMapSurround is IScaleText) { picScaleText.Tag = pMapSurround; PreViewSymbol(pMapSurround, ref picScaleText); } } } } return(true); } catch (Exception ex) { MessageBox.Show("显示属性出错:" + ex.Message); return(false); } }