Esempio n. 1
0
        private void Init()
        {
            this.gridControl1.Focus();
            this.m_pVertXtraGrid.Clear();
            int rowHandle = -1;

            if (this.m_pObject == null)
            {
                this.m_CanDo = true;
            }
            else
            {
                this.toolStripDropDownButton1.DropDownItemClicked +=
                    new ToolStripItemClickedEventHandler(this.toolStripDropDownButton1_DropDownItemClicked);
                try
                {
                    ITableAttachments attachments = (ITableAttachments)this.m_pObject.Class;
                    if (attachments != null)
                    {
                        if (attachments.HasAttachments)
                        {
                            this.toolStrip1.Visible = true;
                            this.InitAttachment();
                        }
                        else
                        {
                            this.toolStrip1.Visible = false;
                        }
                    }
                }
                catch
                {
                }
                IFields   fields   = this.m_pObject.Fields;
                string[]  strArray = new string[2];
                ISubtypes subtypes = this.m_pObject.Class as ISubtypes;
                IDomain   domain   = null;
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    IField pField = fields.get_Field(i);
                    if (this.CheckFieldIsVisible(this.m_pFeatureLayer, pField))
                    {
                        strArray[0] = pField.AliasName;
                        if (pField.Type == esriFieldType.esriFieldTypeGeometry)
                        {
                            strArray[1] = this.GetShapeString(pField);
                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true);
                        }
                        else if (pField.Type == esriFieldType.esriFieldTypeOID)
                        {
                            strArray[1] = this.m_pObject.OID.ToString();
                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true);
                        }
                        else if (pField.Type == esriFieldType.esriFieldTypeBlob)
                        {
                            strArray[1] = "<二进制数据>";
                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true);
                        }
                        else
                        {
                            int               num4;
                            double            minValue;
                            double            maxValue;
                            object            obj2    = this.m_pObject.get_Value(i);
                            ICodedValueDomain domain2 = null;
                            IList             list    = new ArrayList();
                            if ((subtypes != null) && subtypes.HasSubtype)
                            {
                                if (subtypes.SubtypeFieldName == pField.Name)
                                {
                                    int num3;
                                    try
                                    {
                                        strArray[1] =
                                            subtypes.get_SubtypeName((this.m_pObject as IRowSubtypes).SubtypeCode);
                                    }
                                    catch
                                    {
                                        strArray[1] = obj2.ToString();
                                    }
                                    IEnumSubtype subtype = subtypes.Subtypes;
                                    subtype.Reset();
                                    for (string str = subtype.Next(out num3); str != null; str = subtype.Next(out num3))
                                    {
                                        list.Add(str);
                                    }
                                    this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list,
                                                                     !this.FieldCanEdit(pField));
                                }
                                else
                                {
                                    domain = subtypes.get_Domain((this.m_pObject as IRowSubtypes).SubtypeCode,
                                                                 pField.Name);
                                    if (domain is ICodedValueDomain)
                                    {
                                        domain2 = domain as ICodedValueDomain;
                                        if (pField.IsNullable)
                                        {
                                            list.Add("<空>");
                                        }
                                        strArray[1] = obj2.ToString();
                                        num4        = 0;
                                        while (num4 < domain2.CodeCount)
                                        {
                                            list.Add(domain2.get_Name(num4));
                                            if (obj2.ToString() == domain2.get_Value(num4).ToString())
                                            {
                                                strArray[1] = domain2.get_Name(num4);
                                            }
                                            num4++;
                                        }
                                        this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list,
                                                                         !this.FieldCanEdit(pField));
                                    }
                                    else if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) ||
                                               (pField.Type == esriFieldType.esriFieldTypeSingle)) ||
                                              (pField.Type == esriFieldType.esriFieldTypeDouble)) ||
                                             (pField.Type == esriFieldType.esriFieldTypeInteger))
                                    {
                                        minValue = 0.0;
                                        maxValue = 0.0;
                                        if (domain is IRangeDomain)
                                        {
                                            minValue = (double)(domain as IRangeDomain).MinValue;
                                            maxValue = (double)(domain as IRangeDomain).MaxValue;
                                        }
                                        if (pField.Editable)
                                        {
                                            this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, minValue,
                                                                             maxValue);
                                        }
                                        else
                                        {
                                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true);
                                        }
                                    }
                                    else if (pField.Type == esriFieldType.esriFieldTypeDate)
                                    {
                                        this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2, !this.FieldCanEdit(pField));
                                    }
                                    else
                                    {
                                        strArray[1] = obj2.ToString();
                                        this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1],
                                                                         !this.FieldCanEdit(pField));
                                    }
                                }
                            }
                            else
                            {
                                domain = pField.Domain;
                                if (domain != null)
                                {
                                    if (domain is ICodedValueDomain)
                                    {
                                        domain2 = domain as ICodedValueDomain;
                                        if (pField.IsNullable)
                                        {
                                            list.Add("<空>");
                                        }
                                        strArray[1] = obj2.ToString();
                                        num4        = 0;
                                        while (num4 < domain2.CodeCount)
                                        {
                                            list.Add(domain2.get_Name(num4));
                                            if (obj2.ToString() == domain2.get_Value(num4).ToString())
                                            {
                                                strArray[1] = domain2.get_Name(num4);
                                            }
                                            num4++;
                                        }
                                        this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list,
                                                                         !this.FieldCanEdit(pField));
                                    }
                                    else if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) ||
                                               (pField.Type == esriFieldType.esriFieldTypeSingle)) ||
                                              (pField.Type == esriFieldType.esriFieldTypeDouble)) ||
                                             (pField.Type == esriFieldType.esriFieldTypeInteger))
                                    {
                                        minValue = 0.0;
                                        maxValue = 0.0;
                                        if (domain is IRangeDomain)
                                        {
                                            minValue = (double)(domain as IRangeDomain).MinValue;
                                            maxValue = (double)(domain as IRangeDomain).MaxValue;
                                        }
                                        if (pField.Editable)
                                        {
                                            this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, minValue,
                                                                             maxValue);
                                        }
                                        else
                                        {
                                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true);
                                        }
                                    }
                                    else if (pField.Type == esriFieldType.esriFieldTypeDate)
                                    {
                                        this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2, !this.FieldCanEdit(pField));
                                    }
                                    else
                                    {
                                        strArray[1] = obj2.ToString();
                                        this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1],
                                                                         !this.FieldCanEdit(pField));
                                    }
                                }
                                else
                                {
                                    string       name         = (this.m_pObject.Class as IDataset).Name;
                                    CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(pField.Name, name);
                                    if (codeDomainEx != null)
                                    {
                                        if ((codeDomainEx.ParentIDFieldName == null) ||
                                            (codeDomainEx.ParentIDFieldName.Length == 0))
                                        {
                                            NameValueCollection codeDomain = codeDomainEx.GetCodeDomain();
                                            if (pField.IsNullable)
                                            {
                                                list.Add("<空>");
                                            }
                                            strArray[1] = obj2.ToString();
                                            for (num4 = 0; num4 < codeDomain.Count; num4++)
                                            {
                                                string str3 = codeDomain.Keys[num4];
                                                list.Add(str3);
                                                if (obj2.ToString() == codeDomain[str3])
                                                {
                                                    strArray[1] = str3;
                                                }
                                            }
                                            this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list,
                                                                             !this.FieldCanEdit(pField));
                                        }
                                        else
                                        {
                                            strArray[1] = obj2.ToString();
                                            this.m_pVertXtraGrid.AddTreeviewComBoBox(strArray[0],
                                                                                     codeDomainEx.FindName(strArray[1]), codeDomainEx,
                                                                                     !this.FieldCanEdit(pField));
                                        }
                                    }
                                    else
                                    {
                                        if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) ||
                                              (pField.Type == esriFieldType.esriFieldTypeSingle)) ||
                                             (pField.Type == esriFieldType.esriFieldTypeDouble)) ||
                                            (pField.Type == esriFieldType.esriFieldTypeInteger))
                                        {
                                            if (pField.Editable)
                                            {
                                                this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, 0.0, 0.0);
                                            }
                                            else
                                            {
                                                this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true);
                                            }
                                        }
                                        else if (pField.Type == esriFieldType.esriFieldTypeDate)
                                        {
                                            this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2,
                                                                             !this.FieldCanEdit(pField));
                                        }
                                        else
                                        {
                                            strArray[1] = obj2.ToString();
                                            this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1],
                                                                             !this.FieldCanEdit(pField));
                                        }
                                        if (strArray[0] == this.m_EditFeildName)
                                        {
                                            rowHandle = i;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (rowHandle >= 0)
                {
                    this.gridView1.SelectRow(rowHandle);
                }
                this.gridView1.Focus();
                this.m_CanDo = true;
                base.Parent.Focus();
            }
        }
