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); } } }
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; }
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; }
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; }
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); }
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); } }
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; } } } } }