Exemple #1
0
        private void txtWorkspace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            m_Workspace = null;
            switch (m_SelectedWorkspaceType)
            {
            case enumWorkspaceType.SDE:
                FrmSDESetting frmSetting = new FrmSDESetting();
                if (m_SDEPropertySet != null)
                {
                    frmSetting.SDEPropertySet = m_SDEPropertySet;
                }

                if (frmSetting.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                m_SDEPropertySet  = frmSetting.SDEPropertySet;
                txtWorkspace.Text = Utility.WorkspaceHelper.PropertySetToString(m_SDEPropertySet);
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.SDE, m_SDEPropertySet);

                break;

            case enumWorkspaceType.FileGDB:
                if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.FileGDB, folderBrowserWorkspace.SelectedPath);

                break;

            case enumWorkspaceType.PGDB:
                dlgWorkspace.Filter = "PGDB |*.mdb";
                if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = dlgWorkspace.FileName;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.PGDB, dlgWorkspace.FileName);

                break;

            case enumWorkspaceType.File:
                if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, folderBrowserWorkspace.SelectedPath);

                break;
            }

            // 判断
            if (m_Workspace == null)
            {
                XtraMessageBox.Show("非正确的数据库!");
                return;
            }

            // 加载Dataset
            cmbDataset.Properties.Items.Clear();
            cmbDataset.Properties.Items.Add("");
            esriDatasetType  dsType        = (this.m_PathType == enumPathType.Feature ? esriDatasetType.esriDTFeatureDataset : esriDatasetType.esriDTRasterCatalog);
            IEnumDatasetName enDatasetName = m_Workspace.get_DatasetNames(dsType);
            IDatasetName     dsName        = enDatasetName.Next();

            while (dsName != null)
            {
                cmbDataset.Properties.Items.Add(dsName.Name);
                dsName = enDatasetName.Next();
            }
        }
Exemple #2
0
        private void txtWorkspace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            m_Workspace = null;
            switch (m_SelectedWorkspaceType)
            {
                case enumWorkspaceType.SDE:
                    FrmSDESetting frmSetting = new FrmSDESetting();
                    if (m_SDEPropertySet != null)
                        frmSetting.SDEPropertySet = m_SDEPropertySet;

                    if (frmSetting.ShowDialog(this) != DialogResult.OK)
                        return;

                    m_SDEPropertySet = frmSetting.SDEPropertySet;
                    txtWorkspace.Text = Utility.WorkspaceHelper.PropertySetToString(m_SDEPropertySet);
                    m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.SDE, m_SDEPropertySet);

                    break;

                case enumWorkspaceType.FileGDB:
                    if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                        return;

                    txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                    m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.FileGDB, folderBrowserWorkspace.SelectedPath);

                    break;

                case enumWorkspaceType.PGDB:
                    dlgWorkspace.Filter = "PGDB |*.mdb";
                    if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
                        return;

                    txtWorkspace.Text = dlgWorkspace.FileName;
                    m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.PGDB, dlgWorkspace.FileName);

                    break;

                case enumWorkspaceType.File:
                    if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                        return;

                    txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                    m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, folderBrowserWorkspace.SelectedPath);

                    break;
            }

            // 判断
            if (m_Workspace == null)
            {
                XtraMessageBox.Show("非正确的数据库!");
                return;
            }

            // 加载Dataset
            cmbDataset.Properties.Items.Clear();
            cmbDataset.Properties.Items.Add("");
            esriDatasetType dsType = (this.m_PathType == enumPathType.Feature ? esriDatasetType.esriDTFeatureDataset : esriDatasetType.esriDTRasterCatalog);
            IEnumDatasetName enDatasetName = m_Workspace.get_DatasetNames(dsType);
            IDatasetName dsName = enDatasetName.Next();
            while (dsName != null)
            {
                cmbDataset.Properties.Items.Add(dsName.Name);
                dsName = enDatasetName.Next();
            }
        }