コード例 #1
0
        public override void OnClick()
        {
            IFeatureClass fc = (MoData.v_CurLayer as IFeatureLayer).FeatureClass;

            foreach (KeyValuePair <IGeometry, IElement> item in GeometriesToBePasted)
            {
                if (fc.ShapeType != item.Key.GeometryType)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "几何类型不匹配!");
                    return;
                }
            }

            MoData.v_CurWorkspaceEdit.StartEditOperation();
            IFeatureCursor cursor = fc.Insert(true);

            IFeatureBuffer buffer  = fc.CreateFeatureBuffer();
            IFeature       feature = buffer as IFeature;

            foreach (KeyValuePair <IGeometry, IElement> item in GeometriesToBePasted)
            {
                Exception Err = null;
                try
                {
                    feature.Shape = item.Key;
                }
                catch (Exception exErr)
                {
                    //******************************************
                    //guozheng added System Exception log
                    if (SysCommon.Log.Module.SysLog == null)
                    {
                        SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    }
                    SysCommon.Log.Module.SysLog.Write(exErr);
                    //******************************************

                    Err = exErr;
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", exErr.Message);
                }

                if (Err == null)
                {
                    if (feature.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        IAnnotationFeature af = feature as IAnnotationFeature;
                        af.Annotation = item.Value;

                        feature = af as IFeature;
                    }

                    buffer = feature as IFeatureBuffer;
                    cursor.InsertFeature(buffer);
                }
            }

            cursor.Flush();
            MoData.v_CurWorkspaceEdit.StopEditOperation();
            myHook.MapControl.ActiveView.Refresh();
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            IWorkspaceEdit workspace = null;

            for (int i = 0; i < this.m_pAnnoFeatureList.Count; i++)
            {
                IAnnotationFeature feature = this.m_pAnnoFeatureList[i] as IAnnotationFeature;
                try
                {
                    if (workspace == null)
                    {
                        IDataset dataset = (feature as IObject).Class as IDataset;
                        workspace = dataset.Workspace as IWorkspaceEdit;
                        workspace.StartEditOperation();
                    }
                    ITextElement annotation = feature.Annotation as ITextElement;
                    annotation.Symbol  = this.m_pTextElement.Symbol;
                    feature.Annotation = annotation as IElement;
                    (feature as IFeature).Store();
                }
                catch (Exception exception)
                {
                    Logger.Current.Error("", exception, "");
                }
            }
            if (workspace != null)
            {
                workspace.StopEditOperation();
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        ///     Updates the field with the specified field <paramref name="index" /> with the <paramref name="value" /> for the
        ///     row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="index">The index.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="System.ArgumentNullException">row</exception>
        /// <exception cref="System.IndexOutOfRangeException"></exception>
        protected virtual void SetValue(IRow row, int index, object value)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (index < 0 || index > row.Fields.FieldCount - 1)
            {
                throw new IndexOutOfRangeException();
            }

            IAnnotationFeature annoFeature = row as IAnnotationFeature;
            IElement           element     = value as IElement;

            if (annoFeature != null && element != null)
            {
                // We have to handle Annotation a little different because the ELEMENT field is controlled by an interface called
                // IAnnotationFeature that is responsible for setting the element and the Shape.
                IFeatureClass             oclass    = (IFeatureClass)row.Table;
                IAnnotationClassExtension annoClass = oclass.Extension as IAnnotationClassExtension;
                if (annoClass != null)
                {
                    int elementFieldIndex = annoClass.ElementFieldIndex;
                    if (index == elementFieldIndex)
                    {
                        annoFeature.Annotation = element;
                        return;
                    }
                }
            }

            row.Value[index] = value;
        }
コード例 #5
0
        private void btnSelectDatumPoint_Click(object sender, EventArgs e)
        {
            if (cmbDirection.SelectedItem == null)
            {
                return;
            }
            enumAnnotationDirection direction = enumAnnotationDirection.RightUp;

            switch (cmbDirection.SelectedItem.ToString())
            {
            case "左上":
                direction = enumAnnotationDirection.LeftUp;
                break;

            case "右上":
                direction = enumAnnotationDirection.RightUp;
                break;

            case "右下":
                direction = enumAnnotationDirection.RightDown;
                break;

            case "左下":
                direction = enumAnnotationDirection.LeftDown;
                break;
            }
            CmdGetTargetPoint tool = new CmdGetTargetPoint(_context, _plugin);

            _context.CurrentTool        = tool;
            tool.MouseDownEventHandler += delegate(IPoint point)
            {
                List <IPolygon> polygons = CommonHelper.GetMovedPoints(_annotationFeatures, point, direction);
                for (int i = 0; i < _annotationFeatures.Count; i++)
                {
                    IFeature pFeature = _annotationFeatures[i];
                    pFeature.Shape = polygons[i];
                    pFeature.Store();
                    IAnnotationFeature pAnnotationFeature = pFeature as IAnnotationFeature;
                    if (pAnnotationFeature == null)
                    {
                        continue;
                    }
                    IElement pElement = pAnnotationFeature.Annotation as IElement;
                    pElement.Geometry = new PointClass
                    {
                        X = (polygons[i].Envelope.XMin + polygons[i].Envelope.XMax) / 2,
                        Y = (polygons[i].Envelope.YMin + polygons[i].Envelope.YMax) / 2
                    };
                    pAnnotationFeature.Annotation = pElement;
                    pFeature.Store();
                }
                _context.FocusMap.ClearSelection();
                _context.ActiveView.Refresh();
            };
        }
コード例 #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);
        }