Esempio n. 2
0
 private void AddRecordToListView(bool bAll)
 {
     try
     {
         if (bAll)
         {
             this.m_ShowRecNum = this.m_RecordNum - this.m_pDataTable.Rows.Count;
         }
         else
         {
             this.m_ShowRecNum = ((this.m_RecordNum - this.m_pDataTable.Rows.Count) > 300)
                 ? ((long)300)
                 : ((long)this.m_RecordNum);
         }
         IFields  fields = this.m_pCursor.Fields;
         int      num    = 0;
         IRow     row    = this.m_pCursor.NextRow();
         object[] values = new object[fields.FieldCount];
         while (row != null)
         {
             for (int i = 0; i < fields.FieldCount; i++)
             {
                 IField field = fields.get_Field(i);
                 if (field.Type == esriFieldType.esriFieldTypeGeometry)
                 {
                     values[i] = this.m_strGeometry;
                     continue;
                 }
                 if (field.Type == esriFieldType.esriFieldTypeBlob)
                 {
                     values[i] = "二进制数据";
                     continue;
                 }
                 object  obj2   = row.get_Value(i);
                 IDomain domain = field.Domain;
                 if (domain != null)
                 {
                     if (domain is ICodedValueDomain)
                     {
                         for (int j = 0; j < (field.Domain as ICodedValueDomain).CodeCount; j++)
                         {
                             if ((domain as ICodedValueDomain).get_Value(j).ToString() == obj2.ToString())
                             {
                                 obj2 = (domain as ICodedValueDomain).get_Name(j);
                                 break;
                             }
                         }
                     }
                 }
                 else
                 {
                     string       name         = (row.Table as IDataset).Name;
                     CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(field.Name, name);
                     if (codeDomainEx != null)
                     {
                         obj2 = codeDomainEx.FindName(obj2.ToString());
                     }
                 }
                 values[i] = obj2;
             }
             this.m_pDataTable.Rows.Add(values);
             num++;
             if (row.HasOID)
             {
                 this.m_MaxOID = row.OID;
             }
             if (num >= this.m_ShowRecNum)
             {
                 return;
             }
             row = this.m_pCursor.NextRow();
         }
     }
     catch
     {
     }
 }
