private void MoveElement(IElement elem, IPoint new_pos, IAGAnimationContainer pContainer)
        {
            ITransform2D transform2D = elem as ITransform2D;
            IPoint       origin;

            if (elem.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                origin = elem.Geometry as IPoint;
            }
            else
            {
                IEnvelope elementEnvelope = elem.Geometry.Envelope;
                IArea     elementArea     = elementEnvelope as IArea;
                origin = elementArea.Centroid;
            }

            AddPropertySet(elem);

            IElementProperties prop = (IElementProperties)elem; //record the old properties
            IPropertySet       propSet;

            propSet = (IPropertySet)prop.CustomProperty;
            IEnvelope oldEnv = GetElementBound(elem, pContainer);

            propSet.SetProperty("Envelope", oldEnv);

            transform2D.Move(new_pos.X - origin.X, new_pos.Y - origin.Y);
        }
Exemplo n.º 2
0
        public override void OnClick()
        {
            frmInputValue1 frmInputValue = new frmInputValue1();

            frmInputValue.Text = "输入x, y值";
            if (frmInputValue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                double inputValue  = frmInputValue.InputValue1;
                double inputValue2 = frmInputValue.InputValue2;
                double dx          = inputValue - EditTools.CurrentPosition.X;
                double dy          = inputValue2 - EditTools.CurrentPosition.Y;
                Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
                enumFeature.Reset();
                for (IFeature feature = enumFeature.Next(); feature != null; feature = enumFeature.Next())
                {
                    ITransform2D transform2D = feature.Shape as ITransform2D;
                    if (transform2D != null)
                    {
                        transform2D.Move(dx, dy);
                        feature.Shape = (transform2D as IGeometry);
                        feature.Store();
                    }
                }
                Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                (_context.FocusMap as IActiveView).Refresh();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 平移图形要素
        /// </summary>
        /// <param name="element">要平移的对象</param>
        /// <param name="dx">在x方向上的平移量</param>
        /// <param name="dy">在y方向上的平移量</param>
        public static void MoveGeometry(IElement element, double dx, double dy)
        {
            ITransform2D transform2D = element.Geometry as ITransform2D;

            transform2D.Move(dx, dy);
            element.Geometry = transform2D as IGeometry;//移动元素(Element)后,需再次将Geometry赋值给元素,而对要素(Feature)无需此操作
        }
Exemplo n.º 4
0
        public virtual bool Move(double dx, double dy)
        {
            bool rbc = false;

            if (this.pFeature != null)
            {
                if (this.pFeature is IAnnotationFeature)
                {   //是注记要素
                    IAnnotationFeature anFeat = this.pFeature as IAnnotationFeature;
                    IElement           TextEl = (IElement)((IClone)anFeat.Annotation).Clone();
                    ITransform2D       trans  = TextEl as ITransform2D;
                    if (trans != null)
                    {
                        trans.Move(dx, dy);
                    }
                    anFeat.Annotation = TextEl;
                }
                else
                {   //是一般要素
                    IGeometry g = this.pFeature.ShapeCopy;
                    if (g is ITransform2D)
                    {
                        (g as ITransform2D).Move(dx, dy);
                        this.pFeature.Shape = g;
                        rbc = true;
                    }
                }
            }
            return(rbc);
        }
Exemplo n.º 5
0
        public bool GetTK(IPageLayout ipageLayout_0)
        {
            IEnvelope envelope;
            IEnvelope envelope2;

            if (this.string_2.Length == 0)
            {
                return(false);
            }
            IMapFrame frame = (ipageLayout_0 as IActiveView).GraphicsContainer.FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;

            if ((this.double_1 != 0.0) || (this.double_2 != 0.0))
            {
                ipageLayout_0.Page.PutCustomSize(this.double_1 + 6.0, this.double_2 + 6.0);
                envelope  = (frame as IElement).Geometry.Envelope;
                envelope2 = new EnvelopeClass();
                if (this.double_1 == 0.0)
                {
                    this.double_1 = envelope.Width;
                }
                if (this.double_2 == 0.0)
                {
                    this.double_2 = envelope.Height;
                }
                envelope2.PutCoords(envelope.XMin, envelope.YMin, envelope.XMin + this.double_1, envelope.YMin + this.double_2);
                IAffineTransformation2D transformation = new AffineTransformation2DClass();
                transformation.DefineFromEnvelopes(envelope, envelope2);
                ITransform2D transformd = frame as ITransform2D;
                transformd.Transform(esriTransformDirection.esriTransformForward, transformation);
                double dx = 0.0;
                double dy = 0.0;
                if (envelope.XMin < 2.0)
                {
                    dx = 2.0;
                }
                if (envelope.YMin < 2.0)
                {
                    dy = 2.0;
                }
                if ((dx != 0.0) && (dy != 0.0))
                {
                    transformd.Move(dx, dy);
                }
            }
            if (this.double_0 > 0.0)
            {
                envelope = (frame as IElement).Geometry.Envelope;
                double    num3   = (envelope.Width * this.double_0) / 100.0;
                double    num4   = (envelope.Height * this.double_0) / 100.0;
                IEnvelope extent = (frame.Map as IActiveView).Extent;
                envelope2 = new EnvelopeClass();
                envelope2.PutCoords(extent.XMin, extent.YMin, extent.XMin + num3, extent.YMin + num4);
                (frame.Map as IActiveView).Extent = envelope2;
            }
            frame.Border = null;
            return(true);
        }
Exemplo n.º 6
0
        public override bool Move(double dx, double dy)
        {
            bool rbc = false;
            IAnnotationFeature anFeat = this.pFeature as IAnnotationFeature;
            IElement           TextEl = (IElement)((IClone)anFeat.Annotation).Clone();
            ITransform2D       trans  = TextEl as ITransform2D;

            trans.Move(dx, dy);
            anFeat.Annotation = TextEl;
            rbc = true;
            return(rbc);
        }
Exemplo n.º 7
0
        private void moveFeature(int x, int y)
        {
            IFeatureLayer  curLayer = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;
            IWorkspaceEdit iWE      = (curLayer.FeatureClass as IDataset).Workspace as IWorkspaceEdit;

            if (!iWE.IsBeingEdited())
            {
                iWE.StartEditing(false);
            }

            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;
            ISelectionSet     pSS        = curLayerSn.SelectionSet;

            if (pSS.Count != 1)
            {
                return;
            }
            ISelectionSet iSS = (curLayer as IFeatureSelection).SelectionSet;
            ICursor       iCursor;

            iSS.Search(null, false, out iCursor);
            IFeatureCursor iFC        = iCursor as IFeatureCursor;
            IFeature       tmpFeature = iFC.NextFeature();
            IPoint         pPnt       = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            IGeometry      pGeometry  = tmpFeature.ShapeCopy;

            if (pGeometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                pGeometry = pPnt;
            }
            else if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline || pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                double offX = 0, offY = 0;
                offX = pGeometry.Envelope.XMin + pGeometry.Envelope.Width / 2 - pPnt.X;
                offY = pGeometry.Envelope.YMin + pGeometry.Envelope.Height / 2 - pPnt.Y;
                ITransform2D iT2D = pGeometry as ITransform2D;
                iT2D.Move(-offX, -offY);
            }
            iWE.StartEditOperation();
            tmpFeature.Shape = pGeometry;
            tmpFeature.Store();
            iWE.StopEditOperation();
            //iWE.StopEditing(true);
            iWE = null;
            curLayerSn.Clear();
            curLayerSn.Add(tmpFeature);
            m_MapControl.ActiveView.Refresh();
        }
 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.Move(m_dOffsetX, m_dOffsetY);
         m_bDone = true;
         return(m_pGeomCopy);
     }
 }
