Exemple #1
0
        /// <summary>
        /// 初始化过滤条件面板
        /// </summary>
        private void initFilterCondition()
        {
            listField.Items.Clear();
            listValue.Items.Clear();
            txtCondition.Text = (this.m_FeaLay as IFeatureLayerDefinition).DefinitionExpression;

            //得到当前要素图层的所有字段
            ITableFields pTableFields = m_FeaLay as ITableFields;
            IField       pField;

            for (int i = 0; i < pTableFields.FieldCount; i++)
            {
                if (pTableFields.get_FieldInfo(i).Visible == true)
                {
                    pField = pTableFields.get_Field(i);
                    if (pField.Type == esriFieldType.esriFieldTypeOID ||
                        pField.Type == esriFieldType.esriFieldTypeSmallInteger ||
                        pField.Type == esriFieldType.esriFieldTypeInteger ||
                        pField.Type == esriFieldType.esriFieldTypeSingle ||
                        pField.Type == esriFieldType.esriFieldTypeDouble ||
                        pField.Type == esriFieldType.esriFieldTypeDate ||
                        pField.Type == esriFieldType.esriFieldTypeString)
                    {
                        //ListViewItem item = new ListViewItem(new string[] { pField.Name, pField.AliasName });
                        //item.Tag = pField;
                        Class.Item item = new Class.Item(pField.AliasName, pField);
                        listField.Items.Add(item);
                    }
                }
            }
        }
Exemple #2
0
 private void listField_DoubleClick(object sender, EventArgs e)
 {
     if (listField.Items.Count > 0)
     {
         if (listField.SelectedItems.Count > 0)
         {
             Class.Item selItem = this.listField.SelectedItems[0] as Class.Item;
             IField     pFld    = selItem.Value as IField;
             this.txtCondition.Text += pFld.Name;
         }
     }
 }
Exemple #3
0
        private void listField_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listField.Items.Count == 0)
            {
                return;
            }
            if (listField.SelectedItems.Count == 0)
            {
                return;
            }

            Class.Item selItem      = listField.SelectedItems[0] as Class.Item;
            IField     pFld         = selItem.Value as IField;
            ArrayList  uniqueValues = Class.Common.GetUniqueValue(this.m_FeaLay.FeatureClass as ITable, new string[] { pFld.Name });

            this.listValue.Items.Clear();

            IField pField = selItem.Value as IField;

            if (pField.Domain is ICodedValueDomain)//如果为编码域
            {
                for (int i = 0; i < uniqueValues.Count; i++)
                {
                    if (uniqueValues[i].ToString() != "<Null>")
                    {
                        listValue.Items.Add(Class.Common.GetCodedDescriptionDomainValue(pField.Domain as ICodedValueDomain, uniqueValues[i].ToString()));
                    }
                }
            }
            else//如果不为编码域
            {
                if (pField.Type == esriFieldType.esriFieldTypeString)
                {
                    for (int i = 0; i < uniqueValues.Count; i++)
                    {
                        if (uniqueValues[i].ToString() != "<Null>")
                        {
                            listValue.Items.Add("'" + uniqueValues[i].ToString() + "'");
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < uniqueValues.Count; i++)
                    {
                        if (uniqueValues[i].ToString() != "<Null>")
                        {
                            listValue.Items.Add(uniqueValues[i].ToString());
                        }
                    }
                }
            }
        }
Exemple #4
0
        private void listValue_DoubleClick(object sender, EventArgs e)
        {
            if (this.listValue.SelectedItem == null)
            {
                return;
            }

            Class.Item selItem = listField.SelectedItems[0] as Class.Item;
            IField     pField  = selItem.Value as IField;

            if (pField.Domain is ICodedValueDomain)//如果为编码域
            {
                this.txtCondition.Text += Class.Common.GetCodedValueDomainValue(pField.Domain as ICodedValueDomain, this.listValue.SelectedItem.ToString());
            }
            else//如果不为编码域
            {
                this.txtCondition.Text += this.listValue.SelectedItem.ToString();
            }
        }
 /// <summary>
 /// 克隆
 /// </summary>
 /// <returns></returns>
 public new Item Clone()
 {
     Class.Item obj = base.Clone() as Item;
     return(obj);
 }
