private void ChangeSymbol(DevComponents.DotNetBar.Controls.ComboBoxEx cmb, Color pColor, esriSymbologyStyleClass styleClass) { try { DevComponents.Editors.ComboItem item = cmb.SelectedItem as DevComponents.Editors.ComboItem; object obj = item.Tag; if (obj == null) { return; } IFrameDecoration pFrameDecoration = (IFrameDecoration)obj; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = pColor.R; pRgbColor.Green = pColor.G; pRgbColor.Blue = pColor.B; pFrameDecoration.Color = (IColor)pRgbColor; IStyleGalleryItem pItem = new ServerStyleGalleryItemClass(); pItem.Name = "temp"; pItem.Item = pFrameDecoration; stdole.IPictureDisp picture; System.Drawing.Image image; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(styleClass); picture = symbologyStyleClass.PreviewItem(pItem, cmb.Width - 80, cmb.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); item.Image = image; } catch { } }
private void cmbShadow_SelectionChangeCommitted(object sender, EventArgs e) { DevComponents.Editors.ComboItem item = cmbShadow.SelectedItem as DevComponents.Editors.ComboItem; if (item == null) { return; } IFrameDecoration pFrameDecoration = (IFrameDecoration)(item.Tag); GetDecorationColor(pFrameDecoration, btnShadowColor); }
private void colorShadow_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IFrameDecoration decoration = this.ishadow_0 as IFrameDecoration; IColor color = decoration.Color; this.method_5(this.colorShadow, color); decoration.Color = color; this.cboShadow.Invalidate(); this.method_0(); } }
private void colorBackground_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IFrameDecoration decoration = this.ibackground_0 as IFrameDecoration; IColor color = decoration.Color; this.method_5(this.colorBackground, color); decoration.Color = color; this.cboBackground.Invalidate(); this.method_0(); } }
private void txtShadowGapy_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IFrameDecoration decoration = this.ishadow_0 as IFrameDecoration; try { decoration.VerticalSpacing = double.Parse(this.txtShadowGapy.Text); this.method_0(); } catch { } } }
private void txtShadowCornerRounding_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IFrameDecoration decoration = this.ishadow_0 as IFrameDecoration; try { decoration.CornerRounding = short.Parse(this.txtShadowCornerRounding.Text); this.method_0(); } catch { } } }
private void txtBorderGapx_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IFrameDecoration decoration = this.iborder_0 as IFrameDecoration; try { decoration.HorizontalSpacing = double.Parse(this.txtBorderGapx.Text); this.method_0(); } catch { } } }
//获取颜色 private void GetDecorationColor(IFrameDecoration pFrameDecoration, Button btn) { try { IRgbColor pRgbColor = null; Color pColor; pRgbColor = (IRgbColor)pFrameDecoration.Color; pColor = Color.FromArgb(pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); btn.BackColor = pColor; } catch { btn.BackColor = this.BackColor; } }
private void method_4() { if (this.ishadow_0 == null) { this.colorShadow.Enabled = false; this.txtShadowGapx.Enabled = false; this.txtShadowGapy.Enabled = false; this.txtShadowCornerRounding.Enabled = false; } else { this.colorShadow.Enabled = true; this.txtShadowGapx.Enabled = true; this.txtShadowGapy.Enabled = true; this.txtShadowCornerRounding.Enabled = true; IFrameDecoration decoration = this.ishadow_0 as IFrameDecoration; this.txtShadowGapx.Text = decoration.HorizontalSpacing.ToString("0.##"); this.txtShadowGapy.Text = decoration.VerticalSpacing.ToString("0.##"); this.txtShadowCornerRounding.Text = decoration.CornerRounding.ToString(); this.method_6(this.colorShadow, decoration.Color); } }
private void method_3() { if (this.ibackground_0 == null) { this.colorBackground.Enabled = false; this.txtBackgroundGapx.Enabled = false; this.txtBackgroundGapy.Enabled = false; this.txtBackgroundCornerRounding.Enabled = false; } else { this.colorBackground.Enabled = true; this.txtBackgroundGapx.Enabled = true; this.txtBackgroundGapy.Enabled = true; this.txtBackgroundCornerRounding.Enabled = true; IFrameDecoration decoration = this.ibackground_0 as IFrameDecoration; this.txtBackgroundGapx.Text = decoration.HorizontalSpacing.ToString("0.##"); this.txtBackgroundGapy.Text = decoration.VerticalSpacing.ToString("0.##"); this.txtBackgroundCornerRounding.Text = decoration.CornerRounding.ToString(); this.method_6(this.colorBackground, decoration.Color); } }
private void method_1(IFrameElement iframeElement_1) { IBorder border = iframeElement_1.Border; IBackground background = iframeElement_1.Background; IShadow shadow = (iframeElement_1 as IFrameProperties).Shadow; IStyleGalleryItem oO = null; IFrameDecoration decoration = null; if (border == null) { oO = null; } else { oO = new MyStyleGalleryItem { Name = "<定制>", Item = border }; decoration = border as IFrameDecoration; this.txtGap.Text = decoration.HorizontalSpacing.ToString("0.##"); this.txtRound.Text = decoration.CornerRounding.ToString("0.##"); } this.cboBorder.SelectStyleGalleryItem(oO); if (background == null) { oO = null; } else { oO = new MyStyleGalleryItem { Name = "<定制>", Item = background }; if (decoration == null) { decoration = background as IFrameDecoration; this.txtGap.Text = decoration.HorizontalSpacing.ToString("0.##"); this.txtRound.Text = decoration.CornerRounding.ToString("0.##"); } } this.cboBackground.SelectStyleGalleryItem(oO); if (shadow == null) { oO = null; } else { oO = new MyStyleGalleryItem { Name = "<定制>", Item = shadow }; if (decoration == null) { decoration = shadow as IFrameDecoration; this.txtGap.Text = decoration.HorizontalSpacing.ToString("0.##"); this.txtRound.Text = decoration.CornerRounding.ToString("0.##"); } } this.cboShadow.SelectStyleGalleryItem(oO); }
public bool SetElementProp() { try { //if (txtName.Text.Trim() == "") //{ // MessageBox.Show("请输入变量名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);yjl0616 // return false; //} IElementProperties3 pElementProp = m_pOrgElement as IElementProperties3; if (pElementProp != null) { pElementProp.Name = txtName.Text; } //对于FrameElement的情况 if (m_pOrgElement is IFrameElement) { IFrameProperties pFrameProperty = null; IFrameDecoration pFrameDecoration = null; DevComponents.Editors.ComboItem item = cmbBorder.SelectedItem as DevComponents.Editors.ComboItem; if (cmbBorder.SelectedIndex != -1 && item != null) { IBorder pBorder = (IBorder)(item.Tag); pFrameDecoration = (IFrameDecoration)pBorder; pFrameDecoration.HorizontalSpacing = (double)numBorderGapX.Value; pFrameDecoration.VerticalSpacing = (double)numBorderGapY.Value; pFrameDecoration.CornerRounding = (short)numBorderRound.Value; ((IFrameElement)m_pOrgElement).Border = pBorder; } else { ((IFrameElement)m_pOrgElement).Border = null; } item = cmbBack.SelectedItem as DevComponents.Editors.ComboItem; if (cmbBack.SelectedIndex != -1 && item != null) { IBackground pBackground = (IBackground)(item.Tag); pFrameDecoration = (IFrameDecoration)pBackground; pFrameDecoration.HorizontalSpacing = (double)numBackGapX.Value; pFrameDecoration.VerticalSpacing = (double)numBackGapY.Value; pFrameDecoration.CornerRounding = (short)numBackRound.Value; ((IFrameElement)m_pOrgElement).Background = pBackground; } else { ((IFrameElement)m_pOrgElement).Background = null; } item = cmbShadow.SelectedItem as DevComponents.Editors.ComboItem; if (cmbShadow.SelectedIndex != -1 && item != null) { IShadow pShadow = (IShadow)(item.Tag); pFrameDecoration = (IFrameDecoration)pShadow; pFrameDecoration.HorizontalSpacing = (double)numShadowGapX.Value; pFrameDecoration.VerticalSpacing = (double)numShadowGapY.Value; pFrameDecoration.CornerRounding = (short)numShadowRound.Value; pFrameProperty = (IFrameProperties)m_pOrgElement; pFrameProperty.Shadow = pShadow; } else { pFrameProperty = (IFrameProperties)m_pOrgElement; pFrameProperty.Shadow = null; } } IEnvelope pBounds = new EnvelopeClass(); m_pOrgElement.QueryBounds(m_pDisplay, pBounds); //设置偏移 double dx, dy; IPoint pFromPoint = pBounds.LowerLeft; if (chkUseOffDist.Checked) { dx = Convert.ToDouble(numLowerLeftX.Text); dy = Convert.ToDouble(numLowerLeftY.Text); } else { dx = Convert.ToDouble(numLowerLeftX.Text) - pFromPoint.X; dy = Convert.ToDouble(numLowerLeftY.Text) - pFromPoint.Y; } m_pTransform.Move(dx, dy); //设置缩放 pFromPoint = pBounds.LowerLeft; if (chkUsePercent.Checked) { dx = ((Convert.ToDouble(numWidth.Text) / 100) * pBounds.Width) / pBounds.Width; dy = ((Convert.ToDouble(numHeight.Text) / 100) * pBounds.Width) / pBounds.Height; } else { dx = Convert.ToDouble(numWidth.Text) / pBounds.Width; dy = Convert.ToDouble(numHeight.Text) / pBounds.Height; } m_pTransform.Scale(pFromPoint, dx, dy); //设置符号 if (m_pOrgElement is IMarkerElement) { IMarkerElement pMrkElement = m_pOrgElement as IMarkerElement; IMarkerSymbol pSymbol = (IMarkerSymbol)picPoint.Tag; double dblSize = pMrkElement.Symbol.Size; pMrkElement.Symbol = (IMarkerSymbol)picPoint.Tag; pSymbol.Size = dblSize; pMrkElement.Symbol = pSymbol; } else if (m_pOrgElement is ILineElement) { ILineElement pLinElement = m_pOrgElement as ILineElement; pLinElement.Symbol = (ILineSymbol)picLine.Tag; } else if (m_pOrgElement is IFillShapeElement) { IFillShapeElement pFillElement = m_pOrgElement as IFillShapeElement; pFillElement.Symbol = (IFillSymbol)picPoly.Tag; } else if (m_pOrgElement is ITextElement) { ITextElement pTxtElement = m_pOrgElement as ITextElement; pTxtElement.Text = txtText.Text; pTxtElement.Symbol = (ITextSymbol)picText.Tag; } if (m_pOrgElement is IFrameElement) { //判断指北针,比例尺,比例文本 IMapSurroundFrame pMapSurroundFrame = m_pOrgElement as IMapSurroundFrame; if (pMapSurroundFrame != null) { IMapSurround pMapSurround = pMapSurroundFrame.MapSurround; if (pMapSurround != null) { if (pMapSurround is INorthArrow) { pMapSurroundFrame.MapSurround = (IMapSurround)picArrow.Tag; pMapSurroundFrame.MapSurround.Name = "指北针"; } else if (pMapSurround is IScaleBar) { pMapSurroundFrame.MapSurround = (IMapSurround)picScale.Tag; pMapSurroundFrame.MapSurround.Name = "比例尺"; } else if (pMapSurround is IScaleText) { pMapSurroundFrame.MapSurround = (IMapSurround)picScaleText.Tag; pMapSurroundFrame.MapSurround.Name = "比例尺"; } } } } m_pGraphicCtn.UpdateElement(m_pOrgElement); m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); if (chkUseOffDist.Checked) { numLowerLeftX.Text = "0"; numLowerLeftY.Text = "0"; } if (chkUsePercent.Checked) { numHeight.Text = "100"; numWidth.Text = "100"; } return(true); } catch { //MessageBox.Show("保存属性时出现错误,错误描述为:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } // }
//支持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); } }