private void btnOK_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 0)
     {
         try
         {
             ChangeRender2RasterStretchColorRampRender(rasterlayer);
             axmapcontrol.Refresh();
             axtoccontrol.Update();
             axmapcontrol.Extent = rasterlayer.AreaOfInterest;
         }
         catch (Exception ec)
         {
             MessageBox.Show(ec.Message);
         }
     }
     else
     {
         try
         {
             IColorRamp pColorRamp = (IColorRamp)EnumStyleItem[colorComboBox1.SelectedIndex];
             RasterClassify(rasterlayer, cmbClassifyMethod.Text, Convert.ToInt32(nudClassCount.Text), pColorRamp);
             //ChangeRender2ClassifyColorRampRenderer(rasterlayer, Convert.ToInt32(nudClassCount.Text), pColorRamp);
             axmapcontrol.Refresh();
             axtoccontrol.Update();
             axmapcontrol.Extent = rasterlayer.AreaOfInterest;
         }
         catch (Exception ec)
         {
             MessageBox.Show(ec.Message);
         }
     }
 }
Beispiel #2
0
        private void DotDensity(IFeatureLayer pFeatLyr, string sFieldName, int intRendererDensity)
        {
            IGeoFeatureLayer    pGeoFeatureLayer    = pFeatLyr as IGeoFeatureLayer;
            IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass();
            IRendererFields     pRendererFields     = pDotDensityRenderer as IRendererFields;

            //设置渲染字段
            pRendererFields.AddField(sFieldName);
            //设置填充背景色
            IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();

            pDotDensityFillSymbol.DotSize         = 3;
            pDotDensityFillSymbol.BackgroundColor = GetRgbColor(0, 255, 0);
            //设置渲染符号
            ISymbolArray        pSymbolArray        = pDotDensityFillSymbol as ISymbolArray;
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerSymbol.Color = GetRgbColor(0, 0, 255);
            pSymbolArray.AddSymbol(pSimpleMarkerSymbol as ISymbol);
            pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol;
            //设置渲染密度,即每个点符号所代表的数值大小
            pDotDensityRenderer.DotValue = intRendererDensity;
            //创建图例
            pDotDensityRenderer.CreateLegend();
            pGeoFeatureLayer.Renderer = pDotDensityRenderer as IFeatureRenderer;
            axMapControl1.Refresh();
            axMapControl1.Update();
            Close();
        }
Beispiel #3
0
        public void zoomIn()
        {
            IEnvelope pEnvelope = mapControl.TrackRectangle();

            mapControl.Extent = pEnvelope;
            mapControl.Refresh();
        }
Beispiel #4
0
 //缩放至图层;
 private void 缩放至ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (layer_Toccontrol == null)
     {
         return;
     }
     (mapcontrol.Map as IActiveView).Extent = layer_Toccontrol.AreaOfInterest;
     mapcontrol.Refresh();
 }
Beispiel #5
0
 private void FormPhoto_Load(object sender, EventArgs e)
 {
     if (!isnetError)
     {
         PhotoLayer = GetPhotosLayer();
         mainMapControl.AddLayer(PhotoLayer);
         mainMapControl.Refresh();
         ApplicationV.IsBanFormMainMapClick = true;
     }
 }
Beispiel #6
0
        private void ShowLabel()
        {
            if (labelOn)
            {
                if (!this.cbxActiveMap.HasItems || !this.cbxFeatureLayer.HasItems || !this.cbxField.HasItems)
                {
                    return;
                }
                if (annoPropCol != null)
                {
                    annoPropCol.Clear();
                }
                labelLayer  = this.m_map.Map.get_Layer(this.cbxFeatureLayer.SelectedIndex) as IFeatureLayer;
                gLabelLayer = labelLayer as IGeoFeatureLayer;
                annoPropCol = gLabelLayer.AnnotationProperties;

                ITextSymbol pTextSyl = new TextSymbol();
                IFontDisp   font     = new StdFont() as IFontDisp;
                font.Size     = 20;
                font.Italic   = true;
                pTextSyl.Font = font;
                RgbColor color = new RgbColor();
                color.Red      = LabelColor.R;
                color.Green    = LabelColor.G;
                color.Blue     = LabelColor.B;
                pTextSyl.Color = color;

                IBasicOverposterLayerProperties pBasic          = new BasicOverposterLayerProperties();
                IPointPlacementPriorities       pPlacementPoint = new PointPlacementPriorities();
                pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
                pBasic.PointPlacementPriorities = pPlacementPoint;
                pBasic.PointPlacementOnTop      = false;
                pBasic.PointPlacementMethod     = esriOverposterPointPlacementMethod.esriOnTopPoint;

                ILabelEngineLayerProperties labelField = new LabelEngineLayerProperties() as ILabelEngineLayerProperties;

                //IFeatureClass fClass = ((IFeatureLayer)labelLayer).FeatureClass;
                //IFields fields = fClass.Fields;
                //String fieldName = fields.get_Field(this.cbxField.SelectedIndex).Name;

                string fieldName = (string)cbxField.SelectedItem;
                //Console.WriteLine(fields.FindField(fieldName));
                labelField.Expression = "[" + fieldName + "]";
                //set postion
                labelField.BasicOverposterLayerProperties = pBasic;
                //set  symbol
                labelField.Symbol = pTextSyl;
                IAnnotateLayerProperties annoProp = labelField as IAnnotateLayerProperties;
                annoPropCol.Add(annoProp);
                gLabelLayer.DisplayAnnotation = true;
                m_map.Refresh();
            }
        }
