コード例 #1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true);
            file.AllowMultiSelect = false;
            this.btnSelectInputFeatures.Enabled = false;
            if (file.DoModalOpen() == DialogResult.OK)
            {
                this.igxDataset_0 = null;
                if (file.Items.Count != 0)
                {
                    IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                    if (dataset != null)
                    {
                        this.igxDataset_0   = dataset;
                        this.textEdit1.Text = (this.igxDataset_0 as IGxObject).Name;
                        this.btnSelectInputFeatures.Enabled = true;
                    }
                    else
                    {
                        this.igxDataset_0   = null;
                        this.textEdit1.Text = "";
                    }
                }
            }
        }
コード例 #2
0
        private void btnDB_Click(object sender, EventArgs e)
        {
            frmOpenFile openFile = new frmOpenFile();

            openFile.AllowMultiSelect = false;
            openFile.AddFilter(new MyGxFilterWorkspaces(), true);
            openFile.AddFilter(new MyGxFilterFeatureDatasets(), false);
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                IGxObject gxObject = openFile.Items.get_Element(0);
                if (gxObject is IGxDatabase)
                {
                    IGxDatabase database = gxObject as IGxDatabase;
                    txtDB.Text = database.WorkspaceName.PathName;
                    txtDB.Tag  = database;
                    label1.Tag = "Database";
                    xtraTabControl1.TabPages[0].PageVisible = true;
                }
                else if (gxObject is IGxDataset)
                {
                    IGxDataset dataset = gxObject as IGxDataset;
                    txtDB.Text = dataset.DatasetName.WorkspaceName.PathName + "\\" + dataset.DatasetName.Name;
                    txtDB.Tag  = dataset;
                    label1.Tag = "Dataset";
                    xtraTabControl1.TabPages[0].PageVisible = false;
                }
            }
        }
コード例 #3
0
ファイル: VCSControlPage.cs プロジェクト: secondii/Yutai
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        if (dataset2.SpatialReference is IUnknownCoordinateSystem)
                        {
                            this.ispatialReferenceInfo_0 = null;
                            this.textBoxName.Text        = "<NONE>";
                            this.textBoxName.Tag         = null;
                        }
                        else
                        {
                            this.ispatialReferenceInfo_0 =
                                (dataset2.SpatialReference as ISpatialReference3).VerticalCoordinateSystem;
                            this.textBoxName.Tag  = this.ispatialReferenceInfo_0;
                            this.textBoxName.Text = this.ispatialReferenceInfo_0.Name;
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        this.ispatialReference_0 = dataset2.SpatialReference;
                        TreeNode node = new TreeNode(this.ispatialReference_0.Name, 2, 2)
                        {
                            Tag = this.ispatialReference_0
                        };
                        this.treeNode_0.Nodes.Add(node);
                        this.method_4(this.ispatialReference_0);
                        this.method_6();
                    }
                }
            }
        }
