Beispiel #1
2
 public static void LoadGeoData(AxMapControl axMapControl1, AxMapControl axMapControl2, string strFileN)
 {
     string strFExtenN = System.IO.Path.GetExtension(strFileN);
     switch (strFExtenN)
     {
         case ".shp":
             {
                 string strPath = System.IO.Path.GetDirectoryName(strFileN);
                 string strFile = System.IO.Path.GetFileNameWithoutExtension(strFileN);
                 axMapControl1.AddShapeFile(strPath, strFile);
                 axMapControl2.ClearLayers();
                 axMapControl2.AddShapeFile(strPath, strFile);
                 axMapControl2.Extent = axMapControl2.FullExtent;
                 break;
             }
         case ".bmp":
         case ".tif":
         case ".jpg":
         case ".img":
             {
                 IWorkspaceFactory pWSF = new RasterWorkspaceFactoryClass();
                 string pathName = System.IO.Path.GetDirectoryName(strFileN);
                 string fileName = System.IO.Path.GetFileName(strFileN);
                 IWorkspace pWS = pWSF.OpenFromFile(pathName, 0);
                 IRasterWorkspace pRWS = pWS as IRasterWorkspace;
                 IRasterDataset pRasterDataSet = pRWS.OpenRasterDataset(fileName);
                 IRasterPyramid pRasPyramid = pRasterDataSet as IRasterPyramid;
                 if (pRasPyramid != null)
                 {
                     if (!(pRasPyramid.Present))
                     {
                         pRasPyramid.Create();
                     }
                 }
                 IRaster pRaster = pRasterDataSet.CreateDefaultRaster();
                 IRasterLayer pRasterLayer = new RasterLayerClass();
                 pRasterLayer.CreateFromRaster(pRaster);
                 ILayer pLayer = pRasterLayer as ILayer;
                 axMapControl1.AddLayer(pLayer, 0);
                 axMapControl2.ClearLayers();
                 axMapControl2.AddLayer(pLayer, 0);
                 axMapControl2.Extent = axMapControl2.FullExtent;
                 break;
             }
         case ".mxd":
             {
                 if (axMapControl1.CheckMxFile(strFExtenN))
                 {
                     axMapControl1.LoadMxFile(strFExtenN);
                 }
                 else
                     MessageBox.Show("所选择的文件不是Mxd文件!", "提示信息");
                 break;
             }
         default:
             break;
     }
 }
Beispiel #2
0
 public frmRaterSym1(IRasterLayer rasLayer, AxMapControl mapcontrol, AxTOCControl toccontrol)
 {
     InitializeComponent();
     this.rasterlayer = rasLayer;
     axmapcontrol = mapcontrol;
     axtoccontrol = toccontrol;
 }
Beispiel #3
0
        public Tend(IHookHelper hookHelper,AxMapControl amap)
        {
            this.axmapcontrol = amap;

            this.m_hookHelper = hookHelper;
            InitializeComponent();
        }
Beispiel #4
0
        private void Init(AxMapControl mc, int programID)
        {
            gp = new Geoprocessor();
            mapControl = mc;
            UpdateMapLayerNameList(mapLayerNameList, mapControl);
            program = new Program();
            program.id = programID;
            program.select();
            project = new Project();
            project.id = program.projectID;
            project.select();
            netSize = program.getRelatedNetSize();
            conditionList = program.getAllRelatedCondition();
            baseFeature = GisUtil.GetBaseFeature(mapControl, project.baseMapIndex);
            mapFolder = System.IO.Path.GetDirectoryName(project.path);
            targetFolder = generateFolder(mapFolder);
            foreach (Condition condition in conditionList)
            {
                if (condition.type == C.CONFIG_TYPE_STANDARD)
                {
                    totalStandardValue += condition.value;
                }
            }
            fishnetPolygonName = "polygon.shp";
            fishnetName = "fishnet.shp";
            fishnetWidth = netSize.width;
            fishnetHeight = netSize.height;

            featureList = new List<Feature>();
        }
Beispiel #5
0
 public FrameSearchTool(AxMapControl axMapControl,MainForm Father,string LayerName,bool Statistic=false)
 {
     this.Father = Father;
     this.axMapControl = axMapControl;
     this.LayerName = LayerName;
     this.StatisticFlag = Statistic;
 }
 public CreateShpFileForm(AxMapControl _axMapControl, DataGridView _DataView, string path)
 {
     axMapControl = _axMapControl;
     excelDataGridViewX = _DataView;
     m_bin_path = path;
     InitializeComponent();
 }
 public MainWindowViewModel(AxMapControl axMapControl)
 {
     _axMapControl = axMapControl;
     _shapeOp=new ShapeOp(string.Empty);
     _mapIndex=new Dictionary<string, int>(5);
     InitializeCommand();
 }