Beispiel #7
0
        public bool Create(string sLayerName, esriGeometryType nGeometryType, baseFieldList pNewFields, bool bAddIntoMapContol = false)
        {
            if (m_axMapControl == null)
            {
                return(false);
            }
            m_nGeometryType = nGeometryType;
            m_sMapPath      = Global.GetWorkspacePath();
            m_sLayerName    = sLayerName;
            bool bFileExisted = System.IO.File.Exists(m_sMapPath + "\\" + m_sLayerName + ".shp");

            if (bFileExisted && MessageBox.Show("The file is already existed, and do you want to create new one?", "Select one", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                System.IO.File.Delete(m_sMapPath + "\\" + m_sLayerName + ".shp");
                System.IO.File.Delete(m_sMapPath + "\\" + m_sLayerName + ".dbf");
                System.IO.File.Delete(m_sMapPath + "\\" + m_sLayerName + ".shx");
                GeoBaseLib.RemoveLayer(m_axMapControl, m_sLayerName);
            }
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace pFWS = pWorkspaceFactory.OpenFromFile(m_sMapPath, 0) as IFeatureWorkspace;

            m_pFeatureLayer = new FeatureLayerClass();
            //If file existed, directly load
            if (System.IO.File.Exists(m_sMapPath + "\\" + m_sLayerName + ".shp"))
            {
                m_pFeatureLayer.FeatureClass = pFWS.OpenFeatureClass(m_sLayerName);
                m_pFeatureLayer.Name         = m_pFeatureLayer.FeatureClass.AliasName;
                if (bAddIntoMapContol && !GeoBaseLib.IsLayerExisted(m_axMapControl, m_sLayerName))
                {
                    m_axMapControl.AddLayer(m_pFeatureLayer);
                    m_axMapControl.Refresh();
                }
                return(true);
            }
            try
            {
                IFields pFields = CreateFields(pNewFields);
                //Create feature class
                m_pFeatureLayer.FeatureClass = pFWS.CreateFeatureClass(m_sLayerName, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
                m_pFeatureLayer.Name         = m_sLayerName;
                if (bAddIntoMapContol)
                {
                    m_axMapControl.AddShapeFile(m_sMapPath, m_sLayerName + ".shp");
                    m_axMapControl.Refresh();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Create \"" + m_sLayerName + "\" shapefile error:" + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            return(true);
        }
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     rasterRen.Raster = m_rasterLayer.Raster;
     rasterRen.Update();
     rasterRGBRen.RedBandIndex   = comboBox2.SelectedIndex;
     rasterRGBRen.GreenBandIndex = comboBox3.SelectedIndex;
     rasterRGBRen.BlueBandIndex  = comboBox4.SelectedIndex;
     rasterRen.Update();
     m_rasterLayer.Renderer = (IRasterRenderer)rasterRGBRen;
     m_mapControl.Extent    = m_rasterLayer.AreaOfInterest;
     m_mapControl.ActiveView.Refresh();
     m_mapControl.Refresh();
     m_mapControl.Update();
 }
        public void OverViewSynchronizeOnMapReplace(object sender, IMapControlEvents2_OnMapReplacedEvent e)
        {
            if (m_MainFormMapControl != null && m_axMapControl != null)
            {
                m_axMapControl.Map.ClearLayers();
                IMap pMap = m_MainFormMapControl.Map;

                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    m_axMapControl.Map.AddLayer(pMap.get_Layer(i));
                }
            }

            m_axMapControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #10
0
        /// <summary>
        ///添加点图层
        /// </summary>
        /// <param name="axMap"></param>
        /// <param name="longtitude"></param>
        /// <param name="latitude"></param>
        /// <param name="fieldsMap"></param>
        public static IFeature addPointInLayer(AxMapControl axMap, SharedStory story)
        {
            try
            {
                double longitude = Convert.ToDouble(story.Longitude);
                double latitude  = Convert.ToDouble(story.Latitude);
                String storyId   = story.Id;
                String message   = story.Message;

                ILayer layer = getLayerByName(axMap.Map, "story");

                //将ILayer转换为IFeaturelayer,为了对图层上的要素进行编辑
                IFeatureLayer featureLayer = layer as IFeatureLayer;
                //定义一个要素集合,并获取图层的要素集合
                IFeatureClass featureClass = featureLayer.FeatureClass;
                //定义一个实现新增要素的接口实例,并该实例作用于当前图层的要素集
                IFeatureClassWrite writer = (IFeatureClassWrite)featureClass;
                //定义一个工作编辑工作空间,用于开启前图层的编辑状态
                IWorkspaceEdit edit = (featureClass as IDataset).Workspace as IWorkspaceEdit;
                //定义一个IFeature实例,用于添加到当前图层上
                IFeature feature;
                //开启编辑状态
                edit.StartEditing(true);
                //开启编辑操作
                edit.StartEditOperation();
                //定义一个点,用来作为IFeature实例的形状属性,即shape属性
                IPoint point;
                //下面是设置点的坐标和参考系
                point = new PointClass();
                point.SpatialReference = axMap.SpatialReference;
                point.X = longitude;
                point.Y = latitude;

                //将IPoint设置为IFeature的shape属性时,需要通过中间接口IGeometry转换
                IGeometry geometry = point;
                //实例化IFeature对象, 这样IFeature对象就具有当前图层上要素的字段信息
                feature = featureClass.CreateFeature();
                //设置IFeature对象的形状属性
                feature.Shape = geometry;

                //添加字段
                int index = featureClass.FindField("story_id");
                feature.Value[index] = storyId;



                feature.Store();              //保存IFeature对象
                writer.WriteFeature(feature); //将IFeature对象,添加到当前图层上
                edit.StopEditOperation();     //停止编辑操作
                edit.StopEditing(true);       //关闭编辑状态,并保存修改

                axMap.Refresh();              //刷新地图

                return(feature);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            gp.AddOutputsToMap = true;
            //DisplayEnvironmentPameters(gp);
            IGeoProcessorResult results = null;

            results = UnionOverlay1(gp);

            try
            {
                //将结果添加到当前地图中
                FileInfo info = new FileInfo(outputFullPath);
                string   path = outputFullPath.Substring(0, outputFullPath.Length - info.Name.Length);
                axMapControl1.AddShapeFile(path, info.Name);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                this.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("出错:" + ee.Message);
            }
        }
Beispiel #12
0
        //执行拉伸渲染函数
        private void StretchRender(ILayer layer)
        {
            if (comboBoxBand.SelectedItem == null)
            {
                MessageBox.Show("波段不能为空!");
                return;
            }
            IColorRamp   pColorRamp  = (IColorRamp)EnumStyleItem[comboBoxColor.SelectedIndex];
            IRasterLayer pRasterLayr = layer as IRasterLayer;
            IRasterStretchColorRampRenderer pStretchRenderer = new RasterStretchColorRampRendererClass();
            IRasterRenderer pRasterRenderer = (IRasterRenderer)pStretchRenderer;
            IRaster         pRaster         = pRasterLayr.Raster;

            pRasterRenderer.Raster = pRaster;
            pRasterRenderer.Update();
            pStretchRenderer.BandIndex = comboBoxBand.SelectedIndex;
            pStretchRenderer.ColorRamp = pColorRamp;
            IRasterStretch pStretchType = (IRasterStretch)pRasterRenderer;

            pStretchType.StretchType             = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
            pStretchType.StandardDeviationsParam = Convert.ToDouble(textBoxStandardValue.Text);

            pRasterLayr.Renderer = pRasterRenderer;

            m_mapControl.Refresh();
        }
Beispiel #13
0
        public void ClearRouteAnalyst(AxMapControl mapControl)
        {
            //清除所有图标
            SymbolUtil.ClearElement(mapControl);
            stopPoints.Clear();
            barryPoints.Clear();
            barryElements.Clear();
            stopElements.Clear();
            //清除网络分析图层
            for (int i = 0; i < mapControl.LayerCount; i++)
            {
                ILayer        layer        = mapControl.get_Layer(i);
                INetworkLayer networkLayer = layer as INetworkLayer;
                INALayer      naLayer      = layer as INALayer;
                if (networkLayer != null || naLayer != null)
                {
                    mapControl.DeleteLayer(i);
                }
            }
            //清除网络数据集
            ILayer datalayer = LayerUtil.QueryLayerInMap(mapControl, "网络数据集");

            if (datalayer != null)
            {
                mapControl.Map.DeleteLayer(datalayer);
            }
            IActiveView pActiveView = mapControl.ActiveView;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            mapControl.Refresh();
        }
 private void simpleButton1_Click(object sender, EventArgs e)            //渲染图层
 {
     if (comboBoxEdit2.Text == "分级渲染")
     {
         if (comboBoxEdit3.Text != "自定义分级")
         {
             Classifly.classifyRender(featureLayer, comboBoxEdit3.Text, comboBoxEdit1.Text,
                                      getRamp(), Convert.ToInt16(spinEdit1.Text));
         }
         else
         {
             Classifly.userRender(featureLayer, comboBoxEdit3.Text, comboBoxEdit1.Text,
                                  getRamp(), Convert.ToInt16(spinEdit1.Text), valueChooseInChart1.getValues());
         }
     }
     else if (comboBoxEdit2.Text == "圆大小渲染")
     {
         Classifly.ProportionalRenderer(featureLayer, comboBoxEdit1.Text,
                                        ColorToIColor(colorPickEdit3.Color), Convert.ToDouble(spinEdit2.Text));
     }
     else
     {
         Classifly.uniqueRender(featureLayer, comboBoxEdit1.Text);
     }
     axMapControl1.Refresh();
     axTOCControl1.Update();
 }
Beispiel #15
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     if (comboBoxEdit2.Text == "分级渲染")
     {
         if (comboBoxEdit1.Text != "自定义分级")
         {
             Classifly.classifyRender(rasterLayer, comboBoxEdit1.Text,
                                      Convert.ToInt16(spinEdit1.Text), getRamp());
         }
         else
         {
             Console.WriteLine("自定义");
             Classifly.userRender(rasterLayer, getRamp(), Convert.ToInt32(spinEdit1.Text), valueChooseInChart1.getValues());
         }
     }
     else if (comboBoxEdit2.Text == "连续渲染")
     {
         Classifly.stretchRender(rasterLayer, getRamp());
     }
     else
     {
         Classifly.uniqueRender(rasterLayer);
     }
     axMapControl1.Refresh();
     axTOCControl1.Update();
 }
Beispiel #16
0
        private IGeoProcessorResult CreateBuffer(Geoprocessor gp)
        {
            strBufferLayer = cboBufferLayer.Text;
            //Buffer_analysis (in_features, out_feature_class, buffer_distance_or_field, line_side, line_end_type, dissolve_option, dissolve_field)
            ESRI.ArcGIS.AnalysisTools.Buffer buffer = new ESRI.ArcGIS.AnalysisTools.Buffer();
            IFeatureLayer bufferLayer = GetFeatureLayer(strBufferLayer);

            buffer.in_features = bufferLayer;


            string outputFullPath = System.IO.Path.Combine(strOutputPath, textBox1.Text);

            buffer.out_feature_class        = outputFullPath;
            buffer.buffer_distance_or_field = bufferDistanceField + " " + (string)comboBox1.SelectedItem;

            buffer.line_side       = strSideType;
            buffer.line_end_type   = strEndType;
            buffer.dissolve_option = strDissolveType;
            buffer.dissolve_field  = strDissolveFields;

            IGeoProcessorResult results          = (IGeoProcessorResult)gp.Execute(buffer, null);
            IFeatureLayer       pOutputFeatLayer = new FeatureLayerClass();

            outputFeatureName = textBox1.Text;


            FileInfo info = new FileInfo(outputFeatureName);
            string   path = outputFeatureName.Substring(0, outputFeatureName.Length - info.Name.Length);

            axMapControl1.AddShapeFile(path, info.Name);
            axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);

            return(results);
        }
Beispiel #17
0
 /// <summary>
 /// 加载CAD文件
 /// </summary>
 /// <param name="axMapControl">地图控件引用</param>
 /// <param name="strFilePath">文件路径</param>
 /// <returns>正常:“”,异常:异常字符;</returns>
 private SystemErrorType LoadCADFile(ref AxMapControl axMapControl, string strFilePath)
 {
     if (strFilePath == "")
     {
         return(SystemErrorType.enumFilePathIsNull);
     }
     try
     {
         //workspace声明
         IWorkspaceFactory    pCadWorkspaceFactory = null;
         IWorkspace           pWorkspace           = null;
         ICadDrawingWorkspace pCadDrawingWorkspace = null;
         ICadDrawingDataset   pCadDataset          = null;
         ICadLayer            pCadLayer            = null;
         //地图数据操作
         pCadWorkspaceFactory        = new CadWorkspaceFactoryClass();
         pWorkspace                  = pCadWorkspaceFactory.OpenFromFile(strFilePath, 0);
         pCadDrawingWorkspace        = pWorkspace as ICadDrawingWorkspace;
         pCadDataset                 = pCadDrawingWorkspace.OpenCadDrawingDataset(strFilePath);
         pCadLayer                   = new CadLayerClass();
         pCadLayer.CadDrawingDataset = pCadDataset;
         //控件操作
         axMapControl.ClearLayers();
         axMapControl.AddLayer(pCadLayer, 0);
         axMapControl.Refresh();
     }
     catch (Exception)
     {
         return(SystemErrorType.enumArcObjectHandleError);
     }
     return(SystemErrorType.enumOK);
 }
Beispiel #18
0
        /// <summary>
        /// 打开地图文档
        /// </summary>
        /// <param name="axMapControl"></param>
        public void loadMapDoc(AxMapControl axMapControl)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title  = "打开地图文档";
            openFileDialog1.Filter = "地图文档(*.mxd)|*.mxd";//设置过滤属性
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;                                 //未选择文件return
            }
            string filePath = openFileDialog1.FileName; //获取到文件路径

            if (axMapControl.CheckMxFile(filePath))     //检查路径是否合法
            {
                try
                {
                    axMapControl.LoadMxFile(filePath, 0, Type.Missing);
                }
                catch (Exception e) {
                    MessageBox.Show("该地图已损坏或者受保护不能被打开");
                }
            }
            else
            {
                MessageBox.Show(filePath + "不是有效的地图文档路径");
                return;
            }
            axMapControl.Refresh();
        }
