示例#1
0
        public ESRI.ArcGIS.Catalog.IEnumGxObject GetChildren(string parentDir, ESRI.ArcGIS.esriSystem.IFileNames fileNames)
        {
            IGxObjectArray gxChildren = new GxObjectArray();

            if (fileNames != null)
            {
                fileNames.Reset();

                string fileName = fileNames.Next();
                while (fileName != null)
                {
                    if (fileName.Length > 0)
                    {
                        if (!(fileNames.IsDirectory()))
                        {
                            if (fileName.ToUpper().EndsWith(".PY"))
                            {
                                GxPyObject gxChild = new GxPyObject(fileName);
                                gxChildren.Insert(-1, gxChild);
                                gxChild = null;
                                // Remove file name from the list for other GxObjectFactories to search.
                                fileNames.Remove();
                            }
                        }
                    }
                    fileName = fileNames.Next();
                }
            }

            if (gxChildren.Count > 0)
            {
                IEnumGxObject enumChildren = (IEnumGxObject)gxChildren;
                enumChildren.Reset();
                return(enumChildren);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
 public override void OnClick()
 {
     if (
         System.Windows.Forms.MessageBox.Show("是否删除选中对象!", "删除", System.Windows.Forms.MessageBoxButtons.YesNo,
                                              System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
     {
         IEnumGxObject enumGxObject = ((IGxSelection)_context.GxSelection).SelectedObjects;
         enumGxObject.Reset();
         IGxObject      gxObject      = enumGxObject.Next();
         IGxObjectArray gxObjectArray = new GxObjectArray();
         while (gxObject != null)
         {
             gxObjectArray.Insert(-1, gxObject);
             gxObject = enumGxObject.Next();
         }
         (enumGxObject as IGxObjectArray).Empty();
         enumGxObject = (gxObjectArray as IEnumGxObject);
         enumGxObject.Reset();
         gxObject = enumGxObject.Next();
         bool      flag      = false;
         IGxObject gxObject2 = null;
         while (gxObject != null)
         {
             if (gxObject2 == null)
             {
                 gxObject2 = gxObject.Parent;
             }
             IGxObjectEdit gxObjectEdit = gxObject as IGxObjectEdit;
             try
             {
                 if (gxObjectEdit.CanDelete())
                 {
                     gxObjectEdit.Delete();
                 }
                 else
                 {
                     flag = true;
                 }
             }
             catch (Exception ex)
             {
                 flag = true;
             }
             gxObject = enumGxObject.Next();
         }
         if (gxObject2 != null)
         {
             try
             {
                 gxObject2.Refresh();
             }
             catch (Exception ex)
             {
             }
         }
         if (flag)
         {
             System.Windows.Forms.MessageBox.Show("一个或多个对象不能删除!", "删除");
         }
     }
 }
        public ESRI.ArcGIS.Catalog.IEnumGxObject GetChildren(string parentDir, ESRI.ArcGIS.esriSystem.IFileNames fileNames)
        {
            IGxObjectArray gxChildren = new GxObjectArray();

            if (fileNames != null)
            {

                fileNames.Reset();

                string fileName = fileNames.Next();
                while (fileName != null)
                {
                    if (fileName.Length > 0)
                    {
                        if (!(fileNames.IsDirectory()))
                        {
                            if (fileName.ToUpper().EndsWith(".PY"))
                            {
                                GxPyObject gxChild = new GxPyObject(fileName);
                                gxChildren.Insert(-1, gxChild);
                                gxChild = null;
                                // Remove file name from the list for other GxObjectFactories to search.
                                fileNames.Remove();
                            }
                        }
                    }
                    fileName = fileNames.Next();
                }
            }

            if (gxChildren.Count > 0)
            {
                IEnumGxObject enumChildren = (IEnumGxObject)gxChildren;
                enumChildren.Reset();
                return enumChildren;
            }
            else
                return null;
        }