Exemplo n.º 9
0
        private void method_1()
        {
            int num = 0;

            this.ienumElement_0.Reset();
            for (IElement i = this.ienumElement_0.Next(); i != null; i = this.ienumElement_0.Next())
            {
                if (this.method_6(i))
                {
                    IPoint item = this.ilist_0[num] as IPoint;
                    num++;
                    this.iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, i, null);
                    ITransform2D transform2D = i as ITransform2D;
                    transform2D.Move(-item.X, -item.Y);
                    this.igraphicsContainer_0.UpdateElement(i);
                    this.iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, i, null);
                }
                ElementChangeEvent.ElementPositionChange(i);
            }
        }
        public IPointCollection4 modify1VertexOfAPolyline(IGeometryCollection geo, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            Double   hitDistance = 0; Int32 hitPartIndex = 0;
            Int32    hitSegmentIndex = 0;
            Boolean  rightSide       = false;
            IHitTest hitTest         = (IHitTest)geo;
            Boolean  foundGeometry   = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry         geometry        = geo.get_Geometry(hitPartIndex);
                IPointCollection4 pointCollection = (IPointCollection4)geometry;
                IPoint            transformPoint  = pointCollection.get_Point(hitSegmentIndex);
                ITransform2D      transform2D     = (ITransform2D)transformPoint;
                transform2D.Move(offsetX, offsetY);
                pointCollection.UpdatePoint(hitSegmentIndex, transformPoint);
                return(pointCollection);
            }
            return(null);
        }
        public ISegmentCollection Modify1Segment(IGeometryCollection polyline, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            double   hitDistance = 0; int hitPartIndex = 0;
            int      hitSegmentIndex = 0; bool rightSide = false;
            IHitTest hitTest       = (IHitTest)polyline;
            bool     foundGeometry = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry          geometry          = polyline.get_Geometry(hitPartIndex);
                ISegmentCollection segmentCollection =
                    (ISegmentCollection)geometry;
                ISegment     segment     = segmentCollection.get_Segment(hitSegmentIndex);
                ITransform2D transform2D = (ITransform2D)segment;
                transform2D.Move(offsetX, offsetY);
                segmentCollection.SegmentsChanged();
                return(segmentCollection);
            }
            return(null);
        }
