Ejemplo n.º 1
0
        public override void OnClick()
        {
            IGxObject firstObject = ((IGxSelection)_context.GxSelection).FirstObject;

            if (firstObject is IGxFile)
            {
                string path = (firstObject as IGxFile).Path;
                path = (path[path.Length - 1] != '\\'
                    ? string.Concat(path, "\\新建文件型数据库")
                    : string.Concat(path, "新建文件型数据库"));
                string str = string.Concat(path, ".gdb");
                int    num = 1;
                while (Directory.Exists(str))
                {
                    num++;
                    str = string.Concat(path, " (", num.ToString(), ").gdb");
                }
                IWorkspaceFactory fileGDBWorkspaceFactoryClass = new FileGDBWorkspaceFactory();
                try
                {
                    IWorkspaceName workspaceName = fileGDBWorkspaceFactoryClass.Create(Path.GetDirectoryName(str),
                                                                                       Path.GetFileNameWithoutExtension(str), null, 0);
                    IGxObject gxDatabase = new GxDatabase();
                    (gxDatabase as IGxDatabase).WorkspaceName = workspaceName;
                    IGxCatalog catalog = GxCatalogCommon.GetCatalog(firstObject);
                    gxDatabase.Attach(firstObject, catalog);
                    catalog.ObjectAdded(gxDatabase);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnClick()
        {
            IGxObject firstObject = ((IGxSelection)_context.GxSelection).FirstObject;

            if (firstObject is IGxFile)
            {
                string path = (firstObject as IGxFile).Path;
                path = (path[path.Length - 1] != '\\' ? string.Concat(path, "\\新建文件夹") : string.Concat(path, "新建文件夹"));
                string str = path;
                int    num = 1;
                while (Directory.Exists(str))
                {
                    num++;
                    str = string.Concat(path, " (", num.ToString(), ")");
                }
                Directory.CreateDirectory(str);
                IGxObject gxFolder = new GxFolder();
                (gxFolder as IGxFile).Path = str;
                IGxCatalog catalog = GxCatalogCommon.GetCatalog(firstObject);
                gxFolder.Attach(firstObject, catalog);
                catalog.ObjectAdded(gxFolder);
            }
        }