Beispiel #19
0
        /// <summary>
        /// 地图及其图层/表格树、鹰眼图、导航工具、页面布局视图的组合控件的管理类
        /// </summary>
        /// <param name="mainMapControl">主地图控件</param>
        /// <param name="eagleMapControl">鹰眼图地图控件</param>
        /// <param name="tocControl">图层树控件</param>
        /// <param name="pageLayoutControl">页面布局控件</param>
        /// <param name="switchView">显示指定的界面视图的操作</param>
        public MapViewerManager(AxMapControl mainMapControl, AxMapControl eagleMapControl,
                                AxTOCControl tocControl, AxPageLayoutControl pageLayoutControl, Action <EViewActionType[]> switchView)
        {
            SwitchView        = switchView;
            MainMapControl    = mainMapControl;
            DocHelper         = new MapCtrlDocument(mainMapControl);
            TocHelper         = new MapCtrlToc(tocControl, mainMapControl, new AttributeForm(), switchView);
            MenuHelper        = new MapCtrlMenu(mainMapControl);
            EagleMapHelper    = new MapCtrlEagleMap(mainMapControl, eagleMapControl);
            DrawElementHelper = new MapCtrlDrawElement(mainMapControl);
            PageLayoutHelper  = new MapCtrlPageLayoutSyn(mainMapControl, pageLayoutControl);

            mainMapControl.OnFullExtentUpdated += delegate { mainMapControl.Refresh(); }; //主地图:刷新地图
            ((IActiveViewEvents_Event)mainMapControl.Map).ItemAdded += item =>            //向map/PageLayout中添加数据(图层、表格等)都会触发ItemAdded事件
            {
                if (item is ILayer)
                {
                    SwitchView(new[] { EViewActionType.MainMap, EViewActionType.LayerToc });
                }
                else if (item is ITable)
                {
                    SwitchView(new[] { EViewActionType.MainMap, EViewActionType.TableList });
                }
            };
        }
