示例#1
0
 public frmSymbology(IRasterLayer rasterLayer, IMapControl2 mainMap, ITOCControl2 mainToc)
 {
     InitializeComponent();
     m_RasterLayer = rasterLayer;
     m_MainMap = mainMap;
     m_MainTOC = mainToc;
 }
示例#2
0
        public Form1()
        {
            InitializeComponent();
            mapControl = axMapControl1.Object as IMapControl2;

            for (int count = 1; count <= listBox1.Items.Count; count++)
            {
                string path = currentDir + "\\" + count.ToString();
                LoadOriginData(path, count);
            }
        }
示例#3
0
        // 唯一值符号化
        public static void UniqueValueRenderer(IFeatureLayer featureLayer, string fieldName, IMapControl2 mapControl, AxTOCControl tocControl)
        {
            ITable pTable = featureLayer as ITable;
            IUniqueValueRenderer pRenderer = new UniqueValueRendererClass();

            pRenderer.FieldCount = 1;          // 设置唯一值符号化的关键字段为一个
            pRenderer.set_Field(0, fieldName); // 设置唯一值符号化的第一个关键字段
            IRandomColorRamp pColorRamp = new RandomColorRampClass()
            {
                StartHue      = 0,
                MinValue      = 0,
                MinSaturation = 0,
                EndHue        = 100,
                MaxValue      = 100,
                MaxSaturation = 100
            };

            // 根据渲染字段的值的个数,设置一组随机颜色
            pColorRamp.Size = featureLayer.FeatureClass.FeatureCount(new QueryFilterClass());
            bool bSuccess = false;

            pColorRamp.CreateRamp(out bSuccess);
            IEnumColors pEnumColors      = pColorRamp.Colors;
            IColor      pNextUniqueColor = null;
            // 查询字段的值
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.AddField(fieldName);
            int        fieldNumber    = pTable.FindField(fieldName); // 获取渲染字段索引
            ICursor    pCursor        = pTable.Search(pQueryFilter, true);
            IRow       pNextRow       = pCursor.NextRow();
            object     codeValue      = null;
            IRowBuffer pNextRowBuffer = null;

            while (pNextRow != null)
            {
                pNextRowBuffer = pNextRow as IRowBuffer;
                // 获取渲染字段的每一个值
                codeValue        = pNextRowBuffer.get_Value(fieldNumber);
                pNextUniqueColor = pEnumColors.Next();
                if (pNextUniqueColor == null)
                {
                    pEnumColors.Reset();
                    pNextUniqueColor = pEnumColors.Next();
                }
                ISymbol pSymbol = null;
                switch (featureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                    pSymbol = new SimpleFillSymbolClass()
                    {
                        Color = pNextUniqueColor
                    };
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSymbol = new SimpleLineSymbolClass()
                    {
                        Color = pNextUniqueColor
                    };
                    break;

                case esriGeometryType.esriGeometryPoint:
                    pSymbol = new SimpleMarkerSymbolClass()
                    {
                        Color = pNextUniqueColor
                    };
                    break;
                }
                pRenderer.AddValue(codeValue.ToString(), "", pSymbol);
                pNextRow = pCursor.NextRow();
            }
            (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;
            mapControl.Refresh();
            tocControl.Update();
        }
示例#4
0
 public void InitInputCombox(IMapControl2 pMapControl)
 {
 }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;
            //�������hook�����ж�

            if (hook is IToolbarControl)

            {
                IToolbarControl pToolBar= hook as IToolbarControl ;
                pMapControl = pToolBar.Buddy as IMapControl2;
            }
            else if(hook is IMapControl2 )
            {
                pMapControl = hook as IMapControl2;
            }

            // TODO:  Add other initialization code
        }
