Exemplo n.º 1
0
        public void ScalePolyline(IPolyline Raai, double scale)
        {
            ITransform2D TransForm2D = Raai as ITransform2D;


            // Get the center point of the envelope.
            IEnvelope envelope    = Raai.Envelope;
            IPoint    centerPoint = new PointClass();

            centerPoint.X = ((envelope.XMax - envelope.XMin) / 2) + envelope.XMin;
            centerPoint.Y = ((envelope.YMax - envelope.YMin) / 2) + envelope.YMin;

            TransForm2D.Scale(centerPoint, scale, scale);
        }
Exemplo n.º 2
0
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return(null);
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy  = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Scale(m_pCenterPoint, m_dFactorX, m_dFactorY);
         m_bDone = true;
         return(m_pGeomCopy);
     }
 }
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return null;
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Scale(m_pCenterPoint, m_dFactorX, m_dFactorY);
         m_bDone = true;
         return m_pGeomCopy;                
     }
 }
Exemplo n.º 4
0
        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);
            }

            //
        }