Example #1
0
        public static void TraceLayerProperties(this IMap map)
        {
            string s  = "Layer: {0} is visible: {1}";
            string ms = "IMapLayers2: {0} is visible: {1}. Parent is visible:{2}";

            IEnumLayer  enumLayer = (IEnumLayer)map.get_Layers(null, true);
            IMapLayers2 mapLayers = map as IMapLayers2;
            ILayer      layer     = null;

            while ((layer = enumLayer.Next()) != null)
            {
                bool isvis;
                bool isparentvis;

                mapLayers.IsLayerVisibleEx(layer, out isvis, out isparentvis);

                ILayer2 layer2 = layer as ILayer2;
                Trace.WriteLine(s.FormatString(layer2.Name, layer2.Visible));

                Trace.WriteLine(ms.FormatString(layer2.Name, isvis, isparentvis));
            }
        }
Example #2
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ClsAsortVertex.OnClick implementation
            IToolbarControl2 pToolbarControl;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pToolbarControl = (m_hookHelper.Hook) as IToolbarControl2;
                m_MapControl    = (pToolbarControl.Buddy) as IMapControl4;
            }
            else if (m_hookHelper.Hook is IMapControl4)
            {
                m_MapControl = (IMapControl4)(m_hookHelper.Hook);
            }

            IMap    pMap   = m_MapControl.ActiveView.FocusMap as IMap;
            ILayer2 pLayer = null;

            //m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint();

            for (int i = 0; i < pMap.LayerCount; i++)
            {
                pLayer = pMap.get_Layer(i) as ILayer2;
                if (pLayer is IFeatureLayer2)
                {
                    IFeatureLayer2    pFeatLyr = pLayer as IFeatureLayer2;
                    IFeatureSelection pFeatSel = pFeatLyr as IFeatureSelection;

                    ISelectionSet2 pSelSet = pFeatSel.SelectionSet as ISelectionSet2;
                    if (pSelSet.Count <= 0)
                    {
                        return;
                    }
                    else
                    {
                        ICursor pCursor = null;
                        pSelSet.Search(null, false, out pCursor);
                        IFeatureCursor pFeatCursor = pCursor as IFeatureCursor;

                        IFeature pFeat = pFeatCursor.NextFeature();
                        while (pFeat != null)
                        {
                            IGeometry5       pGeometry = pFeat.Shape as IGeometry5;
                            IPointCollection pPointCol = new Multipoint();
                            pPointCol = pGeometry as IPointCollection;

                            double[] arrayX = new double[200];
                            double[] arrayY = new double[200];

                            IPointArray pPtArray = new PointArrayClass();
                            pPtArray = AsortVertex(pPointCol, arrayX, arrayY);


                            for (int k = 0; k < pPointCol.PointCount; k++)
                            {
                                IPoint pPoint = new PointClass();
                                pPoint = pPointCol.get_Point(k);

                                MessageBox.Show(pPointCol.get_Point(k).ID.ToString());
                                for (int l = 0; l < pPtArray.Count; l++)
                                {
                                    if (pPoint.X == pPtArray.get_Element(l).X)
                                    {
                                        int ID = pPtArray.get_Element(l).ID;
                                        pPointCol.get_Point(k).ID = ID;
                                        MessageBox.Show(pPointCol.get_Point(k).ID.ToString());
                                        break;
                                    }
                                }
                            }
                            pFeat = pFeatCursor.NextFeature();
                        }
                    }
                }
            }
            m_MapControl.ActiveView.Refresh();
        }