コード例 #5
0
		// Adds Barriers from Dataset
		private void OpenBarriers()
		{
			System.Windows.Forms.Cursor Cursor = this.Cursor;
			try
			{
				// Create Dialog on first call and init filter
				InitBarriersDlg();

				// Get Barriers 
				IGxObject gxObject = null;

				IEnumGxObject gxObjects = null;
				gxObjects = null;

				if (m_dlgBarriers.DoModalOpen(this.Handle.ToInt32(), out gxObjects) & (gxObjects != null))
				{

					this.Cursor = Cursors.WaitCursor;

					// Init Barriers
					ClearBarriers();

					// use first object
					gxObjects.Reset();
					gxObject = gxObjects.Next();

					// Use first object
					if (gxObject != null)
					{
						// Add Barriersfrom object dataset
						IGxDataset objGxDS = null;
						objGxDS = gxObject as IGxDataset;

						AddBarriersFromDataset(objGxDS.Dataset);
					}

					// Is Barriers added to Router
					if (m_nBarriersCount == 0)
						m_txtBarriers.Text = "";
					else
						m_txtBarriers.Text = gxObject.Name;

					if (m_nBarriersIgnoredCount > 0)
						MessageBox.Show(this, m_nBarriersIgnoredCount.ToString() + " barriers cannot be added.", "Routing Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}

			}
			catch (Exception ex)
			{
				// Clear on Error
				ClearBarriers();
			}
			finally
			{
				this.Cursor = Cursor;
			}
		}
コード例 #6
0
ファイル: LayerDataToXML.cs プロジェクト: Leopold-Z/Test
        private void FillTreeView(IEnumGxObject pGxObjects)
        {
            if (pGxObjects == null)
            {
                return;
            }

            pGxObjects.Reset();
            TreeNode rootnode = new TreeNode("数据源");

            trvDatasets.Nodes.Add(rootnode);

            IGxDataset pGxDataset = pGxObjects.Next() as IGxDataset;

            while (pGxDataset != null)
            {
                if (pGxDataset.Dataset is IFeatureClass)
                {
                    IDataset featureDataset   = pGxDataset.Dataset;
                    TreeNode featureClassName = new TreeNode(featureDataset.Name);
                    rootnode.Nodes.Add(featureClassName);
                }
                else if (pGxDataset.Dataset is IFeatureDataset)
                {
                    TreeNode     datasetName = new TreeNode(pGxDataset.Dataset.Name);
                    IEnumDataset pEnumDataset;
                    pEnumDataset = pGxDataset.Dataset.Subsets;
                    pEnumDataset.Reset();
                    IDataset pDataSet = pEnumDataset.Next();
                    while (pDataSet != null)
                    {
                        //注意:拓扑要素及网络线要素不能作为报表数据源
                        if ((pDataSet is ITopology) || (pDataSet is IGeometricNetwork) || (pDataSet is INetworkDataset))
                        {
                            pDataSet = pEnumDataset.Next();
                        }
                        else
                        {
                            TreeNode featureClassName = new TreeNode(pDataSet.Name);
                            datasetName.Nodes.Add(featureClassName);
                            pDataSet = pEnumDataset.Next();
                        }
                    }
                    rootnode.Nodes.Add(datasetName);
                }
                pGxDataset = pGxObjects.Next() as IGxDataset;
            }
            trvDatasets.Sort();

            for (int i = 0; i < rootnode.Nodes.Count; i++)
            {
                ListViewItem item = new ListViewItem(rootnode.Nodes[i].Text);
                lsvDetails.Items.Add(item);
            }
            lsvDetails.Refresh();
        }
コード例 #7
0
ファイル: UcExportPath.cs プロジェクト: secondii/Yutai
        private void btnOpen_Click(object sender, EventArgs e)
        {
            switch (ExportType)
            {
            case EnumExportType.FeatureClass:
            {
                frmOpenFile frm = new frmOpenFile();
                frm.AllowMultiSelect = false;
                frm.AddFilter(new MyGxFilterWorkspaces(), false);
                frm.AddFilter(new MyGxFilterDatasets(), true);
                frm.Text = @"选择输出位置";
                if (frm.DoModalOpen() == DialogResult.OK)
                {
                    IGxObject gxObject = frm.Items.get_Element(0) as IGxObject;
                    if (gxObject is IGxDatabase)
                    {
                        IGxDatabase gxDatabase = gxObject as IGxDatabase;
                        _dataset   = null;
                        _workspace = gxDatabase.Workspace;
                        _saveType  = EnumSaveType.Workspace;
                    }
                    else if (gxObject is IGxDataset)
                    {
                        IGxDataset gxDataset = gxObject as IGxDataset;
                        _dataset   = gxDataset.Dataset;
                        _workspace = _dataset.Workspace;
                        _saveType  = EnumSaveType.Dataset;
                    }
                }
            }
            break;

            case EnumExportType.Shapefile:
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.ShowNewFolderButton = true;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    this.txtPath.Text = dialog.SelectedPath;

                    Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");
                    IWorkspaceFactory shapefileWorkspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
                    if (shapefileWorkspaceFactory == null)
                    {
                        return;
                    }
                    _dataset   = null;
                    _workspace = shapefileWorkspaceFactory.OpenFromFile(dialog.SelectedPath, 0);
                    _saveType  = EnumSaveType.Workspace;
                }
            }
            break;
            }
        }