Exemplo n.º 12
0
        //开始平移 事件
        private void Btn_MapMove_Click(object sender, EventArgs e)
        {
            frmProgressBar2 pb2 = null;

            try
            {
                this.Btn_MapMove.Enabled = false;
                this.Cursor = Cursors.WaitCursor;
                string LineText = "";

                double dx = 0.0;
                double dy = 0.0;

                dx = CommonClass.TNum(this.numericBox1.Text.Trim());
                dy = CommonClass.TNum(this.numericBox2.Text.Trim());

                if (MessageBox.Show("请确认是否要对选中项进行整体平移操作?", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.Btn_MapMove.Enabled = true;
                    this.Cursor = Cursors.Default;
                    return;
                }

                //获取选中的要素类
                List <IFeatureClass> fcList = new List <IFeatureClass>();
                for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
                {
                    if (this.checkedListBox1.GetItemChecked(i) == true)
                    {   //选中要素类
                        CommonComboBoxItem cbitem = this.checkedListBox1.Items[i] as CommonComboBoxItem;
                        fcList.Add(cbitem.Tag as IFeatureClass);
                    }
                }
                if (fcList != null && fcList.Count > 0)
                {
                    pb2      = new frmProgressBar2();
                    pb2.Text = "平移进度...";
                    pb2.progressBar1.Maximum = fcList.Count + 1;
                    pb2.progressBar1.Value   = 0;
                    pb2.Caption1.Text        = "正在平移...";
                    pb2.Show(this);
                    Application.DoEvents();
                    //
                    ZHFeaturePoint zhfeat    = null;
                    int            featIndex = 0;
                    int            featCount = 0;
                    for (int i = 0; i < fcList.Count; i++)
                    {
                        featIndex = 0;
                        IFeatureClass fc = fcList[i];
                        pb2.Caption1.Text      = "正在平移图层:" + fc.AliasName + "...";
                        pb2.progressBar1.Value = i;
                        Application.DoEvents();
                        //
                        featCount = fc.FeatureCount(null);
                        pb2.progressBar2.Value   = 0;
                        pb2.progressBar2.Maximum = featCount + 1;
                        pb2.Caption2.Text        = "正在平移要素...";
                        Application.DoEvents();
                        //
                        IFeatureCursor fcur = fc.Update(null, false);
                        IFeature       feat = fcur.NextFeature();
                        while (feat != null)
                        {
                            featIndex += 1;
                            if (featIndex % 200 == 0)
                            {
                                pb2.Caption2.Text      = "正在平移图层:" + fc.AliasName + "(当前:" + featIndex.ToString() + "/" + featCount.ToString() + ")";
                                pb2.progressBar2.Value = featIndex;
                                Application.DoEvents();
                                fcur.Flush();
                            }
                            zhfeat = new ZHFeaturePoint(feat);
                            if (fc.FeatureType == esriFeatureType.esriFTAnnotation)
                            {   //注记要素移动 OK
                                IAnnotationFeature anFeat = feat as IAnnotationFeature;
                                IElement           TextEl = (IElement)((IClone)anFeat.Annotation).Clone();
                                ITransform2D       trans  = TextEl as ITransform2D;
                                trans.Move(dx, dy);
                                anFeat.Annotation = TextEl;
                                fcur.UpdateFeature(feat);
                            }
                            else
                            {   //一般要素移动 OK
                                zhfeat.Move(dx, dy);
                                fcur.UpdateFeature(feat);
                            }
                            //
                            feat = fcur.NextFeature();
                        }
                        fcur.Flush();
                        if (fcur != null)
                        {
                            TokayWorkspace.ComRelease(fcur);
                            fcur = null;
                        }
                        pb2.Caption2.Text = "正在重新计算Extent范围...";
                        Application.DoEvents();
                        //重新计算Extent范围
                        TokayWorkspace.UpdateExtent(fc);
                    }
                    if (pb2 != null)
                    {
                        pb2.Close();
                        pb2.Dispose();
                        pb2 = null;
                    }
                    MessageBox.Show("地图平移完毕!", "提示");
                }
            }
            catch (Exception ee)
            {
                Log.WriteLine(ee);
                MessageBox.Show(ee.Message, "提示");
            }
            finally
            {
                this.Btn_MapMove.Enabled = true;
                this.Cursor = Cursors.Default;
                if (pb2 != null)
                {
                    pb2.Close();
                    pb2.Dispose();
                    pb2 = null;
                }
            }
        }
Exemplo n.º 13
0
        private void InsertPicture()
        {
            try
            {
                OpenFileDialog filedlg = new OpenFileDialog();
                filedlg.Filter = "图像文件 (*.jpg;*.bmp;*.gif;*.tif;*.emf)|*.jpg;*.bmp;*.gif;*.tif;*.emf";
                filedlg.Title  = "选择图像文件";

                if (filedlg.ShowDialog() == DialogResult.OK)
                {
                    string sPath = filedlg.FileName;
                    int    pos   = sPath.LastIndexOf('.');
                    string sExt  = sPath.Substring(pos + 1);

                    IPictureElement3 pPicElement = null;
                    switch (sExt.ToLower())
                    {
                    case "jpg":
                        pPicElement = new JpgPictureElementClass();
                        break;

                    case "bmp":
                        pPicElement = new BmpPictureElementClass();
                        break;

                    case "gif":
                        pPicElement = new GifPictureElementClass();
                        break;

                    case "tif":
                        pPicElement = new TifPictureElementClass();
                        break;

                    case "emf":
                        pPicElement = new EmfPictureElementClass();
                        break;

                    default:
                        break;
                    }
                    if (pPicElement == null)
                    {
                        return;
                    }
                    pPicElement.ImportPictureFromFile(sPath);
                    pPicElement.SavePictureInDocument = true;
                    pPicElement.MaintainAspectRatio   = true;

                    IElementProperties pElementProp = (IElementProperties)pPicElement;
                    pElementProp.Name = sPath;

                    double picWidth = 0, picHeight = 0;
                    pPicElement.QueryIntrinsicSize(ref picWidth, ref picHeight);  //得到图片的象素点

                    //象素点转换成厘米
                    picWidth  = picWidth / 37.79;
                    picHeight = picHeight / 37.79;

                    //将厘米转换为当前Page单位
                    ConvertUnit(m_pHookHelper.PageLayout.Page.Units, ref picWidth, ref picHeight);

                    IPolygon         pPoly     = new PolygonClass();
                    IPointCollection pPntCln   = (IPointCollection)pPoly;
                    object           obj       = System.Type.Missing;
                    IPoint           pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(picWidth, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(picWidth, picHeight);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, picHeight);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    double pageWidth, pageHeight;
                    m_pHookHelper.PageLayout.Page.QuerySize(out pageWidth, out pageHeight);

                    ITransform2D pTrans = (ITransform2D)pPoly;
                    pTrans.Move(pageWidth / 2 - picWidth / 2, pageHeight / 2 - picHeight / 2);

                    IElement pElement = null;
                    pElement          = (IElement)pPicElement;
                    pElement.Geometry = pPoly;

                    IGraphicsContainer       pContainer   = (IGraphicsContainer)m_pHookHelper.PageLayout;
                    IGraphicsContainerSelect pGraphicsSel = pContainer as IGraphicsContainerSelect;
                    pGraphicsSel.UnselectAllElements();
                    pGraphicsSel.SelectElement(pElement);
                    pContainer.AddElement(pElement, 0);
                    m_pHookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("插入图片失败:" + ex.Message, "提示");
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 平移图形
        /// </summary>
        /// <param name="geometry">要平移的对象</param>
        /// <param name="dx">在x方向上的平移量</param>
        /// <param name="dy">在y方向上的平移量</param>
        public static void MoveGeometry(IGeometry geometry, double dx, double dy)
        {
            ITransform2D transform2D = geometry as ITransform2D;

            transform2D.Move(dx, dy);
        }
        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.Move(m_dOffsetX, m_dOffsetY);
                m_bDone = true;
                return m_pGeomCopy;
            }

        }
Exemplo n.º 16
0
        /// <summary>
        /// 平移图形元素
        /// </summary>
        /// <param name="feature">要平移的对象</param>
        /// <param name="dx">在x方向上的平移量</param>
        /// <param name="dy">在y方向上的平移量</param>
        public static void MoveGeometry(IFeature feature, double dx, double dy)
        {
            ITransform2D transform2D = feature.Shape as ITransform2D;

            transform2D.Move(dx, dy);
        }
Exemplo n.º 17
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);
            }

            //
        }
