예제 #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 (this.m_PathType == enumPathType.Feature)
                    {
                        dlgWorkspace.Filter = "Shp |*.shp";                    }
                    else
                    {
                        dlgWorkspace.Filter = "所有类型|*.jpg;*.bmp;*.tif;*.img;*.png;*.ovr;";
                    }
                    if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
                        return;

                    txtWorkspace.Text = dlgWorkspace.FileName;
                    m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, System.IO.Path.GetDirectoryName(dlgWorkspace.FileName));
                    string strName=System.IO.Path.GetFileName(dlgWorkspace.FileName);
                    cmbClass.Properties.Items.Clear();
                    cmbClass.Properties.Items.Add(strName);
                    cmbClass.Text = strName;

                    // Shp / 文件栅格的话到此为止
                    return;

            }

            // 判断
            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();
            }
        }
예제 #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 (this.m_PathType == enumPathType.Feature)
                {
                    dlgWorkspace.Filter = "Shp |*.shp";
                }
                else
                {
                    dlgWorkspace.Filter = "所有类型|*.jpg;*.bmp;*.tif;*.img;*.png;*.ovr;";
                }
                if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = dlgWorkspace.FileName;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, System.IO.Path.GetDirectoryName(dlgWorkspace.FileName));
                string strName = System.IO.Path.GetFileName(dlgWorkspace.FileName);
                cmbClass.Properties.Items.Clear();
                cmbClass.Properties.Items.Add(strName);
                cmbClass.Text = strName;

                // Shp / 文件栅格的话到此为止
                return;
            }

            // 判断
            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();
            }
        }