Esempio n. 3
0
        private string method_7(IRow irow_0, IField ifield_0, int int_0)
        {
            int               num;
            string            str     = irow_0.get_Value(int_0).ToString();
            ISubtypes         table   = irow_0.Table as ISubtypes;
            ICodedValueDomain domain  = null;
            IList             list    = new ArrayList();
            IDomain           domain2 = null;

            if ((table != null) && table.HasSubtype)
            {
                if (table.SubtypeFieldName == ifield_0.Name)
                {
                    try
                    {
                        str = table.get_SubtypeName((irow_0 as IRowSubtypes).SubtypeCode);
                    }
                    catch
                    {
                    }
                }
                else
                {
                    domain2 = table.get_Domain((irow_0 as IRowSubtypes).SubtypeCode, ifield_0.Name);
                    if (domain2 is ICodedValueDomain)
                    {
                        domain = domain2 as ICodedValueDomain;
                        if (ifield_0.IsNullable)
                        {
                            list.Add("<空>");
                        }
                        num = 0;
                        while (num < domain.CodeCount)
                        {
                            if (str == domain.get_Value(num).ToString())
                            {
                                str = domain.get_Name(num);
                                break;
                            }
                            num++;
                        }
                    }
                }
            }
            domain2 = ifield_0.Domain;
            if (domain2 != null)
            {
                if (domain2 is ICodedValueDomain)
                {
                    domain = domain2 as ICodedValueDomain;
                    num    = 0;
                    while (num < domain.CodeCount)
                    {
                        if (str == domain.get_Value(num).ToString())
                        {
                            return(domain.get_Name(num));
                        }
                        num++;
                    }
                }
                return(str);
            }
            string       name         = (irow_0.Table as IDataset).Name;
            CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(ifield_0.Name, name);

            if (codeDomainEx == null)
            {
                return(str);
            }
            if ((codeDomainEx.ParentIDFieldName == null) || (codeDomainEx.ParentIDFieldName.Length == 0))
            {
                NameValueCollection codeDomain = codeDomainEx.GetCodeDomain();
                for (num = 0; num < codeDomain.Count; num++)
                {
                    string str3 = codeDomain.Keys[num];
                    if (str == codeDomain[str3])
                    {
                        str = str3;
                    }
                }
                return(str);
            }
            return(codeDomainEx.FindName(str));
        }