Beispiel #8
0
        public Coordinate(AxMapControl axMapControl)
        {
            //  this.ply = plo;

            this.mapControl = axMapControl;
            InitializeComponent();
        }
Beispiel #9
0
 public frmSymbol(IFeatureLayer featLayer,AxMapControl mapcontrol,AxTOCControl toccontrol)
 {
     InitializeComponent();
     this.Layer = featLayer;
     axmapcontrol = mapcontrol;
     axtoccontrol = toccontrol;
 }
Beispiel #10
0
        //窗口启动程序
        private void Buffer_Load(object sender, EventArgs e)
        {
            AxMapControl axMapControl1=new AxMapControl();
            //m_hookHelper.Hook = axMapControl1.Object;
            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();
            string tempDir = SystemSet.Base_Map+"\\处理数据库\\实验数据";
            txtOutputPath.Text = System.IO.Path.Combine(tempDir, ((string)cboLayers.SelectedItem + "_buffer.shp"));

            //set the default units of the buffer
            m_hookHelper.FocusMap.MapUnits = esriUnits.esriMeters;
            CNunit.SelectedIndex = 0;
              /*   int units = Convert.ToInt32(m_hookHelper.FocusMap.MapUnits);
            cboUnits1.SelectedIndex = units;
               */
        }
        public void init(int programID, AxMapControl mc, AxToolbarControl tc, MainWindow mw)
        {
            inited = true;

            program = new Program();
            program.id = programID;
            program.select();

            mapControl = mc;
            toolbarControl = tc;
            mainWindow = mw;
            mainRoadList = program.getAllRelatedMainRoad();
            if (mainRoadList == null)
                mainRoadList = new ObservableCollection<MainRoad>();

            foreach (MainRoad mainRoad in mainRoadList)
            {
                GisUtil.DrawPolylineElement(mainRoad.lineElement, mapControl);   
            }

            valid = isValid();
            dirty = false;

            mapControlMouseDown = null;
            MainRoadListBox.ItemsSource = mainRoadList;
        }
        public void init(int programID, AxMapControl mc, AxToolbarControl tc, MainWindow mw)
        {
            inited = true;

            program = new Program();
            program.id = programID;
            program.select();

            mapControl = mc;
            toolbarControl = tc;
            mainWindow = mw;

            OnFinish configUserControlOnFinish = delegate(bool finish)
            {
                TabItem configTabItem = ProgramTabControl.FindName("ConfigTabItem") as TabItem;
                Grid grid = configTabItem.Header as Grid;
                TextBlock textBlock = grid.Children[0] as TextBlock;
                if(finish)
                {
                    textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7CFC00"));                    
                }
                else
                {
                    textBlock.Foreground = new SolidColorBrush(Colors.Black);                                        
                }
            };
            ConfigUserControl.init(programID, mapControl, configUserControlOnFinish, mainWindow);

            OnFinish siteSelectorUserControlOnFinish = delegate(bool finish)
            {
                TabItem configTabItem = ProgramTabControl.FindName("SiteSelectorTabItem") as TabItem;
                Grid grid = configTabItem.Header as Grid;
                TextBlock textBlock = grid.Children[0] as TextBlock;
                if (finish)
                {
                    textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7CFC00"));
                }
                else
                {
                    textBlock.Foreground = new SolidColorBrush(Colors.Black);
                }
            };
            SiteSelectorUserControl.init(programID, siteSelectorUserControlOnFinish, mapControl, toolbarControl, mainWindow);
            OnFinish housePlacerUserControl = delegate(bool finish)
            {
                TabItem housePlacerTabItem = ProgramTabControl.FindName("HousePlacerTabItem") as TabItem;
                Grid grid = housePlacerTabItem.Header as Grid;
                TextBlock textBlock = grid.Children[0] as TextBlock;
                if (finish)
                {
                    textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7CFC00"));
                }
                else
                {
                    textBlock.Foreground = new SolidColorBrush(Colors.Black);
                }
            };
            HousePlacerUserControl.init(programID, mapControl, housePlacerUserControl, mainWindow);
        }