コード例 #7
0
ファイル: CmdCheQiLianDong.cs プロジェクト: secondii/Yutai
        public override void OnDblClick()
        {
            try
            {
                if (_lineFeedback == null)
                {
                    return;
                }
                IPolyline polyline = _lineFeedback.Stop();
                _context.ActiveView.Refresh();
                _lineFeedback = null;
                if (polyline == null)
                {
                    return;
                }
                IPointCollection pointCollection    = _lineFeature.Shape as IPointCollection;
                IPointCollection newPointCollection = polyline as IPointCollection;

                IAnnotationFeature annotationFeature = _annoFeature as IAnnotationFeature;
                if (annotationFeature == null)
                {
                    return;
                }
                IElement element   = annotationFeature.Annotation;
                IPoint   annoPoint = new PointClass();
                annoPoint.X = (element.Geometry as IPoint).X +
                              (polyline.ToPoint.X -
                               pointCollection.Point[pointCollection.PointCount - 2].X);
                annoPoint.Y = (element.Geometry as IPoint).Y +
                              (polyline.ToPoint.Y -
                               pointCollection.Point[pointCollection.PointCount - 2].Y);
                element.Geometry             = annoPoint;
                annotationFeature.Annotation = element;
                _annoFeature.Store();

                IPoint toPoint = new PointClass();
                toPoint.X = newPointCollection.Point[newPointCollection.PointCount - 1].X +
                            (pointCollection.Point[pointCollection.PointCount - 1].X -
                             pointCollection.Point[pointCollection.PointCount - 2].X);
                toPoint.Y = newPointCollection.Point[newPointCollection.PointCount - 1].Y +
                            (pointCollection.Point[pointCollection.PointCount - 1].Y -
                             pointCollection.Point[pointCollection.PointCount - 2].Y);
                newPointCollection.AddPoint(toPoint);
                _lineFeature.Shape = newPointCollection as IPolyline;
                _lineFeature.Store();
                _context.ActiveView.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #8
0
        public override void OnClick()
        {
            Dictionary <IGeometry, IElement> ges = new Dictionary <IGeometry, IElement>();

            MoData.v_CurWorkspaceEdit.StartEditOperation();

            IEnumFeature features = myHook.MapControl.Map.FeatureSelection as IEnumFeature;

            features.Reset();
            IFeature feature = features.Next();

            while (feature != null)
            {
                IDataset       pDataset       = feature.Class as IDataset;
                IWorkspaceEdit pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                if (pWorkspaceEdit.IsBeingEdited())
                {
                    IElement ele = null;
                    if (feature is IAnnotationFeature)
                    {
                        IAnnotationFeature af = feature as IAnnotationFeature;
                        ele = af.Annotation;
                    }

                    ges.Add(feature.ShapeCopy, ele);
                    try
                    {
                        feature.Delete();
                    }
                    catch (Exception eError)
                    {
                        //******************************************
                        //guozheng added System Exception log
                        if (SysCommon.Log.Module.SysLog == null)
                        {
                            SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                        }
                        SysCommon.Log.Module.SysLog.Write(eError);
                        //******************************************

                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("Ìáʾ", "¼ôÇÐʧ°Ü£¡\nÇëʹÓá®Êý¾Ý±à¼­¡¯Öеġ®ÒªËر༭¡¯Ñ¡ÔñÒªËؽøÐмôÇвÙ×÷¡£");
                    }
                }
                feature = features.Next();
            }

            MoData.v_CurWorkspaceEdit.StopEditOperation();
            ControlsPaste.GeometriesToBePasted = ges;

            myHook.MapControl.ActiveView.Refresh();
        }
コード例 #9
0
ファイル: AnnotationEntity.cs プロジェクト: zj8487/HyDM
		/// <summary>
		/// 创建注记实体
		/// </summary>
        /// <param name="pITable">数据表对象</param>
        /// <param name="entinyNode">VCT空间实体节点</param>
        public override void CreateFeature(ITable pITable, EntityNode entinyNode)
        {
            try
            {
                AnnotationNode pAnnotationNode = entinyNode as AnnotationNode;
                if (pAnnotationNode != null)
                {
                    IFeatureClass pFeatureCls = pITable as IFeatureClass;
                    this.Feature = pFeatureCls.CreateFeature();

                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        this.Feature.set_Value(dBSMIndex, pAnnotationNode.EntityID);

                    ///要素代码赋值
                    int dSYDMIndex = -1;
                    dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                    if (dSYDMIndex != -1)
                        this.Feature.set_Value(dSYDMIndex, pAnnotationNode.FeatureCode);

                    IAnnotationFeature pAnnotationFeature = Feature as IAnnotationFeature;
                    if (pAnnotationFeature != null)
                    {
                        /////注记内容赋值
                        ITextElement pTextElement = new TextElementClass();
                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Angle = pAnnotationNode.Angle;


                        pTextElement.Text = pAnnotationNode.Text;
                        pTextElement.Symbol = pTextSymbol;
                        pAnnotationFeature.Annotation = pTextElement as IElement;
                    }

                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(pAnnotationNode.PointLocation.X, pAnnotationNode.PointLocation.Y);

                    (this.Feature as IFeature).Shape = pPoint;

                    this.Feature.Store();
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
            }
		}
コード例 #10
0
ファイル: CoordConvert.cs プロジェクト: wwcc19870805/DIFGIS
        //注记要素坐标转换
        private void CoordConvertAnnotationFeature(IFeature inFeature, ref IFeature outFeature)
        {
            try
            {
                IAnnotationFeature afin  = inFeature as IAnnotationFeature;
                IAnnotationFeature afout = outFeature as IAnnotationFeature;

                IGeometry pTempGeo = afin.Annotation.Geometry;
                GeometryCoordConvert(ref pTempGeo, m_A1, m_B1, m_C1, m_A2, m_B2, m_C2, m_A3, m_C3);

                IFields fields                   = inFeature.Fields;
                int     shapeIndex               = outFeature.Fields.FindField("SHAPE");
                int     angleIndex               = outFeature.Fields.FindField("Angle");
                int     characterWidthIndex      = outFeature.Fields.FindField("CHARACTERWIDTH");
                int     characterWidthIndexValue = 0;
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    int outFeatureFieldIndex = outFeature.Fields.FindField(fields.get_Field(i).Name);
                    if (outFeature.Fields.get_Field(outFeatureFieldIndex).Editable&& outFeatureFieldIndex != shapeIndex && outFeatureFieldIndex != angleIndex)
                    {
                        characterWidthIndexValue = Convert.ToInt16(inFeature.get_Value(characterWidthIndex));
                        outFeature.set_Value(outFeatureFieldIndex, inFeature.get_Value(i));
                    }
                }

                try
                {
                    IPoint       pTempPoint   = pTempGeo as IPoint;
                    ITextElement pTextElement = afin.Annotation as ITextElement;
                    IElement     pElement     = null;
                    if (pTempGeo.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        pElement = MakeTextElement(pTextElement, pTempPoint.X, pTempPoint.Y, characterWidthIndexValue) as IElement;
                    }
                    else if (pTempGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        pElement = MakeTextElement(pTextElement, pTempGeo as IPolyline, characterWidthIndexValue) as IElement;
                    }
                    afout.Annotation = pElement;
                }
                catch (System.Exception ex)
                {
                }
            }
            catch (System.Exception ex)
            {
            }
        }
コード例 #11
0
        private bool ClipAnnotationFeature(IFeature feature, IPolygon ply)
        {
            IAnnotationFeature  afin = feature as IAnnotationFeature;
            IRelationalOperator ro   = ply as IRelationalOperator;
            IPoint    pPoint;
            IEnvelope pEnvelope;

            pPoint    = new PointClass();
            pEnvelope = afin.Annotation.Geometry.Envelope;
            pPoint.PutCoords((pEnvelope.XMin + pEnvelope.XMax) / 2, (pEnvelope.YMin + pEnvelope.YMax) / 2);

            if (ro.Contains(pPoint))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #12
0
        private void method_5(ICoFeature icoFeature_0, IFeature ifeature_0)
        {
            ICoAnnotationFeature feature  = icoFeature_0 as ICoAnnotationFeature;
            IAnnotationFeature   feature2 = ifeature_0 as IAnnotationFeature;

            if (((feature != null) && (feature2 != null)) && (feature2.Annotation != null))
            {
                ITextElement annotation = feature2.Annotation as ITextElement;
                if (annotation != null)
                {
                    IPoint geometry = ((IElement)annotation).Geometry as IPoint;
                    if (geometry != null)
                    {
                        feature.Point.Add(new CoPointClass(geometry.X, geometry.Y, geometry.Z));
                        feature.Text  = annotation.Text;
                        feature.Angle = annotation.Symbol.Angle;
                        feature.Color = Color.FromArgb(annotation.Symbol.Color.RGB);
                        FontStyle regular = FontStyle.Regular;
                        if (annotation.Symbol.Font.Bold)
                        {
                            regular = FontStyle.Bold;
                        }
                        if (annotation.Symbol.Font.Italic)
                        {
                            regular = FontStyle.Italic;
                        }
                        if (annotation.Symbol.Font.Strikethrough)
                        {
                            regular = FontStyle.Strikeout;
                        }
                        if (annotation.Symbol.Font.Underline)
                        {
                            regular = FontStyle.Underline;
                        }
                        System.Drawing.Font font = new System.Drawing.Font(annotation.Symbol.Font.Name,
                                                                           (float)annotation.Symbol.Font.Size, regular);
                        feature.Font = font;
                    }
                }
            }
        }
コード例 #13
0
ファイル: CommonHelper.cs プロジェクト: frankerlee/Yutai
        public static List <string> ToAnnotations(List <IFeature> features)
        {
            List <string> list = new List <string>();

            foreach (IFeature feature in features)
            {
                IAnnotationFeature pAnnotateFeature = feature as IAnnotationFeature;
                if (pAnnotateFeature == null)
                {
                    continue;
                }
                IElement     pElement     = pAnnotateFeature.Annotation as IElement;
                ITextElement pTextElement = pElement as ITextElement;
                if (pTextElement == null)
                {
                    continue;
                }
                list.Add(pTextElement.Text);
            }
            return(list);
        }
コード例 #14
0
        /// <summary>
        ///     Determines whether the specified objects are equal.
        /// </summary>
        /// <param name="x">The first object of type to compare.</param>
        /// <param name="y">The second object of type to compare.</param>
        /// <param name="index">The index of the field that will be compare.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> if the specified objects are equal; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool Equals(IRow x, IRow y, int index)
        {
            if ((x == null) && (y == null))
            {
                return(true);
            }

            if ((x == null) ^ (y == null))
            {
                return(false);
            }

            IAnnotationFeature xAnnoFeature = x as IAnnotationFeature;
            IAnnotationFeature yAnnoFeature = y as IAnnotationFeature;

            if (xAnnoFeature != null && yAnnoFeature != null)
            {
                // We have to handle Annotation a little different because the ELEMENT field is controlled by an interface called
                // IAnnotationFeature that is responsible for setting the element and the Shape.
                IFeatureClass oclass = x.Table as IFeatureClass;
                if (oclass != null)
                {
                    IAnnotationClassExtension annoClass = oclass.Extension as IAnnotationClassExtension;
                    if (annoClass != null)
                    {
                        int elementFieldIndex = annoClass.ElementFieldIndex;
                        if (index == elementFieldIndex)
                        {
                            // Since it's Annotation, pass in the Element for comparison instead
                            // of the ELEMENT value itself.
                            return(this.AreEqual(xAnnoFeature.Annotation, yAnnoFeature.Annotation));
                        }
                    }
                }
            }

            return(this.AreEqual(x.Value[index], y.Value[index]));
        }
コード例 #15
0
ファイル: ControlsCopy.cs プロジェクト: siszoey/geosufan
        public override void OnClick()
        {
            Dictionary <IGeometry, IElement> ges = new Dictionary <IGeometry, IElement>();
            IEnumFeature features = myHook.MapControl.Map.FeatureSelection as IEnumFeature;

            features.Reset();
            IFeature feature = features.Next();

            while (feature != null)
            {
                IElement ele = null;
                if (feature is IAnnotationFeature)
                {
                    IAnnotationFeature af = feature as IAnnotationFeature;
                    ele = af.Annotation;
                }

                ges.Add(feature.ShapeCopy, ele);
                feature = features.Next();
            }

            ControlsPaste.GeometriesToBePasted = ges;
        }
コード例 #16
0
        public virtual bool Zoom(double zoom) //???未写完
        {
            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;
                    //trans.Move(dx, dy);
                    anFeat.Annotation = TextEl;
                }
                else
                {   //是一般要素
                    //if (this.pFeature.Shape.GeometryType== esriGeometryType.esriGeometryPolygon)
                    //{
                    double           x   = 0;
                    double           y   = 0;
                    IPoint           p   = null;
                    IGeometry        geo = this.pFeature.ShapeCopy;
                    IPointCollection pn  = geo as IPointCollection;
                    for (int i = 0; i < pn.PointCount; i++)
                    {
                        p = pn.get_Point(i);
                        x = p.X;
                        y = p.Y;
                        //???
                    }
                    rbc = true;
                    //}
                }
            }
            return(rbc);
        }
コード例 #17
0
ファイル: frmMapMoveUI.cs プロジェクト: hsg77/ArcMapByCommon
        //开始平移 事件
        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;
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdChangeAnnotationSymbol.OnClick implementation
            IMapControl3 pMapCtr = ClsGlobal.GetMapControl(m_hookHelper);

            if (pMapCtr == null)
            {
                return;
            }

            ISelection pSelection = pMapCtr.Map.FeatureSelection;


            FrmAddText   pFrmAddText  = null;
            IEnumFeature pEnumFeature = pSelection as IEnumFeature;

            int selectcount = 0;

            pEnumFeature.Reset();
            IFeature pFeature = null;

            while ((pFeature = pEnumFeature.Next()) != null)
            {
                selectcount++;
            }


            pEnumFeature.Reset();
            pFeature = null;
            while ((pFeature = pEnumFeature.Next()) != null)
            {
                IAnnotationFeature pAFeature = pFeature as IAnnotationFeature;
                if (pAFeature != null)
                {
                    ITextElement pTextElement = pAFeature.Annotation as ITextElement;
                    if (pFrmAddText == null)
                    {
                        pFrmAddText = new FrmAddText(pTextElement, m_hookHelper);
                        if (pFrmAddText.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            return;
                        }
                    }
                    //    ( (ITextElement) pAFeature.Annotation ).Symbol= pFrmAddText.pTextElement.Symbol;

                    //ITextElement pTextElement2 = pAFeature.Annotation as ITextElement;
                    //pTextElement2.Symbol = pFrmAddText.pTextElement.Symbol;
                    //pTextElement2.Text = pFrmAddText.pTextElement.Text;
                    //pAFeature.Annotation = pTextElement2 as IElement;

                    ITextElement pTextElement2 = pAFeature.Annotation as ITextElement;
                    pTextElement2.Symbol = pFrmAddText.pTextElement.Symbol;
                    if (selectcount == 1)
                    {
                        pTextElement2.Text = pFrmAddText.pTextElement.Text;
                    }
                    pAFeature.Annotation = pTextElement2 as IElement;
                    pFeature.Store();
                }
            }
        }