示例#6
0
        public override void Run(object sender, EventArgs e)
        {
            string[] arrFc2DId;
            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;

            frmSelType frmType = new frmSelType();

            if (frmType.ShowDialog() == DialogResult.OK)
            {
                List <DF2DFeatureClass> list = new List <DF2DFeatureClass>();
                m_arrPipeType = frmType.PipeType;
                for (int i = 0; i < m_arrPipeType.Count; i++)
                {
                    MajorClass mc = m_arrPipeType[i] as MajorClass;
                    arrFc2DId = mc.Fc2D.Split(';');
                    if (arrFc2DId == null)
                    {
                        continue;
                    }
                    foreach (string fc2DId in arrFc2DId)
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                        if (dffc == null || dffc.GetFacilityClassName() != "PipeLine")
                        {
                            continue;
                        }
                        IFeatureClass fc = dffc.GetFeatureClass();
                        if (fc == null)
                        {
                            continue;
                        }
                        //if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                        //{
                        list.Add(dffc);
                        //}
                    }
                }
                Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();
                WaitForm.Start("开始拓扑检查..", "请稍候");
                foreach (DF2DFeatureClass dffc in list)
                {
                    IFeatureClass fc = dffc.GetFeatureClass();
                    if (fc == null)
                    {
                        continue;
                    }
                    FacilityClass fac = dffc.GetFacilityClass();
                    if (fac == null)
                    {
                        continue;
                    }
                    List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                    DFDataConfig.Class.FieldInfo        fi        = fac.GetFieldInfoBySystemName("StartHeight2D");
                    int index = fc.FindField(fi.Name);
                    WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                    if (fi == null || index == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("EndHeight");
                    int index1 = fc.FindField(fi1.Name);
                    if (fi1 == null || index1 == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi2 = fac.GetFieldInfoBySystemName("StartDep");
                    int index2 = fc.FindField(fi2.Name);
                    if (fi2 == null || index2 == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi3 = fac.GetFieldInfoBySystemName("EndDep");
                    int index3 = fc.FindField(fi3.Name);
                    if (fi3 == null || index3 == -1)
                    {
                        continue;
                    }

                    DataTable      dt         = GetDataTableByStruture();
                    IFeatureCursor pFeaCursor = fc.Search(null, true);
                    IFeature       pFea       = pFeaCursor.NextFeature();
                    while (pFea != null)
                    {
                        //Console.WriteLine(pFea.OID + " " + fc.AliasName);
                        bool   b1 = false, b2 = false;
                        string obj  = pFea.get_Value(index).ToString();
                        string obj1 = pFea.get_Value(index1).ToString();
                        if (obj != "" && obj1 != "")
                        {
                            double d;
                            if (!double.TryParse(obj1, out d))
                            {
                                d = 0.0;
                            }

                            if (Math.Abs(double.Parse(obj) - double.Parse(obj1)) > 1)
                            {
                                b1 = true;
                            }
                        }
                        string obj2 = pFea.get_Value(index2).ToString();
                        string obj3 = pFea.get_Value(index3).ToString();
                        /* if (obj3 != null) continue;*/
                        if ((obj2 != "") && (obj3 != ""))
                        {
                            double d;
                            if (!double.TryParse(obj2, out d))
                            {
                                d = 0.0;
                            }

                            if (Math.Abs(double.Parse(obj2) - double.Parse(obj3)) > 0.5)
                            {
                                b2 = true;
                            }
                        }
                        if (b1 && b2)
                        {
                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = fc.AliasName;
                            dr["FeatureofLayer"] = (fc as IDataset).Name;
                            dr["FeatureClass"]   = fc;
                            if (b1 && b2)
                            {
                                dr["ErrorType"] = "管线起止点高程差值超出规范值;管线起止点埋深差值超出规范值";
                            }
                            else if (b1 && !b2)
                            {
                                dr["ErrorType"] = "管线起止点高程差值超出规范值";
                            }
                            else if (b2 && !b1)
                            {
                                dr["ErrorType"] = "管线起止点埋深差值超出规范值";
                            }
                            dt.Rows.Add(dr);
                        }
                        pFea = pFeaCursor.NextFeature();
                    }
                    if (dt.Rows.Count > 0)
                    {
                        dict[fc] = dt;
                    }
                }
                WaitForm.Stop();
                FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);
                dlg.Text = this.CommandName;
                dlg.Show();
            }
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolAddControlPoints.OnMouseDown implementation
            object       Miss    = Type.Missing;
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                IGeoReference pGR      = pRasterLayer as IGeoReference;
                IPoint        mapPoint = pMapCtr.ToMapPoint(X, Y);
                m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                if (FirstPoint == true)//起始点
                {
                    IPointCollection pPCFrom;
                    IPointCollection pPCTo = new MultipointClass();
                    pPCTo.AddPoint(mapPoint, ref Miss, ref Miss);
                    pPCFrom = pGR.PointsTransform(pPCTo, false);
                    //for (int i = 0; i < OriginPoints.PointCount; i++)
                    //{
                    //    pPCFrom.AddPoint(OriginPoints.get_Point(i));
                    //}
                    //pPCFrom.AddPoint(mapPoint);

                    m_NewLineFeedback.Start(mapPoint);
                    // OriginPoints.AddPoint(mapPoint);
                    IPoint pt = pPCFrom.get_Point(0);
                    OriginPoints.AddPoint(pt);
                    FirstPoint = false;
                }
                else//目标点
                {
                    TargetPoints.AddPoint(mapPoint);
                    FirstPoint = true;
                    m_NewLineFeedback.Stop();
                    // IPointCollection pPC = pGR.PointsTransform(TargetPoints, false);
                    //IPointCollection pPC = OriginPoints;
                    //IPoint pt1, pt2;
                    //pt1 = pPC.get_Point(0);
                    //pt2 = TargetPoints.get_Point(0);
                    //if (pPC.PointCount == 1)
                    //{
                    //    //IPoint pt1,pt2;
                    //    //pt1 = pPC.get_Point(0);
                    //    //pt2 = TargetPoints.get_Point(0);
                    //    pGR.Shift(pt2.X - pt1.X, pt2.Y - pt1.Y);

                    //}
                    //else
                    //if (pPC.PointCount ==2 )
                    //{
                    //    pGR.TwoPointsAdjust(pPC, TargetPoints);
                    //}
                    //else
                    //{
                    //    pGR.Warp(pPC, TargetPoints, m_FrmLinkTableRaster.WarpType);
                    //}
                    //m_FrmLinkTableRaster.AddControlPoints(OriginPoints.get_Point(OriginPoints.PointCount -1)
                    //    ,TargetPoints.get_Point(TargetPoints.PointCount -1));
                    m_FrmLinkTableRaster.pRasterLayer = pRasterLayer;
                    m_FrmLinkTableRaster.pMapCtr      = pMapCtr;
                    m_FrmLinkTableRaster.RefreshControlAllPoints();
                }

                TransformedOriginPoints = pGR.PointsTransform(OriginPoints, true);

                // pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
        }
示例#8
0
 //public event RaserLayerRendererEventHandler RaserLayerRenderer;
 public void InitializeLayer(IRasterLayer rasterLayer, IMapControl2 mainMap,ITOCControl2 mainToc)
 {
     m_RasterLayer = rasterLayer;
     m_MainMap = mainMap;
     m_MainTOC = mainToc;
     getMaxMinValue(m_RasterLayer);
 }
示例#9
0
文件: Form1.cs 项目: nohe427/MyAddins
        private void StartEditing(IMapControl2 m_mapControl)
        {
            IMap map = m_mapControl.Map;

            //If an edit session has already been started, exit.
            if (m_engineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                return;

            //Start editing the workspace of the first feature layer found.
            for (int layerCounter = 0; layerCounter <= map.LayerCount - 1; layerCounter++)
            {
                ILayer currentLayer = map.get_Layer(layerCounter);
                if (currentLayer is IFeatureLayer)
                {
                    IFeatureLayer featureLayer = currentLayer as IFeatureLayer;
                    IDataset dataset = featureLayer.FeatureClass as IDataset;
                    IWorkspace workspace = dataset.Workspace;
                    m_engineEditor.StartEditing(workspace, map);
                    ((IEngineEditLayers)m_engineEditor).SetTargetLayer(featureLayer, 0);
                    break;
                }
            }
        }
示例#10
0
 public FrmOneKeyCoding(IMapControl2 pmapcontrol)
 {
     InitializeComponent();
     this.pMapControl = pmapcontrol;
 }
示例#11
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolEditFeatures.OnMouseDown implementation
            try
            {
                ISceneControl pSceneCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as ISceneControl;
                if (pSceneCtr != null)
                {
                    IPoint po;
                    object owner, obj;
                    pSceneCtr.SceneGraph.Locate(pSceneCtr.SceneViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out po, out owner, out obj);//po就是得到的点

                    //方法2
                    IHit3DSet pHit3dSet = null;
                    pSceneCtr.SceneGraph.LocateMultiple(pSceneCtr.SceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pHit3dSet);

                    //po = pHit3D.Point;//po就是得到的点

                    //如果想得到某图层元素,可以看看下面代码

                    //  int index = 2;
                    if (pHit3dSet == null)
                    {
                        return;
                    }
                    pHit3dSet.OnePerLayer();
                    IHit3D   pHit3D   = (IHit3D)pHit3dSet.Hits.get_Element(0);
                    IFeature pFeature = (IFeature)pHit3D.Object;
                    if (pFeature == null)
                    {
                        return;
                    }
                    ILayer pLayer = owner as ILayer;
                    if (pLayer == null)
                    {
                        return;
                    }
                    if (pLayer.Name != "Crater" && pLayer.Name != "NonCrater")
                    {
                        return;
                    }
                    IFeatureClass pFeatureClass = ((IFeatureLayer)pLayer).FeatureClass;
                    pSceneCtr.Scene.ClearSelection();
                    pSceneCtr.Scene.SelectFeature(pLayer, pFeature);
                    IActiveView pActiveView = pSceneCtr.Scene as IActiveView;
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    IMultiPatch pMP = pFeature.Shape as IMultiPatch;
                    FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2);
                    FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2);
                }
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    IMap   pMap = pMapCtr.Map;
                    IPoint po   = pMapCtr.ToMapPoint(X, Y);
                    ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();
                    pMap.SelectByShape(po, pSelectionEnv, true);
                    //for (int i = 0; i < pMap.LayerCount; i++ )
                    //{
                    //    ILayer pLayer = pMap.get_Layer(i);

                    //    if (pLayer.Name == "Crater")
                    //    {
                    //        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    //    }
                    //    if (pLayer.Name =="NonCrater")
                    //    {
                    //        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                    //    }
                    //}
                    pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup;
                    pSelectionsetup.AllFields = true;//这里是关键
                    IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                    IFeature     pF = pFeatureCollection.Next();
                    if (pF != null && pF.Shape is IMultiPatch)
                    {
                        IMultiPatch pMP = pF.Shape as IMultiPatch;
                        FrmEditFeatures.setXLabel((pMP.Envelope.XMax + pMP.Envelope.XMin) / 2);
                        FrmEditFeatures.setYLabel((pMP.Envelope.YMax + pMP.Envelope.YMin) / 2);
                    }


                    //ISelection pSelection =pMap.FeatureSelection;
                    ////从Map.FeatureSelection获得ISelection不能读到Feature的其他属性,
                    ////这是因为从axMapControl1.Map.FeatureSelection QI到IEnumFeature 时,
                    ////ArcGIS中FeatureSelection默认的时候只存入Feature 的Shape,而不是整个Feature的字段数据。
                    ////如果要查看其他数据,必须要进行以下转换才可以:
                    //IEnumFeatureSetup pSelectionsetup = pSelection as IEnumFeatureSetup;
                    //pSelectionsetup.AllFields = true;//这里是关键
                    //IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                    //IFeature pF = pFeatureCollection.Next();
                    //if (pF != null)
                    //{
                    //    pF.Class
                    //}
                }
            }
            catch (System.Exception ex)
            {
            }
        }