Beispiel #13
0
 public void CopyAndOverwriteMap(AxMapControl mapcontrol, AxPageLayoutControl PageLayoutControl)
 {
     IObjectCopy objectCopy = new ObjectCopyClass();
     object toCopyMap = mapcontrol.Map;
     object copiedMap = objectCopy.Copy(toCopyMap);
     object toOverwriteMap = PageLayoutControl.ActiveView.FocusMap;
     objectCopy.Overwrite(copiedMap, ref toOverwriteMap);
 }
 public DataConverTool(DevComponents.DotNetBar.LabelX lab_progress, DevComponents.DotNetBar.LabelX lb, DevExpress.XtraEditors.MarqueeProgressBarControl progressBar, DevComponents.DotNetBar.Controls.RichTextBoxEx MessageShow,AxMapControl axMap)
 {
     this.axMapControl = axMap;
     this.lb = lb;
     this.lab_progress = lab_progress;
     this.progressBar = progressBar;
     this.MessageShow = MessageShow;
 }
 public FormAttributeTable(AxMapControl pMapControl, IMapControl3 pMapCtrl)
 {
     InitializeComponent();
     _MapControl = pMapControl;
     m_mapControl = pMapCtrl;
     ILayer pLayer = (ILayer)m_mapControl.CustomProperty;
     pFLayer = pLayer as IFeatureLayer;
     pFClass = pFLayer.FeatureClass;
 }
 private void CreateEngineControls()
 {
     _mainMapControl = new AxMapControl
     {
         Dock = DockStyle.None,
         BackColor = System.Drawing.Color.AliceBlue
     };
     MainFormsHost.Child = _mainMapControl;
 }          
Beispiel #17
0
 public static void CopyAndOverwriteMap(AxMapControl map, AxPageLayoutControl page)
 {
     //获取拷贝接口对象
     IObjectCopy objectCopy = new ObjectCopyClass();
     object toCopyMap = map.Map;
     object copiedMap = objectCopy.Copy(toCopyMap);//复制地图到copiedMap
     object toOverWriteMap = page.ActiveView.FocusMap;//获取视图控件的焦点地图
     objectCopy.Overwrite(copiedMap, ref toOverWriteMap);//复制地图
 }
Beispiel #18
0
        public ProjectWindow()
        {
            InitializeComponent();

            mapControl = new AxMapControl();
            toolbarControl = new AxToolbarControl();

            windowMapHost.Child = mapControl;
            windowToolbarHost.Child = toolbarControl;
        }
 /// <summary>
 /// 清除选择
 /// </summary>
 public static void ClearSelect(AxMapControl axMapControl)
 {
     if (axMapControl == null)
     {
         return;
     }
     ICommand pCommand;
     pCommand = new ControlsClearSelectionCommand();
     pCommand.OnCreate(axMapControl.Object);
     pCommand.OnClick();
 }
