当前位置: 首页>>代码示例>>C#>>正文


C# ESRI.PartialRefresh方法代码示例

本文整理汇总了C#中ESRI.PartialRefresh方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.PartialRefresh方法的具体用法?C# ESRI.PartialRefresh怎么用?C# ESRI.PartialRefresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ESRI的用法示例。


在下文中一共展示了ESRI.PartialRefresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddShapefileUsingOpenFileDialog

        //#### ArcGIS Snippets ####
        
        #region "Add Shapefile Using OpenFileDialog"

        ///<summary>Add a shapefile to the ActiveView using the Windows.Forms.OpenFileDialog control.</summary>
        ///
        ///<param name="activeView">An IActiveView interface</param>
        /// 
        ///<remarks></remarks>
        public void AddShapefileUsingOpenFileDialog(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
          //parameter check
          if (activeView == null)
          {
            return;
          }

          // Use the OpenFileDialog Class to choose which shapefile to load.
          System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
          openFileDialog.InitialDirectory = "c:\\";
          openFileDialog.Filter = "Shapefiles (*.shp)|*.shp";
          openFileDialog.FilterIndex = 2;
          openFileDialog.RestoreDirectory = true;
          openFileDialog.Multiselect = false;


          if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
          {
            // The user chose a particular shapefile.

            // The returned string will be the full path, filename and file-extension for the chosen shapefile. Example: "C:\test\cities.shp"
            string shapefileLocation = openFileDialog.FileName;

            if (shapefileLocation != "")
            {
              // Ensure the user chooses a shapefile

              // Create a new ShapefileWorkspaceFactory CoClass to create a new workspace
              ESRI.ArcGIS.Geodatabase.IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();

              // System.IO.Path.GetDirectoryName(shapefileLocation) returns the directory part of the string. Example: "C:\test\"
              ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(shapefileLocation), 0); // Explicit Cast

              // System.IO.Path.GetFileNameWithoutExtension(shapefileLocation) returns the base filename (without extension). Example: "cities"
              ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(shapefileLocation));

              ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = new ESRI.ArcGIS.Carto.FeatureLayer();
              featureLayer.FeatureClass = featureClass;
              featureLayer.Name = featureClass.AliasName;
              featureLayer.Visible = true;
              activeView.FocusMap.AddLayer(featureLayer);

              // Zoom the display to the full extent of all layers in the map
              activeView.Extent = activeView.FullExtent;
              activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography, null, null);
            }
            else
            {
              // The user did not choose a shapefile.
              // Do whatever remedial actions as necessary
              // System.Windows.Forms.MessageBox.Show("No shapefile chosen", "No Choice #1",
              //                                     System.Windows.Forms.MessageBoxButtons.OK,
              //                                     System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
          }
          else
          {
            // The user did not choose a shapefile. They clicked Cancel or closed the dialog by the "X" button.
            // Do whatever remedial actions as necessary.
            // System.Windows.Forms.MessageBox.Show("No shapefile chosen", "No Choice #2",
            //                                      System.Windows.Forms.MessageBoxButtons.OK,
            //                                      System.Windows.Forms.MessageBoxIcon.Exclamation);
          }
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:74,代码来源:AddShapefile.cs


注:本文中的ESRI.PartialRefresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。