示例#12
0
        public override void Run(object sender, EventArgs e)
        {
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            IFeature       pFea;


            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;

            List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");

            if (list == null)
            {
                return;
            }
            Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();

            WaitForm.Start("开始数据唯一性检查..", "请稍候");
            foreach (DF2DFeatureClass dfcc in list)
            {
                IFeatureClass fc = dfcc.GetFeatureClass();
                if (fc == null)
                {
                    return;
                }
                WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                DFDataConfig.Class.FieldInfo        fi1       = fac.GetFieldInfoBySystemName("detectid");
                if (fi1 == null)
                {
                    continue;
                }

                DataTable dt        = GetDataTableByStruture();
                string    TableName = (fc as IDataset).Name;
                pFilter.WhereClause = fi1.Name + " in (select " + fi1.Name + " from " + (fc as IDataset).Name + " group by " + fi1.Name + " having count(" + fi1.Name + ") > 1) order by " + fi1.Name + " asc";
                pFeaCursor          = fc.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = fc.AliasName;
                    dr["FeatureofLayer"] = (fc as IDataset).Name;
                    dr["FeatureClass"]   = fc;
                    dr["ErrorType"]      = "【物探点名】字段值重复";
                    dt.Rows.Add(dr);
                    //Console.WriteLine(pFea.OID);
                }

                if (dt.Rows.Count > 0)
                {
                    dict[fc] = dt;
                }
            }
            //if (dict.Count == 0)
            //{

            //    XtraMessageBox.Show("提示表格数据为空!");

            //}
            WaitForm.Stop();
            FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);

            dlg.Text = this.CommandName;
            dlg.Show();
        }
示例#13
0
 public frmSymbology(IRasterLayer rasterLayer, IMapControl4 mainMap)
 {
     InitializeComponent();
     m_RasterLayer = rasterLayer;
     m_MainMap = mainMap;
 }
示例#14
0
 public static void SetMapControl(IMapControl2 mapControl)
 {
     m_pMapC2 = mapControl;
 }
示例#15
0
        public static void Symbology_GraduatedColors(IFeatureLayer featureLayer, string fieldName, int numClasses, IMapControl2 mapControl, AxTOCControl tocControl)
        {
            // 获取渲染字段的值及其出现的频率
            ITable          pTable          = featureLayer as ITable;
            IBasicHistogram pBasicHistogram = new BasicTableHistogramClass()
            {
                Field = fieldName,
                Table = pTable
            };
            object dataFrequency, dataValue; // 频率和值

            pBasicHistogram.GetHistogram(out dataValue, out dataFrequency);
            // 数据分级
            IClassifyGEN pClassifyGEN = new EqualIntervalClass(); // 等间隔

            //IClassifyGEN pClassifyGEN = new GeometricalIntervalClass(); // 几何间隔
            //IClassifyGEN pClassifyGEN = new NaturalBreaksClass(); // 自然裂变
            //IClassifyGEN pClassifyGEN = new QuantileClass(); // 分位数
            //IClassifyGEN pClassifyGEN = new StandardDeviationClass(); // 标准偏差
            try { pClassifyGEN.Classify(dataValue, dataFrequency, numClasses); }
            catch { }
            double[]             Classes      = pClassifyGEN.ClassBreaks as double[];
            int                  ClassesCount = Classes.GetUpperBound(0);
            IClassBreaksRenderer pRenderer    = new ClassBreaksRendererClass()
            {
                // 分类字段 分类数目 升序
                Field                = fieldName,
                BreakCount           = ClassesCount,
                SortClassesAscending = true
            };
            // 生成颜色色带
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRamp()
            {
                FromColor = GetRgbColor(255, 200, 200),
                ToColor   = GetRgbColor(255, 0, 0),
                Size      = ClassesCount
            };
            bool bOk = false;

            pColorRamp.CreateRamp(out bOk);
            IEnumColors pColors = pColorRamp.Colors;

            // 逐一设置填充符号及每一分级的分级断点
            for (int index = 0; index < ClassesCount; index++)
            {
                IColor  pColor  = pColors.Next();
                ISymbol pSymbol = null;
                switch (featureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    pSymbol = new SimpleMarkerSymbolClass()
                    {
                        Color = pColor
                    };
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSymbol = new SimpleLineSymbolClass()
                    {
                        Color = pColor
                    };
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    pSymbol = new SimpleFillSymbolClass()
                    {
                        Color = pColor
                    };
                    break;
                }
                pRenderer.set_Symbol(index, pSymbol);           // 每级的符号
                pRenderer.set_Break(index, Classes[index + 1]); // 每级的断点
            }
            (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;
            mapControl.Refresh();
            tocControl.Update();
        }
示例#16
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            ITin         pTin     = pTinLayer.Dataset;
            ITinEdit     pTinEdit = pTin as ITinEdit;
            ISurface     pSurface = ((ITinAdvanced)pTin).Surface;
            IMapControl2 pMapCtr  = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            //在mapctr操作
            if (pMapCtr != null)
            {
                IPoint  mapPoint = pMapCtr.ToMapPoint(X, Y);
                IZAware za       = mapPoint as IZAware;
                za.ZAware = true;
                double zVal;
                if (frmAddTINNode.bFromSurface == true)
                {
                    zVal = pSurface.GetElevation(mapPoint);
                    if (double.IsNaN(zVal))
                    {
                        zVal = 0;
                    }
                    frmAddTINNode.SetdoubleInputHeightValue(zVal);
                }
                else
                {
                    zVal = frmAddTINNode.dHeight;
                    if (double.IsNaN(zVal))
                    {
                        zVal = 0;
                    }
                }
                mapPoint.Z  = zVal;
                pAddedPoint = mapPoint;
            }
            //在layout控件操作取不到z值
            else
            {
                IPageLayoutControl pLayoutCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IPageLayoutControl;
                //if (pLayoutCtr.ActiveView.FocusMap.Equals(pMap))

                IPoint  mapPoint = pLayoutCtr.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                IZAware za       = mapPoint as IZAware;
                za.ZAware = true;
                double zVal;
                if (frmAddTINNode.bFromSurface == true)
                {
                    zVal = pSurface.GetElevation(mapPoint);
                    if (double.IsNaN(zVal))
                    {
                        zVal = 0;
                    }
                    frmAddTINNode.SetdoubleInputHeightValue(zVal);
                }
                else
                {
                    zVal = frmAddTINNode.dHeight;
                    if (double.IsNaN(zVal))
                    {
                        zVal = 0;
                    }
                }
                mapPoint.Z  = zVal;
                pAddedPoint = mapPoint;
            }
        }