コード例 #8
0
ファイル: frmProject.cs プロジェクト: secondii/Yutai
        private void btnSelectIn_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile
            {
                AllowMultiSelect = false,
                Text             = "选择要素"
            };

            file.RemoveAllFilters();
            file.AddFilter(new MyGxFilterDatasets(), true);
            if (file.DoModalOpen() == DialogResult.OK)
            {
                IArray items = file.Items;
                if (items.Count != 0)
                {
                    this.igxDataset_0      = items.get_Element(0) as IGxDataset;
                    this.idataset_0        = this.igxDataset_0.Dataset;
                    this.txtInputFeat.Text = (this.igxDataset_0 as IGxObject).FullName;
                    this.iworkspace_0      = this.idataset_0.Workspace;
                    string        tableName = this.idataset_0.Name + "_Project1";
                    IFieldChecker checker   = new FieldCheckerClass
                    {
                        InputWorkspace = this.iworkspace_0
                    };
                    checker.ValidateTableName(tableName, out this.string_0);
                    this.txtOutFeat.Text = this.iworkspace_0.PathName + @"\" + this.string_0;
                    if ((this.iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) ||
                        (this.iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace))
                    {
                        if (((IWorkspace2)this.iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass,
                                                                            this.string_0))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                    else if (this.iworkspace_0.Type == esriWorkspaceType.esriFileSystemWorkspace)
                    {
                        if (File.Exists(this.txtOutFeat.Text + ".shp"))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                }
            }
        }
コード例 #9
0
        private void btnImportFC_Click(object sender, EventArgs e)
        {
            frmOpenFile frm = new frmOpenFile();

            frm.AddFilter(new MyGxFilterFeatureClasses(), true);
            if (frm.DoModalOpen() != DialogResult.OK)
            {
                return;
            }
            IGxDataset gxObject = frm.SelectedItems[0] as IGxDataset;

            if (gxObject == null)
            {
                return;
            }
            DialogResult result = MessageBox.Show("导入字段时是否清空已有字段?", "询问", MessageBoxButtons.YesNoCancel,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            if (result == DialogResult.Yes)
            {
                _fieldTable.Rows.Clear();
            }
            IFeatureClass pClass = gxObject.Dataset as IFeatureClass;

            for (int i = 0; i < pClass.Fields.FieldCount; i++)
            {
                IField pField = pClass.Fields.Field[i];
                if (pField.Type == esriFieldType.esriFieldTypeGeometry || pField.Type == esriFieldType.esriFieldTypeOID)
                {
                    continue;
                }
                string pFldName = pField.Name;
                if (_fieldTable.Select("FieldName='" + pFldName + "'").Length > 0)
                {
                    continue;
                }
                DataRow pRow = _fieldTable.NewRow();
                pRow["FieldName"] = pField.Name;
                pRow["AliasName"] = pField.AliasName;
                pRow["AllowNull"] = pField.IsNullable;
                pRow["FieldType"] = FieldHelper.ConvertToSimpleString(pField.Type);
                //pRow["IsKey"] = pField.DefaultValue==null ? "": pField.DefaultValue;
                pRow["FieldLength"] = pField.Length;
                pRow["Precision"]   = pField.Precision;
                _fieldTable.Rows.Add(pRow);
            }
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: l1985q/developer-support
        private void openFeatureButton_Click(object sender, EventArgs e)
        {
            IGxDialog gxDialog = new GxDialogClass
            {
                AllowMultiSelect = false,
                Title = "Select Feature Class to Determine File Size",
                ObjectFilter = new GxFilterFeatureClassesClass()
            };

            IEnumGxObject gxObjects;
            gxDialog.DoModalOpen(0, out gxObjects);

            if (gxObjects == null) return;

            gxObjects.Reset();

            IGxDataset gxDataset = gxObjects.Next() as IGxDataset;
            IGxObjectProperties gxProps = gxDataset as IGxObjectProperties;

            FeatClassTextBox.Text = gxDataset.DatasetName.Name;
            FileSizeGxTextBox.Text = gxProps.GetProperty("ESRI_GxObject_FileSize").ToString();

            double kb = double.Parse(FileSizeGxTextBox.Text)*ConversionFactor;
            
            string size;
            if (kb >= 1024.0)
            {
                double mb = ConvertKBToMB(kb);
                size = Math.Round(mb, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture) + " MB";

                if (mb >= 1024.0)
                {
                    double gb = ConvertMBToGB(mb);
                    size = Math.Round(gb, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture) + "GB";

                    if (gb >= 1024.0)
                    {
                        double tb = ConvertGBToTB(gb);
                        size = Math.Round(tb, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture) + " TB";
                    }
                }
            }
            else
            {
                size = Math.Round(kb, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture) + " KB";
            }

            FileSizeDiskTextBox.Text = size;
        }
コード例 #11
0
        private void btnImportStruct_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true);
            file.AllowMultiSelect = false;
            if ((file.DoModalOpen() == DialogResult.OK) && (file.Items.Count != 0))
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    ITable table = dataset.Dataset as ITable;
                    if (table != null)
                    {
                        int    num;
                        IField field;
                        for (num = this.ifields_0.FieldCount - 1; num > 1; num--)
                        {
                            field = this.ifields_0.get_Field(num);
                            if ((field.Type != esriFieldType.esriFieldTypeOID) &&
                                (field.Type != esriFieldType.esriFieldTypeGeometry))
                            {
                                (this.ifields_0 as IFieldsEdit).DeleteField(field);
                                if (this.bool_2)
                                {
                                    this.ifieldsEdit_1.AddField(field);
                                }
                            }
                        }
                        IFields fields = table.Fields;
                        for (num = 0; num < fields.FieldCount; num++)
                        {
                            field = fields.get_Field(num);
                            if ((field.Type != esriFieldType.esriFieldTypeOID) &&
                                (field.Type != esriFieldType.esriFieldTypeGeometry))
                            {
                                (this.ifields_0 as IFieldsEdit).AddField(field);
                                if (this.bool_2)
                                {
                                    this.ifieldsEdit_0.AddField(field);
                                }
                            }
                        }
                    }
                    this.method_2(this.listView2, this.ifields_0);
                    this.method_5(this.listView2.Items[0].Tag as IField, true);
                }
            }
        }
        private void inputRasterBtn_Click(object sender, EventArgs e)
        {
            IEnumGxObject ipSelectedObjects = null;
            ShowRasterDatasetBrowser((int)(Handle.ToInt32()), out ipSelectedObjects);

            IGxObject selectedObject =  ipSelectedObjects.Next();
            if (selectedObject is IGxDataset)
            {
                IGxDataset ipGxDS = (IGxDataset)selectedObject;
                IDataset ipDataset;
                ipDataset = ipGxDS.Dataset;
                myInputRaster = ipDataset.FullName;
                inputRasterTxtbox.Text = GetInputRasterName(myInputRaster);
                myDirtyFlag = true;
            }
        }
