Exemple #1
0
        /// <summary>
        /// 导入要素
        /// </summary>
        /// <param name="featureClass"></param>
        /// <param name="btnImportFeature"></param>
        internal static void ImportFeature(ref IFeatureClass featureClass, ButtonEdit btnImportFeature)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title            = "添加Shape数据";
            openFileDialog.Multiselect      = false;
            openFileDialog.Filter           = "Shape|*.shp";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.CheckFileExists  = true;
            openFileDialog.Multiselect      = false;

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (openFileDialog.FileName != null)
                {
                    IWorkspaceFactory shapeWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
                    IFeatureWorkspace shapeFeatureWorkspace = (IFeatureWorkspace)shapeWorkspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(openFileDialog.FileName), 0);
                    featureClass = shapeFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileName(openFileDialog.FileName));

                    string aliasName = featureClass.AliasName;

                    btnImportFeature.Invoke(new Action(() => { btnImportFeature.Text = aliasName; }));
                }
                else
                {
                    featureClass = null;
                }
            }
            else
            {
                featureClass = null;
            }
        }
Exemple #2
0
 private void EditButton_Click(object sender, RoutedEventArgs e)
 {
     ButtonEdit?.Invoke();
 }