示例#17
0
        public static void Symbology_Proportional(IFeatureLayer featureLayer, string fieldName, IMapControl2 mapControl, AxTOCControl tocControl)
        {
            // 获取渲染字段统计值
            IStatisticsResults pStatResult = GetDataSataResults(featureLayer, fieldName);

            // 比例符号渲染
            if (pStatResult != null)
            {
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass()
                {
                    Color = GetRgbColor(155, 255, 0)
                };
                ISymbol pMarkerSymbol = new SimpleMarkerSymbolClass()
                {
                    Style = esriSimpleMarkerStyle.esriSMSDiamond,
                    Size  = 3,
                    Color = GetRgbColor(255, 90, 0)
                };
                IProportionalSymbolRenderer pRenderer = new ProportionalSymbolRendererClass()
                {
                    ValueUnit            = esriUnits.esriUnknownUnits, // 渲染单位
                    Field                = fieldName,                  // 渲染字段
                    FlanneryCompensation = false,
                    MinDataValue         = pStatResult.Minimum,        // 最小值
                    MaxDataValue         = pStatResult.Maximum,        // 最大值
                    BackgroundSymbol     = pFillSymbol,                // 背景颜色
                    MinSymbol            = pMarkerSymbol,              // 最小渲染符号
                    LegendSymbolCount    = 5                           // TOC控件中的显示条目
                };
                pRenderer.CreateLegendSymbols();
                (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;
                mapControl.Refresh();
                tocControl.Update();
            }
        }
示例#18
0
 public FormMain()
 {
     InitializeComponent();
     m_pMapC2  = axMapControl_Main.GetOcx() as IMapControl2;
     m_pMapDoc = new MapDocumentClass();
 }
        DFDataConfig.Class.FieldInfo fi, fi1, fi2, fi3, fi4, fi5, fi6;//管点属性字段

        public override void Run(object sender, EventArgs e)
        {
            Map2DCommandManager.Push(this);
            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;
            m_pActiveView = this.m_pMapControl.ActiveView;
            m_pMap        = m_pMapControl.ActiveView.FocusMap;
            List <DF2DFeatureClass> st = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");

            if (st == null)
            {
                return;
            }
            foreach (DF2DFeatureClass dfcc in st)
            {
                IFeatureClass fc = dfcc.GetFeatureClass();
                if (fc == null)
                {
                    continue;
                }
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                fi = fac.GetFieldInfoBySystemName("Classify");
                if (fi == null)
                {
                    continue;
                }
                fi1 = fac.GetFieldInfoBySystemName("x");
                if (fi1 == null)
                {
                    continue;
                }
                fi2 = fac.GetFieldInfoBySystemName("y");
                if (fi2 == null)
                {
                    continue;
                }
                fi3 = fac.GetFieldInfoBySystemName("DetectNo");
                if (fi3 == null)
                {
                    continue;
                }
                fi4 = fac.GetFieldInfoBySystemName("Additional");
                if (fi4 == null)
                {
                    continue;
                }
                fi5 = fac.GetFieldInfoBySystemName("Standard");
                if (fi5 == null)
                {
                    continue;
                }
                fi6 = fac.GetFieldInfoBySystemName("Road");
                if (fi6 == null)
                {
                    continue;
                }
            }
        }
示例#20
0
        public void RefreshLayer()
        {
            if (pGraphicsLayer != null)
            {
                IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer;
                int nCount             = m_IMUFeatureList.Count;

                pGC.DeleteAllElements();
                for (int i = 0; i < nCount; i++)
                {
                    IPolyline ppl = new PolylineClass();
                    ppl.FromPoint = m_IMUFeatureList[i].Shape as IPoint;
                    ppl.ToPoint   = m_CenterlinePointFeatureList[i].Shape as IPoint;

                    IRgbColor pColor = new RgbColorClass();


                    ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass();
                    pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound;

                    ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;
                    pLineProp.DecorationOnTop = true;

                    ILineDecoration pLineDecoration = new LineDecorationClass();
                    ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass();
                    pSimpleLineDecoElem.AddPosition(1);
                    IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass();
                    pArrowMarkerSym.Size             = 8;
                    pArrowMarkerSym.Color            = pColor;
                    pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol;
                    pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
                    pLineProp.LineDecoration = pLineDecoration;

                    ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;

                    pLineSymbol.Color = pColor;
                    pLineSymbol.Width = 1;

                    ILineElement pLineElem = new LineElementClass();
                    pLineElem.Symbol = pLineSymbol;
                    IElement pElem = pLineElem as IElement;
                    pElem.Geometry = ppl;

                    pGC.AddElement(pElem, 0);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    //pElement = new MarkerElementClass();
                    //pElement.Geometry = m_OriginPoints.get_Point(i);
                    //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass();
                    //sms.Style = esriSimpleMarkerStyle.esriSMSSquare;
                    //sms.Size = 9;
                    //IMarkerElement im = pElement as IMarkerElement;
                    //im.Symbol = sms ;
                    //    IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    //  pGraphicsContainer.AddElement(pElement, 0);
                    //pGC.AddElement(pElement,0);
                    //pGC.UpdateElement(pElement);



                    //IMarkerElement pMarkerEle = new MarkerElementClass();
                    //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol();
                    ////pPictureMarkerSymbol.Color = sitecolor as IColor;
                    //pPictureMarkerSymbol.Size = 10;
                    //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap,
                    //    GetParentPathofExe() + @"Resource\Globe.bmp");
                    //IElement pEle = pMarkerEle as IElement;
                    //pEle.Geometry = ppl.FromPoint;
                    //pMarkerEle.Symbol = pPictureMarkerSymbol;
                    //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    ////site.pEle = pEle;
                    //pGraphicsContainer.AddElement(pEle, 0);
                }

                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    if (m_IMUFeatureList.Count == 0)
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    }
                    else
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    }
                }
            }
        }