コード例 #19
0
ファイル: CmdDuoYaoSuCheQi.cs プロジェクト: secondii/Yutai
        public override void OnDblClick()
        {
            try
            {
                ArcGIS.Common.Editor.Editor.StartEditOperation();
                if (_lineFeedback == null)
                {
                    return;
                }
                _polyline = _lineFeedback.Stop();
                if (_lineFeedback != null)
                {
                    _context.ActiveView.Refresh();
                    _lineFeedback = null;
                }
                if (_polyline == null)
                {
                    return;
                }
                ISelectionEnvironment selectionEnvironment = new SelectionEnvironmentClass();
                selectionEnvironment.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
                _context.FocusMap.SelectByShape(_polyline, selectionEnvironment, false);
                ISelection        selection        = _context.FocusMap.FeatureSelection;
                IEnumFeatureSetup enumFeatureSetup = selection as IEnumFeatureSetup;
                IEnumFeature      enumFeature      = enumFeatureSetup as IEnumFeature;
                if (enumFeature == null)
                {
                    return;
                }
                enumFeature.Reset();
                IFeature feature;
                List <MultiCheQiModel> modelList = new List <MultiCheQiModel>();
                while ((feature = enumFeature.Next()) != null)
                {
                    IFeatureClass featureClass = feature.Class as IFeatureClass;
                    if (featureClass == null)
                    {
                        continue;
                    }
                    IFeatureLayer featureLayer =
                        _multiCheQiConfig.FlagLayerList.FirstOrDefault(
                            c => c.FeatureClass.FeatureClassID == featureClass.FeatureClassID);
                    if (featureLayer == null)
                    {
                        continue;
                    }
                    modelList.Add(new MultiCheQiModel(featureLayer, feature, _multiCheQiConfig.FieldSettingList, _polyline));
                }
                if (modelList.Count <= 0)
                {
                    return;
                }

                _context.ActiveView.ScreenDisplay.StartDrawing(_context.ActiveView.ScreenDisplay.hDC, 0);
                IAnnotationClassExtension annotationClassExtension = _multiCheQiConfig.FlagAnnoLayer.FeatureClass.Extension as IAnnotationClassExtension;
                IElement           headerElement           = CommonHelper.CreateHeaderElements(_multiCheQiConfig, _polyline.ToPoint);
                IFeature           headerFeature           = _multiCheQiConfig.FlagAnnoLayer.FeatureClass.CreateFeature();
                IAnnotationFeature headerAnnotationFeature = headerFeature as IAnnotationFeature;
                headerAnnotationFeature.Annotation = headerElement;
                headerFeature.Store();
                double xLength = headerFeature.Shape.Envelope.Width;
                double yLength = headerFeature.Shape.Envelope.Height;

                IPoint headerPoint = new PointClass();
                headerPoint.X                      = (headerElement.Geometry as IPoint).X - xLength / 2;
                headerPoint.Y                      = (headerElement.Geometry as IPoint).Y + yLength * (modelList.Count + 0.5);
                headerElement.Geometry             = headerPoint;
                headerAnnotationFeature.Annotation = headerElement;
                headerFeature.Store();
                annotationClassExtension.Draw(headerAnnotationFeature, _context.ActiveView.ScreenDisplay, null);
                List <MultiCheQiModel> models   = new List <MultiCheQiModel>(modelList.OrderBy(c => c.Distance));
                List <IElement>        elements = CommonHelper.CreateContentElements(_multiCheQiConfig, models,
                                                                                     headerElement.Geometry as IPoint, headerFeature.Shape.Envelope.Width,
                                                                                     headerFeature.Shape.Envelope.Height);
                foreach (IElement element in elements)
                {
                    IFeature           contentFeature           = _multiCheQiConfig.FlagAnnoLayer.FeatureClass.CreateFeature();
                    IAnnotationFeature contentAnnotationFeature = contentFeature as IAnnotationFeature;
                    contentAnnotationFeature.Annotation = element;
                    contentFeature.Store();
                    annotationClassExtension.Draw(contentAnnotationFeature, _context.ActiveView.ScreenDisplay, null);
                }
                _context.ActiveView.ScreenDisplay.FinishDrawing();

                IPointCollection pointCollection = _polyline as IPointCollection;
                IPoint           point1          = new PointClass();
                point1.X = _polyline.ToPoint.X - xLength;
                point1.Y = _polyline.ToPoint.Y;

                IPoint point2 = new PointClass();
                point2.X = _polyline.ToPoint.X - xLength;
                point2.Y = _polyline.ToPoint.Y + yLength * (modelList.Count + 1);

                pointCollection.AddPoint(point1);
                pointCollection.AddPoint(point2);
                IFeature lineFeature = _multiCheQiConfig.FlagLineLayer.FeatureClass.CreateFeature();
                lineFeature.Shape = pointCollection as IPolyline;
                lineFeature.Store();

                _context.ActiveView.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            finally
            {
                ArcGIS.Common.Editor.Editor.StopEditOperation();
            }
        }
コード例 #20
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();
        }