Beispiel #20
0
        //分级渲染函数
        private void RasterClassifyRender(IRasterLayer pRasterLayer)
        {
            try
            {
                IColorRamp pColorRamp = (IColorRamp)EnumStyleItem[comboBoxColor.SelectedIndex];

                IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRenderer() as IRasterClassifyColorRampRenderer;
                IRasterRenderer pRRend = pRClassRend as IRasterRenderer;

                IRaster pRaster = pRasterLayer.Raster;
                IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;
                IRasterBand           pRBand    = pRBandCol.Item(0);
                if (pRBand.Histogram == null)
                {
                    pRBand.ComputeStatsAndHist();
                }
                pRRend.Raster = pRaster;

                pRRend.Update();

                IRgbColor pFromColor = new RgbColor() as IRgbColor;
                pFromColor.Red   = 255;
                pFromColor.Green = 0;
                pFromColor.Blue  = 0;
                IRgbColor pToColor = new RgbColor() as IRgbColor;
                pToColor.Red   = 0;
                pToColor.Green = 0;
                pToColor.Blue  = 255;

                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRamp() as IAlgorithmicColorRamp;

                //colorRamp = pColorRamp as IAlgorithmicColorRamp;///////
                colorRamp.Size = comboBoxClassValue.SelectedIndex + 1;

                //colorRamp.FromColor = pFromColor;
                //colorRamp.ToColor = pToColor;
                int nClass = comboBoxClassValue.SelectedIndex + 1;
                colorRamp.FromColor = pColorRamp.get_Color(0);
                colorRamp.ToColor   = pColorRamp.get_Color(nClass - 1);
                bool createColorRamp;


                colorRamp.CreateRamp(out createColorRamp);

                IFillSymbol fillSymbol = new SimpleFillSymbol() as IFillSymbol;

                for (int i = 0; i < nClass; i++)
                {
                    fillSymbol.Color = colorRamp.get_Color(i);
                    pRClassRend.set_Symbol(i, fillSymbol as ISymbol);
                    pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00"));
                }
                pRasterLayer.Renderer = pRRend;
                m_mapControl.Refresh();
            }
            catch (Exception e)
            {
                MessageBox.Show("创建失败!");
            }
        }