示例#21
0
 public void BindControl(IPageLayoutControl pPageLayout, IMapControl2 pMapControl)
 {
     this.m_pTOCTreeViewWrap.Hook = pPageLayout;
     this.m_pTOCTreeViewWrap.SetMapCtrl(pMapControl);
 }
示例#22
0
 private static void SetMapControl(IMapControl2 mapControl)
 {
 }
示例#23
0
        public static void AddAndVisualizeTreelistPipe(TreeList parentTree, IMapControl2 mapControl)
        {
            try
            {
                if (parentTree == null)
                {
                    return;
                }
                IMapDocument pMapDoc   = new MapDocument();
                string       pFileName = Config.GetConfigValue("2DMxdPipe");
                if (string.IsNullOrEmpty(pFileName) || !File.Exists(pFileName))
                {
                    return;
                }
                SplashScreenManager.Default.SendCommand(null, "正在加载二维管线数据......");
                pMapDoc.Open(pFileName, null);
                IMap pMap = pMapDoc.get_Map(0);
                Dictionary <string, IFeatureClass> dicfc = new Dictionary <string, IFeatureClass>(); //初始化要<素类ID,要素类>字典
                for (int i = 0; i < pMap.LayerCount; i++)                                            //对地图图层进行遍历
                {
                    ILayer layer = pMap.get_Layer(i);
                    ReadMapLayer(layer, dicfc);//读取该图层,并更新字典
                }
                if (dicfc == null || dicfc.Count == 0)
                {
                    return;
                }
                foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                {
                    TreeNodeLogicGroup2D tnlg = new TreeNodeLogicGroup2D()//创建逻辑分组根节点
                    {
                        Name = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias
                    };
                    tnlg.OwnNode = parentTree.AppendNode(new object[] { tnlg.Name }, (TreeListNode)null);
                    tnlg.Visible = true;
                    RecursiveAddAndVisualizePipeData(tnlg.OwnNode.TreeList, lg.LogicGroups, dicfc, mapControl, pMap);
                    foreach (MajorClass mc in lg.MajorClasses)                                                      //遍历当前逻辑分组的二级大类
                    {
                        Dictionary <string, DF2DFeatureClass> dict   = new Dictionary <string, DF2DFeatureClass>(); //MajorClass所对应的<要素类ID,类>字典
                        Dictionary <string, IFeatureLayer>    dicFLs = new Dictionary <string, IFeatureLayer>();    //MajorClass所对应的<要素类ID,图层>字典
                        TreeNodeMajorClass2D tnmc = new TreeNodeMajorClass2D()
                        {
                            Name = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias
                        };
                        tnmc.Visible     = true;
                        tnmc.CustomValue = mc;
                        tnlg.Add(tnmc);
                        SetFeatureClassForGroup(mc, tnmc, dicfc, dict); //设置MajorClass所对应的要素类
                        VisualMapLayer(pMap, mapControl, dict, dicFLs); //为地图控件加载相关的图层
                        SetSubClass(mc, tnmc, dict, dicFLs);            //设置subclass包含的相关参数的值
                        //AddSubClass(mc, tnmc, dicfc,dict,dicFLs);

                        DF2DMajorClass dfmc = new DF2DMajorClass(mc, tnmc);//应用于管线显示控制
                        DF2DMajorClassManager.Instance.Add(dfmc);
                    }
                    tnlg.CollapseAll();
                }
            }
            catch (System.Exception ex)
            {
                return;
            }
        }