Beispiel #20
0
        public static IFeatureLayer getLayerFromName(AxMapControl mapControl)
        {
            IFeatureLayer layer = null;
            int s = 0;
            for (int i = 0; i < mapControl.LayerCount; i++)
            {
                ILayer layers = mapControl.get_Layer(i);
                if (layers is GroupLayer || layers is ICompositeLayer)   //判断是否是groupLayer
                {
                    MessageBox.Show(layers.Name);
                    //创建文件夹:slgc,ztdt,bhzy
                    if(layer.Name.Equals("水利工程"))
                    {
                        //创建文件夹:slgc

                        //将该文件路径传入函数中
                        layer = getSubLayer(layers);  //递归的思想
                    }
                    else if (layer.Name.Substring(0, 2).Equals("方案"))
                    {
                        s++;
                        //创建ztdu文件夹

                        //传入参数  ztdt和方案i

                        layer = getSubLayer(layers);  //递归的思想

                    }
                    else
                    {
                        //创建bhzy文件夹

                        //传入参数
                         layer = getSubLayer(layers);  //递归的思想
                    }

                    if (layer != null)
                    {
                        continue;
                    }
                }
                else
                {
                    //if (mapControl.get_Layer(i).Name.Equals(layerName))
                    //{
                        layer = layers as IFeatureLayer;

                    //}
                }
            }
            //MessageBox.Show(layer.Name);
            return layer;
        }
        public static void Addtool(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //全局变量赋值
            DataEditCommon.g_tbCtlEdit = toolbarControl;
            DataEditCommon.g_pMyMapCtrl = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl = axMapControl;
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.UndoEdit(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.RedoEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AttributeQueryEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureDistance(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureArea(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureClearSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.SaveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomInCommand(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomOutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomInTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomOutTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentBackCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentForwardCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.PanTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomToTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.RefreshViewCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FullExtentTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.MapRotateTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            //Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ToolbarLocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.LocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ClearView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.RotateTool(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.FeatureMoveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MirrorFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCopyCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditPasteCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.DeleteFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.ExtendTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.TrimLineTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.LayersList(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPoint(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddStraightFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddBezierCurve(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddRectangle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddText(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddCircle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddArc(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddEllipse(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPolygon(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
        }
Beispiel #22
0
        /// <summary>
        /// 连接到WMS服务器,载入WMS图层
        /// </summary>
        /// <param name="axMapControl1">axMapControl控件</param>
        /// <param name="url">WMS服务器地址</param>
        public static void Connect2WMS(AxMapControl axMapControl1, string url)
        {
            #region 初始化环境
            IPropertySet pPropertyset = new PropertySetClass();
            pPropertyset.SetProperty("url", url);
            IWMSConnectionName pWMSConnectionName = new WMSConnectionNameClass();
            pWMSConnectionName.ConnectionProperties = pPropertyset;
            ILayerFactory pLayerFactory = new EngineWMSMapLayerFactoryClass();//Provides access to members that control the creation of layers through a factory.

            IWMSGroupLayer pWmsMapLayer = new WMSMapLayerClass();
            IDataLayer pDataLayer = pWmsMapLayer as IDataLayer;
            pDataLayer.Connect(pWMSConnectionName as IName);
            IWMSServiceDescription pWmsServiceDesc = pWmsMapLayer.WMSServiceDescription;
            #endregion

            #region 获取WMS图层
            for (int i = 0; i < pWmsServiceDesc.LayerDescriptionCount; i++)
            {
                IWMSLayerDescription pWmsLayerDesc = pWmsServiceDesc.get_LayerDescription(i);
                ILayer pNewLayer = null;

                if (pWmsLayerDesc.LayerDescriptionCount == 0)
                {
                    IWMSLayer pWmsLayer = pWmsMapLayer.CreateWMSLayer(pWmsLayerDesc);
                    pNewLayer = pWmsLayer as ILayer;
                }
                else
                {
                    IWMSGroupLayer pWmsGroupLayer = pWmsMapLayer.CreateWMSGroupLayers(pWmsLayerDesc);
                    for (int j = 0; j < pWmsGroupLayer.Count; j++)
                    {
                        ILayer layer = pWmsGroupLayer.get_Layer(j);
                        if (layer.Name != "admin")
                        {
                            pWmsMapLayer.InsertLayer(layer, 0);
                            layer.Visible = true;
                        }
                    }
                }
            }
            #endregion

            #region 收尾工作
            ILayer pLayer = pWmsMapLayer as ILayer;
            pLayer.Name = pWmsServiceDesc.WMSTitle;
            pLayer.Visible = true;
            axMapControl1.AddLayer(pLayer, 0);

            IEnvelope pEnv = axMapControl1.FullExtent;
            pEnv.Expand(0.8, 0.8, true);
            axMapControl1.Extent = pEnv;
            #endregion
        }
Beispiel #23
0
 public void Identify(AxMapControl pMapControl)
 {
     if (pMapControl == null)
         return;
     else
     {
         pMapControl.CurrentTool = null;
         //�½����Բ�ѯ����
         IdentifyDialog identifyDialog = IdentifyDialog.CreateInstance(pMapControl);
         identifyDialog.Show();
     }
 }
        public void init(int programID, AxMapControl mc, AxToolbarControl tc, Intersect.ProgramStepUserControl.OnFinish of, MainWindow mw)
        {
            inited = true;

            villageColorRandomer = new VillageColorRandomer();
            program = new Program();
            program.id = programID;
            program.select();
            villageList = program.getAllRelatedVillage();
            if (villageList == null)
            {
                villageList = new ObservableCollection<Village>();
            }
            else
            {
                foreach (Village village in villageList)
                {
                    village.polygonElementColorString = villageColorRandomer.randomColor();
                    InnerRoad innerRoad = village.getRelatedInnerRoad();
                    village.innerRoad = innerRoad;
                }
            }

            mapControl = mc;
            toolbarControl = tc;
            mainWindow = mw;
            foreach (Village village in villageList)
            {
                GisUtil.drawPolygonElement(village.polygonElement, mapControl);
                GisUtil.UpdatePolygonElementColor(village.polygonElement, mapControl
                    , VillageColorRandomer.GetRedFromColorString(village.polygonElementColorString)
                    , VillageColorRandomer.GetGreenFromColorString(village.polygonElementColorString)
                    , VillageColorRandomer.GetBlueFromColorString(village.polygonElementColorString));
                if (village.innerRoad.lineElement != null)
                    GisUtil.DrawPolylineElement(village.innerRoad.lineElement, mapControl);
                if (village.inUse)
                {
                    string reverseColorString = VillageColorRandomer.GetReverseVillageColorString(village.polygonElementColorString);
                    GisUtil.UpdatePolygonElementOutline(village.polygonElement, mapControl
                        , VillageColorRandomer.GetRedFromColorString(reverseColorString)
                        , VillageColorRandomer.GetGreenFromColorString(reverseColorString)
                        , VillageColorRandomer.GetBlueFromColorString(reverseColorString));
                }
            }

            valid = isValid();
            dirty = false;

            onFinish = of;

            mapControlMouseDown = null;
            VillageListBox.ItemsSource = villageList;
        }
Beispiel #25
0
        void CreateEngineControls()
        {
            //set Engine controls to the child of each hosts
            mapControl = new AxMapControl();
            mapHost.Child = mapControl;

            toolbarControl = new AxToolbarControl();
            toolbarHost.Child = toolbarControl;

            tocControl = new AxTOCControl();
            tocHost.Child = tocControl;
        }
Beispiel #26
0
        /// <summary>
        /// 创建Engine控件并将控件绑定到各自的 WindowsFormsHost 元素上
        /// </summary>
        void CreateEngineControls()
        {
            //设置 Engine 控件到每个host的Child属性上
            mapControl = new AxMapControl();
            mapHost.Child = mapControl;

            toolbarControl = new AxToolbarControl();
            toolbarHost.Child = toolbarControl;

            tocControl = new AxTOCControl();
            tocHost.Child = tocControl;
        }
        public ProPortialRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer,  string pFieldName)
        {
            IGeoFeatureLayer pGeo = pFtLayer as IGeoFeatureLayer;

            IProportionalSymbolRenderer pProRender = new ProportionalSymbolRendererClass();

            pProRender.Field = pFieldName;

            pProRender.ValueUnit = esriUnits.esriUnknownUnits;

            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();

            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

            pMarkerSymbol.Size = 2;

            pMarkerSymbol.Color = GetRGBColor(255, 0, 0);

            pProRender.MinSymbol = pMarkerSymbol as ISymbol;

            IDataStatistics pDataStat = new DataStatisticsClass();

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            pDataStat.Cursor = pFtCursor as ICursor;

            pDataStat.Field = pFieldName;

            pProRender.MinDataValue = pDataStat.Statistics.Minimum;

            pProRender.MaxDataValue = pDataStat.Statistics.Maximum;

            IFillSymbol pFillS = new SimpleFillSymbolClass();

            pFillS.Color = GetRGBColor(239, 228, 190);

            ILineSymbol pLineS = new SimpleLineSymbolClass();

            pLineS.Width = 2;

            pFillS.Outline = pLineS;

            ISimpleFillSymbol pSFillS = pFillS as ISimpleFillSymbol;

            pSFillS.Color = GetRGBColor(100, 100, 253);

            pProRender.BackgroundSymbol = pFillS;

            pGeo.Renderer = pProRender as IFeatureRenderer;

            pMapcontrol.ActiveView.Refresh();
        }
Beispiel #28
0
        public FrmSQLSearch(AxMapControl mapControl)
        {
            InitializeComponent();

            m_MapControl = mapControl;
            m_Map = m_MapControl.Map;
            m_activeView = m_MapControl.ActiveView;

            InitcboLayers();

            if (cboLayers.Properties.Items.Count > 0)
                cboLayers.SelectedIndex = 0;
        }
        public void init(int programID, AxMapControl mc, Intersect.ProgramStepUserControl.OnFinish of, MainWindow mw)
        {
            inited = true;

            if (program == null)
                program = new Program();
            program.id = programID;
            program.select();

            if (project == null)
                project = new Project();
            project.id = program.projectID;
            project.select();

            NetSizeUserControl.init(program.id);
            ConditionUserControl.init(program.id);

            mapControl = mc;
            onFinish = of;
            mainWindow = mw;

            mapControlMouseDown = null;

            //在初始化时就要对valid进行判断.
            Thread t = new Thread(delegate()
            {
                System.Threading.Thread.Sleep(500);
                Dispatcher.BeginInvoke((ThreadStart)delegate()
                {
                    if (isValid())
                    {
                        valid = true;
                        onFinish(true);
                        IFeatureClass resultFeatureClass;
                        if ((resultFeatureClass = GisUtil.getFeatureClass(System.IO.Path.GetDirectoryName(project.path), "评价结果.shp")) != null)
                        {
                            IFeatureLayer resultFeatureLayer = new FeatureLayerClass();
                            resultFeatureLayer.FeatureClass = resultFeatureClass;
                            mapControl.AddLayer(resultFeatureLayer);
                        }
                        else
                        {
                            SiteSelector siteSelector = new SiteSelector(mapControl, program.id);
                            siteSelector.startSelectSite();
                        }
                    }
                });
            });
            t.Start();
        }
Beispiel #30
0
 public void Measure(AxMapControl pMapControl)
 {
     if (pMapControl == null)
         return;
     else
     {
         pMapControl.CurrentTool = null;
         HookHelper hk = new HookHelperClass();
         hk.Hook = pMapControl.Object;
         ITool pTool = new MeasureDisTool(hk);
         pMapControl.CurrentTool = pTool;
         pMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
     }
 }
Beispiel #31
0
 /// <summary>
 /// 地图控件与地图文档关联操作
 /// (包括新建、加载、保存、另存地图文档,添加数据、清空图层等)
 /// </summary>
 /// <param name="mapCtrl">地图控件</param>
 public MapCtrlDocument(AxMapControl mapCtrl)
 {
     MapControl = mapCtrl;
 }
Beispiel #32
0
 public StasticResult(AxMapControl am)
 {
     this.axmapcontrol = am;
     InitializeComponent();
 }
Beispiel #33
0
 public Form1(AxMapControl axMapControl)
 {
     this.axMapControl1 = axMapControl;
     InitializeComponent();
 }
Beispiel #34
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                Wmin = 10;
            }
            else
            {
                Wmin = Convert.ToInt32(textBox1.Text);
            }

            if (textBox2.Text == "")
            {
                Wmax = 40;
            }
            else
            {
                Wmax = Convert.ToInt32(textBox2.Text);
            }

            if (Wmin >= Wmax)
            {
                Wmax = Wmin + 10;
            }

            int countTimes = Wmax - Wmin + 1;

            myCost  = new double[countTimes];
            myArea  = new double[countTimes];
            myValue = new double[countTimes];

            AxMapControl mainFormMapControl = (AxMapControl)this.mainForm.Controls.Find("axMapControl1", false)[0];

            for (int i = 0; i < countTimes; i++)
            {
                myCost[i] = 0;
                myArea[i] = 0;

                activeInMapInDataGrid();
                drawBuffer(mainFormMapControl, i + Wmin);//有了选择区

                IMap              pMap              = global.pMap;
                ISelection        selection         = pMap.FeatureSelection;
                IEnumFeatureSetup iEnumFeatureSetup = (IEnumFeatureSetup)selection;
                iEnumFeatureSetup.AllFields = true;
                IEnumFeature enumFeature = (IEnumFeature)iEnumFeatureSetup;
                enumFeature.Reset();

                IFeature feature = enumFeature.Next();
                while (feature != null)
                {
                    myArea[i] += Convert.ToDouble(feature.get_Value(10));
                    myCost[i] += Convert.ToDouble(feature.get_Value(11)) *
                                 Convert.ToDouble(feature.get_Value(10)) * Convert.ToDouble(feature.get_Value(12));
                    feature = enumFeature.Next();
                }

                if (myArea[i] == 0)
                {
                    myValue[i] = 0;
                }
                else
                {
                    myValue[i] = myCost[i] / myArea[i];
                }
            }
            Form4 fff = new Form4();

            fff.Text = "缓冲分析图表";
            fff.ShowDialog();
        }
Beispiel #35
0
        private void drawBuffer(AxMapControl axMapControl1, double roadwidth)
        {
            IGraphicsContainer graphicsCountainer = axMapControl1.ActiveView.GraphicsContainer;

            graphicsCountainer.DeleteAllElements();
            ISelection        pSelection        = axMapControl1.Map.FeatureSelection;
            IEnumFeatureSetup pEnumFeatureSetup = pSelection as IEnumFeatureSetup;

            //IEnumFeature pEumFeatue = (IEnumFeature)pSelection;
            pEnumFeatureSetup.AllFields = true;

            IEnumFeature pEnumFeature = pEnumFeatureSetup as IEnumFeature;

            pEnumFeature.Reset();
            IFeature             pFea                 = pEnumFeature.Next();
            IGeometry            pGeo                 = null;
            ITopologicalOperator pTopo                = null;
            IGeometry            pBuffer              = null;
            double                  m_dDistance       = roadwidth;///////
            IElement                pElement          = null;
            IFillSymbol             pFillSymbol       = null;
            IRgbColor               pRgbColor         = null;
            ISpatialFilter          pSpatialfilter    = null;
            IFeatureLayer           pFeaLayer         = null;
            IFeatureClass           pFeaClass         = null;
            IFeature                pFeature          = null;
            IFeatureCursor          pFeaCursor        = null;
            List <List <IFeature> > pFeatureLayerlist = new List <List <IFeature> >();

            //List < IFeature> pFeaturelist =new List<IFeature>();
            for (int i = 0; i < axMapControl1.LayerCount; i++)
            {
                pFeatureLayerlist.Add(new List <IFeature>());
            }

            while (pFea != null)
            {
                pGeo    = pFea.ShapeCopy;
                pTopo   = pGeo as ITopologicalOperator;
                pBuffer = pTopo.Buffer(m_dDistance);

                pElement          = new PolygonElementClass();
                pElement.Geometry = pBuffer;

                ////    设置缓冲区颜色
                pFillSymbol            = new SimpleFillSymbolClass();
                pRgbColor              = new RgbColorClass();
                pRgbColor.Red          = 255;
                pRgbColor.Green        = 255;
                pRgbColor.Blue         = 153;
                pRgbColor.Transparency = 150;
                pFillSymbol.Color      = pRgbColor;
                (pElement as IFillShapeElement).Symbol = pFillSymbol;
                (axMapControl1.Map as IGraphicsContainer).AddElement(pElement, 0);
                axMapControl1.Refresh();
                pSpatialfilter          = new SpatialFilterClass();
                pSpatialfilter.Geometry = pBuffer;

                for (int i = 0; i < axMapControl1.LayerCount; i++)
                {
                    pFeaLayer = axMapControl1.get_Layer(i) as IFeatureLayer;
                    pFeaClass = pFeaLayer.FeatureClass;
                    // pFeaturelist = new List<IFeature>();

                    if (pFeaLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        pSpatialfilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        pSpatialfilter.GeometryField = pFeaClass.ShapeFieldName;
                        pFeaCursor = pFeaClass.Search(pSpatialfilter, false);

                        pFeature = pFeaCursor.NextFeature();
                        //graphicsCountainer.DeleteAllElements();
                        while (pFeature != null)
                        {
                            //if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                            {
                                //axMapControl1.Map.SelectFeature(pFeaLayer, pFeature);
                                pFeatureLayerlist[i].Add(pFeature);
                                pFeature = pFeaCursor.NextFeature();
                            }
                        }
                    }
                    // pFeatureLayer.Add(pFeaturelist);

                    /*  switch (pFeaClass.ShapeType)
                     * {
                     *    case esriGeometryType.esriGeometryPoint:
                     *        {
                     *           // pSpatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                     *            break;
                     *        }
                     *    case esriGeometryType.esriGeometryPolyline:
                     *        {
                     *            //pSpatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                     *            break;
                     *        }
                     *    case esriGeometryType.esriGeometryPolygon:
                     *        {
                     *            pSpatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                     *            break;
                     *        }
                     * }*/
                }
                pFea = pEnumFeature.Next();
            }
            axMapControl1.Map.ClearSelection();
            for (int p = 0; p < pFeatureLayerlist.Count; p++)
            {
                for (int j = 0; j < pFeatureLayerlist[p].Count; j++)
                {
                    axMapControl1.Map.SelectFeature(axMapControl1.get_Layer(p), pFeatureLayerlist[p][j]);
                }
            }


            axMapControl1.Refresh();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
        }