Beispiel #21
0
 /// <summary>
 /// 刷新指定图层
 /// </summary>
 /// <param name="layer">图层</param>
 public void Refresh(Core.Interface.IMFLayer layer)
 {
     Dosomething((Action)(delegate
     {
         axMapControl.Refresh(esriViewDrawPhase.esriViewGraphics, layer as CompositeGraphicsLayerClass, null);
     }), true);
 }
Beispiel #22
0
        //退出程序
        public void ExitProgram(AxMapControl axMapControl1, AxTOCControl axTOCControl1)
        {
            DialogResult dialogResult = MessageBox.Show("保存文件?", "关闭文件", MessageBoxButtons.YesNoCancel);

            if (dialogResult == DialogResult.Yes)
            {
                SaveDocument(axMapControl1);
                mapDocument.Close();
                axMapControl1.ClearLayers();
                axMapControl1.Refresh();
                axTOCControl1.Update();
                Application.Exit();
            }
            if (dialogResult == DialogResult.No)
            {
                //mapDocument.Close();
                //axMapControl1.ClearLayers();
                //axMapControl1.Refresh();
                //axTOCControl1.Update();
                Application.Exit();
            }
            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }
        }
Beispiel #23
0
        private void button2_Click(object sender, EventArgs e)
        {
            IActiveView        pIActiveView        = pmapcontrol.Map as IActiveView;
            IGraphicsContainer pIGraphicsContainer = pIActiveView.GraphicsContainer;

            pIGraphicsContainer.DeleteAllElements();

            IFeatureLayer  pIFeatureLayer  = pmapcontrol.get_Layer(0) as IFeatureLayer;
            IFeatureCursor pIFeatureCursor = pIFeatureLayer.FeatureClass.Search(null, false);

            IFeature pfeature = pIFeatureCursor.NextFeature();

            while (pfeature != null)
            {
                ITopologicalOperator pITopologicalOperator = pfeature.Shape as ITopologicalOperator;
                IPolygon             pPolygon = pITopologicalOperator.Buffer(double.Parse(textBox1.Text)) as IPolygon;

                IElement pIElement = new PolygonElement();
                pIElement.Geometry = pPolygon;

                pIGraphicsContainer.AddElement(pIElement, 0);

                pfeature = pIFeatureCursor.NextFeature();
            }
            pmapcontrol.Refresh();
            this.Close();
        }