コード例 #21
0
        /// <summary>
        /// 绘制小柱状
        /// </summary>
        /// <param name="datasources">各地质层厚度(0.83,0.3,1.2,200)最后一个值为底板标高</param>
        /// <param name="pt">小柱状中心点</param>
        /// <param name="Angle">旋转角度</param>
        /// <param name="bili">比例</param>
        /// <param name="bid">BID</param>
        /// <param name="edit">函数外控制编辑状态为false,函数内自动控制编辑状态为true,当批量绘图时建议函数外控制编辑状态</param>
        public static bool drawXZZ(List <KeyValuePair <int, double> > datasources, IPoint pt, double Angle, string bid, double bili = 1, bool edit = true)
        {
            double angle = -Angle;

            Angle = -Angle * Math.PI / 180;
            DrawXZZMap draw      = new DrawXZZMap(bili);
            var        AnnoLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_AnnotationXZZ) as IFeatureLayer; //注记图层
            var        lineLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolylineXZZ) as IFeatureLayer;   //线源图层
            var        topLayer  = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolygonXZZ) as IFeatureLayer;    //外部图形图层

            if (AnnoLayer == null || lineLayer == null || topLayer == null)
            {
                System.Windows.Forms.MessageBox.Show("小柱状图层缺失!");
                return(false);
            }
            IWorkspaceEdit workspaceEdit = null;

            if (edit)
            {
                var dataset = lineLayer.FeatureClass as IDataset;
                workspaceEdit = dataset.Workspace as IWorkspaceEdit;
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
            }
            try
            {
                //  准备添加数据
                var polygonTopCursor = topLayer.FeatureClass.Insert(true);
                var polylineCursor   = lineLayer.FeatureClass.Insert(true);
                var AnnoCursor       = AnnoLayer.FeatureClass.Insert(true);
                //  从数据源图层获得数据
                var num1 = datasources[datasources.Count - 1].Value;     //  最后一条横线数值
                datasources.RemoveAt(datasources.Count - 1);
                if (datasources.Count > 1)
                {
                    List <IPoint> txtPoints;
                    List <IPoint> lineStartPoints;

                    var polygons = new List <KeyValuePair <string, IPolygon> >();

                    //  构造图形
                    draw.ContructGeometry(pt, datasources, out polygons, out lineStartPoints, out txtPoints);


                    ITransform2D pTrans2D;

                    //  生成方框图形
                    foreach (var polygon in polygons)
                    {
                        var feature2 = topLayer.FeatureClass.CreateFeatureBuffer();
                        feature2.set_Value(feature2.Fields.FindField("BID"), bid);
                        if (polygon.Key == "top")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 0);
                        }
                        else if (polygon.Key == "white")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 1);
                        }
                        else if (polygon.Key == "black")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 2);
                        }
                        pTrans2D = polygon.Value as ITransform2D;
                        //旋转要素
                        pTrans2D.Rotate(pt, Angle);
                        IPolygon ppp = pTrans2D as IPolygon;

                        GIS.Common.DataEditCommon.ZMValue(feature2, ppp);
                        feature2.Shape = ppp;

                        polygonTopCursor.InsertFeature(feature2);
                    }

                    //  生成注记
                    var enveloplist = new List <IEnvelope>();

                    for (int i = 0; i < txtPoints.Count; i++)
                    {
                        var featureAnno = AnnoLayer.FeatureClass.CreateFeatureBuffer();
                        IAnnotationFeature AnnoFeature = (IAnnotationFeature)featureAnno;

                        pTrans2D = txtPoints[i] as ITransform2D;
                        //旋转要素
                        pTrans2D.Rotate(pt, Angle);

                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Angle = angle;
                        var elementTxt = new TextElementClass
                        {
                            Geometry = pTrans2D as IGeometry,
                            FontName = "微软雅黑",
                            Size     = 12 * bili,
                            SymbolID = 0,
                            Symbol   = pTextSymbol
                        };

                        if (i == txtPoints.Count - 1)
                        {
                            elementTxt.Text = num1.ToString();                                   //  最后一条横线的数值
                            elementTxt.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; //  显示在线下边
                            featureAnno.set_Value(featureAnno.Fields.FindField("strType"), 2);
                        }
                        else
                        {
                            elementTxt.Text = datasources[i].Value.ToString();
                            elementTxt.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                            featureAnno.set_Value(featureAnno.Fields.FindField("strType"), datasources[i].Key);
                        }
                        AnnoFeature.Annotation = elementTxt;
                        featureAnno.set_Value(featureAnno.Fields.FindField("strAngle"), -angle);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strX"), pt.X);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strY"), pt.Y);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strScale"), bili);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strIndex"), i + 1);
                        featureAnno.set_Value(featureAnno.Fields.FindField("BID"), bid);

                        pTrans2D = featureAnno.Shape as ITransform2D;
                        pTrans2D.Rotate(pt, -Angle);

                        enveloplist.Add(((IGeometry)pTrans2D).Envelope);
                        AnnoCursor.InsertFeature(featureAnno);
                    }
                    //  生成线
                    var polyline = new PolylineClass();
                    for (int i = 0; i < enveloplist.Count; i++)
                    {
                        //  计算注记的终点
                        IPoint toPoint = new PointClass();
                        if (i % 2 == 0)
                        {
                            toPoint.X = enveloplist[i].XMax;
                        }
                        else
                        {
                            toPoint.X = enveloplist[i].XMin;
                        }

                        toPoint.Y = lineStartPoints[i].Y;

                        var line = new PathClass
                        {
                            FromPoint = lineStartPoints[i],
                            ToPoint   = toPoint
                        };

                        polyline.AddGeometry(line);
                    }
                    var featureLine = lineLayer.FeatureClass.CreateFeatureBuffer();

                    pTrans2D = polyline as ITransform2D;
                    pTrans2D.Rotate(pt, Angle);
                    IPolyline mline = pTrans2D as IPolyline;
                    GIS.Common.DataEditCommon.ZMValue(featureLine, mline);
                    featureLine.Shape = mline;
                    featureLine.set_Value(featureLine.Fields.FindField("BID"), bid);
                    polylineCursor.InsertFeature(featureLine);
                }

                AnnoCursor.Flush();
                polygonTopCursor.Flush();
                polylineCursor.Flush();
                if (edit)
                {
                    workspaceEdit.StopEditOperation();
                    workspaceEdit.StopEditing(true);

                    DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();
                }
                return(true);
            }
            catch (Exception ex)
            {
                if (edit)
                {
                    workspaceEdit.AbortEditOperation();
                    workspaceEdit.StopEditing(false);
                }
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return(false);
            }
        }
