public override void OnClick() { IWorkspaceCatalogItem itemWorkspace = m_HookHelper.CurrentCatalogItem as IWorkspaceCatalogItem; if (itemWorkspace == null) return; if (itemWorkspace.WorkspaceType == enumWorkspaceType.SDE) { FrmWorkspaceProperty frmProperty = new FrmWorkspaceProperty(); frmProperty.WorkspaceName = itemWorkspace.Name; frmProperty.WorkspaceProperty = itemWorkspace.WorkspacePropertySet as IPropertySet; frmProperty.ShowDialog(); } else { FrmLocalWorkspaceAdd frmPropery2 = new FrmLocalWorkspaceAdd(); frmPropery2.Editable = false; frmPropery2.WorkspaceAlias = itemWorkspace.Name; frmPropery2.WorkspaceType = itemWorkspace.WorkspaceType; string strFullPath = itemWorkspace.WorkspacePropertySet as string; string strPath = System.IO.Path.GetDirectoryName(strFullPath); string strName = System.IO.Path.GetFileName(strFullPath); frmPropery2.WorkspacePath = strPath; frmPropery2.WorkspaceName = strName; frmPropery2.ShowDialog(); } }
public override void OnClick() { FrmLocalWorkspaceAdd frmCreate = new FrmLocalWorkspaceAdd(); if (frmCreate.ShowDialog() == DialogResult.OK) { if (frmCreate.CreateNew) { IWorkspace wsNew = Hy.Esri.Utility.WorkspaceHelper.CreateWorkspace( frmCreate.WorkspaceType, frmCreate.WorkspacePath, frmCreate.WorkspaceName); if (wsNew == null) { DevExpress.XtraEditors.XtraMessageBox.Show("抱歉,创建本地数据库出错啦!"); } else { DevExpress.XtraEditors.XtraMessageBox.Show("已成功创建本地数据库!"); } } WorkspaceInfo wsInfo=new WorkspaceInfo(); wsInfo.Name=frmCreate.WorkspaceAlias; wsInfo.Type=frmCreate.WorkspaceType; wsInfo.Args=System.IO.Path.Combine(frmCreate.WorkspacePath,frmCreate.WorkspaceName); Environment.NhibernateHelper.SaveObject(wsInfo); Environment.NhibernateHelper.Flush(); ICatalogItem itemNew = new WorkspaceCatalogItem( System.IO.Path.Combine(frmCreate.WorkspacePath, frmCreate.WorkspaceName), frmCreate.WorkspaceType, m_HookHelper.RootCatalogItem, frmCreate.WorkspaceAlias); RootCatalogItem itemRoot = m_HookHelper.RootCatalogItem as RootCatalogItem; itemRoot.AddItem(itemNew); } }