Beispiel #36
0
 public schAnaForm(AxMapControl axm)
 {
     axMap = axm;
     InitializeComponent();
 }
Beispiel #37
0
        public UniqueValueRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, int pCount, string pFieldName)
        {
            IGeoFeatureLayer pGeoFeaturelayer = pFtLayer as IGeoFeatureLayer;

            IUniqueValueRenderer pUnique = new UniqueValueRendererClass();

            pUnique.FieldCount = 1;

            pUnique.set_Field(0, pFieldName);


            ISimpleFillSymbol pSimFill = new SimpleFillSymbolClass();



            //给颜色

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            IFeature pFt = pFtCursor.NextFeature();


            IFillSymbol pFillSymbol1;


            ////添加第一个符号
            //pFillSymbol1 = new SimpleFillSymbolClass();
            //pFillSymbol1.Color = GetRGBColor(103, 252, 179) as IColor;

            ////添加第二个符号
            //IFillSymbol pFillSymbol2 = new SimpleFillSymbolClass();
            //pFillSymbol2.Color = GetRGBColor(125, 155, 251) as IColor;



            //创建并设置随机色谱从上面的的图可以看出我们要给每一个值定义一种颜色,我们可以创建色谱,但是色谱的这些参数
            //我调不好这个没,因此掠过则个步骤,我重新定义了两个符号。

            IRandomColorRamp pColorRamp = new RandomColorRampClass();

            pColorRamp.StartHue = 0;

            pColorRamp.MinValue = 20;

            pColorRamp.MinSaturation = 15;

            pColorRamp.EndHue = 360;

            pColorRamp.MaxValue = 100;

            pColorRamp.MaxSaturation = 30;

            pColorRamp.Size = pCount;

            //pColorRamp.Size = pUniqueValueRenderer.ValueCount;

            bool ok = true;

            pColorRamp.CreateRamp(out ok);

            IEnumColors pEnumRamp = pColorRamp.Colors;

            //IColor pColor = pEnumRamp.Next();


            int pIndex = pFt.Fields.FindField(pFieldName);

            //因为我只有24条记录,所以改变这些,这些都不会超过255或者为负数.求余

            int i = 0;


            while (pFt != null)
            {
                IColor pColor = pEnumRamp.Next();
                if (pColor == null)
                {
                    pEnumRamp.Reset();
                    pColor = pEnumRamp.Next();
                }



                //if (i % 2 == 0)
                //{
                //    pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol1 as ISymbol);

                //}
                //else
                //{
                //    pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol2 as ISymbol);
                //}

                //i++;

                pFillSymbol1 = new SimpleFillSymbolClass();

                pFillSymbol1.Color = pColor;
                pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol1 as ISymbol);


                pFt = pFtCursor.NextFeature();

                //  pColor = pEnumRamp.Next();
            }


            pGeoFeaturelayer.Renderer = pUnique as IFeatureRenderer;

            pMapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
 public EditingLayer(AxMapControl mapControl)
 {
     InitializeComponent();
     this.mMapControl = mapControl;
 }