コード例 #22
0
ファイル: CmdCheQiLianDong.cs プロジェクト: secondii/Yutai
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            if (_lineFeedback == null)
            {
                this.SelectByClick(x, y);

                if (_context.FocusMap.SelectionCount != 1)
                {
                    return;
                }
                IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
                _annoFeature = enumFeature.Next();
                IAnnotationFeature annotationFeature = _annoFeature as IAnnotationFeature;
                if (annotationFeature == null)
                {
                    _annoFeature = null;
                    return;
                }
                this.SelectByShape(_annoFeature.Shape);
                IFeatureSelection featureSelection = _cheQiConfig.FlagLineLayer as IFeatureSelection;
                if (featureSelection?.SelectionSet == null || featureSelection.SelectionSet.Count != 1)
                {
                    return;
                }
                ICursor cursor;
                featureSelection.SelectionSet.Search(null, false, out cursor);
                if (cursor == null)
                {
                    return;
                }
                _lineFeature = cursor.NextRow() as IFeature;
                IPolyline polyline = _lineFeature?.Shape as IPolyline;
                if (polyline == null)
                {
                    return;
                }
                _lineFeedback = new NewLineFeedbackClass()
                {
                    Display = _context.ActiveView.ScreenDisplay
                };
                _lineFeedback.Start(polyline.FromPoint);
            }
            else
            {
                IActiveView activeView = _context.ActiveView;
                if (_context.Config.EngineSnapEnvironment.SnapToleranceUnits ==
                    esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
                {
                    _tolerance = ArcGIS.Common.Helpers.CommonHelper.ConvertPixelsToMapUnits(activeView, _tolerance);
                }
                IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                ISnappingResult snappingResult = _pointSnapper.Snap(point);
                if (snappingResult != null)
                {
                    point = snappingResult.Location;
                }

                _lineFeedback.AddPoint(point);
            }
        }
コード例 #23
0
        /// <summary>
        /// 将inFeatureClass要素类中所有符合pQueryFilter的要素复制到saveFeatureClass中,仅复制不做任何修改
        /// </summary>
        /// <param name="inFeatureClass">源要素类</param>
        /// <param name="saveFeatureClass">存储要素类</param>
        /// <param name="pQueryFilter">过滤参数</param>
        /// <returns></returns>
        public bool LoadFeatureClass(IFeatureClass inFeatureClass, IFeatureClass saveFeatureClass, IQueryFilter pQueryFilter)
        {
            //生成两个要素类字段的对应表
            Dictionary <int, int> pFieldsDict = new Dictionary <int, int>();

            this.GetFCFieldsDirectory(inFeatureClass, saveFeatureClass, ref pFieldsDict);
            IFeatureCursor pinFeatCursor   = inFeatureClass.Search(pQueryFilter, false);
            long           nCount          = inFeatureClass.FeatureCount(pQueryFilter);
            IFeature       pinFeat         = pinFeatCursor.NextFeature();
            IFeatureCursor psaveFeatCursor = saveFeatureClass.Insert(true);
            //使用IFeatureBuffer在内存中产生缓存避免多次打开,关闭数据库
            IFeatureBuffer psaveFeatBuf = null;
            IFeature       psaveFeat    = null;
            long           n            = 0;

            while (pinFeat != null)
            {
                try
                {
                    psaveFeatBuf = saveFeatureClass.CreateFeatureBuffer();
                    psaveFeat    = psaveFeatBuf as IFeature;
                    if (inFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        IAnnotationFeature pAF  = (IAnnotationFeature)pinFeat;
                        IAnnotationFeature pNAF = (IAnnotationFeature)psaveFeat;
                        if (pAF.Annotation != null)
                        {
                            pNAF.Annotation = pAF.Annotation;
                        }
                    }
                    psaveFeat.Shape = pinFeat.Shape;
                    foreach (KeyValuePair <int, int> keyvalue in pFieldsDict)
                    {
                        if (pinFeat.get_Value(keyvalue.Key).ToString() == "")
                        {
                            if (psaveFeat.Fields.get_Field(keyvalue.Value).Type == esriFieldType.esriFieldTypeString)
                            {
                                psaveFeat.set_Value(keyvalue.Value, "");
                            }
                            else
                            {
                                psaveFeat.set_Value(keyvalue.Value, 0);
                            }
                        }
                        else
                        {
                            psaveFeat.set_Value(keyvalue.Value, pinFeat.get_Value(keyvalue.Key));
                        }
                    }
                    psaveFeatCursor.InsertFeature(psaveFeatBuf);
                }
                catch (Exception ex) { }
                finally
                {
                    psaveFeat = null;
                    n++;
                    if (n % 2000 == 0)
                    {
                        psaveFeatCursor.Flush();
                    }
                    pinFeat = pinFeatCursor.NextFeature();
                }
            }
            psaveFeatCursor.Flush();
            return(true);
        }
