Пример #1
0
        private void frmExtendDomain_Load(object sender, EventArgs e)
        {
            IWorkspaceDomains domains = this.iworkspace_0 as IWorkspaceDomains;

            if (this.iworkspace_0 != null)
            {
                IEnumDomain domain = domains.Domains;
                string[]    items  = new string[2];
                if (domain != null)
                {
                    domain.Reset();
                    for (IDomain domain2 = domain.Next(); domain2 != null; domain2 = domain.Next())
                    {
                        if (domain2 is IJLKCodeValueDomain)
                        {
                            items[0] = domain2.Name;
                            items[1] = domain2.Description;
                            ListViewItem item = new ListViewItem(items)
                            {
                                Tag = new Class3(domain2)
                            };
                            this.ilist_0.Add(item.Tag);
                            this.DomainListView.Items.Add(item);
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Converts IEnumDomain to domain list.
        /// </summary>
        /// <param name="domains">The IEnumDomain</param>
        /// <returns>list of IDomain</returns>
        public static DomainList ToDomainList(this IEnumDomain domains)
        {
            DomainList list = new DomainList();

            IDomain domain = null;

            while ((domain = domains.Next()) != null)
            {
                list.Add(domain);
            }

            return(list);
        }
Пример #3
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumDomain" />
        /// </summary>
        /// <param name="source">An <see cref="IEnumDomain" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the values from the input source.</returns>
        public static IEnumerable <IDomain> AsEnumerable(this IEnumDomain source)
        {
            if (source != null)
            {
                source.Reset();
                IDomain domain = source.Next();
                while (domain != null)
                {
                    yield return(domain);

                    domain = source.Next();
                }
            }
        }
Пример #4
0
 //复制工作空间坐标空间域
 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;
     }
 }
Пример #5
0
        private void FieldTypeDateCtrl_Load(object sender, EventArgs e)
        {
            this.cboDomain.Properties.Items.Clear();
            try
            {
                int num = -1;
                this.cboDomain.Properties.Items.Add(new DomainWrap1());
                if (this.iworkspace_0 is IWorkspaceDomains)
                {
                    IEnumDomain domains = (this.iworkspace_0 as IWorkspaceDomains).Domains;
                    if (domains != null)
                    {
                        domains.Reset();
                        for (IDomain domain2 = domains.Next(); domain2 != null; domain2 = domains.Next())
                        {
                            if (domain2.FieldType == esriFieldType.esriFieldTypeDate)
                            {
                                this.cboDomain.Properties.Items.Add(new DomainWrap1(domain2));
                                if ((this.ifieldEdit_0.Domain != null) &&
                                    (this.ifieldEdit_0.Domain.Name == domain2.Name))
                                {
                                    num = this.cboDomain.Properties.Items.Count - 1;
                                }
                            }
                        }
                    }
                }
                string domainID = "";
                if (NewObjectClassHelper.m_pObjectClassHelper != null)
                {
                    if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(this.ifieldEdit_0))
                    {
                        if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0] != null)
                        {
                            domainID =
                                NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0].DomainID;
                        }
                    }
                    else if (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass != null)
                    {
                        string name = (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass as IDataset).Name;
                        domainID = CodeDomainManage.GetDamainName(this.ifieldEdit_0.Name, name);
                    }
                }
                using (List <CodeDomainEx> .Enumerator enumerator = CodeDomainManage.CodeDomainExs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        CodeDomainEx current = enumerator.Current;
                        if (current.FieldType == esriFieldType.esriFieldTypeDate)
                        {
                            this.cboDomain.Properties.Items.Add(new DomainWrap1(current));
                            if (domainID == current.DomainID)
                            {
                                goto Label_01F7;
                            }
                        }
                    }
                    goto Label_021F;
Label_01F7:
                    num = this.cboDomain.Properties.Items.Count - 1;
                }
Label_021F:
                this.cboDomain.SelectedIndex = num;
            }
            catch
            {
                this.cboDomain.Enabled = false;
            }
            this.method_1();
        }
Пример #6
0
 private void FieldTypeTextCtrl_Load(object sender, EventArgs e)
 {
     this.cboDomain.Properties.Items.Clear();
     try
     {
         int num = -1;
         this.cboDomain.Properties.Items.Add(new DomainWrap1());
         if (this.iworkspace_0 is IWorkspaceDomains)
         {
             IEnumDomain domains = (this.iworkspace_0 as IWorkspaceDomains).Domains;
             if (domains != null)
             {
                 domains.Reset();
                 for (IDomain domain2 = domains.Next(); domain2 != null; domain2 = domains.Next())
                 {
                     if (domain2.FieldType == esriFieldType.esriFieldTypeString)
                     {
                         this.cboDomain.Properties.Items.Add(new DomainWrap1(domain2));
                         if ((this.ifieldEdit_0.Domain != null) &&
                             (this.ifieldEdit_0.Domain.Name == domain2.Name))
                         {
                             num = this.cboDomain.Properties.Items.Count - 1;
                         }
                     }
                 }
             }
         }
         string domainID = "";
         if (NewObjectClassHelper.m_pObjectClassHelper != null)
         {
             if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(this.ifieldEdit_0))
             {
                 if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0] != null)
                 {
                     domainID =
                         NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0].DomainID;
                 }
             }
             else if (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass != null)
             {
                 string name = (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass as IDataset).Name;
                 domainID = CodeDomainManage.GetDamainName(this.ifieldEdit_0.Name, name);
             }
         }
         foreach (CodeDomainEx ex in CodeDomainManage.CodeDomainExs)
         {
             if (ex.FieldType == esriFieldType.esriFieldTypeString)
             {
                 this.cboDomain.Properties.Items.Add(new DomainWrap1(ex));
                 if (domainID == ex.DomainID)
                 {
                     num = this.cboDomain.Properties.Items.Count - 1;
                 }
             }
         }
         this.cboDomain.SelectedIndex = num;
     }
     catch
     {
         this.cboDomain.Enabled = false;
     }
     this.method_1();
 }
