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); } } }
private void listView1_DoubleClick(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count != 0) { MyDoubleClickResult myDCRShowChildren; IGxObject tag = this.listView1.SelectedItems[0].Tag as IGxObject; if ((this._gxObjectFilter != null) && (tag is IGxDatabase)) { myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren; this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren); if (myDCRShowChildren == MyDoubleClickResult.myDCRChooseAndDismiss) { this.PassListItem(); return; } } if (!(tag is IGxObjectContainer)) { if (tag is IGxNewDatabase) { IWorkspaceName name; IGxObject obj3; ListViewItem item; 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.ChangeODCExtension(str2); IWorkspaceFactory factory = new OLEDBWorkspaceFactory() as IWorkspaceFactory; name = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0); IGxObject gxDatabase = new GxDatabase() as IGxObject; (gxDatabase as IGxDatabase).WorkspaceName = name; gxDatabase.Attach(tag.Parent, this._gxCatalog); item = new ListViewItem(new string[] { gxDatabase.Name, gxDatabase.Category }, this.GetImageIndex(gxDatabase)) { Tag = gxDatabase }; this.listView1.Items.Add(item); } } catch (Exception exception) { exception.ToString(); } } else if (tag.FullName == "添加空间数据库连接") { frmCreateGDBConnection connection = new frmCreateGDBConnection { TopMost = true }; if (connection.ShowDialog() == DialogResult.OK) { IGxObject oneObj = new GxDatabase() as IGxObject; IWorkspaceName name2 = new WorkspaceName() as IWorkspaceName; name2.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory"; name2.PathName = connection.ConnectionPath; (oneObj as IGxDatabase).WorkspaceName = name2; oneObj.Attach(tag.Parent, this._gxCatalog); item = new ListViewItem(new string[] { oneObj.Name, oneObj.Category }, this.GetImageIndex(oneObj)) { Tag = oneObj }; this.listView1.Items.Add(item); } } } else { this.PassListItem(); } } else { GISDataComboItem ex; if (tag is IGxDataset) { esriDatasetType type = (tag as IGxDataset).Type; myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren; this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren); if ((((type != esriDatasetType.esriDTFeatureDataset) && (type != esriDatasetType.esriDTContainer)) && ((type != esriDatasetType.esriDTRasterCatalog) && (type != esriDatasetType.esriDTCadDrawing))) && (type != esriDatasetType.esriDTRasterDataset)) { this.PassListItem(); return; } } this.LoadViewer(tag); this._isFree = false; if (tag.Parent is IGxCatalog) { for (int i = 0; i < this.gisDataComboBox1.Items.Count; i++) { ex = this.gisDataComboBox1.Items[i] as GISDataComboItem; if (ex.Tag == tag) { this.gisDataComboBox1.SelectedIndex = i; break; } } } else { ex = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem; int degree = ex.Level; ex = new GISDataComboItem(tag.Name, tag.FullName, this.GetImageIndex(tag), degree + 1) { Tag = tag }; int selectedIndex = this.gisDataComboBox1.SelectedIndex; this.gisDataComboBox1.AddChildNode(ex); this.gisDataComboBox1.SelectedIndex = selectedIndex + 1; } this._isFree = true; } } }
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { IWorkspaceName workspaceNameClass; IGxObject gxDatabase; ListViewItem listViewItem; string[] name; ImageComboBoxItemEx item; if (this.listView1.SelectedItems.Count != 0) { IGxObject tag = this.listView1.SelectedItems[0].Tag as IGxObject; if (tag is IGxObjectContainer) { this.SetListView(tag); this.m_CanDo = false; if (tag.Parent is IGxCatalog) { int num = 0; while (num < this.imageComboBoxEdit1.Properties.Items.Count) { item = this.imageComboBoxEdit1.Properties.Items[num] as ImageComboBoxItemEx; if (item.Tag != tag) { num++; } else { this.imageComboBoxEdit1.SelectedIndex = num; break; } } } else { item = this.imageComboBoxEdit1.Properties.Items[this.imageComboBoxEdit1.SelectedIndex] as ImageComboBoxItemEx; int degree = item.Degree; item = new ImageComboBoxItemEx(tag.Name, tag.FullName, this.GetImageIndex(tag), degree + 1) { Tag = tag }; int selectedIndex = this.imageComboBoxEdit1.SelectedIndex; this.imageComboBoxEdit1.Properties.Items.Insert(selectedIndex + 1, item); this.imageComboBoxEdit1.SelectedIndex = selectedIndex + 1; } this.m_CanDo = true; } else if (tag is IGxNewDatabase) { if (tag.FullName == "添加OLE DB连接") { try { string str = string.Concat(Environment.SystemDirectory.Substring(0, 2), "\\Documents and Settings\\Administrator\\Application Data\\ESRI\\ArcCatalog\\"); string finalFileName = string.Concat(str, "OLE DB Connection.odc"); if (Directory.Exists(str)) { finalFileName = this.GetFinalFileName(finalFileName); IWorkspaceFactory oLEDBWorkspaceFactoryClass = new OLEDBWorkspaceFactory(); workspaceNameClass = oLEDBWorkspaceFactoryClass.Create(str, Path.GetFileName(finalFileName), null, 0); gxDatabase = new GxDatabase(); (gxDatabase as IGxDatabase).WorkspaceName = workspaceNameClass; gxDatabase.Attach(tag.Parent, this.GxCatalog); name = new string[] { gxDatabase.Name, gxDatabase.Category }; listViewItem = new ListViewItem(name, this.GetImageIndex(gxDatabase)) { Tag = gxDatabase }; this.listView1.Items.Add(listViewItem); } } catch (Exception exception) { exception.ToString(); } } else if (tag.FullName == "添加空间数据库连接") { frmCreateGDBConnection _frmCreateGDBConnection = new frmCreateGDBConnection() { TopMost = true }; if (_frmCreateGDBConnection.ShowDialog() == DialogResult.OK) { gxDatabase = new GxDatabase(); workspaceNameClass = new WorkspaceName() as IWorkspaceName; workspaceNameClass.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory"; workspaceNameClass.PathName = _frmCreateGDBConnection.ConnectionPath; (gxDatabase as IGxDatabase).WorkspaceName = workspaceNameClass; gxDatabase.Attach(tag.Parent, this.GxCatalog); name = new string[] { gxDatabase.Name, gxDatabase.Category }; listViewItem = new ListViewItem(name, this.GetImageIndex(gxDatabase)) { Tag = gxDatabase }; this.listView1.Items.Add(listViewItem); } } } } }
private void listView1_DoubleClick(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count != 0) { MyDoubleClickResult myDCRShowChildren; IGxObject tag = this.listView1.SelectedItems[0].Tag as IGxObject; if ((this.igxObjectFilter_0 != null) && (tag is IGxDatabase)) { myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren; this.igxObjectFilter_0.CanChooseObject(tag, ref myDCRShowChildren); if (myDCRShowChildren == MyDoubleClickResult.myDCRChooseAndDismiss) { this.method_4(); return; } } if (!(tag is IGxObjectContainer)) { if (tag is IGxNewDatabase) { IWorkspaceName name; IGxObject obj3; ListViewItem item; 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_6(str2); IWorkspaceFactory factory = new OLEDBWorkspaceFactoryClass(); name = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0); obj3 = new GxDatabase(); (obj3 as IGxDatabase).WorkspaceName = name; obj3.Attach(tag.Parent, this.igxCatalog_0); item = new ListViewItem(new string[] { obj3.Name, obj3.Category }, this.method_2(obj3)) { Tag = obj3 }; this.listView1.Items.Add(item); } } catch (Exception exception) { exception.ToString(); } } else if (tag.FullName == "添加空间数据库连接") { frmCreateGDBConnection connection = new frmCreateGDBConnection { TopMost = true }; if (connection.ShowDialog() == DialogResult.OK) { obj3 = new GxDatabase(); name = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory", PathName = connection.ConnectionPath }; (obj3 as IGxDatabase).WorkspaceName = name; obj3.Attach(tag.Parent, this.igxCatalog_0); item = new ListViewItem(new string[] { obj3.Name, obj3.Category }, this.method_2(obj3)) { Tag = obj3 }; this.listView1.Items.Add(item); } } } else { this.method_4(); } } else { ImageComboBoxItemEx ex; if (tag is IGxDataset) { esriDatasetType type = (tag as IGxDataset).Type; myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren; this.igxObjectFilter_0.CanChooseObject(tag, ref myDCRShowChildren); if ((((type != esriDatasetType.esriDTFeatureDataset) && (type != esriDatasetType.esriDTContainer)) && ((type != esriDatasetType.esriDTRasterCatalog) && (type != esriDatasetType.esriDTCadDrawing))) && (type != esriDatasetType.esriDTRasterDataset)) { this.method_4(); return; } } this.method_10(tag); this.bool_0 = false; if (tag.Parent is IGxCatalog) { for (int i = 0; i < this.imageComboBoxEdit1.Properties.Items.Count; i++) { ex = this.imageComboBoxEdit1.Properties.Items[i] as ImageComboBoxItemEx; if (ex.Tag == tag) { this.imageComboBoxEdit1.SelectedIndex = i; break; } } } else { ex = this.imageComboBoxEdit1.Properties.Items[this.imageComboBoxEdit1.SelectedIndex] as ImageComboBoxItemEx; int degree = ex.Degree; ex = new ImageComboBoxItemEx(tag.Name, tag.FullName, this.method_2(tag), degree + 1) { Tag = tag }; int selectedIndex = this.imageComboBoxEdit1.SelectedIndex; this.imageComboBoxEdit1.Properties.Items.Insert(selectedIndex + 1, ex); this.imageComboBoxEdit1.SelectedIndex = selectedIndex + 1; } this.bool_0 = true; } } }
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; } } } } }