Exemplo n.º 18
0
        public static IGeometry GetExample11()
        {
            const double CircleDegrees         = 360.0;
            const int    CircleDivisions       = 36;
            const double VectorComponentOffset = 0.0000001;
            const double CircleRadius          = 3.0;
            const double BaseZ = 0.0;

            //Extrusion: 3D Circle Polyline Extruded Along 3D Line Via ConstructExtrudeAlongLine()

            IPointCollection polylinePointCollection = new PolylineClass();

            IGeometry polylineGeometry = polylinePointCollection as IGeometry;

            GeometryUtilities.MakeZAware(polylineGeometry);

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10);

            IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10);

            lowerAxisVector3D.XComponent += VectorComponentOffset;

            IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;

            normalVector3D.Magnitude = CircleRadius;

            double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions);

            for (int i = 0; i < CircleDivisions; i++)
            {
                normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D);

                IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent,
                                                                        originPoint.Y + normalVector3D.YComponent,
                                                                        BaseZ);

                polylinePointCollection.AddPoint(vertexPoint, ref _missing, ref _missing);
            }

            polylinePointCollection.AddPoint(polylinePointCollection.get_Point(0), ref _missing, ref _missing);

            ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            //Define Line To Extrude Along

            ILine extrusionLine = new LineClass();

            extrusionLine.FromPoint = GeometryUtilities.ConstructPoint3D(-4, -4, -5);
            extrusionLine.ToPoint   = GeometryUtilities.ConstructPoint3D(4, 4, 5);

            //Perform Extrusion

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrudeAlongLine(extrusionLine, polylineGeometry);

            //Transform Extrusion Result

            IPoint centroid = GeometryUtilities.ConstructPoint2D(0.5 * (polylineGeometry.Envelope.XMax + polylineGeometry.Envelope.XMin),
                                                                 0.5 * (polylineGeometry.Envelope.YMax + polylineGeometry.Envelope.YMin));

            ITransform2D transform2D = constructMultiPatch as ITransform2D;

            transform2D.Move(extrusionLine.FromPoint.X - centroid.X, extrusionLine.FromPoint.Y - centroid.Y);

            return(constructMultiPatch as IGeometry);
        }