コード例 #24
0
ファイル: Form1.cs プロジェクト: 305120262/CachedLayerSystem
        /// <summary>
        /// Build Cache Backgroud worker
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int           size   = int.Parse(this.tbxSize.Text);
            IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass;
            IGeoDataset   ds_poi = fc_poi as IGeoDataset;
            int           xmin   = (int)Math.Floor(ds_poi.Extent.XMin);
            int           ymin   = (int)Math.Floor(ds_poi.Extent.YMin);
            int           xmax   = (int)Math.Ceiling(ds_poi.Extent.XMax);
            int           ymax   = (int)Math.Ceiling(ds_poi.Extent.YMax);

            List <JsonObject> ls_fields_cache = new List <JsonObject>();

            if (!(fc_poi.Extension is IAnnotationClassExtension))
            {
                for (int i = 0; i < fc_poi.Fields.FieldCount; i++)
                {
                    IField     field = fc_poi.Fields.get_Field(i);
                    JsonObject js_f  = new JsonObject();
                    js_f.AddString("name", field.Name);
                    js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type));
                    js_f.AddString("alias", field.AliasName);
                    if (field.Type == esriFieldType.esriFieldTypeString)
                    {
                        js_f.AddString("length", field.Length.ToString());
                    }
                    else
                    {
                        js_f.AddString("length", "");
                    }
                    ls_fields_cache.Add(js_f);
                }
            }

            IDatabase client  = m_redis.GetDatabase();
            int       grid_id = 0;
            string    ns      = "poi:" + this.tbxCacheName.Text + ":";

            for (int y = ymin; y <= ymax; y += size)
            {
                for (int x = xmin; x <= xmax; x += size)
                {
                    List <String>     str_poi_grid = new List <String>();
                    List <JsonObject> ls_features  = new List <JsonObject>();
                    //String str_response = client.StringGet(ns+"response");
                    //JsonObject response = new JsonObject(str_response);
                    JsonObject response = new JsonObject();
                    IEnvelope  box      = new EnvelopeClass();
                    box.XMin = x;
                    box.YMin = y;
                    box.XMax = x + size;
                    box.YMax = y + size;
                    ISpatialFilter filter_poi = new SpatialFilterClass();
                    filter_poi.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    filter_poi.Geometry   = box;
                    filter_poi.SubFields  = "*";
                    IFeatureCursor cur_poi = fc_poi.Search(filter_poi, true);
                    IFeature       fea_poi = cur_poi.NextFeature();
                    while (fea_poi != null)
                    {
                        JsonObject js_fea = new JsonObject();
                        if (!(fea_poi is IAnnotationFeature))
                        {
                            JsonObject js_attributes = new JsonObject();
                            int        i             = 0;
                            foreach (JsonObject js_field in ls_fields_cache)
                            {
                                object value = fea_poi.get_Value(i);
                                string fieldtype;
                                js_field.TryGetString("type", out fieldtype);
                                string fieldname;
                                js_field.TryGetString("name", out fieldname);
                                #region
                                if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString))
                                {
                                    js_attributes.AddString(fieldname, value.ToString());
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID))
                                {
                                    js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger))
                                {
                                    if (value.ToString() == "")
                                    {
                                        value = 0;
                                    }
                                    js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger))
                                {
                                    if (value.ToString() == "")
                                    {
                                        value = 0;
                                    }
                                    js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDouble))
                                {
                                    if (value.ToString() == "")
                                    {
                                        value = 0;
                                    }
                                    js_attributes.AddDouble(fieldname, double.Parse(value.ToString()));
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDate))
                                {
                                    if (value.ToString() == "")
                                    {
                                        value = DateTime.MinValue;
                                    }
                                    js_attributes.AddDate(fieldname, DateTime.Parse(value.ToString()));
                                }
                                else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSingle))
                                {
                                    if (value.ToString() == "")
                                    {
                                        value = 0;
                                    }
                                    js_attributes.AddBoolean(fieldname, bool.Parse(value.ToString()));
                                }
                                #endregion
                                i++;
                            }
                            js_fea.AddJsonObject("attributes", js_attributes);
                            js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(fea_poi.Shape));
                        }
                        else
                        {
                            IAnnotationFeature anno_fea = fea_poi as IAnnotationFeature;
                            ITextElement       ele      = anno_fea.Annotation as ITextElement;
                            //string text = ele.Text.Replace(System.Environment.NewLine, " ");
                            string      text     = ele.Text;
                            ITextSymbol sym      = ele.Symbol;
                            IFontDisp   font     = sym.Font;
                            double      symsize  = sym.Size;
                            string      fontname = font.Name;
                            decimal     fontsize = font.Size;
                            string.Format(@"a"":""");
                            JsonObject js_symbol = new JsonObject(
                                string.Format(@"{{""type"" : ""esriTS"",""color"": [255,255,255],""haloSize"" : 0,""haloColor"" : [255,255,255,0],""verticalAlignment"" : ""bottom"",""horizontalAlignment"" : ""center"",""size"": {0},""angle"": 0,""xoffset"": 0,""yoffset"": 0,""font"" : {{""family"" : ""{2}"",""size"" : {3},""style"" : ""normal"",""weight"" : ""normal"",""decoration"" : ""none""}},""text"":""{1}""}}", symsize, text, fontname, fontsize));
                            js_fea.AddJsonObject("symbol", js_symbol);
                            IArea pshp = fea_poi.Shape as IArea;
                            js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(pshp.Centroid));
                        }
                        ls_features.Add(js_fea);
                        fea_poi = cur_poi.NextFeature();
                    }
                    response.AddArray("features", ls_features.ToArray());
                    client.StringSet(ns + grid_id.ToString(), response.ToJson());
                    ReleaseCOMObject(cur_poi);
                    grid_id++;
                    progressBar1.BeginInvoke((Action)(() =>
                    {
                        progressBar1.Increment(1);
                    }));
                }
            }
            MessageBox.Show("Build Cache Successfully!");
            this.button1.BeginInvoke((Action)(() =>
            {
                ListCaches();
                this.button1.Enabled = true;
            }));
        }
コード例 #25
0
        private IFeatureBuffer method_9(ICoFeature icoFeature_0)
        {
            object         before = Missing.Value;
            IFeatureBuffer buffer = null;

            if (this.bool_0)
            {
                buffer = this.ifeatureClass_0.CreateFeatureBuffer();
            }
            else
            {
                buffer = this.ifeatureClass_0.CreateFeature() as IFeatureBuffer;
            }
            if (buffer != null)
            {
                buffer.Shape = null;
            }
            switch (icoFeature_0.Type)
            {
            case CoFeatureType.Point:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPoint))
                {
                    foreach (IPoint point in this.method_15((icoFeature_0 as ICoPointFeature).Point))
                    {
                        buffer.Shape = point;
                    }
                }
                break;

            case CoFeatureType.Polygon:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPolygon))
                {
                    IGeometryCollection geometrys2 = new PolygonClass();
                    foreach (CoPointCollection points in (icoFeature_0 as ICoPolygonFeature).Points)
                    {
                        IPointCollection points3 = new RingClass();
                        foreach (IPoint point2 in this.method_15(points))
                        {
                            points3.AddPoint(point2, ref before, ref before);
                        }
                        geometrys2.AddGeometry((IGeometry)points3, ref before, ref before);
                    }
                    ((IPolygon)geometrys2).SimplifyPreserveFromTo();
                    buffer.Shape = (IGeometry)geometrys2;
                }
                break;

            case CoFeatureType.Annotation:
                if (this.ifeatureClass_0.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    IAnnotationFeature   feature  = buffer as IAnnotationFeature;
                    IPoint               point    = new PointClass();
                    ICoAnnotationFeature feature2 = icoFeature_0 as ICoAnnotationFeature;
                    point.X = feature2.Point[0].X;
                    point.Y = feature2.Point[0].Y;
                    point.Z = feature2.Point[0].Z;
                    ITextElement element = this.method_11(feature2.Text, 0.0, (decimal)feature2.Font.Size,
                                                          feature2.Font.Name, feature2.Color.ToArgb(), point);
                    feature.Annotation = (IElement)element;
                }
                break;

            case CoFeatureType.Polyline:
                if ((this.ifeatureClass_0.FeatureType != esriFeatureType.esriFTAnnotation) &&
                    (this.ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPolyline))
                {
                    IGeometryCollection geometrys = new PolylineClass();
                    foreach (CoPointCollection points in (icoFeature_0 as ICoPolylineFeature).Points)
                    {
                        IPoint[]         pointArray = this.method_15(points);
                        IPointCollection points2    = new PathClass();
                        for (int i = 0; i < pointArray.Length; i++)
                        {
                            points2.AddPoint(pointArray[i], ref before, ref before);
                        }
                        geometrys.AddGeometry((IGeometry)points2, ref before, ref before);
                    }
                    buffer.Shape = (IGeometry)geometrys;
                }
                break;
            }
            if (buffer != null)
            {
                if (buffer.Shape != null)
                {
                    this.method_10(buffer, icoFeature_0);
                    return(buffer);
                }
                return(null);
            }
            return(null);
        }