Beispiel #24
0
 private void btnRasterOK_Click(object sender, EventArgs e)
 {
     try
     {
         RasterRender render = new RasterRender();
         pListRamp = style.pListRamp;
         render.RasterClassify(rasterlayer, cmbClassifyMethod.SelectedItem.ToString(), Convert.ToInt32(cmbClassifyCount.SelectedItem), (IColorRamp)pListRamp[cmbSymClassify.SelectedIndex]);
         //axmapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         axmapcontrol.Refresh();
         axtoccontrol.Update();
         axmapcontrol.Extent = rasterlayer.AreaOfInterest;
     }
     catch (Exception ec)
     {
         MessageBox.Show(ec.Message);
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            //获取目标图层;
            IFeatureLayer[] player  = new IFeatureLayer[5];
            int             counter = 0;

            for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
            {
                for (int j = 0; j < pmapcontrol.LayerCount; j++)
                {
                    if (checkedListBox1.CheckedItems[i].ToString() == pmapcontrol.get_Layer(j).Name)
                    {
                        player[counter++] = pmapcontrol.get_Layer(j) as IFeatureLayer;
                    }
                }
            }


            // 获取源图层;
            IFeatureLayer pyuanLyaer = null;

            for (int k = 0; k < pmapcontrol.LayerCount; k++)
            {
                if (comboBox1.GetItemText(comboBox1.SelectedItem) == pmapcontrol.get_Layer(k).Name)
                {
                    pyuanLyaer = pmapcontrol.get_Layer(k) as IFeatureLayer;
                }
            }

            //空间参考
            esriSpatialRelEnum pesriSpatialRelEnum = SpatialRelConvert(comboBox2.GetItemText(comboBox2.SelectedItem));


            //空间位置判断
            if (pyuanLyaer != null && player.Length >= 1)
            {
                ISpatialFilter pISpatialFilter = new SpatialFilterClass();
                for (int i = 0; i < player.Length && player[i] != null; i++)
                {
                    IFeatureCursor    pFeatureCursor     = pyuanLyaer.FeatureClass.Search(null, true);
                    IFeature          pfeature           = pFeatureCursor.NextFeature();
                    IFeatureSelection pIFeatureSelection = player[i] as   IFeatureSelection;
                    while (pfeature != null)
                    {
                        pISpatialFilter.Geometry   = pfeature.ShapeCopy;
                        pISpatialFilter.SpatialRel = pesriSpatialRelEnum;
                        pIFeatureSelection.SelectFeatures(pISpatialFilter as IQueryFilter, esriSelectionResultEnum.esriSelectionResultAdd, true);
                        pfeature = pFeatureCursor.NextFeature();
                    }
                }
                pmapcontrol.Refresh();
                this.Close();
            }
            else
            {
                MessageBox.Show("请至少选择一个目标图层,原图层和空间关系方式!");
            }
        }
Beispiel #26
0
 public void axMapControl1_OnFullExtentUpdated(AxMapControl axMapControl1, AxMapControl axMapControl2, object sender, IMapControlEvents2_OnFullExtentUpdatedEvent e, IEnvelope origin_ipenv)
 {
     //获取鹰眼图层
     axMapControl2.AddLayer(GetOverviewLayer(axMapControl1, axMapControl2, axMapControl1.Map));
     // 设置 MapControl 显示范围至数据的全局范围
     axMapControl2.Extent = origin_ipenv;
     // 刷新鹰眼控件地图
     axMapControl2.Refresh();
 }
 //在主控件的OnMapReplaced事件中使用
 public static void AddEagleEye(AxMapControl mapControl1, AxMapControl mapControl2)
 {
     mapControl2.Map = new MapClass();
     for (int i = 0; i < mapControl1.LayerCount; i++)
     {
         mapControl2.Map.AddLayer(mapControl1.get_Layer(i));
     }
     mapControl2.Extent = mapControl1.FullExtent;
     mapControl2.Refresh();
 }
Beispiel #28
0
        private void ccc(IPoint p)
        {
            IEnvelope pEnvelope = new EnvelopeClass();

            pEnvelope.SetEmpty();
            pEnvelope = pAxMapControl.Extent;
            pEnvelope.CenterAt(p);
            pAxMapControl.Extent = pEnvelope.Envelope;
            pAxMapControl.Refresh();
        }
Beispiel #29
0
        public void ResetStopPointSymbols(AxMapControl mapControl)
        {
            this.stopPoints.Clear();
            this.stopElements.ForEach(element => SymbolUtil.ClearElement(mapControl, element));
            this.stopElements.Clear();
            IActiveView pActiveView = mapControl.ActiveView;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            mapControl.Refresh();
        }
Beispiel #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            gp.AddOutputsToMap = true;
            IGeoProcessorResult results = null;

            string resultname = null;

            if (resultName.Text != null)
            {
                resultname = resultName.Text + ".shp";
            }
            else
            {
                resultname = cbInputLayer.Text + "_" + cbOverLayLayer.Text + "_" + "Intersect.shp";
            }
            outputFullPath = System.IO.Path.Combine(strOutputPath, resultname);

            switch (operationType)
            {
            case "intersection":
                results = IntersectOverlay(gp);
                break;

            case "union":
                results = UnionOverlay(gp);
                break;

            case "clip":
                results = EraseOverlay(gp);
                break;

            case "xor":
                results = SymDiffOverlay(gp);
                break;
            }



            try
            {
                //将结果添加到当前地图中
                FileInfo info = new FileInfo(outputFullPath);
                string   path = outputFullPath.Substring(0, outputFullPath.Length - info.Name.Length);
                axMapControl1.AddShapeFile(path, info.Name);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                this.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("出错:" + ee.Message);
            }
        }