示例#24
0
        public override void Run(object sender, EventArgs e)
        {
            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;
            List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");
            Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();

            WaitForm.Start("开始管线预警检查..", "请稍后");
            foreach (DF2DFeatureClass dffc in list)
            {
                IQueryFilter  pFilter = new QueryFilterClass();
                IFeatureClass fc      = dffc.GetFeatureClass();
                if (fc == null)
                {
                    continue;
                }
                WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                FacilityClass fac = dffc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                DFDataConfig.Class.FieldInfo        fi        = fac.GetFieldInfoBySystemName("Material");
                int index = fc.FindField(fi.Name);
                if (fi == null || index == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("UseState");
                int index1 = fc.FindField(fi1.Name);
                if (fi1 == null || index1 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi2 = fac.GetFieldInfoBySystemName("BuildYear");
                int index2 = fc.FindField(fi2.Name);
                if (fi2 == null || index2 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi3 = fac.GetFieldInfoBySystemName("Owner");
                int index3 = fc.FindField(fi3.Name);
                if (fi2 == null || index3 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("Road");
                int index4 = fc.FindField(fi4.Name);
                if (fi4 == null || index4 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi5 = fac.GetFieldInfoBySystemName("Diameter");
                int index5 = fc.FindField(fi5.Name);
                if (fi5 == null || index5 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi6 = fac.GetFieldInfoBySystemName("PipeLength2D");
                int index6 = fc.FindField(fi6.Name);
                if (fi6 == null || index6 == -1)
                {
                    continue;
                }

                DataTable dt      = GetDataTableByStruture();
                string    Strtime = DateTime.Now.Year.ToString();
                double    time    = double.Parse(Strtime);


                IFeatureCursor pFeaCursor = fc.Search(null, true);
                IFeature       pFea       = pFeaCursor.NextFeature();
                while (pFea != null)
                {
                    string stryear = pFea.get_Value(index2).ToString();
                    if (stryear == "")
                    {
                        stryear = "0";
                    }
                    double year       = double.Parse(stryear);
                    string matter     = pFea.get_Value(index).ToString();
                    string usestate   = pFea.get_Value(index1).ToString();
                    string ownerby    = pFea.get_Value(index3).ToString();
                    string proad      = pFea.get_Value(index4).ToString();
                    string standard   = pFea.get_Value(index5).ToString();
                    string pipelength = pFea.get_Value(index6).ToString();
                    double yeartime   = time - year;
                    yearXtime = 20 - yeartime;
                    DataRow dr = dt.NewRow();
                    dr["FeatureID"]    = pFea.OID;
                    dr["Matter"]       = matter;
                    dr["UseState"]     = usestate;
                    dr["StartTime"]    = year;
                    dr["UseTime"]      = yeartime;
                    dr["OwnerBy"]      = ownerby;
                    dr["Proad"]        = proad;
                    dr["Standard"]     = standard;
                    dr["FeatureClass"] = fc;
                    dr["PipeLength"]   = pipelength;
                    if (yearXtime > 0 && yearXtime <= 2)
                    {
                        dr["TimeAlert"] = yearXtime;
                        dt.Rows.Add(dr);
                    }
                    else if (yearXtime > 2 && yearXtime <= 5)
                    {
                        dr["TimeAlert"] = yearXtime;
                        dt.Rows.Add(dr);
                    }
                    else if (yearXtime < 0)
                    {
                        dr["TimeAlert"] = Math.Abs(yearXtime);
                        dt.Rows.Add(dr);
                    }
                    pFea = pFeaCursor.NextFeature();
                }
                if (dt.Rows.Count > 0)
                {
                    dict[fc] = dt;
                }
            }

            if (dict.Count == 0)
            {
                XtraMessageBox.Show("提示表格数据为空!");
                return;
            }
            WaitForm.Stop();
            FrmPipeAlert dlg = new FrmPipeAlert(dict, m_pMapControl);

            dlg.Text = this.CommandName;
            dlg.Show();
        }
示例#25
0
 private static void RecursiveAddAndVisualizePipeData(TreeList parentTree, List <LogicGroup> list, Dictionary <string, IFeatureClass> dicfc, IMapControl2 mapControl, IMap pMap)
 {
     if (parentTree == null || list == null)
     {
         return;
     }
     foreach (LogicGroup lg in list)
     {
         TreeNodeLogicGroup2D tnlg = new TreeNodeLogicGroup2D()
         {
             Name = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias
         };
         tnlg.OwnNode = parentTree.AppendNode(new object[] { tnlg.Name }, (TreeListNode)null);
         tnlg.Visible = true;
         RecursiveAddAndVisualizePipeData(tnlg.OwnNode.TreeList, lg.LogicGroups, dicfc, mapControl, pMap);
         foreach (MajorClass mc in lg.MajorClasses)
         {
             Dictionary <string, DF2DFeatureClass> dict   = new Dictionary <string, DF2DFeatureClass>(); //subclass所对应的<要素类ID,类>字典
             Dictionary <string, IFeatureLayer>    dicFLs = new Dictionary <string, IFeatureLayer>();    //subclass所对应的<要素类ID,图层>字典
             TreeNodeMajorClass2D tnmc = new TreeNodeMajorClass2D()
             {
                 Name = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias
             };
             tnmc.Visible     = true;
             tnmc.CustomValue = mc;
             tnlg.Add(tnmc);
             SetFeatureClassForGroup(mc, tnmc, dicfc, dict);
             VisualMapLayer(pMap, mapControl, dict, dicFLs);
             SetSubClass(mc, tnmc, dict, dicFLs);
             //AddSubClass(mc, tnlg, fcs, dict, dicFLs);
         }
         tnlg.CollapseAll();
     }
 }
示例#26
0
 public void BindControl(IPageLayoutControl pPageLayout, IMapControl2 pMapControl)
 {
     this.m_pDataSourceTreeView.Hook = pPageLayout;
     this.m_pDataSourceTreeView.SetMapCtrl(pMapControl);
 }
示例#27
0
 public FrmIntersect(IMapControl2 mapcontrol)
 {
     InitializeComponent();
     this.pMapControl = mapcontrol;
 }
示例#28
0
        DFDataConfig.Class.FieldInfo fi, fi1, fi2, fi3, fi4, fi5, fi6;//管线字段信息

        public override void Run(object sender, EventArgs e)
        {
            Map2DCommandManager.Push(this);
            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;
            m_pActiveView = this.m_pMapControl.ActiveView;
            m_pMap        = m_pMapControl.ActiveView.FocusMap;
            List <DF2DFeatureClass> st = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");

            if (st == null)
            {
                return;
            }
            foreach (DF2DFeatureClass dfcc in st)
            {
                IFeatureClass fc = dfcc.GetFeatureClass();
                if (fc == null)
                {
                    continue;
                }
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                fi = fac.GetFieldInfoBySystemName("classify");
                if (fi == null || fi.CanQuery == false)
                {
                    continue;
                }
                fi1 = fac.GetFieldInfoBySystemName("snodeid");
                if (fi1 == null || fi1.CanQuery == false)
                {
                    continue;
                }
                fi2 = fac.GetFieldInfoBySystemName("enodeid");
                if (fi2 == null || fi2.CanQuery == false)
                {
                    continue;
                }
                fi3 = fac.GetFieldInfoBySystemName("matter");
                if (fi3 == null || fi3.CanQuery == false)
                {
                    continue;
                }
                fi4 = fac.GetFieldInfoBySystemName("coverstsle");
                if (fi4 == null || fi4.CanQuery == false)
                {
                    continue;
                }
                fi5 = fac.GetFieldInfoBySystemName("standard");
                if (fi5 == null || fi5.CanQuery == false)
                {
                    continue;
                }
                fi6 = fac.GetFieldInfoBySystemName("proad");
                if (fi6 == null || fi6.CanQuery == false)
                {
                    continue;
                }
            }
            m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
        }
示例#29
0
 public FormCheckResult(Dictionary <IFeatureClass, DataTable> dt, IMapControl2 current2DMapControl)
 {
     InitializeComponent();
     dict          = dt;
     m_pMapControl = current2DMapControl;
 }
		private void Form1_Load(object sender, System.EventArgs e)
		{
			m_MapControl = (IMapControl2) axMapControl1.GetOcx();

			//Find sample data
			string sFilePath = @"..\..\..\Data\World";

			//Add sample shapefile data
			m_MapControl.AddShapeFile(sFilePath, "world30");
			m_MapControl.AddLayerFromFile(sFilePath + @"\continents.lyr",0);

			//Symbolize the data
			SymbolizeData(m_MapControl.get_Layer(0), 0.1, GetRGBColor(0, 0, 0), GetRGBColor(0, 128, 0));
			SymbolizeData(m_MapControl.get_Layer(1), 0.1, GetRGBColor(0, 0, 0), GetRGBColor(140, 196, 254));
			//Set up a global Geographic Coordinate System
			MakeCoordinateSystems();

			//Get the MapControl's graphics container and get the IGraphicsContainer interface
			m_GraphicsContainer = m_MapControl.ActiveView.GraphicsContainer;

			//Populate an array with agent id's and locations
			LoadAgentArray();

			//Loop through the array and display each agent location
			for (int i = 0; i <= 19; i++)
			{
				DisplayAgentLocation(agentArray[i]);
			}

			timer1.Interval = 800;
		}
示例#31
0
        // 唯一值符号化
        public static void Symbology_UniqueValue(IFeatureLayer featureLayer, string fieldName, IMapControl2 mapControl, AxTOCControl tocControl)
        {
            IUniqueValueRenderer pRenderer = new UniqueValueRendererClass()
            {
                FieldCount = 1
            };
            // 随机色带
            IColorRamp pColorRamp = new RandomColorRampClass()
            {
                StartHue = 0, MinSaturation = 0, MinValue = 0,
                EndHue   = 360, MaxSaturation = 100, MaxValue = 100,
                Size     = featureLayer.FeatureClass.FeatureCount(new QueryFilterClass())
            };
            bool bOk = false;

            pColorRamp.CreateRamp(out bOk);
            IEnumColors  pColors      = pColorRamp.Colors;
            ITable       pTable       = featureLayer as ITable;
            int          fieldIndex   = pTable.FindField(fieldName);
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.AddField(fieldName);
            ICursor pCursor = pTable.Search(pQueryFilter, true);
            IRow    pRow    = pCursor.NextRow();

            while (pRow != null)
            {
                IRowBuffer pRowBuffer = pRow as IRowBuffer;
                string     value      = pRowBuffer.get_Value(fieldIndex).ToString();
                IColor     pColor     = pColors.Next();
                ISymbol    pSymbol    = null;
                switch (featureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    pSymbol = new SimpleMarkerSymbolClass()
                    {
                        Color = pColor
                    };
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSymbol = new SimpleLineSymbolClass()
                    {
                        Color = pColor
                    };
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    pSymbol = new SimpleFillSymbolClass()
                    {
                        Color = pColor
                    };
                    break;
                }
                pRenderer.AddValue(value, "", pSymbol);
                pRow = pCursor.NextRow();
            }
            (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;
            mapControl.Refresh();
            tocControl.Update();
        }
示例#32
0
        public override void Execute()
        {
            base.Execute();
            if (!(this.Hook is IDFApplication))
            {
                return;
            }
            else
            {
                m_App = (IDFApplication)this.Hook;
            }

            m_MapView = m_App.Workbench.GetView(typeof(MapView)) as IMapView;
            if (m_MapView == null)
            {
                return;
            }
            //else
            //{
            //    //Modify by YuanHY20081112
            //    m_ToolbarManager = (m_App.Workbench as DefaultWorkbench).commandBarManager;
            //    ToolBase toolBase = m_ToolbarManager.Tools["2dmap.DFEditorTool.DrawArc3P"];
            //    if (m_MapView.CurrentTool == this)
            //    {
            //        if (((StateButtonTool)toolBase).Checked == false)
            //        {
            //            ((StateButtonTool)toolBase).Checked = true;//按下状态
            //            return;
            //        }
            //    }
            //}

            m_MapView.CurrentTool = this;

            m_MapControl   = m_App.CurrentMapControl;
            m_FocusMap     = m_MapControl.ActiveView.FocusMap;
            m_pActiveView  = (IActiveView)this.m_FocusMap;
            m_CurrentLayer = m_App.CurrentEditLayer;

            //获得状态栏的服务
            m_pStatusBarService = m_App.StatusBarService;

            CurrentTool.m_CurrentToolName = CurrentTool.CurrentToolName.drawArc3P;

            CommonFunction.MapRefresh(m_pActiveView);

            m_dblTolerance = CommonFunction.ConvertPixelsToMapUnits(m_pActiveView, 4);

            m_MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;

            m_pStatusBarService.SetStateMessage("提示:依次指定圆弧上的三点(A:绝对XY/R:相对XY/P:平行尺/ESC:取消/ENTER:结束/+shift:修改坐标)");

            //记录用户操作
            clsUserLog useLog = new clsUserLog();

            useLog.UserName  = DFApplication.LoginUser;
            useLog.UserRoll  = DFApplication.LoginSubSys;
            useLog.Operation = "绘制弧/扇形";
            useLog.LogTime   = System.DateTime.Now;
            useLog.TableLog  = (m_App.CurrentWorkspace as IFeatureWorkspace).OpenTable("WSGRI_LOG");
            useLog.setUserLog();
        }
示例#33
0
 public FormHawkEye(IHookHelper hookHelper)
 {
     InitializeComponent();
     this.m_pMapC2_Main    = hookHelper.Hook as IMapControl2;
     this.m_pMapC2_HawkEye = axMapControl_HawkEye.Object as IMapControl2;
 }
示例#34
0
 public override void OnCreate(object hook)
 {
     m_pMapC2 = hook as IMapControl2;
 }
示例#35
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseDown implementation
            if (!DataReady())
            {
                MessageBox.Show("内检测、中线图层设置不正确");
                return;
            }

            object       Miss         = Type.Missing;
            IMapControl2 pMapCtr      = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
            IMapControl3 m_MapControl = pMapCtr as IMapControl3;

            if (pMapCtr != null)
            {
                //IGeoReference pGR = pRasterLayer as IGeoReference;
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                if (bFlag == true)//起始点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        m_snappingFeed.UnInitialize();
                        m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
                        m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pIMULayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pIMULayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pIMULayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            IMUFeature = pFeature;
                            m_NewLineFeedback.Start(mapPoint);

                            bFlag = false;
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pSF);
                    }
                }
                else//目标点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.UnInitialize();
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);

                        m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pCenterlinePointLayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pCenterlinePointLayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pCenterlinePointLayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            CenterlinePointFeature = pFeature;



                            if (m_CenterlinePointFeatureList.Count > 0)
                            {
                                double newIMUM        = Convert.ToDouble(IMUFeature.Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                double newCenterlineM = Convert.ToDouble(CenterlinePointFeature.Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);
                                for (int i = 0; i < m_CenterlinePointFeatureList.Count; i++)
                                {
                                    double previewIMUM      = Convert.ToDouble(m_IMUFeatureList[i].Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                    double previewCentlineM = Convert.ToDouble(m_CenterlinePointFeatureList[i].Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);

                                    if ((newIMUM - previewIMUM) * (newCenterlineM - previewCentlineM) <= 0)
                                    {
                                        MessageBox.Show("特征点不能交叉匹配.");
                                        return;
                                    }
                                }
                            }

                            m_IMUFeatureList.Add(IMUFeature);
                            m_CenterlinePointFeatureList.Add(CenterlinePointFeature);
                            bFlag = true;
                            IPolyline pPline = m_NewLineFeedback.Stop();
                            m_FrmVectorLinkTable.RefreshDataTable();
                        }
                    }
                    m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    //m_snappingFeed.UnInitialize();

                    //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
                    // m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                }
            }
        }
示例#36
0
文件: Form1.cs 项目: nohe427/MyAddins
 private void StopEditing(IMapControl2 mapControl)
 {
     if (MessageBox.Show("Save Edits?", "Save Prompt", MessageBoxButtons.YesNo)
        == DialogResult.Yes)
         m_engineEditor.StopEditing(true);
     else
         m_engineEditor.StopEditing(false);
 }
示例#37
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseMove implementation


            IMapControl3 m_MapControl = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl3;

            m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
            m_snappingFeed.UnInitialize();
            m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
            m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
            m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;


            //起始点
            if (bFlag == true)
            {
                IPoint          point      = TransformToMapPoint(X, Y);
                IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                ISnappingResult snapresult = ptSnapper.Snap(point);
                if (snapresult != null)
                {
                    //   IEngineEditProperties2 ep2 = env as IEngineEditProperties2;
                    //if (ep2.SnapTips == true)
                    {
                        if (m_snappingFeed != null)
                        {
                            if (snapresult.Description == pIMULayer.Name + ": Point")
                            {
                                m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC);
                            }
                        }
                    }
                }
                else
                {
                    m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC);
                }
            }
            // 结束点
            if (bFlag == false)
            {
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                    m_NewLineFeedback.MoveTo(mapPoint);

                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        //   IEngineEditProperties2 ep2 = env as IEngineEditProperties2;
                        //if (ep2.SnapTips == true)
                        {
                            if (m_snappingFeed != null)
                            {
                                if (snapresult.Description == pCenterlinePointLayer.Name + ": Point")
                                {
                                    m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC);
                                }
                            }
                        }
                    }
                    else
                    {
                        m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC);
                    }
                }
            }
        }
