Exemplo n.º 1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                m_weatherLayer = null;

                //get the weather layer
                IEnumLayer layers = m_scene.get_Layers(null, false);
                layers.Reset();
                ILayer layer = layers.Next();
                while (layer != null)
                {
                    if (layer is RSSWeatherLayer3DClass)
                    {
                        m_weatherLayer = (RSSWeatherLayer3DClass)layer;
                        break;
                    }
                    layer = layers.Next();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        public frmBuffer(IMap _pMap)
        {
            InitializeComponent();
            //load all the feature layers in the map to the layers combo
            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            pMap = _pMap;
            layers = pMap.get_Layers(uid, true);
            layers.Reset();
            ILayer layer = null;
            while ((layer = layers.Next()) != null)
            {
                cboLayers.Items.Add(layer.Name);
            }
            //select the first layer
            if (cboLayers.Items.Count > 0)
                cboLayers.SelectedIndex = 0;

            string tempDir = System.IO.Path.GetTempPath();
            txtOutputPath.Text = System.IO.Path.Combine(tempDir, ((string)cboLayers.SelectedItem + "_buffer.shp"));

            //set the default units of the buffer
            int units = Convert.ToInt32(pMap.MapUnits);
            cboUnits.SelectedIndex = units;
        }
Exemplo n.º 3
0
        /// <summary> Returns a list of feature layers based on the geometry type </summary>
        /// <param name="geometryType">Geometry type.  Expected values "Point", "Line" or "Polygon".</param>
        /// <returns>Arraylist</returns>
        public ArrayList FeatureLayers(string geometryType)
        {
            ArrayList pList = new ArrayList();

            if (FocusMap == null)
            {
                return(pList);
            }
            if (FocusMap.LayerCount == 0)
            {
                return(pList);
            }

            try
            {
                UID pID = new UIDClass();
                pID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; //GeoFeatureLayer
                IEnumLayer pEnumLayer = FocusMap.get_Layers(pID, true);
                pEnumLayer.Reset();
                ILayer pLayer = pEnumLayer.Next();
                while (!(pLayer == null))
                {
                    if (pLayer is IFeatureLayer)
                    {
                        IFeatureLayer featurelayer = (IFeatureLayer)pLayer;
                        if (string.Compare(geometryType, "Point", true) == 0)
                        {
                            if ((featurelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryMultipoint) || (featurelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint))
                            {
                                pList.Add(pLayer.Name);
                            }
                        }
                        if (string.Compare(geometryType, "Line", true) == 0)
                        {
                            if ((featurelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) || (featurelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryLine))
                            {
                                pList.Add(pLayer.Name);
                            }
                        }
                        if (string.Compare(geometryType, "Polygon", true) == 0)
                        {
                            if (featurelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                            {
                                pList.Add(pLayer.Name);
                            }
                        }
                    }
                    pLayer = pEnumLayer.Next();
                }
                return(pList);
            }
            catch (Exception ex)
            {
                if (SupressMessaging == false)
                {
                    MessageBox.Show(ex.Message, "All Layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            return(pList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 列出Combox中所有图层和设置当前图层
        /// </summary>
        private void PopulateCombo()
        {
            if (null == m_map)
            {
                return;
            }

            //清空列表
            this.cmbLayersList.Items.Clear();

            //获得所有图层
            IEnumLayer layers = GetAllLayersList();

            if (null != layers)
            {
                //添加图层到列表中
                layers.Reset();
                ILayer layer = null;
                while ((layer = layers.Next()) != null)
                {
                    this.cmbLayersList.Items.Add(layer.Name);
                }
            }
            //设置当前选中图层
            this.cmbLayersList.SelectedIndex = 0;
        }
Exemplo n.º 5
0
        //折叠所有图层
        private void ctMenwMapCollapseAll_Click(object sender, EventArgs e)
        {
            IEnumLayer pEnumLayer = this.axMapControl1.Map.get_Layers(null, false);

            if (pEnumLayer == null)
            {
                return;
            }
            ILayer       pLayer;
            ILegendInfo  pLengendInfo;
            ILegendGroup pLengendGroup;

            pEnumLayer.Reset();
            for (pLayer = pEnumLayer.Next(); pLayer != null; pLayer = pEnumLayer.Next())
            {
                if (pLayer is ILegendInfo)
                {
                    pLengendInfo = pLayer as ILegendInfo;
                    for (int i = 0; i < pLengendInfo.LegendGroupCount; i++)
                    {
                        pLengendGroup         = pLengendInfo.get_LegendGroup(i);
                        pLengendGroup.Visible = false;
                    }
                }
            }
            this.axTOCControl1.Update();
        }
Exemplo n.º 6
0
        private void bufferDlg_Load(object sender, EventArgs e)
        {
            if (null == m_hookHelper || null == m_hookHelper.Hook || 0 == m_hookHelper.FocusMap.LayerCount)
            {
                return;
            }

            //load all the feature layers in the map to the layers combo
            IEnumLayer layers = GetLayers();

            layers.Reset();
            ILayer layer = null;

            while ((layer = layers.Next()) != null)
            {
                cboLayers.Items.Add(layer.Name);
            }
            //select the first layer
            if (cboLayers.Items.Count > 0)
            {
                cboLayers.SelectedIndex = 0;
            }

            string tempDir = System.IO.Path.GetTempPath();

            txtOutputPath.Text = System.IO.Path.Combine(tempDir, ((string)cboLayers.SelectedItem + "_buffer.shp"));

            //set the default units of the buffer
            int units = Convert.ToInt32(m_hookHelper.FocusMap.MapUnits);

            cboUnits.SelectedIndex = units;
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IEnumLayer pEnumLayer = this.m_hookHelper.FocusMap.get_Layers(null, false);

            if (pEnumLayer == null)
            {
                return;
            }
            ILayer       pLayer;
            ILegendInfo  pLengendInfo;
            ILegendGroup pLengendGroup;

            pEnumLayer.Reset();
            for (pLayer = pEnumLayer.Next(); pLayer != null; pLayer = pEnumLayer.Next())
            {
                if (pLayer is ILegendInfo)
                {
                    pLengendInfo = pLayer as ILegendInfo;
                    for (int i = 0; i < pLengendInfo.LegendGroupCount; i++)
                    {
                        pLengendGroup         = pLengendInfo.get_LegendGroup(i);
                        pLengendGroup.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void menuBikeMap_Click(object sender, EventArgs e)
        {
            IEnumLayer pEnumLayer = axMapControl1.Map.Layers;

            pEnumLayer.Reset();

            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                if (pLayer.Name == "1/2-普通地图/生活地图-基础道路")
                {
                    pLayer.Visible = true;
                }
                else if (pLayer.Name == "高程")
                {
                    pLayer.Visible = true;
                }
                else
                {
                    pLayer.Visible = false;
                }
                pLayer = pEnumLayer.Next();
            }
            axMapControl1.Refresh();
        }
        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            string checkedLayerName = ((CheckBox)e.Source).Content.ToString();

            foreach (MapLayerOptionItemData option in this._selectedItems.ToArray())
            {
                if (option.LayerName == checkedLayerName)
                {
                    this._selectedItems.Remove(option);
                }
            }
            //get the layers from the map
            IEnumLayer layers = this._axMapCtrl.Map.get_Layers();

            layers.Reset();

            ILayer layer = null;

            while ((layer = layers.Next()) != null)
            {
                if (layer.Name.ToLower() == checkedLayerName.ToLower())
                {
                    this._axMapCtrl.Map.DeleteLayer(layer);
                }
            }
        }
Exemplo n.º 10
0
 ///<summary> The specified featurelayer </summary>
 /// <param name="LayerName"> The feature layer be retrieved </param>
 ///<returns> Function to retrieve a layer by name </returns>
 public IFeatureLayer FeatureLayer(string LayerName)
 {
     if (FocusMap == null)
     {
         return(null);
     }
     if (FocusMap.LayerCount == 0)
     {
         return(null);
     }
     try
     {
         UID pID = new UIDClass();
         pID.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}";
         IEnumLayer pEnumLayer = FocusMap.get_Layers(pID, true);
         pEnumLayer.Reset();
         ILayer pLayer = pEnumLayer.Next();
         while (!(pLayer == null))
         {
             if (string.Compare(pLayer.Name, LayerName, true) == 0)
             {
                 return(pLayer as IFeatureLayer);
             }
             pLayer = pEnumLayer.Next();
         }
     }
     catch (Exception ex)
     {
         if (SupressMessaging == false)
         {
             MessageBox.Show(ex.Message, "Layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     return(null);
 }
Exemplo n.º 11
0
        /// <summary>
        /// 绘制多边形
        /// </summary>
        /// <param name="pGeom"></param>

        #endregion m_mapControl鼠标事件

        /// <summary>
        /// 要素识别
        /// </summary>
        /// <param name="activeView"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void doIdentify(IActiveView activeView, Int32 x, Int32 y)
        {
            IMap           map            = activeView.FocusMap;
            IdentifyDialog idenfityDialog = new IdentifyDialog();

            idenfityDialog.Map = map;

            // clear the dialog on each mouse click
            idenfityDialog.ClearLayers();
            IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            IDisplay display = screenDisplay; // implicit cast

            idenfityDialog.Display = display;

            IIdentifyDialogProps idenfityDialogProps = (IIdentifyDialogProps)idenfityDialog; // explicit cast
            IEnumLayer           enumLayer           = map.Layers;

            enumLayer.Reset();
            ILayer layer = enumLayer.Next();

            while (layer != null)
            {
                idenfityDialog.AddLayerIdentifyPoint(layer, x, y);
                layer = enumLayer.Next();
            }
            idenfityDialog.Show();
        }
Exemplo n.º 12
0
 private void FrmSurfaceOp_Load(object sender, EventArgs e)
 {
     cmbOutType.Items.Add("坡度");
     cmbOutType.Items.Add("坡向");
     cmbOutType.Items.Add("山体阴影");
     cmbOutType.Items.Add("等值线");
     cmbOutType.SelectedIndex = 0;
     cmbRenderType.Items.Add("无阴影");
     cmbRenderType.Items.Add("有阴影");
     cmbRenderType.SelectedIndex = 0;
     slider1.Maximum             = 90;
     slider1.Value   = 45;
     slider1.Minimum = 0;
     slider2.Maximum = 360;
     slider2.Value   = 315;
     slider2.Minimum = 0;
     txtContour.Text = "2";
     textBoxX3.Text  = "1";
     if (m_mapControl.Map != null)
     {
         //初始化图层列表
         IEnumLayer pEnumLayer = m_mapControl.Map.get_Layers(null, true);
         pEnumLayer.Reset();
         ILayer pLayer = null;
         while ((pLayer = pEnumLayer.Next()) != null)
         {
             if (pLayer is IRasterLayer)
             {
                 IDataLayer   pDatalayer = pLayer as IDataLayer;
                 IDatasetName pDname     = (IDatasetName)pDatalayer.DataSourceName;
                 cmbTargetRasterLayer.Items.Add(pDname.WorkspaceName.PathName + "\\" + pDname.Name);
             }
         }
     }
 }
Exemplo n.º 13
0
        private bool singleSelect        = false;            //是否单选

        public LayerSelection(IEnumLayer enumLayer, bool SingleSelect, string Title)
        {
            InitializeComponent();
            LayerSelectionCheckedListBox.Items.Clear(); //启动时清空选定项
            singleSelect = SingleSelect;
            this.Text    = Title;

            if (singleSelect)
            {
                SelectedCountLabel.Visible = false;
            }
            else
            {
                SelectedCountLabel.Visible = true;
            }
            //遍历图层
            enumLayer.Reset();
            ILayer layer = enumLayer.Next();

            while (layer != null)
            {
                string lyrInfo = layer.Name;
                if ((layer is IRasterLayer rasterLayer) && (!singleSelect))
                {
                    LayerSelectionCheckedListBox.Items.Add(lyrInfo, true);   //是栅格则勾选
                }
Exemplo n.º 14
0
        /// <summary>
        /// 根据图层名获得图层
        /// </summary>
        /// <params name="map">Map</params>
        /// <params name="lyrname">图层名</params>
        /// <returns>要素图层</returns>
        public static IFeatureLayer GetLayerByName(IMap map, string lyrname)
        {
            try
            {
                UID puid = new UID();
                puid.Value = GIS_Const.STR_IFeatureLayer; //"{40A9E885-5533-11d0-98BE-00805F7CED21}";//IFeatureLayer
                IEnumLayer enumLayer = map.get_Layers(puid, true);
                enumLayer.Reset();
                ILayer player;
                player = enumLayer.Next();
                IFeatureLayer featureLayer = new FeatureLayerClass();

                while (player != null)
                {
                    featureLayer = player as IFeatureLayer;
                    string layerName = featureLayer.Name;
                    if (layerName == lyrname)
                    {
                        return(featureLayer);
                        //break;
                    }
                    player = enumLayer.Next();
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// 窗体初始化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SelectByAttrFrm_Load(object sender, EventArgs e)
 {
     this.pMap = this.tempMainFrm.axMapControl1.Map;
     if (this.pMap.LayerCount == 0)
     {
         return;
     }
     this.pEnumLayer = this.pMap.get_Layers(null, true);
     if (pEnumLayer == null)
     {
         return;
     }
     pEnumLayer.Reset();
     for (this.pLayer = pEnumLayer.Next(); this.pLayer != null; this.pLayer = pEnumLayer.Next())
     {
         if (this.pLayer is IFeatureLayer)
         {
             this.comboBoxLayers.Items.Add(this.pLayer.Name);
         }
     }
     if (this.comboBoxLayers.Items.Count == 0)
     {
         MessageBox.Show("没有可供选择的图层!");
         this.Close();
         return;
     }
     this.comboBoxLayers.SelectedIndex = 0;
     this.comboBoxMethod.SelectedIndex = 0;
 }
Exemplo n.º 16
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (this.method_2())
     {
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
         try
         {
             IEnvelope extent  = (this.ifeatureClass_0 as IGeoDataset).Extent;
             ITinEdit  tinEdit = new Tin() as ITinEdit;
             tinEdit.InitNew(extent);
             tinEdit.StartEditing();
             IField pHeightField = null;
             bool   flag         = false;
             if (this.cboHeightField.Text != "")
             {
                 if (this.cboHeightField.SelectedIndex == 0)
                 {
                     flag = true;
                 }
                 else
                 {
                     int num = this.ifeatureClass_0.FindField(this.cboHeightField.Text);
                     if (num != -1)
                     {
                         pHeightField = this.ifeatureClass_0.Fields.get_Field(num);
                     }
                 }
             }
             IField pTagValueField = null;
             object obj            = flag;
             tinEdit.AddFromFeatureClass(this.ifeatureClass_0, null, pHeightField, pTagValueField, (esriTinSurfaceType)this.cboTinSurfaceType.SelectedIndex, ref obj);
             object obj2     = true;
             string tempPath = System.IO.Path.GetTempPath();
             int    num2     = 0;
             string text     = tempPath + "tmptin";
             while (Directory.Exists(text))
             {
                 text = tempPath + "tmptin" + num2++.ToString();
             }
             tinEdit.SaveAs(text, ref obj2);
             tinEdit.StopEditing(true);
             if (this.m_pMap != null)
             {
                 ILayerFactoryHelper layerFactoryHelper = new LayerFactoryHelper();
                 IEnumLayer          enumLayer          = layerFactoryHelper.CreateLayersFromName((tinEdit as IDataset).FullName);
                 enumLayer.Reset();
                 ILayer pLayer = enumLayer.Next();
                 this.m_pMap.AddLayer(pLayer);
             }
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             base.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
         catch (Exception exception_)
         {
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             System.Windows.Forms.MessageBox.Show("无法创建TIN,请确保输入要素的是否合适!");
             CErrorLog.writeErrorLog(this, exception_, "");
         }
     }
 }
Exemplo n.º 17
0
        private void CboAddItemsForIdentity(ComboBox cbo, IFeatureLayer inputLayer)
        {
            esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType;
            string           inputName         = inputLayer.Name;
            IFeatureLayer    featureLayer;
            IEnumLayer       layers = GetLayers();

            if (layers == null)
            {
                return;
            }
            layers.Reset();
            ILayer layer = layers.Next();

            while (layer != null)
            {
                if (layer is IFeatureLayer)
                {
                    featureLayer = layer as IFeatureLayer;
                    if (featureLayer.Name == inputName)
                    {
                        goto label1;
                    }
                    esriGeometryType overlayGeometryType = featureLayer.FeatureClass.ShapeType;
                    if (overlayGeometryType == inputGeometryType || overlayGeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        cbo.Items.Add(layer.Name);
                    }
                }
                label1 : layer = layers.Next();
            }
        }
        private void CboAddItems(ComboBox cbo, esriGeometryType geometryType, IFeatureLayer inputLayer)
        {
            string        inputName = inputLayer.Name;
            IFeatureLayer featureLayer;
            IEnumLayer    layers = GetLayers();

            if (layers == null)
            {
                return;
            }
            layers.Reset();
            ILayer layer = layers.Next();

            while (layer != null)
            {
                if (layer is IFeatureLayer)
                {
                    featureLayer = layer as IFeatureLayer;
                    if (featureLayer.Name == inputName)
                    {
                        goto label1;
                    }
                    if (featureLayer.FeatureClass.ShapeType == geometryType)
                    {
                        cbo.Items.Add(layer.Name);
                    }
                }
                label1 : layer = layers.Next();
            }
        }
Exemplo n.º 19
0
        private void comLayerName_SelectedIndexChanged(object sender, EventArgs e)
        {
            string     selectLayerName = comLayerName.SelectedItem.ToString();    //获得当前选择到的图层名称
            IEnumLayer pEnumlayer      = PMap.Layers;                             //获取地图中的图层集合

            pEnumlayer.Reset();                                                   //
            ILayer pLayer = pEnumlayer.Next();                                    //获得第一个图层

            while (pLayer != null)                                                //
            {
                string name = pLayer.Name;                                        //获得图层名称
                if (selectLayerName == name)                                      //在图层集合中找到相应名称的图层
                {
                    label1.Text            = "SELECT * FROM " + name + " WHERE:"; //设置显示的选择数据条件的文本字符串
                    _pSelectedFeatureLayer = pLayer as IFeatureLayer;             //接口查询,获得矢量要素层
                    _pSelectedFeatureClass = _pSelectedFeatureLayer.FeatureClass; //获得矢量层对应的数据源 特征类
                    IFields pFields = _pSelectedFeatureClass.Fields;              //获得要素类的字段集合
                    listFields.Items.Clear();                                     // 清除掉窗口中listview控件中显示的字段列表
                    for (int i = 0; i < pFields.FieldCount; i++)
                    {
                        IField pField = pFields.get_Field(i);                //获得第i个字段
                        string lsname = pField.Name;                         //获得字段名称
                        if (lsname != _pSelectedFeatureClass.ShapeFieldName) //若字段不是几何字段
                        {
                            // lsname = "\"" + lsname + "\"";
                            listFields.Items.Add(lsname);   // 将字段名称添加到listview字段列表控件中
                        }
                    }

                    return;
                }
                pLayer = pEnumlayer.Next();    //获得下一个图层
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 加载地图窗口中的图层
        /// </summary>
        private void DisplayLayersFromMapControl()
        {
            IMap map = associateMapControl.Map;

            if (map.LayerCount < 1)
            {
                return;
            }
            //获取指定类型图层
            UID uid = new UIDClass();

            //表示搜索的是 IDataLayer
            uid.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}";
            //布尔参数表示要搜索GroupLayer中的图层
            IEnumLayer layers = map.get_Layers(uid, true);

            layers.Reset();
            ILayer layer = layers.Next();

            while (layer != null)
            {
                LayerFilterProperties layerProperty = new LayerFilterProperties();
                //layerProperty.HeaderImage = null;
                layerProperty.LayerCategory    = string.Empty;
                layerProperty.LayerFilterName  = layer.Name;
                layerProperty.LayerFeatureType = GetLayerFeatureType(layer);
                layerProperty.TargetLayer      = layer;
                //保存引用
                layerFilterSet.Add(layerProperty);
                layer = layers.Next();
            }
            //释放Com对象
            System.Runtime.InteropServices.Marshal.ReleaseComObject(layers);
        }
Exemplo n.º 21
0
        //判断鼠标是否在已选择的记录集上
        public static bool MouseOnSelection(IPoint pPnt, IActiveView pActiveView)
        {
            //设置点选择容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();
            double Length = ConvertPixelsToMapUnits(pActiveView, pSelectEnv.SearchTolerance);

            UID pUID = new UIDClass();

            pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";   //UID for IFeatureLayer
            IEnumLayer pEnumLayer = pActiveView.FocusMap.get_Layers(pUID, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                if (MouseOnSelection(pLayer as IFeatureLayer, pPnt, pActiveView, Length) == true)
                {
                    return(true);
                }
                pLayer = pEnumLayer.Next();
            }

            return(false);
        }
Exemplo n.º 22
0
        private void SearchByAttrFrm_Load(object sender, EventArgs e)
        {
            if (m_MapControl.Map.LayerCount == 0)
            {
                return;
            }
            pMap = m_MapControl.Map;

            if (pMap.LayerCount == 0)
            {
                return;
            }
            this.pEnumLayer = this.pMap.get_Layers(null, true);
            if (pEnumLayer == null)
            {
                return;
            }
            pEnumLayer.Reset();
            for (this.pLayer = pEnumLayer.Next(); this.pLayer != null; this.pLayer = pEnumLayer.Next())//添加图层
            {
                if (this.pLayer is IFeatureLayer)
                {
                    this.comboBoxLayers.Items.Add(this.pLayer.Name);
                }
            }
            if (this.comboBoxLayers.Items.Count == 0)
            {
                MessageBox.Show("No layers existed to select!");
                this.Close();
                return;
            }
            this.comboBoxLayers.SelectedIndex = 0;
            this.comboBoxMethod.SelectedIndex = 0;
        }
Exemplo n.º 23
0
        /// <summary>
        /// 列出Combox中所有图层和设置当前图层
        /// </summary>
        private void PopulateCombo()
        {
            if (null == m_map)
            {
                return;
            }

            //清空列表
            this.cmbLayersList.Items.Clear();

            //获得所有图层
            IEnumLayer layers = GetAllLayersList();

            if (null != layers)
            {
                //添加图层到列表中
                layers.Reset();
                ILayer layer = null;
                while ((layer = layers.Next()) != null)
                {
                    if (layer is IGroupLayer)
                    {
                        continue;                        //不添加组图层
                    }
                    if (!layer.Name.Contains("默认"))
                    {
                        continue;
                    }
                    this.cmbLayersList.Items.Add(layer.Name);
                }
            }
            //设置当前选中图层
            this.cmbLayersList.SelectedIndex = 0;
        }
Exemplo n.º 24
0
        private IFeatureLayer GetFeatureLayer(string layerName)
        {
            /*for (int i = 0; i < pMap.LayerCount; i++)
             * {
             *  if (pMap.get_Layer(i).Name.Equals(layerName))
             *  {
             *      return pMap.get_Layer(i) as IFeatureLayer;
             *  }
             *
             * }
             * return null;*/
            //get the layers from the maps
            if (GetLayers() == null)
            {
                return(null);
            }
            IEnumLayer layers = GetLayers();

            layers.Reset();

            ILayer layer = null;

            while ((layer = layers.Next()) != null)
            {
                if (layer.Name == layerName)
                {
                    return(layer as IFeatureLayer);
                }
            }
            return(null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add OperateLayerSelector.OnClick implementation
            if (mApplication != null)
            {
                //Fill in the layer selector drop-down list
                IEnumLayer enumLayer = pMap.get_Layers();
                enumLayer.Reset();

                this.lyrSelectorCb.Items.Clear();//Layer selector initialization
                dicLayers = new Dictionary <string, ILayer>();
                ILayer layer = null;

                while ((layer = enumLayer.Next()) != null)
                {
                    //Add layer name information(not add no activated layer)
                    if (!layer.Visible)
                    {
                        continue;
                    }
                    if (!dicLayers.ContainsKey(layer.Name))
                    {
                        dicLayers.Add(layer.Name, layer);
                        lyrSelectorCb.Items.Add(layer.Name);
                    }
                }
            }
        }
Exemplo n.º 26
0
        private void FrmProjectBackward_Load(object sender, EventArgs e)
        {
            this.EnableGlass = false;
            //初始化图层列表
            IEnumLayer pEnumLayer = m_pMapControl.Map.get_Layers(null, true);

            pEnumLayer.Reset();
            ILayer pLayer = null;

            while ((pLayer = pEnumLayer.Next()) != null)
            {
                if (pLayer is IFeatureLayer)
                {
                    cmbPathFeatureLayer.Items.Add(pLayer.Name);
                }

                if (pLayer is IRasterLayer)
                {
                    cmbDemLayer.Items.Add(pLayer.Name);
                }
            }

            if (cmbPathFeatureLayer.Items.Count > 0)
            {
                cmbPathFeatureLayer.SelectedIndex = 0;
            }
            if (cmbDemLayer.Items.Count > 0)
            {
                cmbDemLayer.SelectedIndex = 0;
            }
        }
        public bool GetAllFabricSubLayers(out IArray CFSubLayers)
        {
            ICadastralFabricSubLayer pCFSubLyr     = null;
            IArray        CFParcelFabricSubLayers2 = new ArrayClass();
            IFeatureLayer pParcelFabricSubLayer    = null;
            UID           pId = new UIDClass();

            pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer

            IEnumLayer pEnumLayer = ArcMap.Editor.Map.get_Layers(pId, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                pCFSubLyr             = (ICadastralFabricSubLayer)pLayer;
                pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr;
                IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass;
                if (pDS.Workspace.Equals(ArcMap.Editor.EditWorkspace))
                {
                    CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer);
                }
                pLayer = pEnumLayer.Next();
            }
            CFSubLayers = CFParcelFabricSubLayers2;
            if (CFParcelFabricSubLayers2.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 28
0
        //**折叠所有图层**//
        private void TOC_CollapseAllLayers()
        {
            IEnumLayer pEnumLayer = this.m_pMapControl.Map.get_Layers(null, false);

            if (pEnumLayer == null)
            {
                return;
            }
            ILayer       pLayer;
            ILegendInfo  pLengendInfo;
            ILegendGroup pLengendGroup;

            pEnumLayer.Reset();
            for (pLayer = pEnumLayer.Next(); pLayer != null; pLayer = pEnumLayer.Next())
            {
                if (pLayer is ILegendInfo)
                {
                    pLengendInfo = pLayer as ILegendInfo;
                    for (int i = 0; i < pLengendInfo.LegendGroupCount; i++)
                    {
                        pLengendGroup         = pLengendInfo.get_LegendGroup(i);
                        pLengendGroup.Visible = false;
                    }
                }
            }
            this.m_pTOCControl.Update();
        }
Exemplo n.º 29
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                if (0 == m_hookHelper.FocusMap.LayerCount)
                {
                    return;
                }

                //get the weather layer
                IEnumLayer layers = m_hookHelper.FocusMap.get_Layers(null, false);
                layers.Reset();
                ILayer layer = layers.Next();
                while (layer != null)
                {
                    if (layer is RSSWeatherLayerClass)
                    {
                        m_weatherLayer = (RSSWeatherLayerClass)layer;
                        break;
                    }
                    layer = layers.Next();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
Exemplo n.º 30
0
        private void cmbLayersList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_map == null)
            {
                return;
            }


            //遍历所有图层
            IEnumLayer layers = GetAllLayersList();

            if (layers == null)
            {
                return;
            }

            layers.Reset();
            ILayer layer = null;

            while ((layer = layers.Next()) != null)
            {
                //if (layer is IGroupLayer)
                //    continue;

                if (this.cmbLayersList.SelectedItem.ToString() == layer.Name)
                {
                    DataEditCommon.g_pLayer = layer;
                }
            }
        }
Exemplo n.º 31
0
 /// <summary>
 /// Gets the name of the layer by.
 /// </summary>
 /// <param name="pMap">The p map.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <param name="isFeatureLayer"></param>
 /// <returns>ILayer.</returns>
 public static ILayer GetLayerByName(IMap pMap, string layerName, bool isFeatureLayer = false)
 {
     try                                                      //try循环遍历所有图层
     {
         IEnumLayer enumLayer = pMap.get_Layers(null, true);  //enumLayer里保存了所有图层
         enumLayer.Reset();
         ILayer layer;
         while ((layer = enumLayer.Next()) != null)
         {
             if (isFeatureLayer && (layer is IFeatureLayer) == false)
             {
                 continue;
             }
             if (layer.Name == layerName)
             {
                 return(layer);
             }
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
     return(null);
 }
Exemplo n.º 32
0
        public Buffer(IMap _pMap)
        {
            InitializeComponent();

            //����Glass����
            this.EnableGlass = false;
            //����ʾ�����С����ť
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            //
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
            //ȥ��ͼ��
            this.ShowIcon = false;

            //load all the feature layers in the map to the layers combo
            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            pMap = _pMap;
            layers = pMap.get_Layers(uid, true);
            layers.Reset();
            ILayer layer = null;
            while ((layer = layers.Next()) != null)
            {
                cboLayers.Items.Add(layer.Name);
            }
            //select the first layer
            if (cboLayers.Items.Count > 0)
                cboLayers.SelectedIndex = 0;

            string tempDir = System.IO.Path.GetTempPath();
            txtOutputPath.Text = System.IO.Path.Combine(tempDir, ((string)cboLayers.SelectedItem + "_buffer.shp"));

            //set the default units of the buffer
            int units = Convert.ToInt32(pMap.MapUnits);
            cboUnits.SelectedIndex = units;
        }
Exemplo n.º 33
0
 /// <summary>
 /// 窗体初始化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SelectByAttrFrm_Load(object sender, EventArgs e)
 {
     this.pMap = this.tempMainFrm.mainMapControl.Map;
     if (this.pMap.LayerCount == 0) return;
     this.pEnumLayer = this.pMap.get_Layers(null, true);
     if (pEnumLayer == null)
     {
         return;
     }
     pEnumLayer.Reset();
     for (this.pLayer = pEnumLayer.Next(); this.pLayer != null; this.pLayer = pEnumLayer.Next())
     {
         if (this.pLayer is IFeatureLayer)
         {
             this.comboBoxLayers.Items.Add(this.pLayer.Name);
         }
     }
     if (this.comboBoxLayers.Items.Count == 0)
     {
         MessageBox.Show("没有可供选择的图层!");
         this.Close();
         return;
     }
     this.comboBoxLayers.SelectedIndex = 0;
     this.comboBoxMethod.SelectedIndex = 0;
 }
Exemplo n.º 34
0
        private void LegendWizard_Load(object sender, EventArgs e)
        {
            if (m_pageLayoutControl.ActiveView.FocusMap == null)
            {
                MessageBox.Show("请先添加地图");
                return;

            }
            #region //点击 添加图例按钮 或在 PageLayoutControl中双击图例时
            if (mapSurroundFrame == null)  //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例;
            {

                //Get the GraphicsContainer
                IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer;
                graphicsContainer.Reset();
                IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties;
                //Get the MapFrame
                IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap);
                if (mapFrame == null) return;
                while (pElementPerties != null) //从地图中获得已有的图例
                {
                    if (pElementPerties.Type == "Map Surround Frame")
                    {
                        pMapSurrounFrame = pElementPerties as IMapSurroundFrame;
                        if (pMapSurrounFrame.MapSurround.Name == "Legend")
                        {
                            m_legend = pMapSurrounFrame.MapSurround as ILegend;
                            break;
                        }
                    }
                    pElementPerties = (IElementProperties)graphicsContainer.Next();
                }
                if (m_legend == null) //当地图中没有添加图例时 创建新图例
                {
                    //Create a legend
                    UID uID = new UIDClass();
                    uID.Value = "esriCarto.Legend";

                    //Create a MapSurroundFrame from the MapFrame
                    mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

                    if (mapSurroundFrame == null) return;
                    if (mapSurroundFrame.MapSurround == null) return;

                    m_legend = mapSurroundFrame.MapSurround as ILegend;
                }
                else
                {
                    mapSurroundFrame = pMapSurrounFrame;

                }

                UID m_uid = new UIDClass();
                m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}";
                m_mapLayers = m_mapControl.Map as IMapLayers;
                m_emuLayer = m_mapLayers.get_Layers(m_uid, true);//获取图层
                if (m_emuLayer != null)
                {
                    m_emuLayer.Reset();
                    ILayer m_layer = null;
                    while ((m_layer = m_emuLayer.Next()) != null)
                    {
                        this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中
                    }
                }
            }
               #endregion
            else //在双击任意范围打印框中图例时,获得图例,及图层信息;
            {
                if (m_Map == null)
                {
                    MessageBox.Show("请先添加地图!");
                }
                for (int k = 0; k < m_Map.LayerCount; k++)
                {
                    listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString());
                }
                m_legend = mapSurroundFrame .MapSurround as ILegend;
            }
            //以下设置需要用到的变量 及初始化 对话框
            plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的

            pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式

            if (m_legend.Title != null)
                textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本
            else
                textBox1.Text = "Legend";

            this.textBoxWidth.Text = "36";
            this.textBoxHeight.Text = "15";
            IMapSurround mapSurround = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = mapSurround;
            m_FrameProperties = (IFrameProperties)mapSurroundFrame;
            ISymbolBackground pSymbolBack = m_FrameProperties.Background as ISymbolBackground;
            ISymbolBorder pSymbolBorder = m_FrameProperties.Border as ISymbolBorder;
            ISymbolShadow pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow;
            if (pSymbolBack !=null )
            this.btnBackGroundColor.BackColor =ColorTranslator.FromOle ( pSymbolBack.FillSymbol.Color.RGB ) ;
            if (pSymbolBorder != null)
            this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB);
             if (pSymbolShadow != null)
            this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB);
        }
Exemplo n.º 35
0
        private IFeatureLayer GetFeatureLayer(string layerName)
        {
            //get the layers from the maps
            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            layers = pMap.get_Layers(uid, true);
            layers.Reset();

            ILayer layer = null;
            while ((layer = layers.Next()) != null)
            {
                if (layer.Name == layerName)
                    return layer as IFeatureLayer;
            }

            return null;
        }
Exemplo n.º 36
0
        private Dictionary<IFeatureLayer, string> GetTransMapLayers(IEnumLayer layers, IWorkspace transWorkspace)
        {
            Dictionary<IFeatureLayer, string> theReturn = new Dictionary<IFeatureLayer,string>();

            layers.Reset();
            ILayer theLayer = layers.Next();
            while (theLayer != null)
            {
                if (theLayer is IFeatureLayer)
                {
                    IDataset theDataset = ((IFeatureLayer)theLayer).FeatureClass as IDataset;
                    if (theDataset != null && theDataset.Workspace == transWorkspace)
                    {
                        theReturn.Add((IFeatureLayer)theLayer, theDataset.Name);
                    }
                }
                theLayer = layers.Next();
            }

            return theReturn;
        }