Exemplo n.º 19
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_command.OnClick();
            m_hookHelper.ActiveView.Refresh();
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint);
            IFeatureLayer featureLayer = GIS.Common.DataEditCommon.copypasteLayer;

            if (featureLayer == null)
            {
                return;
            }
            IFeatureSelection m_featureSelection = featureLayer as IFeatureSelection;

            ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = m_featureSelection.SelectionSet;
            if (m_selectionSet.Count == 0)
            {
                return;
            }
            IFeatureClass pFeatureClass = featureLayer.FeatureClass;
            ICursor       pCursor       = null;

            m_selectionSet.Search(null, false, out pCursor);
            IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor;
            IFeature       m_pFeature     = pFeatureCursor.NextFeature();
            double         dx             = 0;
            double         dy             = 0;

            if (m_pFeature == null)
            {
                return;
            }
            DataEditCommon.InitEditEnvironment();
            DataEditCommon.CheckEditState();
            while (m_pFeature != null)
            {
                ITransform2D pTrans2D = m_pFeature.ShapeCopy as ITransform2D;
                if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry0Dimension)
                {
                    IPoint pt = m_pFeature.Shape as IPoint;
                    if (dx == 0)
                    {
                        dx = pPoint.X - pt.X;
                    }
                    if (dy == 0)
                    {
                        dy = pPoint.Y - pt.Y;
                    }
                    pTrans2D.Move(dx, dy);
                    m_pFeature.Shape = pTrans2D as IGeometry;
                    m_pFeature.Store();
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry1Dimension)
                {
                    IPolyline lPolyline = m_pFeature.Shape as IPolyline;
                    if (dx == 0)
                    {
                        dx = pPoint.X - lPolyline.FromPoint.X;
                    }
                    if (dy == 0)
                    {
                        dy = pPoint.Y - lPolyline.FromPoint.Y;
                    }
                    pTrans2D.Move(dx, dy);
                    m_pFeature.Shape = pTrans2D as IGeometry;
                    m_pFeature.Store();
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry2Dimension)
                {
                    if (m_pFeature.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        IAnnotationFeature annoFeature = m_pFeature as IAnnotationFeature;

                        IElement     element     = (IElement)annoFeature.Annotation;
                        ITextElement textElement = new TextElementClass();
                        IPoint       mPoint      = element.Geometry as IPoint;
                        pTrans2D = mPoint as ITransform2D;
                        if (dx == 0)
                        {
                            dx = pPoint.X - mPoint.X;
                        }
                        if (dy == 0)
                        {
                            dy = pPoint.Y - mPoint.Y;
                        }
                        pTrans2D.Move(dx, dy);
                        element.Geometry       = pTrans2D as IGeometry;
                        annoFeature.Annotation = element;
                        m_pFeature.Store();
                    }
                    else
                    {
                        IPolygon lPolyline = m_pFeature.Shape as IPolygon;
                        if (dx == 0)
                        {
                            dx = pPoint.X - lPolyline.FromPoint.X;
                        }
                        if (dy == 0)
                        {
                            dy = pPoint.Y - lPolyline.FromPoint.Y;
                        }
                        pTrans2D.Move(dx, dy);
                        m_pFeature.Shape = pTrans2D as IGeometry;
                        m_pFeature.Store();
                    }
                }
                else
                {
                }
                m_pFeature = pFeatureCursor.NextFeature();
            }
            DataEditCommon.g_engineEditor.StopOperation("editpaste");
            GIS.Common.DataEditCommon.copypaste = 0;
            DataEditCommon.copypasteLayer       = null;
            m_hookHelper.ActiveView.Refresh();
            //IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            //pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint);
            //IFeatureLayer featureLayer = DataEditCommon.g_pLayer as IFeatureLayer;
            //if (featureLayer == null) return;
            //if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == featureLayer.FeatureClass.ShapeType && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType == featureLayer.FeatureClass.FeatureType)
            //{
            //    ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = DataEditCommon.MyCopy.m_selectionSet;
            //    for (int i = 0; i < m_selectionSet.Count; i++)
            //    {

            //    }
            //}
            //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && featureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
            //{

            //}
            //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType!=esriFeatureType.esriFTAnnotation&& featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            //{

            //}
            //DataEditCommon.InitEditEnvironment();
            //DataEditCommon.CheckEditState();
        }