Beispiel #31
0
 public static void AddLayersToEagleEye(AxMapControl axMapControl1,AxMapControl axMapControl2)
 {
     // 当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换
     axMapControl2.Map = new MapClass();
     axMapControl2.ClearLayers();
     // 添加主地图控件中的所有图层到鹰眼控件中
     for (int i = axMapControl1.LayerCount - 1; i >= 0; i--)
     {
         axMapControl2.AddLayer(axMapControl1.get_Layer(i));
     }
     // 设置 MapControl 显示范围至数据的全局范围
     axMapControl2.Extent = axMapControl1.Extent;
     // 刷新鹰眼控件地图
     axMapControl2.Refresh();
 }
Beispiel #32
0
        //查询
        public static void QueryByBuffer(AxMapControl axMapControl)
        {
            // IDataset data = null;
            ILayer layer = axMapControl.get_Layer(0);
            IFeatureLayer featureLayer = layer as IFeatureLayer;
            //获取featurelayer的featureClass
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IFeature feature = null;
            IQueryFilter queryFilter = new QueryFilterClass();
            IFeatureCursor featureCursor;
            queryFilter.WhereClause = "NAME";
            featureCursor = featureClass.Search(queryFilter, true);
            feature = featureCursor.NextFeature();
            if (feature != null)
            {
                axMapControl.Map.SelectFeature(axMapControl.get_Layer(axMapControl.Map.LayerCount), feature);
                axMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            axMapControl.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;
            IGeometry geometry = null;
            geometry = axMapControl.TrackPolygon();

            //geometry = axMapControl.get_Layer(axMapControl.Map.LayerCount - 1) as IGeometry;
            axMapControl.Map.SelectByShape(geometry, null, false);
            axMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Beispiel #33
0
    public static void OperateMapDoc(AxMapControl axMapControl1, AxMapControl axMapControl2, string strOperateType)
    {
        OpenFileDialog OpenFileDialog = new OpenFileDialog();
        SaveFileDialog SaveFileDialog = new SaveFileDialog();
        OpenFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd";
        SaveFileDialog.Filter = "地图文档文件(*.mxd)|*.mxd";
        string strDocFileN = string.Empty;
        pMapDocument = new MapDocumentClass();
        switch (strOperateType)
        {
            case "NewDoc":
                {
                    SaveFileDialog.Title = "输入需要新建地图文档的名称";
                    SaveFileDialog.ShowDialog();
                    strDocFileN = SaveFileDialog.FileName;
                    if (strDocFileN == string.Empty)
                        return;
                    pMapDocument.New(strDocFileN);
                    pMapDocument.Open(strDocFileN, "");
                    axMapControl1.Map = pMapDocument.get_Map(0);
                    break;
                }
            case "OpenDoc":
                {
                    OpenFileDialog.Title = "输入需要加载的地图文档";
                    OpenFileDialog.ShowDialog();
                    strDocFileN = OpenFileDialog.FileName;
                    if (strDocFileN == string.Empty)
                        return;
                    pMapDocument.Open(strDocFileN, "");
                    for (int i = 0; i < pMapDocument.MapCount; i++)
                    {
                        axMapControl1.Map = pMapDocument.get_Map(i);
                        //axMapControl2.Map = pMapDocument.get_Map(i);
                    }
                    axMapControl1.Refresh();

                    break;
                }
            case "SaveDoc":
                {
                    if (pMapDocument.get_IsReadOnly(pMapDocument.DocumentFilename) == true)
                    {
                        MessageBox.Show("此地图为只读文档", "信息提示");
                        return;
                    }
                    pMapDocument.Save(pMapDocument.UsesRelativePaths, true);
                    MessageBox.Show("保存成功!", "信息提示");
                    break;
                }
            case "SaveDocAS":
                {
                    SaveFileDialog.Filter = "地图文档另存";
                    SaveFileDialog.ShowDialog();
                    strDocFileN = SaveFileDialog.FileName;
                    if (strDocFileN == string.Empty)
                        return;
                    if (strDocFileN == pMapDocument.DocumentFilename)
                    {
                        pMapDocument.Save(pMapDocument.UsesRelativePaths, true);
                        MessageBox.Show("保存成功!", "信息提示");
                        break;
                    }
                    else
                    {
                        pMapDocument.SaveAs(strDocFileN, true, true);
                        MessageBox.Show("保存成功", "信息提示");
                    }
                    break;
                }
            default:
                break;
        }
    }
        /// <summary>
        /// 全屏显示
        /// </summary>
        public static void FullExtend(AxMapControl axMapControl)
        {
            if (axMapControl == null)
            {
                return;
            }
            IEnvelope env = new EnvelopeClass() as IEnvelope;
            env.PutCoords(21256119.5385824, 4381043.1259153, 21812540.059758, 4846733.37736962);
            axMapControl.ActiveView.Extent = env;
            axMapControl.Refresh();

            //ICommand pCommand;
            //pCommand = new ESRI.ArcGIS.Controls.ControlsMapFullExtentCommand();
            //pCommand.OnCreate(axMapControl.Object);
            //pCommand.OnClick();
        }
Beispiel #35
0
        /// <summary> �ڵ�ͼ�ؼ������͸����ʱͼԪ/// </summary>
        /// <param name="pMapCtrl">��ͼ�ؼ�</param>
        /// <param name="pGeo">Envelope��Polygon����ʵ��</param>
        /// <param name="bAutoClear">�Ƿ����ԭ������</param>
        public void AddTransTempEle(AxMapControl pMapCtrl, IGeometry pGeo, bool bAutoClear)
        {
            try
            {
                if (pMapCtrl == null) return;
                if (pGeo == null) return;
                if (pGeo.IsEmpty) return;
                IGeometry pPolygon = null;
                if (pGeo is IEnvelope)
                {
                    object Miss = Type.Missing;
                    pPolygon = new PolygonClass();
                    IGeometryCollection pGeoColl = pPolygon as IGeometryCollection;
                    pGeoColl.AddGeometry(pGeo, ref Miss, ref Miss);
                }
                else if (pGeo is IPolygon)
                {
                    (pGeo as ITopologicalOperator).Simplify();
                    pPolygon = pGeo;
                }
                else
                {
                    MessageBox.Show("����ʵ�����Ͳ�ƥ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                //��ȡ͸��Ҫ�ز�
                IFeatureLayer pFlyr = null;
                for (int i = 0; i < pMapCtrl.LayerCount; i++)
                {
                    if (pMapCtrl.get_Layer(i).Name == "TransTemp")
                    {
                        pFlyr = pMapCtrl.get_Layer(i) as IFeatureLayer;
                        break;
                    }
                }
                //͸����ʱ�㲻������Ҫ����
                if (pFlyr == null)
                {
                    pFlyr = AddFeatureLayerByMemoryWS(pMapCtrl, pMapCtrl.SpatialReference);
                    if (pFlyr == null)
                    {
                        MessageBox.Show("����͸����ʱͼ�㷢���쳣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                IFeatureClass pFC = pFlyr.FeatureClass;
                if (bAutoClear)
                {
                    if (pFC.FeatureCount(null) > 0)
                    {
                        IFeatureCursor pFCursor = pFC.Search(null, false);
                        if (pFCursor != null)
                        {

                            IFeature pFeature = pFCursor.NextFeature();
                            if (pFeature != null)
                            {
                                while (pFeature != null)
                                {
                                    pFeature.Delete();
                                    pFeature = pFCursor.NextFeature();
                                }
                            }
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFCursor);
                        }
                    }
                }
                //����Ҫ��
                IFeature pNFeature = pFC.CreateFeature();
                pNFeature.Shape = pPolygon;
                pNFeature.set_Value(pFC.FindField("Code"), "1");
                pNFeature.Store();
                pMapCtrl.Refresh(esriViewDrawPhase.esriViewGeography, pFlyr, pFlyr.AreaOfInterest);
            }
            catch (Exception Err)
            {
                MessageBox.Show(Err.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }