//复制工作空间坐标空间域 private void CreateWorkspaceDomains(IWorkspace pWs1, IWorkspace pWs2) { try { WaitForm.SetCaption("正在复制工作空间域,请稍后..."); IWorkspaceDomains pWsD1 = pWs1 as IWorkspaceDomains; IWorkspaceDomains pWsD2 = pWs2 as IWorkspaceDomains; IEnumDomain pEnumDomain = pWsD1.Domains; IDomain pDomain1 = null; IDomain pDomain2 = null; if (pEnumDomain == null) { return; } while ((pDomain1 = pEnumDomain.Next()) != null) { if (pDomain1.Type == esriDomainType.esriDTCodedValue)//编码域 { ICodedValueDomain tempDomain1 = pDomain1 as ICodedValueDomain; ICodedValueDomain tempDomain2 = new CodedValueDomainClass(); for (int i = 0; i < tempDomain1.CodeCount; i++) { tempDomain2.AddCode(tempDomain1.get_Value(i), tempDomain1.get_Name(i)); } pDomain2 = tempDomain2 as IDomain; pDomain2.Description = pDomain1.Description; pDomain2.FieldType = pDomain1.FieldType; pDomain2.DomainID = pDomain1.DomainID; pDomain2.MergePolicy = pDomain1.MergePolicy; pDomain2.Name = pDomain1.Name; pDomain2.Owner = pDomain1.Owner; pDomain2.SplitPolicy = pDomain1.SplitPolicy; pWsD2.AddDomain(pDomain2); } else//范围域 { IRangeDomain tempDomain1 = pDomain1 as IRangeDomain; IRangeDomain tempDomain2 = new RangeDomainClass(); tempDomain2.MaxValue = tempDomain1.MaxValue; tempDomain2.MinValue = tempDomain1.MinValue; pDomain2 = tempDomain2 as IDomain; pWsD2.AddDomain(pDomain2); } } } catch (System.Exception ex) { return; } }
public static IDomain AddDomain(IWorkspace workspace, IDomain domain) { if (domain == null) { return(null); } IWorkspaceDomains pWorkspaceDomains = workspace as IWorkspaceDomains; if (pWorkspaceDomains == null) { return(null); } IDomain pDomain = pWorkspaceDomains.DomainByName[domain.Name]; if (pDomain != null) { return(pDomain); } if (domain.Type == esriDomainType.esriDTCodedValue) { ICodedValueDomain pCodedValueDomain = new CodedValueDomainClass(); ICodedValueDomain pOriginCodedValueDomain = domain as ICodedValueDomain; for (int i = 0; i < pOriginCodedValueDomain.CodeCount; i++) { pCodedValueDomain.AddCode(pOriginCodedValueDomain.Value[i], pOriginCodedValueDomain.Name[i]); } pDomain = pCodedValueDomain as IDomain; } else { IRangeDomain pRangeDomain = new RangeDomainClass(); IRangeDomain pOriginRangeDomain = domain as IRangeDomain; pRangeDomain.MinValue = pOriginRangeDomain.MinValue; pRangeDomain.MaxValue = pOriginRangeDomain.MaxValue; pDomain = pRangeDomain as IDomain; } pDomain.Name = domain.Name; pDomain.FieldType = domain.FieldType; pDomain.Description = domain.Description; pDomain.SplitPolicy = esriSplitPolicyType.esriSPTDuplicate; pDomain.MergePolicy = esriMergePolicyType.esriMPTDefaultValue; pWorkspaceDomains.AddDomain(pDomain); return(pDomain); }
public void ChangeDomainType(esriDomainType esriDomainType_0) { IDomain domain; if (!this.bool_0) { if (this.idomain_1.Type != esriDomainType_0) { if (this.idomain_0 == null) { this.idomain_0 = this.idomain_1; } domain = null; if (esriDomainType_0 == esriDomainType.esriDTCodedValue) { domain = new CodedValueDomainClass { FieldType = this.idomain_1.FieldType }; } else if (esriDomainType_0 == esriDomainType.esriDTRange) { domain = new RangeDomainClass(); if (this.idomain_1.FieldType == esriFieldType.esriFieldTypeString) { domain.FieldType = esriFieldType.esriFieldTypeInteger; } else { domain.FieldType = this.idomain_1.FieldType; } } if (domain != null) { domain.Description = this.idomain_1.Description; domain.Name = this.idomain_1.Name; domain.SplitPolicy = this.idomain_1.SplitPolicy; domain.MergePolicy = this.idomain_1.MergePolicy; } this.idomain_1 = domain; this.bool_2 = true; } } else if (this.idomain_1.Type != esriDomainType_0) { domain = null; if (esriDomainType_0 == esriDomainType.esriDTCodedValue) { domain = new CodedValueDomainClass { FieldType = this.idomain_1.FieldType }; } else if (esriDomainType_0 == esriDomainType.esriDTRange) { domain = new RangeDomainClass(); if (this.idomain_1.FieldType == esriFieldType.esriFieldTypeString) { domain.FieldType = esriFieldType.esriFieldTypeInteger; } else { domain.FieldType = this.idomain_1.FieldType; } } if (domain != null) { domain.Description = this.idomain_1.Description; domain.Name = this.idomain_1.Name; domain.SplitPolicy = this.idomain_1.SplitPolicy; domain.MergePolicy = this.idomain_1.MergePolicy; } this.idomain_1 = domain; } }