コード例 #26
0
ファイル: ModifyMove.cs プロジェクト: wwcc19870805/DIFGIS
        private void MoveFeature()
        {
            ITransform2D   pTrans2d;
            IWorkspaceEdit pWorkspaceEdit;      //工作空间的编辑接口

            pWorkspaceEdit = Class.Common.CurWspEdit;
            pWorkspaceEdit.StartEditOperation();

            m_pEnvelope = ((IFeature)m_OriginFeatureArray.get_Element(0)).Extent;

            for (int i = 0; i < m_OriginFeatureArray.Count; i++)
            {
                IFeature pFeature = (IFeature)m_OriginFeatureArray.get_Element(i);

                if (pFeature.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    IAnnotationFeature pAnnotationFeature = pFeature as IAnnotationFeature;
                    IElement           element            = new TextElementClass();
                    element = pAnnotationFeature.Annotation;

                    IPoint pPointOld = null;
                    if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline pPolyline = element.Geometry as IPolyline;
                        pPointOld = pPolyline.FromPoint;
                    }
                    else if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        pPointOld = element.Geometry as IPoint;
                    }
                    IPoint pPointNew = new PointClass();
                    pPointNew.PutCoords(pPointOld.X + (m_pPoint2.X - m_pPoint0.X), pPointOld.Y + (m_pPoint2.Y - m_pPoint0.Y));
                    element.Geometry = pPointNew;

                    try
                    {
                        pAnnotationFeature.Annotation = element;
                        ((IFeature)pAnnotationFeature).Store();
                    }
                    catch
                    {
                        System.Windows.Forms.MessageBox.Show("当前操作不在有效坐标范围内,操作失败");
                    }
                    m_pEnvelope.Union(pFeature.Shape.Envelope);
                }
                else
                {
                    pTrans2d = (ITransform2D)pFeature.Shape; //接口的跳转
                    pTrans2d.Move(m_pPoint2.X - m_pPoint0.X, m_pPoint2.Y - m_pPoint0.Y);

                    m_pEnvelope.Union(((IGeometry)pTrans2d).Envelope);

                    pFeature.Shape = (IGeometry)pTrans2d;
                    pFeature.Store();
                }
            }
            pWorkspaceEdit.StopEditOperation();
            m_App.Workbench.UpdateMenu();

            //m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_pEnvelope);//视图刷新
        }
コード例 #27
0
ファイル: FeatClsOperAPI.cs プロジェクト: zj8487/HyDM
        /// <summary>
        /// 创建并导入注记层
        /// </summary>
        /// <param name="pInputCls"></param>
        /// <param name="Ws"></param>
        public static void ConvertAnnotation(IFeatureClass pInputCls, IWorkspace Ws)
        {
            try
            {
                IFields pFields = pInputCls.Fields;

                IEnumDataset    pEnumDataset = Ws.get_Datasets(esriDatasetType.esriDTFeatureDataset);
                IFeatureDataset ipDataset    = (IFeatureDataset)pEnumDataset.Next();
                IFeatureClass   pOutputCls   = CreateAnnotation(pInputCls, ipDataset, pFields);

                if (pOutputCls == null)
                {
                    return;
                }

                IFeatureCursor pInputCursor = pInputCls.Search(null, false);
                IFeature       Inputfeature = pInputCursor.NextFeature();
                int            index        = -1;

                //获取输入图层的注记要素
                IElement           ipElement = null;
                IAnnotationFeature ipAnno    = null;
                IFeatureCursor     _featureCursor;
                IFeatureBuffer     _featureBuffer;
                IFields            pOutputFields;
                IField             ipField;
                object             value;
                esriFieldType      type;
                IAnnotationFeature ipAnnoOutput;
                IGeometry          ipGeom;
                while (Inputfeature != null)
                {
                    if (Inputfeature.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        ipAnno    = (IAnnotationFeature)Inputfeature;
                        ipElement = ipAnno.Annotation;
                    }
                    _featureCursor = pOutputCls.Insert(true);
                    _featureBuffer = pOutputCls.CreateFeatureBuffer();

                    pOutputFields = pOutputCls.Fields;
                    for (int k = 0; k < pFields.FieldCount; k++)
                    {
                        ipField = pFields.get_Field(k);
                        value   = Inputfeature.get_Value(k);
                        if (ipField.Name.ToUpper().Contains("SHAPE") || value == null || value.ToString() == "")
                        {
                            continue;
                        }
                        type = ipField.Type;
                        if (type != esriFieldType.esriFieldTypeOID && type != esriFieldType.esriFieldTypeGeometry)
                        {
                            int indexField = pOutputFields.FindField(ipField.Name);
                            try
                            {
                                _featureBuffer.set_Value(indexField, value);
                            }
                            catch (Exception exp)
                            {
                                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
                            }
                        }
                        Marshal.ReleaseComObject(ipField);  //释放接口,hehy-20090303
                    }

                    //在输出图层中插入注记要素
                    ipAnnoOutput            = (IAnnotationFeature)_featureBuffer;
                    ipAnnoOutput.Annotation = ipElement;
                    ipGeom = Inputfeature.ShapeCopy;
                    _featureBuffer.Shape = ipGeom;

                    _featureCursor.InsertFeature(_featureBuffer); //将输出图层中的要素保存

                    Marshal.ReleaseComObject(_featureCursor);     //释放接口,hehy-20090303
                    Marshal.ReleaseComObject(_featureBuffer);
                    Marshal.ReleaseComObject(Inputfeature);
                    Marshal.ReleaseComObject(ipAnnoOutput);

                    Inputfeature = pInputCursor.NextFeature();
                }

                Marshal.ReleaseComObject(pInputCursor);
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
            }
        }
コード例 #28
0
ファイル: ModifyRotate.cs プロジェクト: wwcc19870805/DIFGIS
        private void RotateFeature()
        {
            ITransform2D   pTrans2d;
            IWorkspaceEdit pWorkspaceEdit;      //工作空间的编辑接口

            pWorkspaceEdit = Class.Common.CurWspEdit;
            pWorkspaceEdit.StartEditOperation();

            m_pEnvelope = ((IFeature)m_OriginFeatureArray.get_Element(0)).Extent;

            for (int i = 0; i < m_OriginFeatureArray.Count; i++)
            {
                IFeature pFeature = (IFeature)m_OriginFeatureArray.get_Element(i);

                if (pFeature.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    IAnnotationFeature pAnnotationFeature = pFeature as IAnnotationFeature;
                    //IElement element = new TextElementClass();
                    IElement element = pAnnotationFeature.Annotation;

                    ITextElement textElement = element as ITextElement;

                    ITextSymbol pTextSymbol = new TextSymbolClass();
                    pTextSymbol = textElement.Symbol as ITextSymbol;

                    IPoint pPointOld = null;
                    if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline pPolyline = element.Geometry as IPolyline;
                        pPointOld = pPolyline.FromPoint;
                    }
                    else if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        pPointOld = element.Geometry as IPoint;
                    }
                    pTextSymbol.Angle  = Class.Common.RadToDeg(Class.Common.GetAzimuth_P12(m_pPoint0, m_pPoint2));
                    textElement.Symbol = pTextSymbol;
                    element            = (IElement)textElement;
                    element.Geometry   = pPointOld;

                    try
                    {
                        pAnnotationFeature.Annotation = element;
                        ((IFeature)pAnnotationFeature).Store();
                    }
                    catch
                    {
                        System.Windows.Forms.MessageBox.Show("当前操作不在有效坐标范围内,操作失败");
                    }
                    m_pEnvelope.Union(pFeature.Shape.Envelope);
                }
                else
                {
                    pTrans2d = (ITransform2D)pFeature.Shape; //接口的跳转
                    pTrans2d.Rotate(m_pPoint0, Class.Common.GetAzimuth_P12(m_pPoint0, m_pPoint2));

                    //CommonFunction.GeoZM((IGeometry)pTrans2d,pFeatureLayer);

                    m_pEnvelope.Union(((IGeometry)pTrans2d).Envelope);

                    pFeature.Shape = (IGeometry)pTrans2d;
                    pFeature.Store();
                }
            }
            m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_pEnvelope); //视图刷新

            pWorkspaceEdit.StopEditOperation();                                                  //结束编辑
            m_App.Workbench.UpdateMenu();
        }