Beispiel #39
0
 /// <summary>
 /// 利用最大感兴趣缩放至图层
 /// </summary>
 /// <param name="mapControl"></param>
 public static void ZoomToByMaxLayer(AxMapControl mapControl)
 {
     mapControl.Extent = GetMaxEnvelope(mapControl);
     mapControl.Refresh();
 }
Beispiel #40
0
        public static void OpenFile(AxMapControl mapControl)
        {
            OpenFileDialog OpenFdlg = new OpenFileDialog();

            OpenFdlg.Title  = "选择需要加载的地理数据文件";
            OpenFdlg.Filter = "mxd文件|*.mxd|Shape文件|*.shp|所有文件|*.*";
            //OpenFdlg.InitialDirectory="C:\\Users\\Administrator\\Desktop";//设置初始打开的文件夹
            OpenFdlg.RestoreDirectory = true;
            if (OpenFdlg.ShowDialog() == DialogResult.OK)
            {
                string strFileName = OpenFdlg.FileName;//完全名
                if (strFileName == string.Empty)
                {
                    return;
                }
                string pathName    = System.IO.Path.GetDirectoryName(strFileName);            //位置
                string strFExtendN = System.IO.Path.GetExtension(strFileName);                //后缀名
                string fileName    = System.IO.Path.GetFileNameWithoutExtension(strFileName); //单独的文件名
                string fileNameE   = System.IO.Path.GetFileName(strFileName);                 //文件名和扩展名
                switch (strFExtendN)
                {
                case ".shp":
                    mapControl.AddShapeFile(pathName, fileName);
                    OFile.CopyAndOverwriteMap(mapControl);
                    break;

                case ".mxd":
                    if (mapControl.CheckMxFile(strFileName))
                    {
                        mapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                        mapControl.LoadMxFile(strFileName, 0, Type.Missing);
                        mapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
                        OFile.CopyAndOverwriteMap(mapControl);
                    }
                    else
                    {
                        MessageBox.Show("所选文件不是地图文档文件!", "信息提示");
                        return;
                    }
                    break;

                case ".bmp":
                case ".tif":
                case ".TIF":
                case ".jpg":
                case ".img":
                case ".png":

                    IWorkspaceFactory pWSF;
                    pWSF = new RasterWorkspaceFactory();
                    IWorkspace pWS;
                    pWS = pWSF.OpenFromFile(pathName, 0);
                    IRasterWorkspace pRWS;
                    pRWS = pWS as IRasterWorkspace;
                    IRasterDataset pRasterDataset;
                    pRasterDataset = pRWS.OpenRasterDataset(fileNameE);
                    //影像金字塔判断与创建
                    IRasterPyramid pRasPyrmid;
                    pRasPyrmid = pRasterDataset as IRasterDataset as IRasterPyramid;
                    if (pRasPyrmid != null)
                    {
                        if (!(pRasPyrmid.Present))
                        {
                            pRasPyrmid.Create();    //在进度条中说明正在创建金字塔
                        }
                    }
                    IRaster pRaster;
                    pRaster = pRasterDataset.CreateDefaultRaster();
                    IRasterLayer pRasterLayer;
                    pRasterLayer = new RasterLayerClass();
                    pRasterLayer.CreateFromRaster(pRaster);
                    ILayer pLayer = pRasterLayer as ILayer;
                    mapControl.AddLayer(pLayer, 0);
                    OFile.CopyAndOverwriteMap(mapControl);
                    break;
                }
            }
        }
Beispiel #41
0
 public AttrQueryForm(AxMapControl mapControl)//传递参数mapControl
 {
     InitializeComponent();
     this.mMapControl = mapControl;
 }
Beispiel #42
0
 public static void CopyAndOverwriteMap(AxMapControl mapControl)
 {
     IObjectCopy objectCopy = new ObjectCopyClass();
     object      toCopyMap  = mapControl.Map;
     object      copiedMap  = objectCopy.Copy(toCopyMap);
 }
Beispiel #43
0
 public static void Use_OnViewRefreshed(AxTOCControl toccControl,
                                        AxMapControl mapControl, AxPageLayoutControl axPageLayoutControl)
 {
     toccControl.Update();
     OFile.CopyAndOverwriteMap(mapControl);
 }