Exemplo n.º 20
0
        void AlignElementMethod(string name, string h, string v, string hDirection, string vDirection, bool isPage)
        {
            IElement           targetEle = null;
            double             xmin      = 0;
            double             xmax      = 0;
            double             ymin      = 0;
            double             ymax      = 0;
            IEnvelope          targetEnv = new EnvelopeClass() as IEnvelope;
            IGraphicsContainer cont      = ArcMap.Document.ActiveView as IGraphicsContainer;

            if (!isPage)
            {
                cont.Reset();
                IElement ele = cont.Next();
                while (ele != null)
                {
                    IElementProperties3 pros = ele as IElementProperties3;
                    if (pros.Name == name)
                    {
                        targetEle = ele;
                        break;
                    }
                    ele = cont.Next();
                }
                if (targetEle == null)
                {
                    return;
                }
                targetEle.QueryBounds(ArcMap.Document.ActiveView.ScreenDisplay, targetEnv);
                xmin = targetEnv.XMin;
                xmax = targetEnv.XMax;
                ymin = targetEnv.YMin;
                ymax = targetEnv.YMax;
            }
            else
            {
                IPageLayout layout = ArcMap.Document.ActiveView as IPageLayout;
                IPage       pg     = layout.Page;
                pg.QuerySize(out xmax, out ymax);
            }

            double vH = 0;
            double vV = 0;
            bool   bH = double.TryParse(h, out vH);
            bool   bV = double.TryParse(v, out vV);

            IGraphicsContainerSelect contAlign = ArcMap.Document.ActiveView as IGraphicsContainerSelect;
            IEnumElement             enumEle   = contAlign.SelectedElements;
            IElement eleSel = enumEle.Next();

            while (eleSel != null)
            {
                IElementProperties3 pros = eleSel as IElementProperties3;
                IEnvelope           env  = new EnvelopeClass() as IEnvelope;
                eleSel.QueryBounds(ArcMap.Document.ActiveView.ScreenDisplay, env);
                double dx = 0;
                double dy = 0;
                if (bH)
                {
                    if (hDirection == "左侧Left")
                    {
                        dx = xmin - env.XMin - vH;
                    }
                    else
                    {
                        dx = xmax - env.XMax + vH;
                    }
                }
                if (bV)
                {
                    if (vDirection == "上侧Top")
                    {
                        dy = ymax - env.YMax + vV;
                    }
                    else
                    {
                        dy = ymin - env.YMin - vV;
                    }
                }
                ITransform2D trans = eleSel.Geometry as ITransform2D;
                trans.Move(dx, dy);
                eleSel.Geometry = trans as IGeometry;
                cont.UpdateElement(eleSel);
                eleSel = enumEle.Next();
            }
            ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGraphicSelection, null, null);
        }