コード例 #29
0
ファイル: Button1.cs プロジェクト: sishui198/ArcObjectsCode
        public void CopyAnnotationFeatures()
        {
            try
            {
                IMxDocument pMxDoc      = (IMxDocument)ArcMap.Application.Document;
                IMap        pMap        = pMxDoc.FocusMap;
                ILayer      SourceLayer = pMap.Layer[0];
                ILayer      TargetLayer = pMap.Layer[1];

                IFeatureLayer SourceFLayer = (IFeatureLayer)SourceLayer;
                IFeatureLayer TargetFLayer = (IFeatureLayer)TargetLayer;

                IFeatureClass SourceFeatureClass = SourceFLayer.FeatureClass;
                IFeatureClass TargetFeatureClass = TargetFLayer.FeatureClass;

                IFields TargetFields = TargetFeatureClass.Fields;
                IFields SourceFields = SourceFeatureClass.Fields;

                IDictionary <int, int> symbSourceTargIdXref = new Dictionary <int, int>();
                symbSourceTargIdXref.Add(4, 17);
                symbSourceTargIdXref.Add(5, 22);
                symbSourceTargIdXref.Add(43, 45);
                symbSourceTargIdXref.Add(45, 45);
                ISymbolCollection targetSymbolsColl = (TargetFeatureClass.Extension as IAnnoClass).SymbolCollection;

                IField pFld;

                int[] lSrcFlds;
                int[] lTarFlds;

                int lFld, lExFld, i;
                lExFld = 0;
                for (lFld = 0; lFld <= (SourceFields.FieldCount - 1); lFld++)
                {
                    pFld = SourceFields.Field[lFld];

                    if (pFld.Type != esriFieldType.esriFieldTypeOID && pFld.Type != esriFieldType.esriFieldTypeGeometry && pFld.Name.ToUpper() != "ELEMENT" && pFld.Name.ToUpper() != "ZORDER" && pFld.Editable == true)
                    {
                        lExFld = lExFld + 1;
                    }
                }


                lSrcFlds = new int[lExFld];
                lTarFlds = new int[lExFld];

                i = 0;

                for (lFld = 0; lFld <= (SourceFields.FieldCount - 1); lFld++)
                {
                    pFld = SourceFields.Field[lFld];
                    if (pFld.Type != esriFieldType.esriFieldTypeOID && pFld.Type != esriFieldType.esriFieldTypeGeometry && pFld.Name.ToUpper() != "ELEMENT" && pFld.Name.ToUpper() != "ZORDER" && pFld.Editable == true)
                    {
                        lSrcFlds[i] = lFld;
                        lTarFlds[i] = TargetFields.FindField(pFld.Name);
                        i           = i + 1;
                    }
                }


                IFeatureCursor pICursor;
                pICursor = SourceFeatureClass.Search(null, true);

                IFeature pIFeat;
                pIFeat = pICursor.NextFeature();

                IFDOGraphicsLayerFactory pGLF;
                pGLF = new FDOGraphicsLayerFactory();

                IDataset pDataset;
                pDataset = (IDataset)TargetFeatureClass;



                IAnnotationFeature pAnnoFeature;
                IClone             pAClone;
                IElement           pElement;


                IAnnoClass pTargetAnnoClass = (IAnnoClass)TargetFeatureClass.Extension;


                while (pIFeat != null)
                {
                    pAnnoFeature = (IAnnotationFeature)pIFeat;

                    if (pAnnoFeature.Annotation != null)
                    {
                        ITextElement sourceTextElement = pAnnoFeature.Annotation as ITextElement;
                        pAClone  = (IClone)sourceTextElement;
                        pElement = (IElement)pAClone.Clone();

                        ITextElement ptempTxt = (ITextElement)pAClone.Clone();
                        //set id
                        IFeature pTempFeat = TargetFeatureClass.CreateFeature();



                        ISymbolCollectionElement TargetSymbCollElem = (ISymbolCollectionElement)ptempTxt;

                        ISymbolCollectionElement sourceSymbCollElem = sourceTextElement as ISymbolCollectionElement;

                        int sourceSymbID = sourceSymbCollElem.SymbolID;

                        int symbolID = symbSourceTargIdXref[sourceSymbID];

                        ISymbolIdentifier2 pSymbI;
                        ISymbolCollection2 pSymbolColl2 = ( ISymbolCollection2 )pTargetAnnoClass.SymbolCollection;

                        pSymbolColl2.GetSymbolIdentifier(symbolID, out pSymbI);

                        //reset the desired symbol id

                        TargetSymbCollElem.set_SharedSymbol(pSymbI.ID, pSymbI.Symbol);


                        //save the annotation feature
                        IAnnotationFeature pAnnoFeat = (IAnnotationFeature)pTempFeat;

                        pAnnoFeat.Annotation = ptempTxt as IElement;
                        pTempFeat.Store();

                        //reset the over rided property by analysing the override code

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideXOffset) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.XOffset = sourceSymbCollElem.XOffset;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideYOffset) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.YOffset = sourceSymbCollElem.YOffset;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideHorzAlignment) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.HorizontalAlignment = sourceSymbCollElem.HorizontalAlignment;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideVertAlignment) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.VerticalAlignment = sourceSymbCollElem.VerticalAlignment;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideFlipAngle) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.FlipAngle = TargetSymbCollElem.FlipAngle;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideSize) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Size = sourceSymbCollElem.Size;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideColor) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Color = sourceSymbCollElem.Color;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideCharSpacing) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.CharacterSpacing = sourceSymbCollElem.CharacterSpacing;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideCharWidth) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.CharacterWidth = sourceSymbCollElem.CharacterWidth;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideWordSpacing) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.WordSpacing = sourceSymbCollElem.WordSpacing;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideLeading) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Leading = sourceSymbCollElem.Leading;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideBold) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Bold = sourceSymbCollElem.Bold;
                        }
                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideItalic) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Italic = sourceSymbCollElem.Italic;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideUnderline) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Underline = sourceSymbCollElem.Underline;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideBackground) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.Background = sourceSymbCollElem.Background;
                        }

                        if ((sourceSymbCollElem.OverriddenProperties ^ (int)esriSymbolOverrideEnum.esriSymbolOverrideFontName) <= sourceSymbCollElem.OverriddenProperties)
                        {
                            TargetSymbCollElem.FontName = sourceSymbCollElem.FontName;
                        }

                        //save the feature again
                        pAnnoFeat.Annotation = ptempTxt as IElement;
                        pTempFeat.Store();
                    }
                    pIFeat = pICursor.NextFeature();
                }


                pMxDoc.UpdateContents();
                pMxDoc.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }