Ejemplo n.º 1
0
 public void AddChildNodes(IGxObject igxObject_1, TreeNode treeNode_2)
 {
     if (igxObject_1 is IGxObjectContainer)
     {
         if ((igxObject_1 as IGxObjectContainer).AreChildrenViewable)
         {
             IEnumGxObject children = (igxObject_1 as IGxObjectContainer).Children;
             children.Reset();
             for (IGxObject obj3 = children.Next(); obj3 != null; obj3 = children.Next())
             {
                 TreeNode node = this.method_6(obj3);
                 this.AddChildNodes(obj3, node);
                 treeNode_2.Nodes.Add(node);
             }
         }
         else if ((igxObject_1 as IGxObjectContainer).HasChildren)
         {
             if (igxObject_1 is IGxDatabase)
             {
                 if (!(igxObject_1 as IGxDatabase).IsRemoteDatabase)
                 {
                     this.method_5(treeNode_2);
                 }
             }
             else
             {
                 this.method_5(treeNode_2);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void method_12(IGxObject igxObject_1)
        {
            IGxObject parent = igxObject_1.Parent;
            TreeNode  node   = this.method_10(base.Nodes, parent);

            if (node != null)
            {
                IEnumGxObject children = (parent as IGxObjectContainer).Children;
                children.Reset();
                int index = 0;
                for (IGxObject obj4 = children.Next(); obj4 != null; obj4 = children.Next())
                {
                    if (obj4 == igxObject_1)
                    {
                        break;
                    }
                    index++;
                }
                TreeNode node2 = this.method_6(igxObject_1);
                node.Nodes.Insert(index, node2);
                if ((igxObject_1 is IGxDatabase) && !(igxObject_1 as IGxDatabase).IsRemoteDatabase)
                {
                    this.method_5(node2);
                }
            }
        }
Ejemplo n.º 3
0
 private void CatalogView_Load(object sender, EventArgs e)
 {
     if (!base.DesignMode)
     {
         if (this.GxCatalog == null)
         {
             this.GxCatalog = new GxCatalog();
         }
         this.kTreeView1.GxCatalog = this.GxCatalog;
         this.kTreeView1.InitTreeView();
         string name = (this.GxCatalog as IGxObject).Name;
         this.imageComboBoxEdit1.Properties.SmallImages = this.imageList1;
         this.listView1.LargeImageList = this.imageList1;
         this.listView1.SmallImageList = this.imageList1;
         ImageComboBoxItemEx imageComboBoxItemEx = new ImageComboBoxItemEx(name, this.GxCatalog,
                                                                           this.GetImageIndex(this.GxCatalog as IGxObject), 0)
         {
             Tag = this.GxCatalog
         };
         this.imageComboBoxEdit1.Properties.Items.Add(imageComboBoxItemEx);
         IEnumGxObject children = (this.GxCatalog as IGxObjectContainer).Children;
         children.Reset();
         for (IGxObject i = children.Next(); i != null; i = children.Next())
         {
             imageComboBoxItemEx = new ImageComboBoxItemEx(i.Name, i.FullName, this.GetImageIndex(i), 1)
             {
                 Tag = i
             };
             this.imageComboBoxEdit1.Properties.Items.Add(imageComboBoxItemEx);
         }
         this.imageComboBoxEdit1.SelectedIndex = 0;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Opens a dialog so the user can select an output workspace.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void outputWorkspaceButton_Click(object sender, EventArgs e)
 {
     try
     {
         IGxObjectFilter           geodatabaseFilter = new GxFilterFileGeodatabasesClass();
         IGxDialog                 dlg     = new GxDialogClass();
         IGxObjectFilterCollection filters = (IGxObjectFilterCollection)dlg;
         filters.AddFilter(geodatabaseFilter, false);
         dlg.Title         = "Select the file geodatabase for the output";
         dlg.ButtonCaption = "Select";
         IEnumGxObject objects = null;
         if (dlg.DoModalOpen(0, out objects))
         {
             IGxObject          obj = objects.Next();
             IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass();
             IFeatureWorkspace  workspace        = (IFeatureWorkspace)workspaceFactory.OpenFromFile(obj.FullName, 0);
             _transform.SetWorkspace(workspace);
             outputWorkspaceTextBox.Text = obj.Name;
             EnableSave();
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
 private void method_2()
 {
     if ((this.igxObject_0 != null) && (this.igxObject_0 is IGxObjectContainer))
     {
         IEnumGxObject children = (this.igxObject_0 as IGxObjectContainer).Children;
         children.Reset();
         for (IGxObject obj3 = children.Next(); obj3 != null; obj3 = children.Next())
         {
             this.iarray_0.Add(obj3.InternalObjectName);
             this.listView1.Items.Add(obj3.FullName);
         }
     }
     if (this.igxObject_1 != null)
     {
         if (this.igxObject_1 is IGxDatabase)
         {
             this.txtOutLocation.Text = this.igxObject_1.FullName;
             this.iname_1             = this.igxObject_1.InternalObjectName;
         }
         else if (this.igxObject_1 is IGxDataset)
         {
             this.txtOutLocation.Text = this.igxObject_1.FullName;
             this.iname_1             = this.igxObject_1.InternalObjectName;
         }
         else if (this.igxObject_1 is IGxFolder)
         {
             IWorkspaceName name = new WorkspaceNameClass
             {
                 WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory",
                 PathName = (this.igxObject_1.InternalObjectName as IFileName).Path
             };
             this.iname_1 = name as IName;
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Recursively Publish metadata documents associated to a container
 /// </summary>
 /// <param name="item">The GxObject object</param>
 /// <param name="pr">The publication request object</param>
 private void publishMetadata(IGxObject item, PublicationRequest pr)
 {
     if (item is IGxObjectContainer && !item.Category.Trim().ToLower().StartsWith("arcgis server"))
     {
         IGxObjectContainer container = (IGxObjectContainer)item;
         IEnumGxObject      children  = container.Children;
         if (children == null)
         {
             writeResults(pr.publish(item));
             return;
         }
         IGxObject child = children.Next();
         while (child != null)
         {
             publishMetadata(child, pr);
             child = children.Next();
         }
     }
     else
     {
         if (item is IMetadata)
         {
             writeResults(pr.publish(item));
         }
         else
         {
             writeResults(pr.publish(item, pr.makeAgsUrl(item)));
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Opens a dialog so the user can select a dataset containing the new data to be transformed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void inputDatasetButton_Click(object sender, EventArgs e)
 {
     try
     {
         IGxObjectFilter           datasetFilter = new GxFilterFeatureDatasetsClass();
         IGxDialog                 dlg           = new GxDialogClass();
         IGxObjectFilterCollection filters       = (IGxObjectFilterCollection)dlg;
         filters.AddFilter(datasetFilter, true);
         dlg.Title         = "Select the feature dataset containing the data to be transformed";
         dlg.ButtonCaption = "Select";
         IEnumGxObject objects = null;
         if (dlg.DoModalOpen(0, out objects))
         {
             IGxObject obj = objects.Next();
             _inputDatasetName        = (IFeatureDatasetName2)obj.InternalObjectName;
             inputDatasetTextBox.Text = obj.Parent.Name + "/" + obj.Name;
             List <IDatasetName> fcNames =
                 EsriUtilities.GetFeatureClassNames(esriGeometryType.esriGeometryPoint,
                                                    _inputDatasetName);
             fcNames.Sort(_nameComparer);
             controlPointsComboBox.DataSource    = fcNames;
             controlPointsComboBox.DisplayMember = "Name";
             EnableSave();
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
Ejemplo n.º 8
0
        public override void OnClick()
        {
            IGxPasteTarget gxPasteTarget = ((IGxSelection)_context.GxSelection).FirstObject as IGxPasteTarget;

            if (gxPasteTarget != null)
            {
                bool          flag         = false;
                IEnumGxObject enumGxObject = CmdCopyItem.m_GxObjectContainer as IEnumGxObject;
                enumGxObject.Reset();
                IGxObject     gxObject     = enumGxObject.Next();
                IEnumNameEdit enumNameEdit = new NamesEnumerator() as IEnumNameEdit;
                while (gxObject != null)
                {
                    enumNameEdit.Add(gxObject.InternalObjectName);
                    gxObject = enumGxObject.Next();
                }
                if (gxPasteTarget.CanPaste(enumNameEdit as IEnumName, ref flag))
                {
                    flag = false;
                    gxPasteTarget.Paste(enumNameEdit as IEnumName, ref flag);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("无法粘贴打指定位置!");
                }
            }
        }
Ejemplo n.º 9
0
        private void btnSCLFPath_Click(object sender, EventArgs e)
        {
            IGxDialog gxDialog    = new GxDialogClass();
            var       gxFilterCol = (IGxObjectFilterCollection)gxDialog;

            gxFilterCol.AddFilter(new GxFilterFileFolder(), false);
            //gxFilterCol.AddFilter(new GxFilterFileGeodatabases(), true);
            //gxFilterCol.AddFilter(new GxFilterFGDBFeatureDatasets(), false);
            gxFilterCol.AddFilter(new GxFilterPersonalGeodatabases(), false);
            gxFilterCol.AddFilter(new GxFilterPGDBFeatureDatasets(), false);
            //gxFilterCol.AddFilter(new GxFilterPGDBTables(), false);
            //gxFilterCol.AddFilter(new GxFilterFeatureClasses(), false);
            gxDialog.Title            = " 结果输出路径";
            gxDialog.AllowMultiSelect = false;

            IEnumGxObject gxSelection = null;

            gxDialog.DoModalOpen(ArcMap.Application.hWnd, out gxSelection);

            IGxObject gxObject = null;

            while ((gxObject = gxSelection.Next()) != null)
            {
                txtOutPath.Text = gxObject.FullName;
            }

            //OutputPath = gxDialog.FinalLocation.FullName;
            //OutputName = gxDialog.Name;

            //if (string.IsNullOrWhiteSpace(OutputName))
            //    txtSCLFPath.Text = "";
            //else
            //    txtSCLFPath.Text = OutputPath + @"\" + OutputName;
        }
Ejemplo n.º 10
0
        private void btnFeatureDomains_Click(object sender, EventArgs e)
        {
            try
            {
                bool isDomain = false;

                if (sender.Equals(btnFeatureDomains))
                {
                    isDomain = true;
                }

                IGxDialog xmlFileSelectDialog = new GxDialogClass();
                xmlFileSelectDialog.AllowMultiSelect = false;
                if (isDomain)
                {
                    xmlFileSelectDialog.Title = resourceManager.GetString("OSMEditor_OSMPropertyPage_fileselect_title_domain");
                }
                else
                {
                    xmlFileSelectDialog.Title = resourceManager.GetString("OSMEditor_OSMPropertyPage_fileselect_title_feature");
                }
                xmlFileSelectDialog.RememberLocation = true;
                xmlFileSelectDialog.ButtonCaption    = resourceManager.GetString("OSMEditor_OSMPropertyPage_fileselect_buttoncaption");

                xmlFileSelectDialog.ObjectFilter = new GxFilterXmlFiles();

                IEnumGxObject selectedConfigurationFile = null;

                if (xmlFileSelectDialog.DoModalOpen(m_editor.Parent.hWnd, out selectedConfigurationFile))
                {
                    if (selectedConfigurationFile == null)
                    {
                        return;
                    }

                    selectedConfigurationFile.Reset();

                    IGxFile xmlFile = selectedConfigurationFile.Next() as IGxFile;

                    if (xmlFile == null)
                    {
                        return;
                    }

                    if (isDomain)
                    {
                        txtOSMDomainFileLocation.Text = xmlFile.Path;
                    }
                    else
                    {
                        txtOSMFeaturePropertiesFileLocation.Text = xmlFile.Path;
                    }

                    SetPageDirty(true);
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 11
0
        private void btnSelectDataSources_Click(object sender, EventArgs e)
        {
            IEnumGxObject gxObjects = AddLayerWithGxDialog();

            trvDatasets.Nodes.Clear();
            lsvDetails.Items.Clear();
            FillTreeView(gxObjects);
        }
		// 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;
			}
		}
Ejemplo n.º 13
0
 private void KTreeView_DragDrop(object sender, DragEventArgs e)
 {
     if (this.bool_0)
     {
         IGxObject tag = this.treeNode_1.Tag as IGxObject;
         if (tag is IGxObjectContainer)
         {
             this.Expand(this.treeNode_1);
             IEnumNameEdit edit       = new NamesEnumeratorClass();
             IEnumerator   enumerator =
                 (e.Data.GetData("System.Collections.ArrayList") as ArrayList).GetEnumerator();
             enumerator.Reset();
             IGxObject current = null;
             while (enumerator.MoveNext())
             {
                 current = enumerator.Current as IGxObject;
                 if (current != null)
                 {
                     edit.Add(current.InternalObjectName);
                 }
             }
             if ((tag as IGxPasteTarget).Paste(edit as IEnumName, ref this.bool_1) && this.bool_1)
             {
                 enumerator.Reset();
                 while (enumerator.MoveNext())
                 {
                     current = enumerator.Current as IGxObject;
                     if (current is IGxDataset)
                     {
                         if ((current as IGxDataset).DatasetName.Type == esriDatasetType.esriDTFeatureDataset)
                         {
                             IEnumGxObject children = (current as IGxObjectContainer).Children;
                             children.Reset();
                             for (IGxObject obj5 = children.Next(); obj5 != null; obj5 = children.Next())
                             {
                                 obj5.Detach();
                             }
                         }
                         else
                         {
                             current.Detach();
                         }
                     }
                     else if (current != null)
                     {
                         current.Detach();
                     }
                 }
             }
             if (this.SelectNodeChanged != null)
             {
                 this.SelectNodeChanged(this);
             }
         }
     }
 }
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 15
0
        public override void OnClick()
        {
            CmdCopyItem.m_GxObjectContainer = new GxObjectArray();
            IEnumGxObject selectedObjects = ((IGxSelection)_context.GxSelection).SelectedObjects;

            selectedObjects.Reset();
            for (IGxObject gxObject = selectedObjects.Next(); gxObject != null; gxObject = selectedObjects.Next())
            {
                CmdCopyItem.m_GxObjectContainer.Insert(-1, gxObject);
            }
        }
Ejemplo n.º 16
0
        private IGxObject AddExistingFilters()
        {
            IEnumGxObject enumGxObject = null;

            IGxObjectFilter           gxObjectFilter_Fabrics = new GxFilterCadastralFabricsClass();
            IGxDialog                 gxDialog = new GxDialogClass();
            IGxObjectFilterCollection gxObjectFilterCollection = (IGxObjectFilterCollection)gxDialog;

            gxObjectFilterCollection.AddFilter(gxObjectFilter_Fabrics, true);
            gxDialog.Title = "Browse Fabrics";
            gxDialog.DoModalOpen(0, out enumGxObject);
            return(enumGxObject.Next());
        }
Ejemplo n.º 17
0
        private void btnDestFeatures_Click(object sender, EventArgs e)
        {
            IGxDialog gxDialog    = new GxDialogClass();
            var       gxFilterCol = (IGxObjectFilterCollection)gxDialog;

            gxFilterCol.AddFilter(new GxFilterPolygonFeatureClasses(), false);
            gxDialog.AllowMultiSelect = false;
            gxDialog.Title            = " 添加目标要素类";

            IEnumGxObject gxSelection = null;

            gxDialog.DoModalOpen(ArcMap.Application.hWnd, out gxSelection);
            var gxObject = gxSelection.Next();

            if (gxObject != null)
            {
                string features_path            = gxObject.Parent.FullName;
                string features_name            = gxObject.Name;
                string features_parent_path     = System.IO.Path.GetDirectoryName(features_path);
                string features_parent_path_ext = System.IO.Path.GetExtension(features_parent_path);
                if (features_parent_path_ext == ".gdb" || features_parent_path_ext == ".mdb")
                {
                    features_path = features_parent_path;
                }

                cmbDestFeatures.Text = "";
                cmbDestFeatures.Items.Clear();

                DataManagementTools dataManagementTools = new DataManagementTools();
                DestFeatureClass = dataManagementTools.OpenFeatureClass(features_path, features_name);

                if (DestFeatureClass == null)
                {
                    cmbDestFeatures.Text = "";
                    return;
                }

                cmbDestFeatures.Text = gxObject.FullName;

                var table = (ITable)DestFeatureClass;
                for (int i = 0; i < table.Fields.FieldCount; i++)
                {
                    var field = table.Fields.Field[i];
                    if (field.Type != esriFieldType.esriFieldTypeDate)
                    {
                        cmbDestField.Items.Add(field.Name); // 添加Feature UID字段的控件选择
                    }
                }
            }
        }
        /// <summary>
        /// Opens a dialog so the user can select a workspace.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOutWS_Click(object sender, EventArgs e)
        {
            try
            {
                IGxObjectFilter           wsFilter = new GxFilterWorkspacesClass();
                IGxDialog                 dlg      = new GxDialogClass();
                IGxObjectFilterCollection filters  = (IGxObjectFilterCollection)dlg;
                filters.AddFilter(wsFilter, false);
                dlg.Title         = "Select File Geodatabase or Shapefile Folder";
                dlg.ButtonCaption = "Select";
                IEnumGxObject objects = null;
                if (dlg.DoModalOpen(0, out objects))
                {
                    IGxObject          obj = objects.Next();
                    IWorkspaceFactory2 workspaceFactory;
                    if (obj.Category == "File Geodatabase")
                    {
                        workspaceFactory = new FileGDBWorkspaceFactoryClass();
                    }
                    else if (obj.Category == "Folder")
                    {
                        workspaceFactory = new ShapefileWorkspaceFactoryClass();
                    }
                    else
                    {
                        ShowError("Not a file geodatabase or shapefile folder.");
                        return;
                    }
                    IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(obj.FullName, 0);
                    _transform.SetWorkspace(workspace);
                    textBoxOutWS.Text = obj.BaseName;
                    _workspaceOK      = true;

                    List <IDatasetName> allNames = _transform.GetFeatureClassNames();
                    listViewData.Items.Clear();
                    for (int i = 0; i < allNames.Count; i++)
                    {
                        AddItemToListViewData(allNames[i]);
                    }
                    FillControlComboBox();
                    SelectComboBoxItem(comboBoxControlPts, _transform.GetWorkspacePath(),
                                       "Control_Points_Unprojected");
                }
                EnableSelectInputs();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Ejemplo n.º 19
0
        private void frmExplorerData_Load(object sender, EventArgs e)
        {
            if (_gxCatalog == null)
            {
                _gxCatalog = new GxCatalog();
            }
            GISDataComboItem item = new GISDataComboItem((_gxCatalog as IGxObject).Name, (_gxCatalog as IGxObject).Name,
                                                         this.GetImageIndex(this._gxCatalog as IGxObject), 0)
            {
                Tag = _gxCatalog
            };

            gisDataComboBox1.Items.Add(item);
            IEnumGxObject children = (this._gxCatalog as IGxObjectContainer).Children;

            children.Reset();
            for (IGxObject subObj = children.Next(); subObj != null; subObj = children.Next())
            {
                item = new GISDataComboItem(subObj.Name, subObj.FullName, this.GetImageIndex(subObj), 1)
                {
                    Tag = subObj
                };
                this.gisDataComboBox1.AddChildNode(item);
            }
            gisDataComboBox1.SelectedIndex = 0;
            this._array2.RemoveAll();
            this._gxObjects.Clear();
            this.cboShowType.Items.Clear();
            for (int i = 0; i < this._filterArray.Count; i++)
            {
                IGxObjectFilter filter = this._filterArray.Element[i] as IGxObjectFilter;
                this.cboShowType.Items.Add(filter.Description);
                if (filter == this._gxObjectFilter)
                {
                    this.cboShowType.SelectedIndex = i;
                }
            }
            if ((this._modalType == 0) && (this._filterArray.Count > 1))
            {
                this.cboShowType.Items.Add("已列出的所有过滤条件");
            }
            if (this.cboShowType.SelectedIndex == -1)
            {
                this.cboShowType.SelectedIndex = this.cboShowType.Items.Count - 1;
            }
            if ((_pStartLocation != null) && (_pStartLocation is string))
            {
                this.LoadViewer(_pStartLocation as string);
            }
        }
Ejemplo n.º 20
0
        private IGxObject OpenShapefile(string Caption)
        {
            IGxDialog     fileChooser = new GxDialogClass();
            IEnumGxObject chosenFiles = null;

            fileChooser.Title            = Caption;
            fileChooser.ButtonCaption    = "Select";
            fileChooser.AllowMultiSelect = false;
            fileChooser.ObjectFilter     = new GxFilterShapefilesClass();
            fileChooser.DoModalOpen(0, out chosenFiles);

            chosenFiles.Reset();
            return(chosenFiles.Next());
        }
Ejemplo n.º 21
0
        private void frmOpenFile_Load(object sender, EventArgs e)
        {
            if (this.igxCatalog_0 == null)
            {
                this.igxCatalog_0 = new GxCatalog();
            }
            ImageComboBoxItemEx item = new ImageComboBoxItemEx((this.igxCatalog_0 as IGxObject).Name, this.igxCatalog_0,
                                                               this.method_2(this.igxCatalog_0 as IGxObject), 0)
            {
                Tag = this.igxCatalog_0
            };

            this.imageComboBoxEdit1.Properties.Items.Add(item);
            IEnumGxObject children = (this.igxCatalog_0 as IGxObjectContainer).Children;

            children.Reset();
            for (IGxObject obj3 = children.Next(); obj3 != null; obj3 = children.Next())
            {
                item = new ImageComboBoxItemEx(obj3.Name, obj3.FullName, this.method_2(obj3), 1)
                {
                    Tag = obj3
                };
                this.imageComboBoxEdit1.Properties.Items.Add(item);
            }
            this.imageComboBoxEdit1.SelectedIndex = 0;
            this.iarray_1.RemoveAll();
            this.ilist_0.Clear();
            this.cboShowType.Properties.Items.Clear();
            for (int i = 0; i < this.iarray_0.Count; i++)
            {
                IGxObjectFilter filter = this.iarray_0.get_Element(i) as IGxObjectFilter;
                this.cboShowType.Properties.Items.Add(filter.Description);
                if (filter == this.igxObjectFilter_0)
                {
                    this.cboShowType.SelectedIndex = i;
                }
            }
            if ((this.int_0 == 0) && (this.iarray_0.Count > 1))
            {
                this.cboShowType.Properties.Items.Add("已列出的所有过滤条件");
            }
            if (this.cboShowType.SelectedIndex == -1)
            {
                this.cboShowType.SelectedIndex = this.cboShowType.Properties.Items.Count - 1;
            }
            if ((m_pStartingLocation != null) && (m_pStartingLocation is string))
            {
                this.method_3(m_pStartingLocation as string);
            }
        }
        public static IGxObject OpenArcFile(IGxObjectFilter objectFilter, string Caption)
        {
            IGxDialog     fileChooser = new GxDialogClass();
            IEnumGxObject chosenFiles = null;

            fileChooser.Title            = Caption;
            fileChooser.ButtonCaption    = "Select";
            fileChooser.AllowMultiSelect = false;
            fileChooser.ObjectFilter     = objectFilter;
            fileChooser.DoModalOpen(0, out chosenFiles);

            chosenFiles.Reset();
            return(chosenFiles.Next());
        }
		// Opens Address Locator for addresses geocoding
		private void OpenAddressLocator()
		{
			try
			{
				// Create Dialog on first call and init filter
				InitAddressLocatorDlg();

				ILocator objLocator = null;
				objLocator = null;

				// Get Locator
				IEnumGxObject gxObjects = null;
				gxObjects = null;

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

					// Get first Locator
					IGxObject gxObject = null;
					gxObject = gxObjects.Next();

					if (gxObject != null)
					{
						IGxLocator gxLocator = null;
						gxLocator = gxObject as IGxLocator;
						objLocator = gxLocator.Locator;
						m_objAddressGeocoding = objLocator as IAddressGeocoding;
					}
				}

				if (m_objAddressGeocoding == null)
					m_txtAddressLocator.Text = "";
				else
					m_txtAddressLocator.Text = objLocator.Name;
			}
			catch (Exception ex)
			{
				// Clear on Error
				m_objAddressGeocoding = null;
				m_txtAddressLocator.Text = "";
			}
			finally
			{
				// Check FindRoute, Barriers and Restrictions buttons state
				CheckRouteButtons();
			}
		}
        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;
            }
        }
Ejemplo n.º 25
0
        public static GCDConsoleLib.Vector BrowseOpenVector(string formTitle, System.IO.DirectoryInfo diWorkspace, string sFCName, BrowseGISTypes eType, IntPtr hParentWindowHandle)
        {
            IGxDialog pGxDialog = new GxDialogClass();
            IGxObjectFilterCollection pFilterCol = (IGxObjectFilterCollection)pGxDialog;

            switch (eType)
            {
            case BrowseGISTypes.Point: pFilterCol.AddFilter(new GxFilterPointFeatureClasses(), true); break;

            case BrowseGISTypes.Line: pFilterCol.AddFilter(new GxFilterPolylineFeatureClasses(), true); break;

            case BrowseGISTypes.Polygon: pFilterCol.AddFilter(new GxFilterPolygonFeatureClasses(), true); break;

            default: pFilterCol.AddFilter(new GxFilterFeatureClasses(), true); break;
            }

            IEnumGxObject pEnumGx   = null;
            IGxObject     pGxObject = null;

            pGxDialog.RememberLocation = true;
            pGxDialog.AllowMultiSelect = false;
            pGxDialog.Title            = formTitle;
            pGxDialog.ButtonCaption    = "Select";
            if (diWorkspace != null && diWorkspace.Exists)
            {
                object existingDirectory = diWorkspace.FullName;
                pGxDialog.set_StartingLocation(ref existingDirectory);
            }

            pGxDialog.Name = sFCName;
            GCDConsoleLib.Vector gResult = null;
            try
            {
                if (pGxDialog.DoModalOpen(hParentWindowHandle.ToInt32(), out pEnumGx))
                {
                    pGxObject = pEnumGx.Next();
                    sFCName   = pGxObject.BaseName;
                    gResult   = new GCDConsoleLib.Vector(new System.IO.FileInfo(pGxObject.FullName));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error attempting to browse for vector GIS data source", ex);
            }

            return(gResult);
        }
        public void ShowRasterDatasetBrowser(int handle, out IEnumGxObject ipSelectedObjects)
        {
            IGxObjectFilterCollection ipFilterCollection = new GxDialogClass();

            IGxObjectFilter ipFilter1 = new GxFilterRasterDatasetsClass();
            ipFilterCollection.AddFilter(ipFilter1, true);
            IGxDialog ipGxDialog = (IGxDialog)(ipFilterCollection);

            ipGxDialog.RememberLocation = true;
            ipGxDialog.Title = "Open";

            ipGxDialog.AllowMultiSelect = false;
            ipGxDialog.RememberLocation = true;

            ipGxDialog.DoModalOpen((int)(Handle.ToInt32()), out ipSelectedObjects);
            return;
        }
Ejemplo n.º 27
0
 private void SetListView(IGxObject pGxObject)
 {
     Cursor.Current = Cursors.WaitCursor;
     string[] name = new string[2];
     this.ClearListView();
     if (pGxObject is IGxObjectContainer)
     {
         if (pGxObject is IGxDatabase)
         {
             if (!(pGxObject as IGxDatabase).IsConnected)
             {
                 (pGxObject as IGxDatabase).Connect();
             }
             if (!(pGxObject as IGxDatabase).IsConnected)
             {
                 return;
             }
         }
         else if (pGxObject is IGxAGSConnection)
         {
             if (!(pGxObject as IGxAGSConnection).IsConnected)
             {
                 (pGxObject as IGxAGSConnection).Connect();
             }
             if (!(pGxObject as IGxAGSConnection).IsConnected)
             {
                 return;
             }
         }
         IEnumGxObject children = (pGxObject as IGxObjectContainer).Children;
         children.Reset();
         IGxObject gxObject = children.Next();
         while (gxObject != null)
         {
             name[0] = gxObject.Name;
             name[1] = gxObject.Category;
             ListViewItem listViewItem = new ListViewItem(name, this.GetImageIndex(gxObject))
             {
                 Tag = gxObject
             };
             this.listView1.Items.Add(listViewItem);
             gxObject = children.Next();
         }
     }
     Cursor.Current = Cursors.Default;
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Open the add data dialog.
        /// </summary>
        /// <param name="sCaption">Caption of the dialog.</param>
        /// <param name="pFilter">Dataset filters.</param>
        /// <param name="bMultiSelect">Allow for multiple selections.</param>
        /// <returns></returns>
        private string OpenGXDialog(string sCaption, IGxObjectFilter pFilter, bool bMultiSelect)
        {
            IGxDialog     pBrowse  = new GxDialogClass();
            IEnumGxObject pSelect  = null;
            IGxObject     pObject  = null;
            IGxCatalog    pCatalog = pBrowse.InternalCatalog;

            string sFile = "";

            try
            {
                //set up the filters

                //setup the browse window
                pBrowse.AllowMultiSelect = bMultiSelect;
                pBrowse.Title            = sCaption;
                pBrowse.ObjectFilter     = pFilter; //!!!this should be written to read a filter collection, but throws a COM QI error
                pBrowse.RememberLocation = true;

                //open the browse window and get the selected file info
                if (pBrowse.DoModalOpen(0, out pSelect))
                {
                    pObject = pSelect.Next();
                    while (pObject != null)
                    {
                        sFile  += pObject.FullName + ";";
                        pObject = pSelect.Next();
                    }
                    //pInternalName = (IGxObjectInternalName) pObject;
                    //pName = (IName) pInternalName.InternalObjectName;

                    //remove the last semi colon
                    if (sFile.Length > 0)
                    {
                        sFile = sFile.Substring(0, sFile.Length - 1);
                    }
                }
                return(sFile);
            }
            catch (Exception oErr)
            {
                MessageBox.Show(oErr.ToString(), "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Ejemplo n.º 29
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (CheckGxObjectFilter(_filter))
            {
                IGxDialog dialog = (GxDialog)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("EAB9CE2A-E777-11D1-AEE7-080009EC734B")));
                dialog.AllowMultiSelect = false;
                dialog.ButtonCaption    = "选择数据库";
                ConvertToGxObjectFilterCollection(dialog, _filter);
                IEnumGxObject selection = null;
                if (dialog.DoModalOpen(0, out selection))
                {
                    IGxObject obj = selection.Next();
                    if (obj != null)
                    {
                        _fileName = obj.FullName;
                        string ext = obj.Name.Substring(obj.Name.Length - 4).ToUpper();
                        if (ext.ToUpper() == ".GDB")
                        {
                            _workspace = new FileGDBWorkspaceFactoryClass().OpenFromFile(_fileName, 0);
                        }
                        else if (ext.ToUpper() == ".MDB")
                        {
                            _workspace = new AccessWorkspaceFactoryClass().OpenFromFile(_fileName, 0);
                        }
                    }
                    txtPath.Text = _fileName;
                }
            }
            else
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Multiselect = false;
                dialog.Title       = @"请选择文件";
                dialog.Filter      = _filter;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _fileName    = dialog.FileName;
                    txtPath.Text = _fileName;
                }
            }
        }
Ejemplo n.º 30
0
 private IGxObject method_3(string string_1, IEnumGxObject ienumGxObject_0)
 {
     ienumGxObject_0.Reset();
     for (IGxObject obj2 = ienumGxObject_0.Next(); obj2 != null; obj2 = ienumGxObject_0.Next())
     {
         if (obj2.Name == string_1)
         {
             return(obj2);
         }
         if (obj2 is IGxFolder)
         {
             obj2 = this.method_3(string_1, (obj2 as IGxObjectContainer).Children);
             if (obj2 != null)
             {
                 return(obj2);
             }
         }
     }
     return(null);
 }
        public void ShowRasterDatasetBrowser(int handle, out IEnumGxObject ipSelectedObjects)
        {
            IGxObjectFilterCollection ipFilterCollection = new GxDialogClass();

            IGxObjectFilter ipFilter1 = new GxFilterRasterDatasetsClass();
            ipFilterCollection.AddFilter(ipFilter1, true);
            IGxDialog ipGxDialog = (IGxDialog)(ipFilterCollection);

            ipGxDialog.RememberLocation = true;
            ipGxDialog.Title = "Open";

            ipGxDialog.AllowMultiSelect = false;
            ipGxDialog.RememberLocation = true;

            ipGxDialog.DoModalOpen((int)(Handle.ToInt32()), out ipSelectedObjects);
            return;
        }