Пример #7
0
        /// <summary>
        /// Adds coded domain values to the Voyage Tracks feature class.
        /// </summary>
        /// <param name="sWorkspace"></param>
        /// <param name="sLayerName"></param>
        private void AddCodedDomain(string sWorkspace, string sLayerName)
        {
            try
            {
                IWorkspace    pWorkspace = clsStatic.OpenWorkspace(sWorkspace);
                IFeatureLayer pFL        = clsStatic.GetFeatureLayer(pWorkspace, sLayerName); // pFWS.OpenTable("Voyage");
                ITable        pTable     = (ITable)pFL.FeatureClass;

                IWorkspaceDomains pWSD             = (IWorkspaceDomains)pWorkspace;
                ICodedValueDomain codedValueDomain = new CodedValueDomainClass();
                IEnumDomain       pDomains         = pWSD.Domains;
                pDomains.Reset();
                IDomain pDomain = pDomains.Next();
                while (pDomain != null)
                {
                    if (pDomain.Name == "Cargo")
                    {
                        break;
                    }
                }
                if (pDomain == null)
                {
                    if (clsStatic.GetArcLicense())
                    {
                        //VESSEL CARGO DOMAIN
                        // Value and name pairs.
                        for (int i = 0; i <= 9; i++)
                        {
                            codedValueDomain.AddCode(i, "Not Available");
                        }
                        for (int i = 10; i <= 19; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 20; i <= 90; i += 10)
                        {
                            codedValueDomain.AddCode(i, "Not Available");
                        }

                        for (int i = 21; i <= 81; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category A");
                        }
                        for (int i = 22; i <= 82; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category B");
                        }
                        for (int i = 23; i <= 83; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category C");
                        }
                        for (int i = 24; i <= 84; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category D");
                        }
                        for (int i = 29; i <= 89; i += 20)
                        {
                            codedValueDomain.AddCode(i, "No additional information");
                        }

                        for (int i = 25; i <= 28; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 31; i <= 39; i++)
                        {
                            codedValueDomain.AddCode(i, "Not Available");
                        }

                        for (int i = 45; i <= 48; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 51; i <= 59; i++)
                        {
                            codedValueDomain.AddCode(i, "Not Available");
                        }

                        for (int i = 65; i <= 68; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 71; i <= 91; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category A");
                        }
                        for (int i = 72; i <= 92; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category B");
                        }
                        for (int i = 73; i <= 93; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category C");
                        }
                        for (int i = 74; i <= 94; i += 20)
                        {
                            codedValueDomain.AddCode(i, "Carrying DG, HS, or MP, IMO hazard or pollutant category D");
                        }
                        for (int i = 79; i <= 99; i += 20)
                        {
                            codedValueDomain.AddCode(i, "No additional information");
                        }

                        for (int i = 75; i <= 78; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 85; i <= 88; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 95; i <= 98; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved for future use");
                        }

                        for (int i = 100; i <= 199; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved, for regional use");
                        }
                        for (int i = 200; i <= 255; i++)
                        {
                            codedValueDomain.AddCode(i, "Reserved, for future use");
                        }

                        // The code to set the common properties for the new coded value domain.
                        pDomain             = (IDomain)codedValueDomain;
                        pDomain.Name        = "Cargo";
                        pDomain.FieldType   = esriFieldType.esriFieldTypeInteger;
                        pDomain.SplitPolicy = esriSplitPolicyType.esriSPTDefaultValue;
                        pDomain.MergePolicy = esriMergePolicyType.esriMPTDefaultValue;
                        // Add the new domain to the workspace.
                        pWSD.AddDomain(pDomain);
                    }
                }
                //assign the domain to the voyage table cargo field
                IFields pFields     = pTable.Fields;
                int     iFieldIndex = pTable.FindField("Cargo");
                IField  pField      = pFields.get_Field(iFieldIndex);

                // Check that the field and domain have the same field type.
                if (pField.Type == pDomain.FieldType)
                {
                    // Cast the feature class to the ISchemaLock and IClassSchemaEdit interfaces.
                    ISchemaLock      schemaLock      = (ISchemaLock)pTable;
                    IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)pTable;

                    // Attempt to get an exclusive schema lock.
                    try
                    {
                        // Lock the class and alter the domain.
                        schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                        classSchemaEdit.AlterDomain("Cargo", pDomain);
                    }
                    catch (Exception ex)
                    {
                        // Handle the exception in a way appropriate for the application.
                        clsStatic.ShowErrorMessage(ex.ToString());
                    }
                    finally
                    {
                        // Set the schema lock to be a shared lock.
                        schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                    }
                }
            }
            catch (Exception ex)
            {
                clsStatic.ShowErrorMessage(ex.ToString());
            }
        }