示例#38
0
        public override void Run(object sender, EventArgs e)
        {
            int            i = 0, k;
            string         strDicValue;
            string         strPntID;
            IFeatureClass  Pntfc;
            IFeatureClass  Arcfc;
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            IFeature       pFea;

            string[] arrFc2DId;

            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;
            frmSelType frmType = new frmSelType();

            if (frmType.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    List <DF2DFeatureClass> pPntlist = new List <DF2DFeatureClass>();
                    List <DF2DFeatureClass> pArclist = new List <DF2DFeatureClass>();

                    m_arrPipeType = frmType.PipeType;
                    for (i = 0; i < m_arrPipeType.Count; i++)
                    {
                        MajorClass mc = m_arrPipeType[i] as MajorClass;
                        arrFc2DId = mc.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            IFeatureClass fc = dffc.GetFeatureClass();
                            if (fc == null)
                            {
                                continue;
                            }
                            if (dffc.GetFacilityClassName() == "PipeNode")
                            {
                                pPntlist.Add(dffc);
                                continue;
                            }
                            if (dffc.GetFacilityClassName() == "PipeLine")
                            {
                                pArclist.Add(dffc);
                                continue;
                            }
                        }
                    }
                    if ((pPntlist == null) || (pArclist == null))
                    {
                        return;
                    }
                    Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();
                    WaitForm.Start("开始数据一致性检查..", "请稍候");
                    int count = 0;
                    foreach (DF2DFeatureClass Pntdfcc in pPntlist)
                    {
                        DataTable        dt      = GetDataTableByStruture();
                        DF2DFeatureClass Arcdfcc = pArclist[count];
                        Pntfc = Pntdfcc.GetFeatureClass();
                        Arcfc = Arcdfcc.GetFeatureClass();
                        if (Pntfc == null && Arcfc == null)
                        {
                            return;
                        }
                        WaitForm.SetCaption("正在检查图层:" + " " + Pntfc.AliasName);
                        FacilityClass fac = Pntdfcc.GetFacilityClass();
                        if (fac == null)
                        {
                            continue;
                        }
                        FacilityClass facc = Arcdfcc.GetFacilityClass();
                        if (facc == null)
                        {
                            continue;
                        }
                        //List<DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                        DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("LinkType");
                        if (fi == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("Detectid");
                        if (fi1 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("StartNo");
                        if (fi2 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi3 = facc.GetFieldInfoBySystemName("EndNo");
                        if (fi3 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("UState");
                        if (fi4 == null)
                        {
                            continue;
                        }
                        //                 DFDataConfig.Class.FieldInfo fi5 = facc.GetFieldInfoBySystemName("source");
                        //                 if (fi5 == null) continue;
                        pFeaCursor = Pntfc.Search(null, true);

                        while ((pFea = pFeaCursor.NextFeature()) != null)
                        {
                            bool b1 = false, b2 = false;

                            strPntID    = pFea.get_Value(Pntfc.FindField(fi1.Name)).ToString();
                            strDicValue = pFea.get_Value(Pntfc.FindField(fi.Name)).ToString();


                            if (strDicValue == "三通" || strDicValue == "三分支")
                            {
                                k = 3;
                            }
                            else if (strDicValue == "四通" || strDicValue == "四分支")
                            {
                                k = 4;
                            }
                            else if (strDicValue == "五通" || strDicValue == "五分支")
                            {
                                k = 5;
                            }
                            else if (strDicValue == "六通" || strDicValue == "六分支")
                            {
                                k = 6;
                            }
                            else if (strDicValue == "七通" || strDicValue == "七分支")
                            {
                                k = 7;
                            }
                            else if (strDicValue == "八通" || strDicValue == "八分支")
                            {
                                k = 8;
                            }
                            else
                            {
                                k = 2;
                            }
                            pFilter.WhereClause = fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "'";
                            if (Arcfc.FeatureCount(pFilter) != k)
                            {
                                b1 = true;
                            }
                            if (Pntfc.FindField(fi4.Name) != -1 && Arcfc.FindField(fi4.Name) != -1)
                            {
                                pFilter.WhereClause = "(" + fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "') and " + fi4.Name + " <> '" + strDicValue + "'";
                                if (Arcfc.FeatureCount(pFilter) > 0)
                                {
                                    b2 = true;
                                }
                            }



                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = Pntfc.AliasName;
                            dr["FeatureofLayer"] = (Pntfc as IDataset).Name;
                            dr["FeatureClass"]   = Pntfc;

                            if (b1 && b2)
                            {
                                dr["ErrorType"] = "多通多分支与管点连接管线数量不一致;管点与相连接管线的使用状态不一致";
                            }
                            else if (b1 && !b2)
                            {
                                dr["ErrorType"] = "多通多分支与管点连接管线数量不一致";
                            }
                            else if (!b1 && b2)
                            {
                                dr["ErrorType"] = "管点与相连接管线的使用状态不一致";
                            }
                            dt.Rows.Add(dr);
                            //Console.WriteLine(pFea.OID + " " + Pntfc.AliasName);
                        }

                        if (dt.Rows.Count > 0)
                        {
                            dict[Pntfc] = dt;
                        }
                        count++;
                    }
                    WaitForm.Stop();
                    FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);
                    dlg.Text = this.CommandName;
                    dlg.Show();
                }
                catch (System.Exception ex)
                {
                }
            }
        }
 public FrmQuery(IMapControl2 pFMapControl)
 {
     InitializeComponent();
     pMapControl = pFMapControl;
     pMap = pFMapControl.Map;
 }