コード例 #13
0
ファイル: LayerDataToXML.cs プロジェクト: Leopold-Z/Test
        //使用GxDialog对话框选择要输出的数据源(要素集和(或)要素类、shapefile文件)
        private IEnumGxObject AddLayerWithGxDialog()
        {
            try
            {
                IGxDialog gxDlg = new GxDialogClass();
                // create a data format filter
                IGxObjectFilter gxObjFilter = new GxFilterFeatureDatasetsAndFeatureClassesClass();
                // set the properties of the open dialog
                gxDlg.Title            = "Add Feature Datasets and/or Feature Classes";
                gxDlg.ObjectFilter     = gxObjFilter;
                gxDlg.AllowMultiSelect = true;
                gxDlg.RememberLocation = true;

                IEnumGxObject gxObjects;
                bool          open = gxDlg.DoModalOpen(0, out gxObjects);

                IGxDataset gxDataset = gxObjects.Next() as IGxDataset;
                if (gxDataset != null)
                {
                    if (gxDataset.Dataset is IFeatureClass)
                    {
                        IFeatureClass   featureClass   = gxDataset.Dataset as IFeatureClass;
                        IFeatureDataset featureDataSet = featureClass.FeatureDataset;
                        if (featureDataSet == null)
                        {
                            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
                            featureWorkspace = pWorkspaceFactory.OpenFromFile(gxDlg.FinalLocation.FullName, this.Handle.ToInt32()) as IFeatureWorkspace;
                        }
                        else
                        {
                            featureWorkspace = featureDataSet.Workspace as IFeatureWorkspace;
                        }
                    }
                    else if (gxDataset.Dataset is IFeatureDataset)
                    {
                        IFeatureDataset featureDataSet = gxDataset.Dataset as IFeatureDataset;
                        featureWorkspace = featureDataSet.Workspace as IFeatureWorkspace;
                    }
                }
                return(gxObjects);
            }
            catch
            {
                MessageBox.Show("不能打开数据集或要素类!!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(null);
        }
コード例 #14
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true);
            file.AllowMultiSelect = false;
            if ((file.DoModalOpen() == DialogResult.OK) && (file.Items.Count != 0))
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    if ((this.igxDataset_0.Type == esriDatasetType.esriDTFeatureClass) &&
                        (dataset.Type == esriDatasetType.esriDTFeatureClass))
                    {
                        if ((this.igxDataset_0.Dataset as IFeatureClass).ShapeType ==
                            (dataset.Dataset as IFeatureClass).ShapeType)
                        {
                            if (
                                this.method_0(this.igxDataset_0.DatasetName.WorkspaceName,
                                              dataset.DatasetName.WorkspaceName) &&
                                (this.igxDataset_0.DatasetName.Name == dataset.DatasetName.Name))
                            {
                                MessageBox.Show("源对象类和目标对象类必须不同!");
                            }
                            else
                            {
                                this.igxDataset_1   = dataset;
                                this.textEdit1.Text = (this.igxDataset_1 as IGxObject).Name;
                            }
                        }
                        else
                        {
                            MessageBox.Show("装载数据必须和源数据有相同的几何数据类型!");
                        }
                    }
                    else
                    {
                        this.igxDataset_1   = dataset;
                        this.textEdit1.Text = (this.igxDataset_1 as IGxObject).Name;
                    }
                }
                else
                {
                    this.textEdit1.Text = "";
                }
            }
        }