Exemple #6
0
        /// <summary>
        ///  保存图层属性
        /// </summary>
        /// <returns></returns>
        public bool SaveProperties()
        {
            if (txtLayerName.Text.Trim() == "")
            {
                return(false);
            }
            if (this.rdoGroupScale.SelectedIndex == 1)
            {
                try
                {
                    if (double.Parse(txtScaleMin.Text) <= double.Parse(txtScaleMax.Text))
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
            }
            m_FeaLay.Name = txtLayerName.Text;
            if (this.rdoGroupScale.SelectedIndex == 0)
            {
                m_FeaLay.MinimumScale = 0;
                m_FeaLay.MaximumScale = 0;
            }
            else if (this.rdoGroupScale.SelectedIndex == 1)
            {
                m_FeaLay.MinimumScale = double.Parse(txtScaleMin.Text);
                m_FeaLay.MaximumScale = double.Parse(txtScaleMax.Text);
            }

            (m_FeaLay as ILayerGeneralProperties).LayerDescription = txtDescription.Text; //地图描述

            Class.Item item = cboDisplayField.SelectedItem as Class.Item;
            m_FeaLay.DisplayField = item.Value.ToString();                                //主显示字段
            m_FeaLay.Visible      = chkVisible.Checked;                                   //可见性
            (m_FeaLay as ILayerEffects).Transparency = short.Parse(txtTransparency.Text); //透明度

            m_FeaLay.ShowTips = chkShowTip.Checked;                                       //显示主显示字段
            if (m_FeaLay is IGeoFeatureLayer)
            {
                if (chkLabelAll.Checked)
                {
                    ChangeLayerAnno(m_FeaLay);
                }

                (m_FeaLay as IGeoFeatureLayer).DisplayAnnotation = chkLabelAll.Checked; //标注图层中所有要素
            }

            m_FeaLay.ScaleSymbols = chkScaleSymbol.Checked;//符号随比例尺缩放


            ////////字段信息
            m_pTableFields = m_FeaLay as ITableFields;
            for (int i = 0; i < listViewFieldInfo.Nodes.Count; i++)
            {
                int index = m_pTableFields.FindField(listViewFieldInfo.Nodes[i][2].ToString());
                if (index > -1)
                {
                    IFieldInfo pFieldInfo = m_pTableFields.get_FieldInfo(index);
                    pFieldInfo.Visible = listViewFieldInfo.Nodes[i].Checked == true ? true : false;
                }
            }

            if (!CheckCondition(this.m_FeaLay, txtCondition.Text))
            {
                MessageBox.Show("查询条件错误!");
            }
            else
            {
                (this.m_FeaLay as IFeatureLayerDefinition).DefinitionExpression = txtCondition.Text;
                m_MapCtrl.ActiveView.Refresh();
            }

            return(true);
        }
Exemple #7
0
        /// <summary>
        /// 初始化控件
        /// </summary>
        private void initControls()
        {
            IFeatureLayer pFeaLayer = (IFeatureLayer)m_FeaLay;

            if (pFeaLayer == null)
            {
                return;
            }
            IDatasetEditInfo pEdit     = (IDatasetEditInfo)pFeaLayer.FeatureClass;
            ILayerEffects    pLayerEff = (ILayerEffects)m_FeaLay;

            //数据源
            IDataLayer        pDataLayer   = (IDataLayer)m_FeaLay;
            IDatasetName      pDatasetName = pDataLayer.DataSourceName as IDatasetName;
            IWorkspaceName    pWSName      = pDatasetName.WorkspaceName;
            IFeatureClassName pFCName      = pDatasetName as IFeatureClassName;

            string strDataSourceType = "";
            string strFeatureDataSet = "";

            if (pFCName.FeatureDatasetName == null)
            {
                strDataSourceType = "数据类型 :" + "个人空间数据库 要素类";
                strFeatureDataSet = "数 据 集 :" + "无";
            }
            else
            {
                strDataSourceType = "数据类型 :" + pFCName.FeatureDatasetName.Category + "(" + pFeaLayer.DataSourceType + ")";
                strFeatureDataSet = "数 据 集 :" + pFCName.FeatureDatasetName.Name;
            }
            string strFeatureClass = "要 素 类 :" + pDatasetName.Name;
            string strFeatureType  = "要素类型 :" + pFCName.FeatureType.ToString();
            string strGeometyrType = "几何类型 :" + pFCName.ShapeType.ToString();
            string strLocationPath = "位    置 :" + pWSName.PathName;
            string strRelativeBase = "相对路径 :" + pDataLayer.RelativeBase;

            this.txtSoureFile.Text = strDataSourceType + "\r\n" +
                                     strFeatureDataSet + "\r\n" +
                                     strFeatureClass + "\r\n" +
                                     strFeatureType + "\r\n" +
                                     strGeometyrType + "\r\n" +
                                     strRelativeBase + "\r\n" +
                                     strLocationPath;

            this.txtXMin.Text = m_FeaLay.AreaOfInterest.XMin.ToString(".##");
            this.txtXMax.Text = m_FeaLay.AreaOfInterest.XMax.ToString(".##");
            this.txtYMin.Text = m_FeaLay.AreaOfInterest.YMin.ToString(".##");
            this.txtYMax.Text = m_FeaLay.AreaOfInterest.YMax.ToString(".##");

            //基本信息
            this.txtLayerName.Text = m_FeaLay.Name;
            if (pEdit != null)
            {
                this.chkEdit.Checked = pEdit.CanEdit;
            }

            if (m_FeaLay.FeatureClass != null)
            {
                int dfIndex = -1;
                this.chkVisible.Checked = pFeaLayer.Visible;
                this.cboDisplayField.Properties.Items.Clear();

                for (int i = 0; i < m_FeaLay.FeatureClass.Fields.FieldCount; i++)
                {
                    IField pField = m_FeaLay.FeatureClass.Fields.get_Field(i);
                    if (pField.Name == pFeaLayer.DisplayField)
                    {
                        dfIndex = i;
                    }
                    Class.Item item = new Class.Item(pField.AliasName, pField.Name);
                    cboDisplayField.Properties.Items.Add(item);
                }
                this.cboDisplayField.SelectedIndex = dfIndex;
                this.txtTransparency.Text          = pLayerEff.Transparency.ToString();

                //this.txtScaleMin.Text = (pFeaLayer as ILayerGeneralProperties).LastMinimumScale.ToString();
                //this.txtScaleMax.Text = (pFeaLayer as ILayerGeneralProperties).LastMaximumScale.ToString();
                this.txtScaleMin.Text = pFeaLayer.MinimumScale.ToString();
                this.txtScaleMax.Text = pFeaLayer.MaximumScale.ToString();

                this.txtDescription.Text = (pFeaLayer as ILayerGeneralProperties).LayerDescription;
                if (pFeaLayer.MinimumScale == 0 && pFeaLayer.MaximumScale == 0)
                {
                    this.rdoGroupScale.SelectedIndex = 0;
                    txtScaleMin.Enabled = false;
                    txtScaleMax.Enabled = false;
                }
                else
                {
                    this.rdoGroupScale.SelectedIndex = 1;
                    txtScaleMin.Enabled = true;
                    txtScaleMax.Enabled = true;
                }

                chkShowTip.Checked = pFeaLayer.ShowTips;
                if (pFeaLayer is IGeoFeatureLayer)
                {
                    chkLabelAll.Checked = (pFeaLayer as IGeoFeatureLayer).DisplayAnnotation;
                }
                chkScaleSymbol.Checked = pFeaLayer.ScaleSymbols;

                m_pTableFields = pFeaLayer as ITableFields;

                //字段信息
                string strType = "";

                for (int i = 0; i < m_pTableFields.FieldCount; i++)
                {
                    IField     pField     = m_pTableFields.get_Field(i);
                    IFieldInfo pFieldInfo = m_pTableFields.get_FieldInfo(i);

                    switch (pField.Type)//类型
                    {
                    case esriFieldType.esriFieldTypeBlob:
                        strType = "二进制块";
                        break;

                    case esriFieldType.esriFieldTypeDate:
                        strType = "日期型";
                        break;

                    case esriFieldType.esriFieldTypeDouble:
                        strType = "双精度";
                        break;

                    case esriFieldType.esriFieldTypeGeometry:
                        strType = "几何形体";
                        break;

                    case esriFieldType.esriFieldTypeGlobalID:
                        strType = "GlobalID";
                        break;

                    case esriFieldType.esriFieldTypeGUID:
                        strType = "GUID";
                        break;

                    case esriFieldType.esriFieldTypeOID:
                        strType = "OID";
                        break;

                    case esriFieldType.esriFieldTypeRaster:
                        strType = "栅格";
                        break;

                    case esriFieldType.esriFieldTypeSingle:
                        strType = "单精度";
                        break;

                    case esriFieldType.esriFieldTypeSmallInteger:
                        strType = "短整形";
                        break;

                    case esriFieldType.esriFieldTypeString:
                        strType = "字符型";
                        break;
                    }
                    TreeListNode node = this.listViewFieldInfo.Nodes.Add(new object[] { pField.AliasName, pField.Name, strType });
                    node.Checked = pFieldInfo.Visible;
                }

                //初始化过滤条件面板
                initFilterCondition();
            }
        }