Exemplo n.º 1
0
 public override void OnClick()
 {
     try
     {
         IGxObject firstObject = ((IGxSelection)_context.GxSelection).FirstObject;
         Cursor.Current = Cursors.WaitCursor;
         if (firstObject is IGxDatabase)
         {
             (firstObject as IGxDatabase).Connect();
         }
         else if (firstObject is IGxAGSConnection)
         {
             (firstObject as IGxAGSConnection).Connect();
         }
         else if (firstObject is IGxGDSConnection)
         {
             (firstObject as IGxGDSConnection).Connect();
         }
         GxCatalogCommon.GetCatalog(firstObject).ObjectRefreshed(firstObject);
     }
     catch (Exception exception)
     {
     }
     Cursor.Current = Cursors.Default;
 }
Exemplo n.º 2
0
        public override void OnClick()
        {
            frmObjectClass _frmObjectClass = new frmObjectClass()
            {
                UseType = enumUseType.enumUTObjectClass
            };
            IObjectClass objectClass = null;

            if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
            {
                GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
                if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace == null)
                {
                    return;
                }
                _frmObjectClass.Dataset = (((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace;
                if (_frmObjectClass.ShowDialog() == DialogResult.OK)
                {
                    objectClass = _frmObjectClass.ObjectClass;
                }
            }
            if (objectClass != null)
            {
                ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
            }
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
 public override void OnClick()
 {
     if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
     {
         GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
         if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace != null)
         {
             frmCreateGDBRasterDataset _frmCreateGDBRasterDataset = new frmCreateGDBRasterDataset()
             {
                 OutLocation = ((IGxSelection)_context.GxSelection).FirstObject
             };
             try
             {
                 if (_frmCreateGDBRasterDataset.ShowDialog() == DialogResult.OK)
                 {
                     ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
                 }
             }
             catch (Exception exception)
             {
                 CErrorLog.writeErrorLog(this, exception, "");
             }
         }
     }
 }
Exemplo n.º 5
0
        public override void OnClick()
        {
            frmNewRelationClass _frmNewRelationClass;

            try
            {
                if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
                {
                    GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
                    if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace != null)
                    {
                        _frmNewRelationClass = new frmNewRelationClass()
                        {
                            Workspace = (((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace
                        };
                        try
                        {
                            if (_frmNewRelationClass.ShowDialog() == DialogResult.OK)
                            {
                                ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
                            }
                        }
                        catch (Exception exception)
                        {
                            // CErrorLog.writeErrorLog(this, exception, "");
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else if (((IGxSelection)_context.GxSelection).FirstObject is IGxDataset)
                {
                    IDataset dataset = (((IGxSelection)_context.GxSelection).FirstObject as IGxDataset).Dataset;
                    if (dataset is IFeatureDataset)
                    {
                        _frmNewRelationClass = new frmNewRelationClass()
                        {
                            FeatureDataset = dataset as IFeatureDataset
                        };
                        try
                        {
                            if (_frmNewRelationClass.ShowDialog() == DialogResult.OK)
                            {
                                ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
                            }
                        }
                        catch (Exception exception1)
                        {
                            //CErrorLog.writeErrorLog(this, exception1, "");
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 6
0
        public void ConnectArcGISServer()
        {
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            IGxObject tag = base.SelectedNode.Tag as IGxObject;

            (tag as IGxAGSConnection).Connect();
            this.method_7(base.SelectedNode);
            base.SelectedNode.ImageIndex         = this.method_3(tag);
            base.SelectedNode.SelectedImageIndex = this.method_4(tag);
            GxCatalogCommon.GetCatalog(tag).ObjectRefreshed(tag);
            System.Windows.Forms.Cursor.Current = Cursors.Default;
        }
Exemplo n.º 7
0
        public void ConnectDatabase()
        {
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            IGxObject tag = base.SelectedNode.Tag as IGxObject;

            (tag as IGxDatabase).Connect();
            if ((tag as IGxDatabase).IsConnected)
            {
                this.method_7(base.SelectedNode);
                base.SelectedNode.ImageIndex         = this.method_3(tag);
                base.SelectedNode.SelectedImageIndex = this.method_4(tag);
                GxCatalogCommon.GetCatalog(tag).ObjectRefreshed(tag);
            }
            System.Windows.Forms.Cursor.Current = Cursors.Default;
        }
Exemplo n.º 8
0
        public override void OnClick()
        {
            IGxObject firstObject = ((IGxSelection)_context.GxSelection).FirstObject;

            if (firstObject is IGxDatabase)
            {
                (firstObject as IGxDatabase).Disconnect();
            }
            else if (firstObject is IGxAGSConnection)
            {
                (firstObject as IGxAGSConnection).Disconnect();
            }
            else if (firstObject is IGxGDSConnection)
            {
                (firstObject as IGxGDSConnection).Disconnect();
            }
            GxCatalogCommon.GetCatalog(firstObject).ObjectChanged(firstObject);
            GxCatalogCommon.GetCatalog(firstObject).ObjectRefreshed(firstObject);
        }
Exemplo n.º 9
0
        public override void OnClick()
        {
            frmNewObjectClass frmNewObjectClass = new frmNewObjectClass();
            IObjectClass      objectClass       = null;
            IGxSelection      gxSelection       = _context.GxSelection as IGxSelection;

            if (gxSelection.FirstObject is IGxDatabase)
            {
                GxCatalogCommon.ConnectGDB(gxSelection.FirstObject as IGxDatabase);
                if ((gxSelection.FirstObject as IGxDatabase).Workspace == null)
                {
                    return;
                }
                frmNewObjectClass.Workspace = (gxSelection.FirstObject as IGxDatabase).Workspace;
                if (frmNewObjectClass.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    objectClass = frmNewObjectClass.ObjectClass;
                }
            }
            else if (gxSelection.FirstObject is IGxDataset &&
                     (gxSelection.FirstObject as IGxDataset).DatasetName.Type == esriDatasetType.esriDTFeatureDataset)
            {
                try
                {
                    frmNewObjectClass.Workspace = (gxSelection.FirstObject as IGxDataset).Dataset;
                    if (frmNewObjectClass.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        objectClass = frmNewObjectClass.ObjectClass;
                    }
                }
                catch
                {
                    MessageService.Current.Warn("该要素集有问题,不能新建要素类!");
                }
            }
            if (objectClass != null)
            {
                gxSelection.FirstObject.Refresh();
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
 public override void OnClick()
 {
     if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
     {
         GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
         if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace != null)
         {
             frmNewFeatureDataset _frmNewFeatureDataset = new frmNewFeatureDataset()
             {
                 Workspace = (((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace
             };
             try
             {
                 if (_frmNewFeatureDataset.ShowDialog() == DialogResult.OK)
                 {
                     ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
                 }
             }
             catch
             {
             }
         }
     }
 }
Exemplo n.º 12
0
 private void KTreeView_DoubleClick(object sender, EventArgs e)
 {
     if (base.SelectedNode != null)
     {
         IGxObject tag = base.SelectedNode.Tag as IGxObject;
         if (tag != null)
         {
             IGxObject newObject;
             TreeNode  node;
             Exception exception;
             if (tag is IGxNewDatabase)
             {
                 IWorkspaceName name;
                 if (tag.FullName == "添加OLE DB连接")
                 {
                     try
                     {
                         string path = Environment.SystemDirectory.Substring(0, 2) +
                                       @"\Documents and Settings\Administrator\Application Data\ESRI\ArcCatalog\";
                         string str2 = path + "OLE DB Connection.odc";
                         if (Directory.Exists(path))
                         {
                             str2 = this.method_17(str2);
                             IWorkspaceFactory factory = new OLEDBWorkspaceFactoryClass();
                             name      = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0);
                             newObject = new GxDatabase();
                             (newObject as IGxDatabase).WorkspaceName = name;
                             newObject.Attach(tag.Parent, this.igxCatalog_0);
                             node = new TreeNode(newObject.Name, this.method_3(newObject),
                                                 this.method_4(newObject))
                             {
                                 Tag = newObject
                             };
                             base.SelectedNode.Parent.Nodes.Add(node);
                         }
                     }
                     catch (Exception exception1)
                     {
                         exception = exception1;
                         exception.ToString();
                     }
                 }
                 else if (tag.FullName == "添加空间数据库连接")
                 {
                     frmCreateGDBConnection connection = new frmCreateGDBConnection();
                     if (connection.ShowDialog() == DialogResult.OK)
                     {
                         newObject = new GxDatabase();
                         name      = new WorkspaceNameClass
                         {
                             WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory",
                             PathName = connection.ConnectionPath
                         };
                         (newObject as IGxDatabase).WorkspaceName = name;
                         newObject.Attach(tag.Parent, this.igxCatalog_0);
                         node = new TreeNode(newObject.Name, this.method_3(newObject), this.method_4(newObject))
                         {
                             Tag = newObject
                         };
                         base.SelectedNode.Parent.Nodes.Add(node);
                     }
                 }
             }
             else if (tag.FullName == "添加Database Server")
             {
                 frmAddDatabaseServer server = new frmAddDatabaseServer();
                 if (server.ShowDialog() != DialogResult.OK)
                 {
                 }
             }
             else if (tag is IGxDatabase)
             {
                 if ((tag as IGxDatabase).IsRemoteDatabase && !(tag as IGxDatabase).IsConnected)
                 {
                     this.ConnectDatabase();
                 }
             }
             else if (tag is IGxAGSConnection)
             {
                 if (!(tag as IGxAGSConnection).IsConnected)
                 {
                     this.ConnectArcGISServer();
                 }
             }
             else if (tag is IGxGDSConnection)
             {
                 System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                 IGxObject obj4 = base.SelectedNode.Tag as IGxObject;
                 (obj4 as IGxGDSConnection).Connect();
                 if ((obj4 as IGxGDSConnection).IsConnected)
                 {
                     this.method_7(base.SelectedNode);
                     base.SelectedNode.ImageIndex         = this.method_3(obj4);
                     base.SelectedNode.SelectedImageIndex = this.method_4(obj4);
                     GxCatalogCommon.GetCatalog(tag).ObjectRefreshed(obj4);
                 }
                 System.Windows.Forms.Cursor.Current = Cursors.Default;
             }
             else if (tag.Name == "添加ArcGIS Server")
             {
                 frmNewArcGISServer server2 = new frmNewArcGISServer();
                 if (server2.ShowDialog() == DialogResult.OK)
                 {
                     newObject = server2.NewObject;
                     if (newObject != null)
                     {
                         newObject.Attach(tag.Parent, this.igxCatalog_0);
                         node = new TreeNode(newObject.Name, this.method_3(newObject), this.method_4(newObject))
                         {
                             Tag = newObject
                         };
                         base.SelectedNode.Parent.Nodes.Add(node);
                     }
                 }
             }
             else if (tag.Name == "添加Server Object")
             {
                 try
                 {
                     frmNewServerObject obj5 = new frmNewServerObject
                     {
                         AGSServerConnectionName = (tag.Parent as IGxAGSConnection).AGSServerConnectionName
                     };
                     if (obj5.ShowDialog() == DialogResult.OK)
                     {
                         tag.Parent.Refresh();
                     }
                 }
                 catch (Exception exception2)
                 {
                     exception = exception2;
                 }
             }
         }
     }
 }