コード例 #15
0
ファイル: JoinTable.cs プロジェクト: frankerlee/Yutai
        public static IFeatureClass SelectFeatureClassDialog()
        {
            IGxDialog pGxDialog = new GxDialogClass();

            pGxDialog.ObjectFilter     = new GxFilterFeatureClassesClass();
            pGxDialog.AllowMultiSelect = false;
            pGxDialog.RememberLocation = true;
            IEnumGxObject pEnumGxObject;

            if (pGxDialog.DoModalOpen(0, out pEnumGxObject))
            {
                IGxObject  pSelectGxObject = pEnumGxObject.Next();
                IGxDataset pGxDataset      = (IGxDataset)pSelectGxObject;
                return(pGxDataset.Dataset as IFeatureClass);
            }
            return(null);
        }
コード例 #16
0
 private bool method_1(IDataset idataset_0)
 {
     for (int i = 0; i < this.SourceDatalistBox.Items.Count; i++)
     {
         IGxDataset dataset = this.SourceDatalistBox.Items[i] as IGxDataset;
         if (dataset.Type != idataset_0.Type)
         {
             return(false);
         }
         if ((dataset.Type == esriDatasetType.esriDTFeatureClass) &&
             ((dataset.DatasetName as IFeatureClassName).ShapeType != (idataset_0 as IFeatureClass).ShapeType))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #17
0
        private void cmdLayerBrowse_Click(object sender, EventArgs e)
        {
            frmOpenFile frmOpenFile = new frmOpenFile();

            frmOpenFile.AddFilter(new MyGxFilterPolygonFeatureClasses(), true);
            frmOpenFile.Text = "选择要素";
            if (frmOpenFile.DoModalOpen() == System.Windows.Forms.DialogResult.OK)
            {
                IArray items = frmOpenFile.Items;
                for (int i = 0; i < items.Count; i++)
                {
                    IGxDataset gxDataset = items.get_Element(i) as IGxDataset;
                    this.cmbBuildingLayer.Items.Add(new ObjectWrap(gxDataset.Dataset));
                }
                this.cmbBuildingLayer.SelectedIndex = this.cmbBuildingLayer.Items.Count - 1;
            }
        }
コード例 #18
0
ファイル: ClsStatic.cs プロジェクト: johnforrest/GeoCoding
        /// <summary>
        /// 打开指定路径的匹配结果表
        /// </summary>
        /// <returns>返回的表内容</returns>
        public static ITable OpenRelateTable(out string path)
        {
            IGxDialog dlg = new GxDialog();

            IGxObjectFilter pGxFilter = new GxFilterTablesClass();

            dlg.ObjectFilter     = pGxFilter;
            dlg.Title            = "添加关系表";
            dlg.ButtonCaption    = "添加";
            dlg.AllowMultiSelect = false;

            IEnumGxObject pEnumGxObject;

            dlg.DoModalOpen(0, out pEnumGxObject);
            if (pEnumGxObject != null)
            {
                pEnumGxObject.Reset();
                IGxObject gxObj;

                while ((gxObj = pEnumGxObject.Next()) != null)
                {
                    if (gxObj is IGxDataset)
                    {
                        IGxDataset gxDataset = gxObj as IGxDataset;
                        IDataset   pDataset  = gxDataset.Dataset;
                        if (pDataset.Type == esriDatasetType.esriDTTable)
                        {
                            ITable pTable = pDataset as ITable;
                            if (pTable.FindField("源OID") != -1 && pTable.FindField("待更新OID") != -1 &&
                                pTable.FindField("变化标记") != -1)
                            {
                                path = gxObj.FullName;
                                return(pTable);
                            }
                            else
                            {
                                MessageBox.Show("您打开的表格式不正确,请打开匹配关系表!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
            }
            path = string.Empty;
            return(null);
        }
コード例 #19
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        this.ispatialReference_0 = dataset2.SpatialReference;
                        this.textBoxName.Text    = this.ispatialReference_0.Name;
                        this.textBoxName.Tag     = this.ispatialReference_0;
                        if (this.ispatialReference_0 is IUnknownCoordinateSystem)
                        {
                            this.btnModify.Enabled = false;
                        }
                        else
                        {
                            this.btnModify.Enabled = true;
                        }
                        IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2;
                        if (NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision != precision.IsHighPrecision)
                        {
                            if (precision.IsHighPrecision)
                            {
                                precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision;
                                (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon();
                            }
                            else
                            {
                                precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision;
                            }
                        }
                    }
                }
            }
        }
コード例 #20
0
ファイル: CreateRasterForm.cs プロジェクト: goby/summerzju
        private void OnLoadFeatureClass(object sender, EventArgs e)
        {
            IGxDialog iGxDlg = new GxDialogClass();

            iGxDlg.Title        = "选择点数据集";
            iGxDlg.ObjectFilter = new GxFilterPointFeatureClassesClass();
            IEnumGxObject selection;

            iGxDlg.DoModalOpen(0, out selection);
            selection.Reset();

            IGxObject iGxObject;

            while ((iGxObject = selection.Next()) != null)
            {
                IGxDataset iGxDataset = (IGxDataset)iGxObject;
                if (iGxDataset != null)
                {
                    IDataset      iDataset = iGxDataset.Dataset;
                    IFeatureClass iFc      = (IFeatureClass)iDataset;
                    mFeatureClass = iFc;

                    textBox6.Text = iGxObject.FullName;

                    //设置ComboBox
                    comboBox1.ResetText();
                    IFields iFields = iFc.Fields;
                    long    iCount  = iFields.FieldCount;
                    for (int i = 0; i < iCount; i++)
                    {
                        IField iField = iFields.get_Field(i);
                        comboBox1.Items.Add(iField.Name);
                    }

                    if (comboBox1.Items.Count > 0)
                    {
                        comboBox1.SelectedIndex = 0;
                    }
                }
            }
        }//Open Feature Class
コード例 #21
0
        public override void OnClick()
        {
            frmOpenFile frmOpenFile = new frmOpenFile();

            frmOpenFile.Text             = "添加数据";
            frmOpenFile.AllowMultiSelect = false;
            frmOpenFile.AddFilter(new MyGxFilterPolylineFeatureClasses(), true);
            if (frmOpenFile.DoModalOpen() == System.Windows.Forms.DialogResult.OK)
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                IArray        items        = frmOpenFile.Items;
                IGxDataset    gxDataset    = items.get_Element(0) as IGxDataset;
                IFeatureClass featureClass = gxDataset.Dataset as IFeatureClass;
                new frmDGXFeatureClassToTin
                {
                    FeatureClass = featureClass,
                    m_pMap       = this._plugin.Scene as IBasicMap
                }.ShowDialog();
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
コード例 #22
0
ファイル: GxDialogHelper.cs プロジェクト: frankerlee/Yutai
        public static IFeatureClass SelectFeatureClassDialog(List <IGxObjectFilter> gxFilters)
        {
            IGxDialog pGxDialog = new GxDialogClass();
            IGxObjectFilterCollection pFilterCol = pGxDialog as IGxObjectFilterCollection;

            foreach (IGxObjectFilter gxObjectFilter in gxFilters)
            {
                pFilterCol.AddFilter(gxObjectFilter, true);
            }
            pGxDialog.AllowMultiSelect = false;
            pGxDialog.RememberLocation = true;
            IEnumGxObject pEnumGxObject;

            if (pGxDialog.DoModalOpen(0, out pEnumGxObject))
            {
                IGxObject  pSelectGxObject = pEnumGxObject.Next();
                IGxDataset pGxDataset      = (IGxDataset)pSelectGxObject;
                return(pGxDataset.Dataset as IFeatureClass);
            }
            return(null);
        }
コード例 #23
0
ファイル: GxDialogHelper.cs プロジェクト: frankerlee/Yutai
        public static List <IFeatureClass> SelectFeatureClassesDialog()
        {
            List <IFeatureClass> list      = new List <IFeatureClass>();
            IGxDialog            pGxDialog = new GxDialogClass();

            pGxDialog.ObjectFilter     = new GxFilterFeatureClassesClass();
            pGxDialog.AllowMultiSelect = true;
            pGxDialog.RememberLocation = true;
            IEnumGxObject pEnumGxObject;

            if (pGxDialog.DoModalOpen(0, out pEnumGxObject))
            {
                IGxObject pSelectGxObject;
                while ((pSelectGxObject = pEnumGxObject.Next()) != null)
                {
                    IGxDataset pGxDataset = (IGxDataset)pSelectGxObject;
                    list.Add(pGxDataset.Dataset as IFeatureClass);
                }
            }

            return(list);
        }
コード例 #24
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IGxDataset tag = this.txtInputFeatureClass.Tag as IGxDataset;

            if (tag == null)
            {
                MessageBox.Show("请选择要素类或表!");
            }
            else if ((tag.Type == esriDatasetType.esriDTFeatureClass) || (tag.Type == esriDatasetType.esriDTTable))
            {
                if (this.SourceDatalistBox.Items.Count == 0)
                {
                    this.SourceDatalistBox.Items.Add(tag);
                }
                else
                {
                    if (this.SourceDatalistBox.Items.IndexOf(tag) != -1)
                    {
                        MessageBox.Show("数据类已存在!");
                        return;
                    }
                    IGxDataset dataset2 = this.SourceDatalistBox.Items[0] as IGxDataset;
                    if (dataset2.Type != tag.Type)
                    {
                        MessageBox.Show("要加入的数据集和已有数据集类型不一致,不能添加!");
                        return;
                    }
                    this.SourceDatalistBox.Items.Add(tag);
                }
                this.txtInputFeatureClass.Tag  = null;
                this.txtInputFeatureClass.Text = "";
                this.btnAdd.Enabled            = false;
            }
            else
            {
                MessageBox.Show("请选择要素类或表!");
            }
        }
コード例 #25
0
ファイル: CoordinateControl.cs プロジェクト: secondii/Yutai
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        this.ispatialReference_0 = dataset2.SpatialReference;
                        IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2;
                        if (this.bool_2 != precision.IsHighPrecision)
                        {
                            if (precision.IsHighPrecision)
                            {
                                precision.IsHighPrecision = this.bool_2;
                                (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon();
                            }
                            else
                            {
                                precision.IsHighPrecision = this.bool_2;
                            }
                        }
                        this.method_1(this.ispatialReference_0);
                        if (this.SpatialReferenceChanged != null)
                        {
                            this.SpatialReferenceChanged(this.ispatialReference_0);
                        }
                        this.method_0();
                    }
                }
            }
        }
コード例 #26
0
ファイル: ClsStatic.cs プロジェクト: johnforrest/GeoCoding
        /// <summary>
        /// 打开源图层
        /// </summary>
        /// <param name="path">路径</param>
        /// <returns></returns>
        public static IFeatureClass OpenSourceLayer(out string path)
        {
            IGxDialog dlg = new GxDialog();

            IGxObjectFilter pGxFilter = new GxFilterFeatureClassesClass();

            dlg.ObjectFilter     = pGxFilter;
            dlg.Title            = "添加源图层";
            dlg.ButtonCaption    = "添加";
            dlg.AllowMultiSelect = false;

            IEnumGxObject pEnumGxObject;

            dlg.DoModalOpen(0, out pEnumGxObject);
            if (pEnumGxObject != null)
            {
                pEnumGxObject.Reset();
                IGxObject gxObj;

                while ((gxObj = pEnumGxObject.Next()) != null)
                {
                    if (gxObj is IGxDataset)
                    {
                        IGxDataset gxDataset = gxObj as IGxDataset;
                        IDataset   pDataset  = gxDataset.Dataset;
                        if (pDataset.Type == esriDatasetType.esriDTFeatureClass)
                        {
                            IFeatureClass pIFeatureClass = pDataset as IFeatureClass;
                            path = gxObj.FullName;
                            return(pIFeatureClass);
                        }
                    }
                }
            }
            path = string.Empty;
            return(null);
        }
コード例 #27
0
 private bool method_2()
 {
     if (this.SourceDatalistBox.Items.Count != 0)
     {
         IGxDataset dataset = this.SourceDatalistBox.Items[0] as IGxDataset;
         IFields    fields  = (dataset.Dataset as ITable).Fields;
         IGxDataset tag     = this.txtInputFeatureClass.Tag as IGxDataset;
         IFields    fields2 = (tag.Dataset as ITable).Fields;
         if (fields2.FieldCount != fields.FieldCount)
         {
             return(false);
         }
         bool flag2 = false;
         for (int i = 0; i < fields.FieldCount; i++)
         {
             flag2 = false;
             IField field = fields.get_Field(i);
             if (field.Editable)
             {
                 for (int j = 0; j < fields2.FieldCount; j++)
                 {
                     IField field2 = fields2.get_Field(i);
                     if ((string.Compare(field.Name, field2.Name, true) == 0) && (field.Type == field2.Type))
                     {
                         flag2 = true;
                     }
                 }
                 if (!flag2)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
コード例 #28
0
        public void Refresh()
        {
            //If the selection does not support IGxDataset, do nothing.
            IGxSelection       pSelection     = null;
            IGxObject          pLocation      = null;
            IGraphicsContainer pGraphicsLayer = null;

            try
            {
                pSelection = m_pSelection;
                pLocation  = pSelection.Location;
                if (!(pLocation is IGxDataset))
                {
                    return;
                }

                //Clear the contents of the graphics layer.

                pGraphicsLayer = (IGraphicsContainer)frmExtentView.AxMapControl1.Map.BasicGraphicsLayer;
                pGraphicsLayer.DeleteAllElements();

                //Some dataset may not have content at all
                IGxDataset        pGxDataset        = null;
                IGeoDataset       pGeoDataset       = null;
                IElement          pElement          = null;
                IFillShapeElement pFillShapeElement = null;
                try
                {
                    //Get the geodataset out of the GxDataset.
                    pGxDataset = (IGxDataset)pLocation;
                    if (pGxDataset.Type == esriDatasetType.esriDTLayer |
                        pGxDataset.Type == esriDatasetType.esriDTFeatureClass |
                        pGxDataset.Type == esriDatasetType.esriDTFeatureDataset)
                    {
                        pGeoDataset = (IGeoDataset)pGxDataset.Dataset;
                    }
                    else
                    {
                        return;
                    }

                    //Create a rectangular graphic element to represent the geodataset's full extent.

                    pElement          = new RectangleElement();
                    pElement.Geometry = pGeoDataset.Extent;

                    //Set the element's symbology.

                    pFillShapeElement        = (IFillShapeElement)pElement;
                    pFillShapeElement.Symbol = m_pFillSymbol;

                    //Add the rectangle element to the graphics layer, and force the map to redraw.
                    pGraphicsLayer.AddElement(pElement, 0);
                    frmExtentView.AxMapControl1.Refresh();
                }
                catch (Exception ex)
                {
                    frmExtentView.AxMapControl1.Refresh();
                    throw ex;
                }
                finally
                {
                    pGxDataset        = null;
                    pGeoDataset       = null;
                    pElement          = null;
                    pFillShapeElement = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                pSelection     = null;
                pLocation      = null;
                pGraphicsLayer = null;
            }
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IGxApplication  gxApp     = m_application as IGxApplication;
            IGxDataset      gxDataset = null;
            esriDatasetType dsType    = esriDatasetType.esriDTAny;

            if (gxApp != null)
            {
                gxDataset = gxApp.SelectedObject as IGxDataset;
                dsType    = gxDataset.Type;
            }

            if (dsType != esriDatasetType.esriDTNetworkDataset)
            {
                return;
            }

            IDataset ds = gxDataset.Dataset;

            if (ds == null)
            {
                return;
            }

            INetworkDataset nds = ds as INetworkDataset;

            if (nds == null)
            {
                return;
            }

            if (!nds.Buildable)
            {
                return;
            }

            INetworkBuild netBuild = nds as INetworkBuild;

            if (netBuild == null)
            {
                return;
            }

            IDatasetComponent dsComponent = nds as IDatasetComponent;
            IDENetworkDataset deNet       = null;

            if (dsComponent != null)
            {
                deNet = dsComponent.DataElement as IDENetworkDataset;
            }

            if (deNet == null)
            {
                return;
            }

            FilterSubsetEvaluator.RemoveFilterSubsetAttribute(deNet);
            ScaleSubsetEvaluator.RemoveScaleSubsetAttributes(deNet);

            FilterSubsetEvaluator.AddFilterSubsetAttribute(deNet);
            ScaleSubsetEvaluator.AddScaleSubsetAttributes(deNet);

            netBuild.UpdateSchema(deNet);
        }
コード例 #30
0
ファイル: UcExportPath.cs プロジェクト: frankerlee/Yutai
        private void btnOpen_Click(object sender, EventArgs e)
        {
            switch (ExportType)
            {
            case EnumExportType.FeatureClass:
            {
                IGxDialog dialog = new GxDialogClass();
                IGxObjectFilterCollection filterCollection = dialog as IGxObjectFilterCollection;
                filterCollection.AddFilter(new GxFilterWorkspacesClass(), true);
                filterCollection.AddFilter(new GxFilterDatasetsClass(), false);
                dialog.AllowMultiSelect = false;
                dialog.ButtonCaption    = "选择";
                dialog.RememberLocation = true;
                dialog.Title            = "选择输出位置";
                IEnumGxObject selection = null;
                if (dialog.DoModalOpen(0, out selection))
                {
                    if (selection == null)
                    {
                        return;
                    }
                    IGxObject gxObject = selection.Next();
                    if (gxObject is IGxDatabase)
                    {
                        IGxDatabase gxDatabase = gxObject as IGxDatabase;
                        _dataset   = null;
                        _workspace = gxDatabase.Workspace;
                        _saveType  = EnumSaveType.Workspace;
                    }
                    else if (gxObject is IGxDataset)
                    {
                        IGxDataset gxDataset = gxObject as IGxDataset;
                        _dataset   = gxDataset.Dataset;
                        _workspace = _dataset.Workspace;
                        _saveType  = EnumSaveType.Dataset;
                    }
                    txtPath.Text = gxObject.FullName;
                }
            }
            break;

            case EnumExportType.Shapefile:
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.ShowNewFolderButton = true;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    this.txtPath.Text = dialog.SelectedPath;

                    Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");
                    IWorkspaceFactory shapefileWorkspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
                    if (shapefileWorkspaceFactory == null)
                    {
                        return;
                    }
                    _dataset   = null;
                    _workspace = shapefileWorkspaceFactory.OpenFromFile(dialog.SelectedPath, 0);
                    _saveType  = EnumSaveType.Workspace;
                }
            }
            break;
            }
        }