コード例 #1
0
ファイル: frmSetLabel.cs プロジェクト: siszoey/geosufan
        private void AddLabel(string StrDisplayField)
        {
            pGeoFeatLayer.DisplayAnnotation = false;
            pMapControl.ActiveView.Refresh();

            pGeoFeatLayer.DisplayField = StrDisplayField;

            IAnnotateLayerPropertiesCollection pAnnoProps = null;

            pAnnoProps = pGeoFeatLayer.AnnotationProperties;

            ILineLabelPosition pPosition = null;

            pPosition          = new LineLabelPositionClass();
            pPosition.Parallel = true;
            pPosition.Above    = true;

            ILineLabelPlacementPriorities    pPlacement = new LineLabelPlacementPrioritiesClass();
            IBasicOverposterLayerProperties4 pBasic     = new BasicOverposterLayerPropertiesClass();

            pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasic.LineLabelPlacementPriorities = pPlacement;
            pBasic.LineLabelPosition            = pPosition;
            pBasic.BufferRatio     = 0;
            pBasic.FeatureWeight   = esriBasicOverposterWeight.esriHighWeight;
            pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart;
            //pBasic.PlaceOnlyInsidePolygon = true;//仅在地物内部显示标注  deleted by chulili s20111018 界面上并没有这项设置,这句话应注释掉,否则像是错误

            ILabelEngineLayerProperties pLabelEngine = null;

            pLabelEngine = new LabelEngineLayerPropertiesClass();
            pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties;
            pLabelEngine.Expression = "[" + StrDisplayField + "]";
            ITextSymbol pTextSymbol = null;

            pTextSymbol = pLabelEngine.Symbol;
            System.Drawing.Font pFont = null;
            pFont = LabelText.Font;
            IFontDisp pFontDisp = ESRI.ArcGIS.ADF.Converter.ToStdFont(pFont);

            pTextSymbol.Font = pFontDisp;

            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = Convert.ToInt32(LabelText.ForeColor.R);
            pColor.Green        = Convert.ToInt32(LabelText.ForeColor.G);
            pColor.Blue         = Convert.ToInt32(LabelText.ForeColor.B);
            pTextSymbol.Color   = pColor as IColor;
            pLabelEngine.Symbol = pTextSymbol;

            IAnnotateLayerProperties pAnnoLayerProps = null;

            pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
            pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            pAnnoProps.Clear();

            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatLayer.DisplayAnnotation = true;
            pMapControl.ActiveView.Refresh();
        }
コード例 #2
0
        public void labeling(IGeoFeatureLayer _iGeoFLayer, string _labelFuc, double _maxScale, double _minScale, bool _showMapTips, bool _displayAnnotation, IActiveView _aView)
        {
            RgbColor _labelColor = new RgbColor();

            _labelColor.RGB = Microsoft.VisualBasic.Information.RGB(0, 0, 0);
            IAnnotateLayerPropertiesCollection propertiesColl        = _iGeoFLayer.AnnotationProperties;
            IAnnotateLayerProperties           labelEngineProperties = new LabelEngineLayerProperties() as IAnnotateLayerProperties;
            IElementCollection placedElements   = new ElementCollection();
            IElementCollection unplacedElements = new ElementCollection();

            propertiesColl.QueryItem(0, out labelEngineProperties, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties lpLabelEngine = labelEngineProperties as ILabelEngineLayerProperties;

            lpLabelEngine.Expression   = _labelFuc;
            lpLabelEngine.Symbol.Color = _labelColor;
            labelEngineProperties.AnnotationMaximumScale = _maxScale; // closer
            labelEngineProperties.AnnotationMinimumScale = _minScale; // further
            IFeatureLayer  thisFeatureLayer         = _iGeoFLayer as IFeatureLayer;
            IDisplayString displayString            = thisFeatureLayer as IDisplayString;
            IDisplayExpressionProperties properties = displayString.ExpressionProperties;

            properties.Expression         = _labelFuc; //example: "[OWNER_NAME] & vbnewline & \"$\" & [TAX_VALUE]";
            _iGeoFLayer.DisplayAnnotation = _displayAnnotation;

            // refresh map window
            _aView.Refresh();
        }
コード例 #3
0
 public AnnotationClass(IFeatureLayer pFeatureLayer)
 {
     if (pFeatureLayer != null)
     {
         if (pFeatureLayer is IGeoFeatureLayer)
         {
             IGeoFeatureLayer objGFL = pFeatureLayer as IGeoFeatureLayer;
             IAnnotateLayerPropertiesCollection annoPropsColl = objGFL.AnnotationProperties;
             if (objGFL.DisplayAnnotation && annoPropsColl.Count > 0)
             {
                 IAnnotateLayerProperties             annoLayerProps = null;
                 ESRI.ArcGIS.Carto.IElementCollection null_ESRIArcGISCartoIElementCollection  = null;
                 ESRI.ArcGIS.Carto.IElementCollection null_ESRIArcGISCartoIElementCollection2 = null;
                 annoPropsColl.QueryItem(0, out annoLayerProps, out null_ESRIArcGISCartoIElementCollection, out null_ESRIArcGISCartoIElementCollection2);
                 if (annoLayerProps is ILabelEngineLayerProperties && annoLayerProps.DisplayAnnotation)
                 {
                     ILabelEngineLayerProperties labelProps = annoLayerProps as ILabelEngineLayerProperties;
                     if (annoLayerProps.WhereClause == "" && labelProps.IsExpressionSimple)
                     {
                         IsSingleProperty = true;
                         PropertyName     = labelProps.Expression.Replace("[", "").Replace("]", "");
                         TextSymbol       = new TextSymbolClass(labelProps.Symbol as ISymbol);
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// 创建标注
        /// </summary>
        /// <param name="feaName"></param>
        /// <param name="featureDataset"></param>
        /// <param name="feaworkspace"></param>
        /// <param name="fsEditAnno"></param>
        /// <param name="intScale"></param>
        public void createAnnoFeatureClass(string feaName, IFeatureDataset featureDataset, IFeatureWorkspace feaworkspace, IFieldsEdit fsEditAnno, int intScale)
        {
            //创建注记的特殊字段
            try
            {
                //注记的workSpace
                IFeatureWorkspaceAnno pFWSAnno = feaworkspace as IFeatureWorkspaceAnno; //标注操作空间

                IGraphicsLayerScale pGLS = new GraphicsLayerScaleClass();               //图形比例接口
                pGLS.Units          = esriUnits.esriMeters;                             //图形比例设定
                pGLS.ReferenceScale = Convert.ToDouble(intScale);                       //创建注记必须要设置比例尺

                IFormattedTextSymbol myTextSymbol = new TextSymbolClass();              //文本格式接口
                ISymbol pSymbol = (ISymbol)myTextSymbol;                                //标记
                //Anno要素类必须有的缺省符号
                ISymbolCollection2 pSymbolColl = new SymbolCollectionClass();
                ISymbolIdentifier2 pSymID      = new SymbolIdentifierClass();
                pSymbolColl.AddSymbol(pSymbol, "Default", out pSymID);

                //Anno要素类的必要属性
                IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
                pAnnoProps.CreateUnplacedElements = true;
                pAnnoProps.CreateUnplacedElements = true;
                pAnnoProps.DisplayAnnotation      = true;
                pAnnoProps.UseOutput = true;

                ILabelEngineLayerProperties pLELayerProps = (ILabelEngineLayerProperties)pAnnoProps;
                pLELayerProps.Symbol             = pSymbol as ITextSymbol;
                pLELayerProps.SymbolID           = 0;
                pLELayerProps.IsExpressionSimple = true;
                pLELayerProps.Offset             = 0;
                pLELayerProps.SymbolID           = 0;

                IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
                pLELayerProps.ExpressionParser = aAnnoVBScriptEngine;
                pLELayerProps.Expression       = "[DESCRIPTION]";
                IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
                pATP.ReferenceScale = pGLS.ReferenceScale;
                pATP.ScaleRatio     = 1;

                IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
                pAnnoPropsColl.Add(pAnnoProps);

                IObjectClassDescription pOCDesc = new AnnotationFeatureClassDescription();
                IFields fields = pOCDesc.RequiredFields;
                IFeatureClassDescription pFDesc = pOCDesc as IFeatureClassDescription;

                for (int j = 0; j < pOCDesc.RequiredFields.FieldCount; j++)
                {
                    fsEditAnno.AddField(pOCDesc.RequiredFields.get_Field(j));
                }
                fields = fsEditAnno as IFields;
                pFWSAnno.CreateAnnotationClass(feaName, fields, pOCDesc.InstanceCLSID, pOCDesc.ClassExtensionCLSID, pFDesc.ShapeFieldName, "", featureDataset, null, pAnnoPropsColl, pGLS, pSymbolColl, true);
            }
            catch
            {
            }
        }
コード例 #5
0
        private IFeatureClass method_1(IFeatureWorkspace ifeatureWorkspace_0, string string_4, double double_0,
                                       ITextSymbol itextSymbol_0, IFields ifields_0)
        {
            IObjectClassDescription  description  = new AnnotationFeatureClassDescriptionClass();
            IFeatureClassDescription description2 = description as IFeatureClassDescription;
            IClone     requiredFields             = description.RequiredFields as IClone;
            IFields    fields = requiredFields.Clone() as IFields;
            IFieldEdit edit   = null;
            int        index  = fields.FindField(description2.ShapeFieldName);

            edit = fields.get_Field(index) as IFieldEdit;
            IGeometryDefEdit      geometryDef    = edit.GeometryDef as IGeometryDefEdit;
            IFeatureWorkspaceAnno anno           = ifeatureWorkspace_0 as IFeatureWorkspaceAnno;
            IGraphicsLayerScale   referenceScale = new GraphicsLayerScaleClass
            {
                ReferenceScale = double_0,
                Units          = esriUnits.esriMeters
            };
            UID instanceCLSID                  = description.InstanceCLSID;
            UID classExtensionCLSID            = description.ClassExtensionCLSID;
            ISymbolCollection symbolCollection = new SymbolCollectionClass();

            symbolCollection.set_Symbol(0, itextSymbol_0 as ISymbol);
            IAnnotateLayerPropertiesCollection2 annoProperties = new AnnotateLayerPropertiesCollectionClass();
            IAnnotateLayerProperties            item           = new LabelEngineLayerPropertiesClass
            {
                Class         = "要素类 1",
                FeatureLinked = false,
                AddUnplacedToGraphicsContainer = false,
                CreateUnplacedElements         = true,
                DisplayAnnotation = true,
                UseOutput         = true
            };
            ILabelEngineLayerProperties properties2 = item as ILabelEngineLayerProperties;

            properties2.Offset   = 0.0;
            properties2.SymbolID = 0;
            properties2.Symbol   = itextSymbol_0;
            annoProperties.Add(item);
            for (int i = 0; i < ifields_0.FieldCount; i++)
            {
                if (fields.FindField(ifields_0.get_Field(i).Name) == -1)
                {
                    (fields as IFieldsEdit).AddField(ifields_0.get_Field(i));
                }
            }
            try
            {
                return(anno.CreateAnnotationClass(string_4, fields, instanceCLSID, classExtensionCLSID,
                                                  description2.ShapeFieldName, "", null, null, annoProperties, referenceScale, symbolCollection, false));
            }
            catch (Exception exception)
            {
                Logger.Current.Error("", exception, "");
            }
            return(null);
        }
コード例 #6
0
ファイル: AnnoClassSetCtrl.cs プロジェクト: secondii/Yutai
        private void btnNew_Click(object sender, EventArgs e)
        {
            frmInput input = new frmInput("名称:", "")
            {
                Text = "输入"
            };

            if (input.ShowDialog() == DialogResult.OK)
            {
                if (input.InputValue.Trim().Length == 0)
                {
                    MessageBox.Show("非法类名!");
                }
                else
                {
                    ISymbolIdentifier2 identifier;
                    for (int i = 0; i < this.listBoxControl1.Items.Count; i++)
                    {
                        SymbolIdentifierWrap wrap = this.listBoxControl1.Items[i] as SymbolIdentifierWrap;
                        if (wrap.AnnotateLayerProperties.Class == input.InputValue)
                        {
                            MessageBox.Show("类名必须唯一!");
                            return;
                        }
                    }
                    ITextSymbol symbol   = new TextSymbolClass();
                    int         symbolID = this.method_4(NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl);
                    NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl.set_Symbol(symbolID, symbol as ISymbol);
                    IAnnotateLayerProperties item = new LabelEngineLayerPropertiesClass
                    {
                        Class         = input.InputValue,
                        FeatureLinked = NewObjectClassHelper.m_pObjectClassHelper.IsRelatedFeature,
                        AddUnplacedToGraphicsContainer = false,
                        CreateUnplacedElements         = true,
                        DisplayAnnotation = true,
                        UseOutput         = true
                    };
                    ILabelEngineLayerProperties properties2 = item as ILabelEngineLayerProperties;
                    if (NewObjectClassHelper.m_pObjectClassHelper.IsRelatedFeature)
                    {
                        new AnnotationVBScriptEngineClass();
                        IFeatureClass relatedFeatureClass =
                            NewObjectClassHelper.m_pObjectClassHelper.RelatedFeatureClass;
                        properties2.Expression         = "[" + relatedFeatureClass.ObjectClassID + "]";
                        properties2.IsExpressionSimple = true;
                    }
                    properties2.Offset   = 0.0;
                    properties2.SymbolID = symbolID;
                    properties2.Symbol   = symbol;
                    NewObjectClassHelper.m_pObjectClassHelper.m_pAnnoPropertiesColn.Add(item);
                    NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl.GetSymbolIdentifier(symbolID, out identifier);
                    this.listBoxControl1.Items.Add(new SymbolIdentifierWrap(item, identifier));
                }
            }
        }
コード例 #7
0
ファイル: AnnoClassSetCtrl.cs プロジェクト: secondii/Yutai
 public void Init()
 {
     if (NewObjectClassHelper.m_pObjectClassHelper.IsRelatedFeature)
     {
         this.panel1.Visible = false;
         this.panel2.Visible = true;
     }
     else
     {
         this.panel2.Visible = false;
         this.panel1.Visible = true;
     }
     if (NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl.Count == 0)
     {
         ITextSymbol symbol = new TextSymbolClass();
         NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl.set_Symbol(0, symbol as ISymbol);
         IAnnotateLayerProperties item = new LabelEngineLayerPropertiesClass
         {
             Class         = "要素类 1",
             FeatureLinked = NewObjectClassHelper.m_pObjectClassHelper.IsRelatedFeature,
             AddUnplacedToGraphicsContainer = false,
             CreateUnplacedElements         = true,
             DisplayAnnotation = true,
             UseOutput         = true
         };
         ILabelEngineLayerProperties properties2 = item as ILabelEngineLayerProperties;
         if (NewObjectClassHelper.m_pObjectClassHelper.IsRelatedFeature)
         {
             new AnnotationVBScriptEngineClass();
             IFeatureClass relatedFeatureClass = NewObjectClassHelper.m_pObjectClassHelper.RelatedFeatureClass;
             properties2.Expression         = "[" + relatedFeatureClass.ObjectClassID + "]";
             properties2.IsExpressionSimple = true;
         }
         properties2.Offset   = 0.0;
         properties2.SymbolID = 0;
         properties2.Symbol   = symbol;
         NewObjectClassHelper.m_pObjectClassHelper.m_pAnnoPropertiesColn.Add(item);
     }
     this.listBoxControl1.Items.Clear();
     for (int i = 0; i < NewObjectClassHelper.m_pObjectClassHelper.m_pAnnoPropertiesColn.Count; i++)
     {
         IAnnotateLayerProperties properties3;
         int num2;
         ISymbolIdentifier2 identifier;
         NewObjectClassHelper.m_pObjectClassHelper.m_pAnnoPropertiesColn.QueryItem(i, out properties3, out num2);
         NewObjectClassHelper.m_pObjectClassHelper.m_pSymbolColl.GetSymbolIdentifier(num2, out identifier);
         this.listBoxControl1.Items.Add(new SymbolIdentifierWrap(properties3, identifier));
     }
     this.listBoxControl1.SelectedIndex = 0;
 }
コード例 #8
0
        private void btnAddClass_Click(object sender, EventArgs e)
        {
            frmInput input = new frmInput("类名称:", "");

            if (input.ShowDialog() == DialogResult.OK)
            {
                if (input.InputValue.Trim().Length == 0)
                {
                    MessageBox.Show("非法类名!");
                }
                else
                {
                    for (int i = 0; i < this.cboClass.Properties.Items.Count; i++)
                    {
                        AnnotateLayerPropertiesWrap wrap =
                            this.cboClass.Properties.Items[i] as AnnotateLayerPropertiesWrap;
                        if (wrap.AnnotateLayerProperties.Class == input.InputValue)
                        {
                            MessageBox.Show("类名必须唯一!");
                            return;
                        }
                    }
                    IAnnotateLayerProperties properties = new LabelEngineLayerPropertiesClass
                    {
                        Class         = input.InputValue,
                        FeatureLinked = this.iannotateLayerProperties_0.FeatureLinked,
                        FeatureLayer  = this.iannotateLayerProperties_0.FeatureLayer,
                        AddUnplacedToGraphicsContainer = this.iannotateLayerProperties_0.AddUnplacedToGraphicsContainer,
                        AnnotationMaximumScale         = this.iannotateLayerProperties_0.AnnotationMaximumScale,
                        AnnotationMinimumScale         = this.iannotateLayerProperties_0.AnnotationMinimumScale,
                        CreateUnplacedElements         = this.iannotateLayerProperties_0.CreateUnplacedElements,
                        DisplayAnnotation  = this.iannotateLayerProperties_0.DisplayAnnotation,
                        LabelWhichFeatures = this.iannotateLayerProperties_0.LabelWhichFeatures,
                        Priority           = this.iannotateLayerProperties_0.Priority,
                        UseOutput          = this.iannotateLayerProperties_0.UseOutput,
                        WhereClause        = this.iannotateLayerProperties_0.WhereClause
                    };
                    ILabelEngineLayerProperties properties2 = properties as ILabelEngineLayerProperties;
                    ILabelEngineLayerProperties properties3 =
                        this.iannotateLayerProperties_0 as ILabelEngineLayerProperties;
                    properties2.Expression         = properties3.Expression;
                    properties2.IsExpressionSimple = properties3.IsExpressionSimple;
                    int num2 = this.method_2();
                    properties2.SymbolID = num2;
                    properties2.Symbol   = (properties3.Symbol as IClone).Clone() as ITextSymbol;
                    this.cboClass.Properties.Items.Add(new AnnotateLayerPropertiesWrap(properties, num2, true));
                    this.bool_3 = true;
                }
            }
        }
コード例 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string str = this.txtClassName.Text.Trim();

            if (str.Length != 0)
            {
                if (this.method_0(str))
                {
                    MessageBox.Show("类名已存在!");
                }
                else
                {
                    IAnnotateLayerProperties properties;
                    int num;
                    this.iannotateLayerPropertiesCollection2_0.QueryItem(0, out properties, out num);
                    IAnnotateLayerProperties properties2 = new LabelEngineLayerPropertiesClass
                    {
                        Class         = str,
                        FeatureLinked = properties.FeatureLinked,
                        FeatureLayer  = properties.FeatureLayer,
                        AddUnplacedToGraphicsContainer = properties.AddUnplacedToGraphicsContainer,
                        AnnotationMaximumScale         = properties.AnnotationMaximumScale,
                        AnnotationMinimumScale         = properties.AnnotationMinimumScale,
                        CreateUnplacedElements         = properties.CreateUnplacedElements,
                        DisplayAnnotation  = properties.DisplayAnnotation,
                        LabelWhichFeatures = properties.LabelWhichFeatures,
                        Priority           = properties.Priority,
                        UseOutput          = properties.UseOutput,
                        WhereClause        = properties.WhereClause
                    };
                    ILabelEngineLayerProperties properties3 = properties2 as ILabelEngineLayerProperties;
                    ILabelEngineLayerProperties properties4 = properties as ILabelEngineLayerProperties;
                    properties3.Expression         = properties4.Expression;
                    properties3.IsExpressionSimple = properties4.IsExpressionSimple;
                    num = this.method_1();
                    properties3.SymbolID = num;
                    properties3.Symbol   = (properties4.Symbol as IClone).Clone() as ITextSymbol;
                    TreeNode node = new TreeNode(str)
                    {
                        Checked = properties2.DisplayAnnotation,
                        Tag     = new frmLabelManager.AnnotateLayerPropertiesWrap(properties2, num, true)
                    };
                    this.treeNode_0.Nodes.Add(node);
                }
            }
        }
コード例 #10
0
        private void SetLabelExpressionOnFeatureLayer(IFeatureLayer FeatLayer, out bool LabelExcluded)
        {
            string s = "";

            LabelExcluded = false;
            if (FeatLayer is IGeoFeatureLayer)
            {
                IGeoFeatureLayer pGeoFeatLyr = (IGeoFeatureLayer)FeatLayer;
                IAnnotateLayerPropertiesCollection pAnnoLyrPropsColl = pGeoFeatLyr.AnnotationProperties;
                IAnnotateLayerProperties           pAnnoLyrProps; IElementCollection obj1; IElementCollection obj2;
                pAnnoLyrPropsColl.QueryItem(0, out pAnnoLyrProps, out obj1, out obj2);
                ILabelEngineLayerProperties LblEngProp = (ILabelEngineLayerProperties)pAnnoLyrProps;

                s = LblEngProp.Expression.ToLower();
                if (FeatLayer.FeatureClass.LengthField.Name.ToLower().Contains("st_length"))
                { //exclude the label on function generated field shape_length
                    if (s.Contains("shape_length"))
                    {
                        LblEngProp.IsExpressionSimple = true;
                        LblEngProp.Expression         = "";
                        LabelExcluded = true;
                        return;
                    }
                }

                LblEngProp.Expression = s.Replace("shape_length", FeatLayer.FeatureClass.LengthField.Name);

                IFeatureClass pFC = FeatLayer.FeatureClass;
                int           iFld1 = pFC.Fields.FindField("shapestderrore");
                if (iFld1 > -1)
                {
                    string s1 = pFC.Fields.get_Field(iFld1).Name;
                    s = LblEngProp.Expression;
                    LblEngProp.Expression = s.Replace("shapestderrore", s1);
                }

                int iFld2 = pFC.Fields.FindField("shapestderrorn");
                if (iFld2 > -1)
                {
                    s = LblEngProp.Expression;
                    string s2 = pFC.Fields.get_Field(iFld2).Name;
                    LblEngProp.Expression = s.Replace("shapestderrorn", s2);
                }
            }
        }
コード例 #11
0
        private void ExportSLD(bool labelStatus)
        {
            if (labelStatus == true)
            {
                annotateLPC = geoFeatureLayer.AnnotationProperties;
                annotateLPC.QueryItem(0, out annotateLP, out elementCol, out elementCol2);
                leProps         = (ILabelEngineLayerProperties)annotateLP;
                labelField      = leProps.Expression.Replace(@"[", "").Replace(@"]", "");
                textSymbol      = leProps.Symbol;
                labelFont       = textSymbol.Font;
                labelFontFamily = labelFont.Name;
                labelSize       = textSymbol.Size.ToString().Replace(",", ".");

                simpleSldXmlWithLabel = String.Format(SLDExporterResource.SimpleSLDwithLabel, textBoxGSsldName.Text, fillColorHEX, outlineColorHEX, outlineWidth, labelField, labelFontFamily, labelSize);
            }
            else
            {
                simpleSldXmlWithoutLabel = String.Format(SLDExporterResource.SimpleSLDwithoutLabel, textBoxGSsldName.Text, fillColorHEX, outlineColorHEX, outlineWidth);
            }
        }
コード例 #12
0
ファイル: FrmCountySheet.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// ÉèÖÃÊôÐÔ±ê×¢
        /// </summary>
        /// <param name="pGeoFeatureLayer">ͼ²ã</param>
        /// <param name="vLabelField">ÊôÐÔ×Ö¶Î</param>
        /// <param name="vMapFrameScale">ͼ²ã±ÈÀý³ß</param>
        /// <param name="vMapRefrenceScale">²Î¿¼±ÈÀý³ß</param>
        private void SetLableToGeoFeatureLayer(IGeoFeatureLayer pGeoFeatureLayer, string vLabelField, int vMapFrameScale, double vMapRefrenceScale)
        {
            IAnnotateLayerPropertiesCollection pAnnoLayerProperCol = pGeoFeatureLayer.AnnotationProperties;
            IAnnotateLayerProperties           pAnnoLayerProper;
            IElementCollection placedElements;
            IElementCollection unplacedElements;

            //µÃµ½µ±Ç°²ãµÄµ±Ç°±ê×¢ÊôÐÔ
            pAnnoLayerProperCol.QueryItem(0, out pAnnoLayerProper, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties      pLabelEngineLayerProper     = (ILabelEngineLayerProperties)pAnnoLayerProper;
            IBasicOverposterLayerProperties4 pBasicOverposterLayerProper = (IBasicOverposterLayerProperties4)pLabelEngineLayerProper.BasicOverposterLayerProperties;
            //±ê×¢µÄ×ÖÌå
            ITextSymbol pTextSymbol = pLabelEngineLayerProper.Symbol;
            IRgbColor   pRGBColor   = new RgbColorClass();

            pRGBColor.Red     = 0;
            pRGBColor.Blue    = 255;
            pRGBColor.Green   = 0;
            pTextSymbol.Color = pRGBColor;
            stdole.StdFont pStdFont = new stdole.StdFontClass();
            IFontDisp      pFont    = (IFontDisp)pStdFont;

            pFont.Name = "ËÎÌå";
            if (vMapRefrenceScale != 0)
            {
                double size = (vMapFrameScale / 3) * vMapFrameScale / vMapRefrenceScale;
                pFont.Size = (decimal)size;
            }
            pTextSymbol.Font = pFont;
            //±ê×¢ÄÚÈÝ
            pLabelEngineLayerProper.Expression          = "[" + vLabelField + "]";
            pBasicOverposterLayerProper.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart;
            //±ê×¢µÄ·½ÏòÐÅÏ¢
            pBasicOverposterLayerProper.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysHorizontal;
            //±ê×¢µÄÓ뼸ºÎͼÐεĴóС¹Øϵ
            pBasicOverposterLayerProper.PlaceOnlyInsidePolygon = false;
            //¿ªÆô±ê×¢
            pGeoFeatureLayer.DisplayAnnotation = true;
        }
コード例 #13
0
        /// <summary>
        /// 设置图层
        /// </summary>
        private void DoApply()
        {
            IFeatureLayer           featureLayer    = (IFeatureLayer)m_layer;
            IGeoFeatureLayer        geoLayer        = (IGeoFeatureLayer)m_layer;
            IFeatureClass           featureClass    = featureLayer.FeatureClass;
            ILayerGeneralProperties layerProperties = (ILayerGeneralProperties)featureLayer;

            // 图层属性页
            String tmp = this.textBoxLayerName.Text.Trim();

            if (!String.IsNullOrEmpty(tmp))
            {
                m_layer.Name = tmp;
            }
            tmp = layerProperties.LayerDescription.Trim();
            layerProperties.LayerDescription = tmp;
            m_layer.Visible = this.checkBoxVisibility.Checked;

            if (this.radioButtonScaleAll.Checked)
            {
                geoLayer.MaximumScale = 0;
                geoLayer.MinimumScale = 0;
            }
            else
            {
                tmp = this.comboBoxScaleMax.Text.Trim();
                double d = 0;
                if (Double.TryParse(tmp, out d))
                {
                    geoLayer.MaximumScale = d;
                }
                else
                {
                    geoLayer.MaximumScale = 0;
                }
                tmp = this.comboBoxScaleMin.Text.Trim();
                if (Double.TryParse(tmp, out d))
                {
                    geoLayer.MinimumScale = d;
                }
                else
                {
                    geoLayer.MinimumScale = 0;
                }
            }

            // 标注
            IAnnotateLayerPropertiesCollection annoLayerPropsColl = geoLayer.AnnotationProperties;
            IAnnotateLayerProperties           annoLayerProps     = null;
            IElementCollection placedElements   = null;
            IElementCollection unplacedElements = null;

            annoLayerPropsColl.QueryItem(0, out annoLayerProps, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties aLELayerProps = annoLayerProps as ILabelEngineLayerProperties;

            annoLayerProps.DisplayAnnotation = checkBoxLabelVisibility.Checked;
            if (annoLayerProps.DisplayAnnotation)
            {
                // cmbFontName.Text = "宋体";
                ITextSymbol      textSymbol = aLELayerProps.Symbol;
                stdole.IFontDisp fontDisp   = textSymbol.Font;
                decimal          d          = 8;
                if (decimal.TryParse(cmbFontSize.Text, out d))
                {
                    fontDisp.Size = d;
                }

                fontDisp.Bold      = toolBarStyle.Buttons[0].Pushed;
                fontDisp.Italic    = toolBarStyle.Buttons[1].Pushed;
                fontDisp.Underline = toolBarStyle.Buttons[2].Pushed;
                fontDisp.Name      = cmbFontName.Text;
                IRgbColor rgbColor = new RgbColorClass();
                rgbColor.Transparency             = this.colorButtonFont.Color.A;
                rgbColor.Red                      = this.colorButtonFont.Color.R;
                rgbColor.Green                    = this.colorButtonFont.Color.G;
                rgbColor.Blue                     = this.colorButtonFont.Color.B;
                textSymbol.Color                  = rgbColor;
                textSymbol.Font                   = fontDisp;
                aLELayerProps.Symbol              = textSymbol;
                annoLayerProps                    = aLELayerProps as IAnnotateLayerProperties;
                annoLayerProps.FeatureLayer       = geoLayer;
                annoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
                // annoLayerPropsColl.Add(annoLayerProps);

                if (cmbFieldName.SelectedIndex == -1)
                {
                    aLELayerProps.IsExpressionSimple = false;
                }
                else
                {
                    aLELayerProps.IsExpressionSimple = true;
                    String expr = "[" + cmbFieldName.Items[cmbFieldName.SelectedIndex] + "]";
                    aLELayerProps.Expression = expr;
                }

                if (this.rbScaleWithLayer.Checked)
                {
                    annoLayerProps.AnnotationMaximumScale = 0;
                    annoLayerProps.AnnotationMinimumScale = 0;
                }
                else
                {
                    double dTmp = 0;
                    if (double.TryParse(cmbMaxScale.Text, out dTmp))
                    {
                        annoLayerProps.AnnotationMaximumScale = dTmp;
                    }
                    dTmp = 0;
                    if (double.TryParse(cmbMinScale.Text, out dTmp))
                    {
                        annoLayerProps.AnnotationMinimumScale = dTmp;
                    }
                }


                //ITextSymbol pTextSymbol = aLELayerProps.Symbol;
                //stdole.IFontDisp pFontDisp = pTextSymbol.Font;
                //pFontDisp.Size = decimal.Parse(fontSize);
                //pFontDisp.Bold = boldBool;
                //pFontDisp.Italic = italicBool;
                //pFontDisp.Name = fontStyle;
                //IRgbColor pRgbColor = new RgbColorClass();
                //pRgbColor.Red = int.Parse(fontColor.R.ToString());
                //pRgbColor.Blue = int.Parse(fontColor.B.ToString());
                //pRgbColor.Green = int.Parse(fontColor.G.ToString());
                //pTextSymbol.Font = pFontDisp;
                //pTextSymbol.Color = pRgbColor;
                //aLELayerProps.Symbol = pTextSymbol;
                //annoLayerProps = aLELayerProps as IAnnotateLayerProperties;
                //annoLayerProps.FeatureLayer = geoLayer;
                //annoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
                //annoLayerPropsColl.Add(annoLayerProps);
            }

            // 符号
            EPSUtils.RendererFeatureLayer(featureLayer, checkBoxCostomSymbol.Checked);
            MapUtils.GetActiveView().Refresh();
        }
コード例 #14
0
ファイル: FrmLabelDesign.cs プロジェクト: eglrp/TESTPROJECT-1
        private void FrmLabelDesign_Load(object sender, EventArgs e)
        {
            IGeoFeatureLayer geoFeatureLayer              = (IGeoFeatureLayer)pLayer;
            IAnnotateLayerPropertiesCollection  pAnnColl  = geoFeatureLayer.AnnotationProperties;
            IAnnotateLayerPropertiesCollection2 pAnnColl2 = (IAnnotateLayerPropertiesCollection2)pAnnColl;
            IAnnotateLayerProperties            pAnnProp  = pAnnColl2.get_Properties(0);
            ILabelEngineLayerProperties         pLable    = (ILabelEngineLayerProperties)pAnnProp;
            IBasicOverposterLayerProperties4    pBasic    = (IBasicOverposterLayerProperties4)pLable.BasicOverposterLayerProperties;

            //IPointPlacementPriorities pPlace = pBasic.PointPlacementPriorities;

            chklabel.Checked = pAnnProp.DisplayAnnotation;
            ITable  pTable  = (ITable)pLayer;
            IFields pFields = pTable.Fields;

            for (int i = 0; i < pFields.FieldCount; i++)
            {
                if (pFields.Field[i].Name != "Shape")
                {
                    cmbfields.Items.Add(pFields.Field[i].Name);
                }
            }
            //if (chklabel.Checked)
            //{
            //    cmbfields.Text = pLable.Expression;
            //}
            //else
            //{
            //    cmbfields.SelectedIndex = 0;
            //}
            cmbfields.Text = pLable.Expression;

            InstalledFontCollection pFontCollection = new InstalledFontCollection();

            FontFamily[] pFontFamily = pFontCollection.Families;
            for (int i = 0; i < pFontFamily.Length; i++)
            {
                string pFontName = pFontFamily[i].Name;
                this.cmbfont.Items.Add(pFontName);
            }

            //标注方向
            ILineLabelPosition pLineLabelPosition = pBasic.LineLabelPosition;

            if (pLineLabelPosition != null)
            {
                if (pLineLabelPosition.Horizontal)  //水平
                {
                    radioBtnHorizontal.Checked    = true;
                    radioBtnParallel.Checked      = false;
                    radioBtnPerpendicular.Checked = false;
                }
                if (pLineLabelPosition.Perpendicular)//垂直
                {
                    radioBtnHorizontal.Checked    = false;
                    radioBtnParallel.Checked      = false;
                    radioBtnPerpendicular.Checked = true;
                }
                if (pLineLabelPosition.Parallel)//平行
                {
                    radioBtnHorizontal.Checked    = false;
                    radioBtnParallel.Checked      = true;
                    radioBtnPerpendicular.Checked = false;
                }
            }

            if (pLable.Symbol != null)
            {
                pTextSymbol = pLable.Symbol;
                stdole.IFontDisp pFont = pTextSymbol.Font;
                symbolcolor.SelectedColor = ClsGDBDataCommon.IColorToColor(pTextSymbol.Color);
                //cmbfont.Text = pTextSymbol.Font.Name;
                for (int i = 0; i < cmbfont.Items.Count; i++)
                {
                    if (cmbfont.Items[i].ToString() == pTextSymbol.Font.Name)
                    {
                        cmbfont.SelectedIndex = i;
                    }
                }
                cmbsize.Text = pTextSymbol.Size.ToString();
                if (pFont.Bold == true)
                {
                    toolBtnBold.Checked = true;
                }
                else
                {
                    toolBtnBold.Checked = false;
                }
                if (pFont.Italic == true)
                {
                    toolBtnIntend.Checked = true;
                }
                else
                {
                    toolBtnIntend.Checked = false;
                }
                if (pFont.Underline == true)
                {
                    toolBtnUnderline.Checked = true;
                }
                else
                {
                    toolBtnUnderline.Checked = false;
                }
                if (pFont.Strikethrough == true)
                {
                    toolBtnStrikethrough.Checked = true;
                }
                else
                {
                    toolBtnStrikethrough.Checked = false;
                }
            }
            else
            {
                symbolcolor.SelectedColor = Color.Black;
                cmbfont.SelectedIndex     = cmbfont.Items.Count - 9;
                cmbsize.Text                 = "8";
                toolBtnBold.Checked          = false;
                toolBtnIntend.Checked        = false;
                toolBtnUnderline.Checked     = false;
                toolBtnStrikethrough.Checked = false;
            }
        }
コード例 #15
0
        private IFeatureClass CreateFeatureClass(IFeatureDataset featureDataset,TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode) 
        {
            try
            {
                if (featureDataset != null)
                {
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
         
                    ///创建数据表字段
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IEnumFieldError enumFieldError = null;
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///字段信息验证
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = featureDataset.Workspace;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ////创建FeatureClass
                    IFeatureClass featureClass = null;
                    if (tableStructureNode.IsGeometryTable)
                    {
                        ////创建非注记FeatureClass
                        if (featureCodeNode.GeometryType != "")
                        {
                            featureClass = featureDataset.CreateFeatureClass(featureCodeNode.TableName,
                               fixFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID,
                               esriFeatureType.esriFTSimple, fcDesc.ShapeFieldName, "");
                        }
                        else
                        {
                            ///创建注记
                            IFormattedTextSymbol pTxtSymbo=new TextSymbolClass();

                            IFeatureWorkspaceAnno pFeatureWorkspaceAnno = this.m_pIDataset.Workspace as IFeatureWorkspaceAnno;

                            IGraphicsLayerScale pGraphSacle = new GraphicsLayerScaleClass();
                            pGraphSacle.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            //pGraphSacle.ReferenceScale=1000;


                            ISymbolCollection pSymbolCollection = new SymbolCollectionClass();

                            IAnnotateLayerProperties pAnnoLayerProp = new LabelEngineLayerPropertiesClass();
                            pAnnoLayerProp.FeatureLinked = true;
                            pAnnoLayerProp.CreateUnplacedElements = false;
                            pAnnoLayerProp.DisplayAnnotation = true;
                            pAnnoLayerProp.UseOutput = true;

                            IAnnotationExpressionEngine pAnnoExpressionEngine =new AnnotationVBScriptEngineClass();
                            ILabelEngineLayerProperties pLabelEngineLayerProperties = pAnnoLayerProp as ILabelEngineLayerProperties;
                            pLabelEngineLayerProperties.ExpressionParser = pAnnoExpressionEngine;
                            pLabelEngineLayerProperties.Expression = "[DESCRIPTION]";
                            pLabelEngineLayerProperties.IsExpressionSimple = true;
                            pLabelEngineLayerProperties.Offset = 0;
                            pLabelEngineLayerProperties.SymbolID = 0;
                            pLabelEngineLayerProperties.Symbol = pTxtSymbo;

                            IAnnotateLayerTransformationProperties pAnnoLayerTransProp = pAnnoLayerProp as IAnnotateLayerTransformationProperties;
                            pAnnoLayerTransProp.ReferenceScale=200;
                            pAnnoLayerTransProp.Units= ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            pAnnoLayerTransProp.ScaleRatio=1;

                            IAnnotateLayerPropertiesCollection pAnnoLayerProptyCollection =new AnnotateLayerPropertiesCollectionClass();
                           pAnnoLayerProptyCollection.Add(pAnnoLayerProp);

                           featureClass= pFeatureWorkspaceAnno.CreateAnnotationClass(featureCodeNode.TableName,fixFields,ocDesc.InstanceCLSID
                               ,ocDesc.ClassExtensionCLSID,fcDesc.ShapeFieldName,"",featureDataset,null,
                               pAnnoLayerProptyCollection, pGraphSacle, pSymbolCollection,true);
                        }
                    }
                    else
                    {
                        ///创建非空间数据
                    }
                    return featureClass;
                }
                return null;
            }
            catch(Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }
コード例 #16
0
ファイル: ModuleLabel.cs プロジェクト: radtek/geosufan
        /// <summary>
        /// 从图层对应节点的XML中读取当前层的标注设置
        /// </summary>
        /// <param name="pAnnoLayerProper"></param>
        public static void ReadLabelConfigFromXML(ref IAnnotateLayerProperties pAnnoLayerProper, XmlNode nodeLayerXml, string pFeatureType)
        {
            //设置标注的相关信息             ;
            ILabelEngineLayerProperties pLabelEngineLayerProperties = null;

            if (pAnnoLayerProper == null)
            {
                pLabelEngineLayerProperties = new LabelEngineLayerProperties() as ILabelEngineLayerProperties;
                pAnnoLayerProper            = pLabelEngineLayerProperties as IAnnotateLayerProperties;
            }
            else
            {
                pLabelEngineLayerProperties = pAnnoLayerProper as ILabelEngineLayerProperties;
            }

            IAnnotationExpressionEngine pAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();

            pLabelEngineLayerProperties.ExpressionParser = pAnnoVBScriptEngine;

            IBasicOverposterLayerProperties4 pBasicOverposterLayerProperties = pLabelEngineLayerProperties.BasicOverposterLayerProperties as IBasicOverposterLayerProperties4;

            switch (pFeatureType)
            {
            case "esriGeometryPoint":
                pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
                break;

            case "esriGeometryPolyline":
                pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                break;

            case "esriGeometryPolygon":
                pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
                break;
            }

            ITextSymbol pTextSymbol = pLabelEngineLayerProperties.Symbol;
            IFontDisp   pFont       = pTextSymbol.Font;

            foreach (XmlNode nd in nodeLayerXml)
            {
                if (nd.Name == "AttrLabel")
                {
                    //读取共同的标注设置信息
                    pFont.Name = nd.Attributes["FontName"].Value;
                    pFont.Size = Convert.ToDecimal(nd.Attributes["FontSize"].Value.ToLower());
                    if (nd.Attributes["FontBold"].Value != "")
                    {
                        pFont.Bold = Convert.ToBoolean(nd.Attributes["FontBold"].Value.ToLower());
                    }
                    if (nd.Attributes["FontItalic"].Value != "")
                    {
                        pFont.Italic = Convert.ToBoolean(nd.Attributes["FontItalic"].Value.ToLower());
                    }
                    if (nd.Attributes["FontUnderLine"].Value != "")
                    {
                        pFont.Underline = Convert.ToBoolean(nd.Attributes["FontUnderLine"].Value.ToLower());
                    }
                    pTextSymbol.Font = pFont;
                    IColor pColor = new RgbColorClass();
                    if (nd.Attributes["FontBoldColor"].Value != "")
                    {
                        pColor.RGB = Convert.ToInt32(nd.Attributes["FontBoldColor"].Value);
                    }
                    else
                    {
                        pColor.RGB = 36054566;
                        //pColor.Green = 0;
                        //pColor.Blue = 0;
                        pTextSymbol.Color = pColor as IColor;
                    }
                    pTextSymbol.Color = pColor;


                    if (nd.Attributes["Expression"].Value != "")
                    {
                        pLabelEngineLayerProperties.Expression = "[" + nd.Attributes["Expression"].Value + "]";
                    }

                    if (nd.Attributes["MaxScale"].Value != "" && nd.Attributes["MaxScale"].Value != null)
                    {
                        pAnnoLayerProper.AnnotationMaximumScale = Convert.ToDouble(nd.Attributes["MaxScale"].Value);
                    }
                    if (nd.Attributes["MinScale"].Value != "" && nd.Attributes["MinScale"].Value != null)
                    {
                        pAnnoLayerProper.AnnotationMinimumScale = Convert.ToDouble(nd.Attributes["MinScale"].Value);
                    }

                    if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerName")
                    {
                        pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerName;
                    }
                    else if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerPart")
                    {
                        pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart;
                    }
                    else if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerShape")
                    {
                        pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
                    }
                    //下面按不同要素类型读取不同的标注设置信息
                    //点要素
                    if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPoint)
                    {
                        pBasicOverposterLayerProperties.PointPlacementOnTop = Convert.ToBoolean(nd.Attributes["PointPlacementOnTop"].Value.ToLower());
                        if (nd.Attributes["PointPlacementMethod"].Value == "esriAroundPoint")
                        {
                            pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriAroundPoint;

                            IPointPlacementPriorities pPointPlacementPriorities = pBasicOverposterLayerProperties.PointPlacementPriorities;
                            string strPlacement;
                            try
                            {
                                //读取标注位置的设置
                                strPlacement = nd.Attributes["PointPlacementPriorities"].Value;
                                SetPlacementPriotities(pPointPlacementPriorities, strPlacement);
                                pBasicOverposterLayerProperties.PointPlacementPriorities = pPointPlacementPriorities;
                            }
                            catch
                            {
                                //MessageBox.Show("该图层XML中不存在PointPlacementPriorities属性!");
                            }
                        }
                        else if (nd.Attributes["PointPlacementMethod"].Value == "esriOnTopPoint")
                        {
                            pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriOnTopPoint;
                        }
                        else if (nd.Attributes["PointPlacementMethod"].Value == "esriSpecifiedAngles")
                        {
                            double[] dArray = new double[1];
                            string   sAngle = nd.Attributes["PointPlacementAngles"].Value;
                            if (sAngle.Contains(",") == false)
                            {
                                dArray[0] = Convert.ToDouble(sAngle);
                            }
                            else
                            {
                                string[] sAngles = sAngle.Split(new char[] { ',' });
                                dArray = new double[sAngles.Length];
                                for (int i = 0; i < sAngles.Length; i++)
                                {
                                    dArray[i] = Convert.ToDouble(sAngles[i]);
                                }
                            }
                            pBasicOverposterLayerProperties.PointPlacementAngles = dArray;
                        }
                        else if (nd.Attributes["PointPlacementMethod"].Value == "esriRotationField")
                        {
                            pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField;
                            pBasicOverposterLayerProperties.RotationField        = nd.Attributes["RotationField"].Value;
                            if (nd.Attributes["RotationType"].Value == "esriRotateLabelArithmetic")
                            {
                                pBasicOverposterLayerProperties.RotationType = esriLabelRotationType.esriRotateLabelArithmetic;
                            }
                            else if (nd.Attributes["RotationType"].Value == "esriRotateLabelGeographic")
                            {
                                pBasicOverposterLayerProperties.RotationType = esriLabelRotationType.esriRotateLabelGeographic;
                            }

                            pBasicOverposterLayerProperties.PerpendicularToAngle = Convert.ToBoolean(nd.Attributes["PerpendicularToAngle"].Value);
                        }
                    }
                    //线要素
                    else if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPolyline)
                    {
                        ILineLabelPosition pLineLabelPosition = pBasicOverposterLayerProperties.LineLabelPosition;
                        if (nd.Attributes["Above"] != null)
                        {
                            pLineLabelPosition.Above = Convert.ToBoolean(nd.Attributes["Above"].Value);
                        }
                        if (nd.Attributes["AtEnd"] != null)
                        {
                            pLineLabelPosition.AtEnd = Convert.ToBoolean(nd.Attributes["AtEnd"].Value);
                        }
                        if (nd.Attributes["AtStart"] != null)
                        {
                            pLineLabelPosition.AtStart = Convert.ToBoolean(nd.Attributes["AtStart"].Value);
                        }
                        if (nd.Attributes["Below"] != null)
                        {
                            pLineLabelPosition.Below = Convert.ToBoolean(nd.Attributes["Below"].Value);
                        }
                        if (nd.Attributes["Horizontal"] != null)
                        {
                            pLineLabelPosition.Horizontal = Convert.ToBoolean(nd.Attributes["Horizontal"].Value);
                        }
                        if (nd.Attributes["InLine"] != null)
                        {
                            pLineLabelPosition.InLine = Convert.ToBoolean(nd.Attributes["InLine"].Value);
                        }
                        if (nd.Attributes["Left"] != null)
                        {
                            pLineLabelPosition.Left = Convert.ToBoolean(nd.Attributes["Left"].Value);
                        }
                        if (nd.Attributes["Offset"] != null)
                        {
                            pLineLabelPosition.Offset = Convert.ToDouble(nd.Attributes["Offset"].Value);
                        }
                        if (nd.Attributes["OnTop"] != null)
                        {
                            pLineLabelPosition.OnTop = Convert.ToBoolean(nd.Attributes["OnTop"].Value);
                        }
                        if (nd.Attributes["Parallel"] != null)
                        {
                            pLineLabelPosition.Parallel = Convert.ToBoolean(nd.Attributes["Parallel"].Value);
                        }
                        if (nd.Attributes["Perpendicular"] != null)
                        {
                            pLineLabelPosition.Perpendicular = Convert.ToBoolean(nd.Attributes["Perpendicular"].Value);
                        }
                        if (nd.Attributes["ProduceCurvedLabels"] != null)
                        {
                            pLineLabelPosition.ProduceCurvedLabels = Convert.ToBoolean(nd.Attributes["ProduceCurvedLabels"].Value);
                        }
                        if (nd.Attributes["Right"] != null)
                        {
                            pLineLabelPosition.Right = Convert.ToBoolean(nd.Attributes["Right"].Value);
                        }
                    }
                    //面要素
                    else if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPolygon)
                    {
                        if (nd.Attributes["PolygonPlacementMethod"].Value == "esriAlwaysHorizontal")
                        {
                            pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysHorizontal;
                        }
                        else if (nd.Attributes["PolygonPlacementMethod"].Value == "esriAlwaysStraight")
                        {
                            pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysStraight;
                        }
                        else if (nd.Attributes["PolygonPlacementMethod"].Value == "esriMixedStrategy")
                        {
                            pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriMixedStrategy;
                        }

                        pBasicOverposterLayerProperties.PlaceOnlyInsidePolygon = Convert.ToBoolean(nd.Attributes["PlaceOnlyInsidePolygon"].Value);
                    }
                }
            }
        }
コード例 #17
0
ファイル: FeatClsOperAPI.cs プロジェクト: zj8487/HyDM
        /// <summary>
        /// 创建注记层
        /// </summary>
        /// <param name="strFeaClsName">注记层名称</param>
        /// <param name="destDataset">待创建的注记层所在的featuredataset</param>
        /// <param name="ipInputFields">注记层字段</param>
        public static IFeatureClass CreateAnnotation(IFeatureClass pInputCls, IFeatureDataset destDataset, IFields ipInputFields)
        {
            try
            {
                //要素类标识信息
                IObjectClassDescription  ipObjectClassDesc = new AnnotationFeatureClassDescription();
                IFeatureClassDescription ipFeatClassDesc   = (IFeatureClassDescription)ipObjectClassDesc;


                IAnnoClass pAnnoClass = pInputCls.Extension as IAnnoClass;
                double     scale      = pAnnoClass.ReferenceScale;


                IUID ipCLSID = ipObjectClassDesc.InstanceCLSID;
                ipCLSID.Value = "esriCore.AnnotationFeature";


                IUID ipExtCLSID = ipObjectClassDesc.ClassExtensionCLSID;
                ipExtCLSID.Value = "esriCore.AnnotationFeatureClassExtension";

                //IField ipField;
                IFields     ipFields     = ipObjectClassDesc.RequiredFields;
                IFieldsEdit ipFieldsEdit = (IFieldsEdit)ipFields;
                int         numFields    = ipInputFields.FieldCount;

                esriFieldType type;
                for (int i = 0; i < numFields; i++)
                {
                    IField ipField = ipInputFields.get_Field(i);
                    type = ipField.Type;
                    if (type != esriFieldType.esriFieldTypeOID && type != esriFieldType.esriFieldTypeGeometry)
                    {
                        string fldName  = ipField.Name;
                        int    fldIndex = ipFields.FindField(fldName);

                        if (fldIndex == -1)
                        {
                            ipFieldsEdit.AddField(ipField);
                        }
                    }
                }

                //工作空间
                IWorkspace            ipWorkspace            = destDataset.Workspace;
                IFeatureWorkspaceAnno ipFeatureWorkspaceAnno = (IFeatureWorkspaceAnno)ipWorkspace;


                //显示比例
                IGraphicsLayerScale ipGraphicsLayerScale = new GraphicsLayerScaleClass();
                ipGraphicsLayerScale.ReferenceScale = scale;
                ipGraphicsLayerScale.Units          = pAnnoClass.ReferenceScaleUnits;

                //符号信息
                //' set up symbol collection
                ISymbolCollection pSymbolColl = new SymbolCollectionClass();

                ITextSymbol myTxtSym = new TextSymbolClass();
                //Set the font for myTxtSym
                stdole.IFontDisp myFont = new stdole.StdFontClass() as stdole.IFontDisp;
                IFont            pFt    = (IFont)myFont;
                pFt.Name = "Courier New";

                myTxtSym.Font = myFont;

                // Set the Color for myTxtSym to be Dark Red
                IRgbColor myColor = new RgbColorClass();
                myColor.Red    = 150;
                myColor.Green  = 0;
                myColor.Blue   = 0;
                myTxtSym.Color = myColor;

                // Set other properties for myTxtSym
                myTxtSym.Angle               = 0;
                myTxtSym.RightToLeft         = false;
                myTxtSym.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
                myTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
                myTxtSym.Size = 9;

                ISymbol pSymbol = (ISymbol)myTxtSym;
                pSymbolColl.set_Symbol(0, pSymbol);


                //set up the annotation labeling properties including the expression
                IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
                pAnnoProps.FeatureLinked = true;
                pAnnoProps.AddUnplacedToGraphicsContainer = false;
                pAnnoProps.CreateUnplacedElements         = true;
                pAnnoProps.DisplayAnnotation = true;
                pAnnoProps.UseOutput         = true;

                ILabelEngineLayerProperties pLELayerProps       = (ILabelEngineLayerProperties)pAnnoProps;
                IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
                pLELayerProps.ExpressionParser   = aAnnoVBScriptEngine;
                pLELayerProps.Expression         = "[DESCRIPTION]";
                pLELayerProps.IsExpressionSimple = true;
                pLELayerProps.Offset             = 0;
                pLELayerProps.SymbolID           = 0;
                pLELayerProps.Symbol             = myTxtSym;

                IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
                double dRefScale = ipGraphicsLayerScale.ReferenceScale;
                pATP.ReferenceScale = dRefScale;
                pATP.Units          = esriUnits.esriMeters;
                pATP.ScaleRatio     = 1;

                IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
                pAnnoPropsColl.Add(pAnnoProps);

                //' use the AnnotationFeatureClassDescription co - class to get the list of required fields and the default name of the shape field
                IObjectClassDescription  pOCDesc = new AnnotationFeatureClassDescriptionClass();
                IFeatureClassDescription pFDesc  = (IFeatureClassDescription)pOCDesc;

                IFields pReqFields       = pOCDesc.RequiredFields;
                IUID    pInstCLSID       = pOCDesc.InstanceCLSID;
                IUID    pExtCLSID        = pOCDesc.ClassExtensionCLSID;
                string  bsShapeFieldName = pFDesc.ShapeFieldName;

                IDataset pDs = (IDataset)pInputCls;

                //创建
                string        bstName  = ipFeatClassDesc.ShapeFieldName;
                IFeatureClass pOutFcls =
                    ipFeatureWorkspaceAnno.CreateAnnotationClass(pDs.Name, ipFields, pOCDesc.InstanceCLSID,
                                                                 pOCDesc.ClassExtensionCLSID, pInputCls.ShapeFieldName, "", destDataset, null, pAnnoPropsColl,
                                                                 ipGraphicsLayerScale, pSymbolColl, true);
                return(pOutFcls);
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return(null);
            }
            return(null);
        }
コード例 #18
0
        /// <summary>
        /// 对生成的各图层进行符号、标注设置
        /// </summary>
        /// <param name="impfilepath">导入符号mxd文件路径</param>
        /// <param name="passpoint">生成的点图层</param>
        /// <param name="passline">生成的线图层</param>
        public void ImpSymbolFromFile(string impfilepath, ILayer passpoint, ILayer passline)
        {
            IMapDocument pMapDocument = new MapDocumentClass();

            pMapDocument.Open(impfilepath, null);
            IMap pMap = pMapDocument.Map[0];

            for (int i = 0; i < pMap.LayerCount; i++)
            {
                ILayer pLayerSymbol = pMap.get_Layer(i);
                if (pLayerSymbol is IFeatureLayer && pLayerSymbol.Name.Contains("point"))
                {
                    IFeatureLayer    pFLayerSymbol   = pLayerSymbol as IFeatureLayer;
                    IGeoFeatureLayer pGFLayerSymbol  = pFLayerSymbol as IGeoFeatureLayer;
                    IFeatureLayer    pFPasspointWait = passpoint as IFeatureLayer;
                    IGeoFeatureLayer pGPasspointWait = pFPasspointWait as IGeoFeatureLayer;
                    if (pGFLayerSymbol != null)
                    {
                        pGPasspointWait.Renderer = pGFLayerSymbol.Renderer;

                        IAnnotateLayerProperties pAnnoLayerP; // = new LabelEngineLayerPropertiesClass();//渲染图层的符号图层标注
                        IElementCollection       PELECOLL;    //queryitem的参数,用不到
                        IElementCollection       pelecoll;    //同上
                        pGFLayerSymbol.AnnotationProperties.QueryItem(0, out pAnnoLayerP, out PELECOLL, out pelecoll);
                        ILabelEngineLayerProperties pLabelEenLayPro = pAnnoLayerP as ILabelEngineLayerProperties;


                        IFontDisp   pFont       = new StdFontClass() as IFontDisp;
                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Color   = pLabelEenLayPro.Symbol.Color;
                        pFont.Bold          = pLabelEenLayPro.Symbol.Font.Bold;
                        pFont.Italic        = pLabelEenLayPro.Symbol.Font.Italic;
                        pFont.Strikethrough = pLabelEenLayPro.Symbol.Font.Strikethrough;
                        pFont.Underline     = pLabelEenLayPro.Symbol.Font.Underline;
                        pFont.Name          = pLabelEenLayPro.Symbol.Font.Name;
                        pFont.Size          = pLabelEenLayPro.Symbol.Font.Size;
                        pTextSymbol.Font    = pFont;

                        pGPasspointWait.AnnotationProperties.Clear();
                        ILabelEngineLayerProperties pLabelWaitLayPro = new LabelEngineLayerPropertiesClass();//设置待渲染图层的标注
                        pLabelWaitLayPro.Expression = pLabelEenLayPro.Expression;
                        pLabelWaitLayPro.Symbol     = pTextSymbol;

                        IAnnotateLayerProperties pAnnLayProWait = pLabelWaitLayPro as IAnnotateLayerProperties;//新生成的符号图层设置标注
                        pAnnLayProWait.DisplayAnnotation  = true;
                        pAnnLayProWait.FeatureLayer       = pGPasspointWait;
                        pAnnLayProWait.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures;
                        pAnnLayProWait.WhereClause        = "";
                        pGPasspointWait.AnnotationProperties.Add(pAnnLayProWait);
                        pGPasspointWait.DisplayAnnotation = true;
                    }
                }
                else if (pLayerSymbol is IFeatureLayer && pLayerSymbol.Name.Contains("line"))
                {
                    IFeatureLayer    pFLayerSymbol   = pLayerSymbol as IFeatureLayer;
                    IGeoFeatureLayer pGFLayerSymbol  = pFLayerSymbol as IGeoFeatureLayer;
                    IFeatureLayer    pFPasspointWait = passline as IFeatureLayer;
                    IGeoFeatureLayer pGPasspointWait = pFPasspointWait as IGeoFeatureLayer;
                    if (pGFLayerSymbol != null)
                    {
                        pGPasspointWait.Renderer = pGFLayerSymbol.Renderer;

                        IAnnotateLayerProperties pAnnoLayerP = new LabelEngineLayerPropertiesClass(); //符号图层标注
                        IElementCollection       PELECOLL;                                            //queryitem的参数,用不到
                        IElementCollection       pelecoll;                                            //同上
                        pGFLayerSymbol.AnnotationProperties.QueryItem(0, out pAnnoLayerP, out PELECOLL, out pelecoll);
                        ILabelEngineLayerProperties pLabelEenLayPro = pAnnoLayerP as ILabelEngineLayerProperties;

                        IFontDisp   pFont       = new StdFontClass() as IFontDisp;
                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Color   = pLabelEenLayPro.Symbol.Color;
                        pFont.Bold          = pLabelEenLayPro.Symbol.Font.Bold;
                        pFont.Italic        = pLabelEenLayPro.Symbol.Font.Italic;
                        pFont.Strikethrough = pLabelEenLayPro.Symbol.Font.Strikethrough;
                        pFont.Underline     = pLabelEenLayPro.Symbol.Font.Underline;
                        pFont.Name          = pLabelEenLayPro.Symbol.Font.Name;
                        pFont.Size          = pLabelEenLayPro.Symbol.Font.Size;
                        pTextSymbol.Font    = pFont;

                        pGPasspointWait.AnnotationProperties.Clear();
                        ILabelEngineLayerProperties pLabelWaitLayPro = new LabelEngineLayerPropertiesClass();//设置待渲染图层的标注
                        pLabelWaitLayPro.Expression = pLabelEenLayPro.Expression;
                        pLabelWaitLayPro.Symbol     = pTextSymbol;

                        IAnnotateLayerProperties pAnnLayProWait = pLabelWaitLayPro as IAnnotateLayerProperties;//新生成的符号图层设置标注
                        pAnnLayProWait.DisplayAnnotation  = true;
                        pAnnLayProWait.FeatureLayer       = pGPasspointWait;
                        pAnnLayProWait.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures;
                        pAnnLayProWait.WhereClause        = "";
                        pGPasspointWait.AnnotationProperties.Add(pAnnLayProWait);
                        pGPasspointWait.DisplayAnnotation = true;
                    }
                }
            }
            m_pTOCCtl.SetBuddyControl(m_pMapCtl);
            m_pTOCCtl.ActiveView.Refresh();
            m_pMapCtl.ActiveView.Refresh();
        }
コード例 #19
0
ファイル: FrmSetLabel.cs プロジェクト: johnforrest/GeoCoding
        //初始化
        private void FrmSetLabel_Load(object sender, EventArgs e)
        {
            IFields       pFields;
            IFeatureClass pFeatCls;
            int           i;
            bool          bIsComplexExpression; //标识是否是复杂表达式

            //清空列表
            cmbFieldName.Items.Clear();
            cmbFontName.Items.Clear();
            cmbFontSize.Items.Clear();

            //初始化字体
            //FontFamily FontF;
            foreach (FontFamily FontF in FontFamily.Families)
            {
                cmbFontName.Items.Add(FontF.Name);
            }

            //初始化字体的大小
            int k;

            for (k = 5; k <= 11; k++)
            {
                cmbFontSize.Items.Add(k);
            }
            for (k = 12; k <= 72; k += 2)
            {
                cmbFontSize.Items.Add(k);
            }

            //初始化点击了OK键为false
            m_bOK = false;

            //初始化传出参数
            m_XMLElement = null;

            //获得当前图层的标注的属性
            ILabelEngineLayerProperties        pLabelEngineLayerProper;
            IAnnotateLayerPropertiesCollection pAnnoLayerProperCollection;

            pAnnoLayerProperCollection = m_pGeoFeatLayer.AnnotationProperties;

            //得到当前图层的当前标注属性
            IElementCollection pElementCollection1, pElementCollection2;

            pAnnoLayerProperCollection.QueryItem(0, out m_pAnnoLayerProperties, out pElementCollection1, out pElementCollection2);
            pLabelEngineLayerProper = (ILabelEngineLayerProperties)m_pAnnoLayerProperties;
            m_pSymbol     = (ISymbol)pLabelEngineLayerProper.Symbol;
            m_pTextSymbol = (ITextSymbol)m_pSymbol;

            //初始化该图层的字段,并初始化为该层的标注字段
            ILabelEngineLayerProperties pLableEngine;
            IField pField;
            IField pDisplayField = null;
            string sDisplayFieldName;
            int    iStrLeng, iFieldIndex;

            pLableEngine = (ILabelEngineLayerProperties)m_pAnnoLayerProperties;
            //判断是否是复杂表达式
            sDisplayFieldName    = pLableEngine.Expression.Trim();
            bIsComplexExpression = JudgeIsComplexExpression(sDisplayFieldName);

            //if (bIsComplexExpression==false)
            //{
            //    //获得表达式的长度
            //    iStrLeng = pLableEngine.Expression.Length;
            //    //去除[]符号
            //    sDisplayFieldName = Strings.Left(Strings.Right(pLableEngine.Expression, iStrLeng - 1), iStrLeng - 2);
            //    sDisplayFieldName = sDisplayFieldName.ToUpper();
            //}

            //如果图层不为空
            if (m_pGeoFeatLayer != null)
            {
                pFeatCls = m_pGeoFeatLayer.FeatureClass;
                pFields  = pFeatCls.Fields;
                //IDataset pDs = pFeatCls;
                for (i = 0; i <= pFields.FieldCount - 1; i++)
                {
                    pField = pFields.get_Field(i);
                    if ((pField.Type != esriFieldType.esriFieldTypeGeometry) && pField.Type != esriFieldType.esriFieldTypeBlob)
                    {
                        cmbFieldName.Items.Add(pField.Name + "[" + pField.AliasName + "]");
                    }
                }

                //设置当前层的标注字段
                if (bIsComplexExpression == false)
                {
                    //获得表达式的长度
                    iStrLeng = Strings.Len(pLableEngine.Expression);
                    //去除[]符号
                    sDisplayFieldName = Strings.Left(Strings.Right(pLableEngine.Expression, iStrLeng - 1), iStrLeng - 2);
                    iFieldIndex       = pFields.FindField(sDisplayFieldName);

                    if (iFieldIndex > -1)
                    {
                        pDisplayField = pFields.get_Field(iFieldIndex);
                    }

                    cmbFieldName.Text = pDisplayField.Name + "[" + pDisplayField.AliasName + "]";
                }
                else
                {
                    cmbFieldName.Items.Add("<复杂表达式>");
                    cmbFieldName.Text = "复杂表达式";
                    m_pNewLabelEngineLayerProperties = (ILabelEngineLayerProperties)pLabelEngineLayerProper;
                    cmbFieldName.Enabled             = false;
                }
            }
            else
            {
                cmbFieldName.Enabled = false;
            }

            //初始化颜色
            IFormattedTextSymbol pFormattedTextSymbol;

            pFormattedTextSymbol = (IFormattedTextSymbol)m_pTextSymbol;
            //设置初始颜色盒控件的颜色
            this.btnColorPick.SelectedColor = GetSystemColor(pFormattedTextSymbol.Color);
            //当前图层的当前标注的字体
            cmbFontName.Text = m_pTextSymbol.Font.Name;
            //当前图层的当前标注字体的大小
            cmbFontSize.Text = m_pTextSymbol.Font.Size.ToString();
            //初始化当前字体的样式
            btnFontBold.Checked      = m_pTextSymbol.Font.Bold;
            btnFontUnderline.Checked = m_pTextSymbol.Font.Underline;
            btnFontItalic.Checked    = m_pTextSymbol.Font.Italic;

            if (m_pTextSymbol.Font.Italic)
            {
                if (m_pTextSymbol.Font.Bold)
                {
                    if (m_pTextSymbol.Font.Underline)
                    {
                        //lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, m_pTextSymbol.Font.Size, FontStyle.Bold || FontStyle.Italic || FontStyle.Underline);
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Bold);
                    }
                    else
                    {
                        //lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, m_pTextSymbol.Font.Size, FontStyle.Bold || FontStyle.Italic);
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Italic);
                    }
                }
                else
                {
                    if (m_pTextSymbol.Font.Underline)
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Underline);
                    }
                    else
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Italic);
                    }
                }
            }
            else
            {
                if (m_pTextSymbol.Font.Bold)
                {
                    if (m_pTextSymbol.Font.Underline)
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Underline);
                    }
                    else
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Bold);
                    }
                }
                else
                {
                    if (m_pTextSymbol.Font.Underline)
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Underline);
                    }
                    else
                    {
                        lblText.Font = new System.Drawing.Font(m_pTextSymbol.Font.Name, (float)m_pTextSymbol.Font.Size, FontStyle.Regular);
                    }
                }
            }

            lblText.ForeColor = GetSystemColor(m_pTextSymbol.Color);

            //初始化标注显示的比例范围
            if ((m_pAnnoLayerProperties.AnnotationMaximumScale != m_pGeoFeatLayer.MaximumScale) || (m_pAnnoLayerProperties.AnnotationMinimumScale != m_pGeoFeatLayer.MinimumScale))
            {
                optUserDefined.CheckValue = "Y";
                txtMinScale.Text          = m_pAnnoLayerProperties.AnnotationMinimumScale.ToString();
                txtMaxScale.Text          = m_pAnnoLayerProperties.AnnotationMaximumScale.ToString();
            }
            else
            {
                optScaleNameWithLayer.CheckValue = "Y";
            }

            //如果显示最大最小比例尺都是0的话,则雨当前地图的参考比例尺相同
            if ((m_pAnnoLayerProperties.AnnotationMaximumScale == 0) && (m_pAnnoLayerProperties.AnnotationMinimumScale == 0))
            {
                optScaleNameWithLayer.CheckValue = "Y";
            }
        }
コード例 #20
0
ファイル: FrmSetLabel.cs プロジェクト: johnforrest/GeoCoding
        //表达式
        private void btnExpresion_Click(object sender, EventArgs e)
        {
            bool    bIsComplexExpression = false;          //标识是否是复杂表达式
            bool    bExistComplexExpression = false;       //标识,"<复杂表达式>"是否在下拉框中存在
            int     iComplexExpressionIndex = -1;          //记录<复杂表达式>在下拉框中的索引
            int     i, j;
            string  sValue;
            IField  pField;
            IFields pFields;

            FrmLabelExpression FrmLabelExpression = new FrmLabelExpression();

            FrmLabelExpression.GeoFeatureLayer            = m_pGeoFeatLayer;
            FrmLabelExpression.LabelEngineLayerProperties = (ILabelEngineLayerProperties)m_pAnnoLayerProperties;
            FrmLabelExpression.ShowDialog();

            m_pNewLabelEngineLayerProperties = FrmLabelExpression.LabelEngineLayerProperties;
            bIsComplexExpression             = JudgeIsComplexExpression(m_pNewLabelEngineLayerProperties.Expression);

            //检查<复杂表达式>在下拉框中是否已经存在
            for (i = 0; i <= cmbFieldName.Items.Count - 1; i++)
            {
                if (cmbFieldName.Items[i].ToString().Trim() == "<复杂表达式>")
                {
                    bExistComplexExpression = true;
                    iComplexExpressionIndex = i;
                    break;
                }
            }

            //初始化下拉框   如果是复杂表达式
            if (bIsComplexExpression)
            {
                if (bExistComplexExpression == true)
                {
                    cmbFieldName.Text = "<复杂表达式>";
                }
                else
                {
                    cmbFieldName.Items.Add("<复杂表达式>");
                    cmbFieldName.Text = "<复杂表达式>";
                }
                cmbFieldName.Enabled = false;
            }
            else
            {
                //如果<复杂表达式>存在于下拉框中的话,则移除它,注意:在添加前移除
                if (bExistComplexExpression)
                {
                    cmbFieldName.Items.RemoveAt(iComplexExpressionIndex);
                }

                //获得[]之间的字段名称
                sValue = m_pNewLabelEngineLayerProperties.Expression;
                i      = Strings.InStr(sValue, "[", CompareMethod.Text);
                j      = Strings.InStr(sValue, "]", CompareMethod.Text);
                sValue = Strings.Mid(sValue, i + 1, j - i - 1);

                //找到对应的字段名称,并初始化
                pFields = m_pGeoFeatLayer.FeatureClass.Fields;

                for (i = 0; i <= pFields.FieldCount - 1; i++)
                {
                    pField = pFields.get_Field(i);
                    if (Strings.UCase(pField.Name) == Strings.UCase(sValue))
                    {
                        cmbFieldName.Text = pField.Name + "[" + pField.AliasName + "]";
                        break;
                    }
                }
                cmbFieldName.Enabled = true;
            }
        }
コード例 #21
0
        private void getLayerLabel(IGeoFeatureLayer pGeoFeatLayer)
        {
            Boolean bIsLabel = pGeoFeatLayer.DisplayAnnotation;

            if (bIsLabel)
            {
                this.chkIsLabel.Checked = true;
            }
            else
            {
                this.chkIsLabel.Checked = false;//changed by chulili 20110712修改bug true->false
            }

            //added by chulili 20110804按照图层的标注设置初始化界面
            //this.chkIsLabel.Checked = pGeoFeatureLayer.DisplayAnnotation;
            IAnnotateLayerPropertiesCollection pAnnotateLayerPropertiesCollection = pGeoFeatLayer.AnnotationProperties;

            if (pAnnotateLayerPropertiesCollection == null)
            {
                return;
            }
            //定义IAnnotateLayerPropertiesCollection.QueryItem方法中调用的对象
            IAnnotateLayerProperties pAnnoLayerProperties = null;
            IElementCollection       pElementCollection   = null;
            IElementCollection       pElementCollection1  = null;

            //获取标注渲染对象
            pAnnotateLayerPropertiesCollection.QueryItem(0, out pAnnoLayerProperties, out pElementCollection, out pElementCollection1);
            if (pAnnoLayerProperties == null)
            {
                return;
            }
            ILabelEngineLayerProperties pLabelEngineLayerPro = pAnnoLayerProperties as ILabelEngineLayerProperties;

            if (pLabelEngineLayerPro == null)
            {
                return;
            }
            ITextSymbol pTextSymbol = pLabelEngineLayerPro.Symbol;
            IBasicOverposterLayerProperties pBasicOverposterLayerProp = pLabelEngineLayerPro.BasicOverposterLayerProperties;

            if (pBasicOverposterLayerProp != null)
            {
                switch (pBasicOverposterLayerProp.NumLabelsOption)
                {
                case esriBasicNumLabelsOption.esriOneLabelPerName:
                    this.rdbPerName.Checked = true;
                    break;

                case esriBasicNumLabelsOption.esriOneLabelPerPart:
                    this.rdbPerPart.Checked = true;
                    break;

                case esriBasicNumLabelsOption.esriOneLabelPerShape:
                    this.rdbPerShape.Checked = true;
                    break;

                default:
                    this.rdbPerName.Checked = true;
                    break;
                }
            }
            /////////////////////////////
            string strMaxScale = pAnnoLayerProperties.AnnotationMaximumScale.ToString();
            string strMinScale = pAnnoLayerProperties.AnnotationMinimumScale.ToString();

            ////////////////////////////
            this.txtMaxLabelScale.Text = strMaxScale;
            this.txtMinLabelScale.Text = strMinScale;

            this.btnBold.Checked               = pTextSymbol.Font.Bold;
            this.btnItalic.Checked             = pTextSymbol.Font.Italic;
            this.btnUnderLine.Checked          = pTextSymbol.Font.Underline;
            this.FontColorPicker.SelectedColor = ColorTranslator.FromOle(pTextSymbol.Color.RGB);

            newSize   = (float)Convert.ToDouble(pTextSymbol.Font.Size);
            newFamily = new FontFamily(pTextSymbol.Font.Name);
            newFont   = FontStyle.Regular;//CmbFields
            string strField = pLabelEngineLayerPro.Expression;

            //获取字段名称
            if (strField.StartsWith("["))
            {
                strField = strField.Substring(1);
            }
            if (strField.EndsWith("]"))
            {
                strField = strField.Substring(0, strField.Length - 1);
            }
            //设置界面上字段名称
            for (int i = 0; i < CmbFields.Items.Count; i++)
            {
                if (CmbFields.Items[i].ToString() == strField)
                {
                    CmbFields.SelectedIndex = i;
                    break;
                }
            }
            //设置界面上字体名称
            for (int i = 0; i < CmbFontName.Items.Count; i++)
            {
                if (CmbFontName.Items[i].ToString() == pTextSymbol.Font.Name)
                {
                    CmbFontName.SelectedIndex = i;
                    break;
                }
            }
            //设置界面上字体大小
            decimal dSize        = decimal.Round(pTextSymbol.Font.Size, 0, MidpointRounding.AwayFromZero);
            string  strLabelSize = Convert.ToInt32(dSize).ToString();

            for (int i = 0; i < CmbFontSize.Items.Count; i++)
            {
                if (CmbFontSize.Items[i].ToString() == strLabelSize)
                {
                    CmbFontSize.SelectedIndex = i;
                    break;
                }
            }

            if (pTextSymbol.Font.Underline)
            {
                newFont = newFont ^ FontStyle.Underline;
            }
            if (pTextSymbol.Font.Bold)
            {
                newFont = newFont ^ FontStyle.Bold;
            }
            if (pTextSymbol.Font.Italic)
            {
                newFont = newFont ^ FontStyle.Italic;
            }
            //设置界面上字体格式
            setFont();
            //设置界面上字体颜色
            LabelText.ForeColor = ColorTranslator.FromOle(pTextSymbol.Color.RGB);
        }
コード例 #22
0
        private void AddLabel(string StrDisplayField)
        {
            pGeoFeatLayer.DisplayAnnotation = false;
            pMapControl.ActiveView.Refresh();

            pGeoFeatLayer.DisplayField = StrDisplayField;

            IAnnotateLayerPropertiesCollection pAnnoProps = null;

            pAnnoProps = pGeoFeatLayer.AnnotationProperties;

            ILineLabelPosition pPosition = null;

            pPosition          = new LineLabelPositionClass();
            pPosition.Parallel = true;
            pPosition.Above    = true;

            ILineLabelPlacementPriorities    pPlacement = new LineLabelPlacementPrioritiesClass();
            IBasicOverposterLayerProperties4 pBasic     = new BasicOverposterLayerPropertiesClass();

            pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasic.LineLabelPlacementPriorities = pPlacement;
            pBasic.LineLabelPosition            = pPosition;
            pBasic.BufferRatio   = 0;
            pBasic.FeatureWeight = esriBasicOverposterWeight.esriHighWeight;
            if (this.rdbPerName.Checked)
            {
                pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerName;  //每个名称标注一次
            }
            else if (this.rdbPerPart.Checked)
            {
                pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart;  //每个部分标注一次
            }
            else
            {
                pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;  //每个地物标注一次
            }
            //pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriNoLabelRestrictions ;
            //pBasic.PlaceOnlyInsidePolygon = true;  //仅在地物内部显示标注  deleted by chulili s20111018 界面上并没有这项设置,这句话应注释掉,否则像是错误

            ILabelEngineLayerProperties pLabelEngine = null;

            pLabelEngine = new LabelEngineLayerPropertiesClass();
            pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties;
            pLabelEngine.Expression = "[" + StrDisplayField + "]";
            ITextSymbol pTextSymbol = null;

            pTextSymbol = pLabelEngine.Symbol;
            System.Drawing.Font pFont = null;
            pFont = LabelText.Font;
            IFontDisp pFontDisp = ESRI.ArcGIS.ADF.Converter.ToStdFont(pFont);

            pTextSymbol.Font = pFontDisp;

            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = Convert.ToInt32(LabelText.ForeColor.R);
            pColor.Green        = Convert.ToInt32(LabelText.ForeColor.G);
            pColor.Blue         = Convert.ToInt32(LabelText.ForeColor.B);
            pTextSymbol.Color   = pColor as IColor;
            pLabelEngine.Symbol = pTextSymbol;

            IAnnotateLayerProperties pAnnoLayerProps = null;

            pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
            pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            //最大\最小比例尺
            try
            {
                if (this.txtMaxLabelScale.Text.Trim() != "")
                {
                    pAnnoLayerProps.AnnotationMaximumScale = Convert.ToDouble(this.txtMaxLabelScale.Text);
                }
                if (this.txtMinLabelScale.Text.Trim() != "")
                {
                    pAnnoLayerProps.AnnotationMinimumScale = Convert.ToDouble(this.txtMinLabelScale.Text);
                }
            }
            catch (Exception err)
            {}
            pAnnoProps.Clear();

            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatLayer.DisplayAnnotation = this.chkIsLabel.Checked;
            (pMapControl.Map as IActiveView).Refresh();
        }
コード例 #23
0
        public static void AddToMapVector(FileInfo sSource, string sDisplayName, IGroupLayer pGrpLyr, string displayField, IFeatureRenderer pRenderer, string queryFilter, string labelField, short fTransparency = -1)
        {
            if (string.IsNullOrEmpty(sDisplayName))
            {
                throw new ArgumentNullException("Display Name", "Null or empty display Name");
            }

            IFeatureLayer pResultLayer = IsFeatureLayerInGroupLayer(sSource.FullName, pGrpLyr);


            IFeatureWorkspace pWS = (IFeatureWorkspace)ArcMapUtilities.GetWorkspace(sSource);
            IFeatureClass     pFC = pWS.OpenFeatureClass(Path.GetFileNameWithoutExtension(sSource.FullName));

            pResultLayer = new FeatureLayer();
            pResultLayer.FeatureClass = pFC;
            if (fTransparency >= 0)
            {
                ILayerEffects pLayerEffects = (ILayerEffects)pResultLayer;
                pLayerEffects.Transparency = fTransparency;
            }

            if (!string.IsNullOrEmpty(sDisplayName))
            {
                pResultLayer.Name = sDisplayName;
            }

            IMapLayers pMapLayers = (IMapLayers)ArcMap.Document.FocusMap;

            if (pGrpLyr == null)
            {
                pMapLayers.InsertLayer(pResultLayer, true, 0);
            }
            else
            {
                pMapLayers.InsertLayerInGroup(pGrpLyr, pResultLayer, true, 0);
            }

            if (pRenderer != null)
            {
                ((IGeoFeatureLayer)pResultLayer).Renderer = pRenderer;
            }

            if (!string.IsNullOrEmpty(labelField))
            {
                IGeoFeatureLayer pGFL = pResultLayer as IGeoFeatureLayer;

                // This first attempt seems to set the label field, but doesn't
                // cause the labeling to refresh and take effect
                //IDisplayString displayString = pGFL as IDisplayString;
                //IDisplayExpressionProperties properties = displayString.ExpressionProperties;
                //properties.Expression = string.Format("[{0}]", labelField);

                // This second attempt takes more effort but actually works
                // https://community.esri.com/thread/19005
                IAnnotateLayerPropertiesCollection labelPropsCollection = pGFL.AnnotationProperties;
                labelPropsCollection.Clear();

                //IBasicOverposterLayerProperties pBOLayerProps = new BasicOverposterLayerProperties();
                //pBOLayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon
                //pBOLayerProps.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape
                //pBOLayerProps.FeatureWeight = esriBasicOverposterWeight.esriNoWeight
                //pBOLayerProps.LabelWeight = esriBasicOverposterWeight.esriLowWeight

                //Dim tSym As ITextSymbol
                //Set tSym = New TextSymbol
                //Dim font As IFontDisp
                //Set font = tSym.font
                //font.Bold = False
                //font.size = 6
                //tSym.font = font

                ILabelEngineLayerProperties aLELayerProps = (ILabelEngineLayerProperties) new LabelEngineLayerProperties();
                aLELayerProps.Expression = string.Format("[{0}]", labelField);

                //Set aLELayerProps.Symbol = tSym
                //Set aLELayerProps.BasicOverposterLayerProperties = pBOLayerProps
                IAnnotateLayerProperties lProps = aLELayerProps as IAnnotateLayerProperties;
                lProps.Class = "Any Name";
                labelPropsCollection.Add(lProps);

                pGFL.DisplayAnnotation = true;
            }

            if (pRenderer is IUniqueValueRenderer)
            {
                // If you didn't use a color ramp that was predefined in a style,
                // you need to use "Custom" here, otherwise use the name of the color ramp you chose.
                ((IGeoFeatureLayer)pResultLayer).DisplayField = displayField;

                // This makes the layer properties symbology tab show the correct interface
                IUID pUID = new UIDClass();
                pUID.Value = "{683C994E-A17B-11D1-8816-080009EC732A}";
                ((IGeoFeatureLayer)pResultLayer).RendererPropertyPageClassID = pUID as UIDClass;
            }

            if (!string.IsNullOrEmpty(queryFilter))
            {
                ((IFeatureLayerDefinition)pResultLayer).DefinitionExpression = queryFilter;
            }

            int refsLeft = 0;

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pFC);
            }while (refsLeft > 0);

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pResultLayer);
            }while (refsLeft > 0);

            ArcMap.Document.UpdateContents();
            ArcMap.Document.ActiveView.Refresh();
            ArcMap.Document.CurrentContentsView.Refresh(null);
        }
コード例 #24
0
        /// <summary>
        /// 初始化form element
        /// </summary>
        private void Initialize()
        {
            IFeatureLayer           featureLayer    = (IFeatureLayer)m_layer;
            IGeoFeatureLayer        geoLayer        = (IGeoFeatureLayer)m_layer;
            IFeatureClass           featureClass    = featureLayer.FeatureClass;
            ILayerGeneralProperties layerProperties = (ILayerGeneralProperties)featureLayer;

            // 图层属性页
            this.textBoxLayerName.Text        = m_layer.Name;
            this.textBoxLayerDescription.Text = layerProperties.LayerDescription;
            this.checkBoxVisibility.Checked   = m_layer.Visible;

            String scaleMin = geoLayer.MinimumScale.ToString();
            String sacleMax = geoLayer.MaximumScale.ToString();

            if ("0" == scaleMin && "0" == sacleMax)
            {
                this.radioButtonScaleAll.Checked  = true;
                this.radioButtonScaleZoom.Checked = false;
            }
            else
            {
                this.radioButtonScaleAll.Checked  = false;
                this.radioButtonScaleZoom.Checked = true;
                this.comboBoxScaleMax.Text        = sacleMax;
                this.comboBoxScaleMin.Text        = scaleMin;
            }

            // 字段定义页
            IFields fields     = featureClass.Fields;
            int     fieldCount = fields.FieldCount;

            for (int i = 0; i < fieldCount; i++)
            {
                IField       field = fields.get_Field(i);
                ListViewItem item  = new ListViewItem(field.Name);
                item.SubItems.Add(field.AliasName);
                item.SubItems.Add(field.Editable ? "允许编辑" : "不允许编辑");
                item.SubItems.Add(field.IsNullable ? "允许为空" : "不允许为空");
                item.SubItems.Add(field.Length.ToString());
                item.SubItems.Add(field.Precision.ToString());
                item.SubItems.Add(field.Scale.ToString());
                item.SubItems.Add(GetFieldType(field.Type));
                listViewFields.Items.Add(item);
            }

            // 数据源及四至范围
            IEnvelope envelope = m_layer.AreaOfInterest;

            textBoxLeft.Text   = envelope.XMin.ToString();
            textBoxRight.Text  = envelope.XMax.ToString();
            textBoxTop.Text    = envelope.YMin.ToString();
            textBoxBottom.Text = envelope.YMax.ToString();

            IDataset dataset = (IDataset)featureLayer;

            textBoxDataSource.AppendText("数据源类型:           ");
            textBoxDataSource.AppendText(featureLayer.DataSourceType);
            textBoxDataSource.AppendText("\r\n数据集:               ");
            textBoxDataSource.AppendText(dataset.BrowseName);
            textBoxDataSource.AppendText("\r\n数据源名称:           ");
            textBoxDataSource.AppendText(dataset.Workspace.PathName);

            textBoxDataSource.AppendText("\r\n要素类:               ");
            textBoxDataSource.AppendText(featureClass.AliasName);
            textBoxDataSource.AppendText("\r\n要素类类型:           ");
            textBoxDataSource.AppendText(GetFeatureType(featureClass.FeatureType));
            textBoxDataSource.AppendText("\r\n几何类型:             ");
            textBoxDataSource.AppendText(GetGeometryType(featureClass.ShapeType));

            IGeoDataset geoDataset = (IGeoDataset)featureClass;
            // 通过IGeoDataset接口获取FeatureClass坐标系统
            ISpatialReference          spatialReference   = geoDataset.SpatialReference;
            IProjectedCoordinateSystem projectCoordSystem = null;

            if (spatialReference is IProjectedCoordinateSystem)
            {
                projectCoordSystem = (IProjectedCoordinateSystem)spatialReference;

                if (projectCoordSystem == null)
                {
                    return;
                }

                textBoxDataSource.AppendText("\r\n");

                IProjection project = projectCoordSystem.Projection;
                textBoxDataSource.AppendText("\r\n投影坐标系:           ");
                textBoxDataSource.AppendText(projectCoordSystem.Name);
                textBoxDataSource.AppendText("\r\n投影:                 ");
                textBoxDataSource.AppendText(project.Name);
                textBoxDataSource.AppendText("\r\nFalseEasting:         ");
                textBoxDataSource.AppendText(projectCoordSystem.FalseEasting.ToString());
                textBoxDataSource.AppendText("\r\nFalseNorthing:        ");
                textBoxDataSource.AppendText(projectCoordSystem.FalseNorthing.ToString());
                textBoxDataSource.AppendText("\r\n中央经线:             ");
                textBoxDataSource.AppendText(projectCoordSystem.get_CentralMeridian(true).ToString());
                textBoxDataSource.AppendText("\r\n缩放比例:             ");
                textBoxDataSource.AppendText(projectCoordSystem.ScaleFactor.ToString());
                textBoxDataSource.AppendText("\r\n高度原点:             ");
                try
                {
                    textBoxDataSource.AppendText(projectCoordSystem.LongitudeOfOrigin.ToString());
                }
                catch (Exception e)
                {
                    textBoxDataSource.AppendText("0");
                }

                textBoxDataSource.AppendText("\r\n单位:                 ");
                textBoxDataSource.AppendText(projectCoordSystem.CoordinateUnit.Name);

                textBoxDataSource.AppendText("\r\n");

                IGeographicCoordinateSystem geographCoordinateSystem = projectCoordSystem.GeographicCoordinateSystem;
                if (geographCoordinateSystem != null)
                {
                    textBoxDataSource.AppendText("\r\n地理坐标系:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Name);
                    textBoxDataSource.AppendText("\r\n基准面:               ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Datum.Name);
                    textBoxDataSource.AppendText("\r\n本初子午线:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.PrimeMeridian.Name);
                    textBoxDataSource.AppendText("\r\n单位:                 ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.CoordinateUnit.Name);
                }
            }
            else if (spatialReference is IGeographicCoordinateSystem)
            {
                IGeographicCoordinateSystem geographCoordinateSystem = spatialReference as IGeographicCoordinateSystem;
                if (geographCoordinateSystem != null)
                {
                    textBoxDataSource.AppendText("\r\n地理坐标系:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Name);
                    textBoxDataSource.AppendText("\r\n基准面:               ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Datum.Name);
                    textBoxDataSource.AppendText("\r\n本初子午线:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.PrimeMeridian.Name);
                    textBoxDataSource.AppendText("\r\n单位:                 ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.CoordinateUnit.Name);
                }
            }



            // filter

            IDisplayString displayString = (IDisplayString)featureLayer;

            textBoxFilter.AppendText(displayString.ExpressionProperties.Expression);

            // 标注
            IAnnotateLayerPropertiesCollection annoLayerPropsColl = geoLayer.AnnotationProperties;
            IAnnotateLayerProperties           annoLayerProps     = null;
            IElementCollection placedElements   = null;
            IElementCollection unplacedElements = null;

            annoLayerPropsColl.QueryItem(0, out annoLayerProps, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties aLELayerProps = annoLayerProps as ILabelEngineLayerProperties;

            // annoLayerProps.DisplayAnnotation;
            checkBoxLabelVisibility.Checked = annoLayerProps.DisplayAnnotation;

            //初始化字体大小下拉框
            for (int k = 5; k <= 11; k++)
            {
                cmbFontSize.Items.Add(k);
            }
            for (int k = 12; k <= 72; k = k + 2)
            {
                cmbFontSize.Items.Add(k);
            }
            // cmbFontSize.Text = "8";

            //初始化字体下拉框
            foreach (FontFamily onefontfamily in FontFamily.Families)
            {
                //去掉名称头个字为@的字体
                if (onefontfamily.Name.Substring(0, 1) != "@")
                {
                    cmbFontName.Items.Add(onefontfamily.Name);
                }
            }
            // cmbFontName.Text = "宋体";
            ITextSymbol pTextSymbol = aLELayerProps.Symbol;

            stdole.IFontDisp pFontDisp = pTextSymbol.Font;
            cmbFontSize.Text = pFontDisp.Size.ToString();
            toolBarStyle.Buttons[0].Pushed = pFontDisp.Bold;
            toolBarStyle.Buttons[1].Pushed = pFontDisp.Italic;
            toolBarStyle.Buttons[2].Pushed = pFontDisp.Underline;
            cmbFontName.Text = pFontDisp.Name;
            IRgbColor rgbColor = (IRgbColor)pTextSymbol.Color;

            colorButtonFont.Color = Color.FromArgb(rgbColor.Transparency,
                                                   rgbColor.Red,
                                                   rgbColor.Green,
                                                   rgbColor.Blue);
            colorButtonFont.Refresh();
            for (int i = 0; i < fields.FieldCount; i++)
            {
                IField field = fields.get_Field(i);
                cmbFieldName.Items.Add(field.Name);
            }

            cmbFieldName.Enabled = aLELayerProps.IsExpressionSimple;
            String expr = aLELayerProps.Expression.Trim('[').Trim(']');

            cmbFieldName.SelectedIndex = cmbFieldName.FindString(expr);

            cmbMaxScale.Text = annoLayerProps.AnnotationMaximumScale.ToString();
            cmbMinScale.Text = annoLayerProps.AnnotationMinimumScale.ToString();

            if (cmbMaxScale.Text == "0" && cmbMinScale.Text == "0")
            {
                rbScaleWithLayer.Checked    = true;
                this.rbScaleDefined.Checked = false;
            }
            else
            {
                rbScaleWithLayer.Checked    = false;
                this.rbScaleDefined.Checked = true;
            }

            //ITextSymbol pTextSymbol = aLELayerProps.Symbol;
            //stdole.IFontDisp pFontDisp = pTextSymbol.Font;
            //pFontDisp.Size = decimal.Parse(fontSize);
            //pFontDisp.Bold = boldBool;
            //pFontDisp.Italic = italicBool;
            //pFontDisp.Name = fontStyle;
            //IRgbColor pRgbColor = new RgbColorClass();
            //pRgbColor.Red = int.Parse(fontColor.R.ToString());
            //pRgbColor.Blue = int.Parse(fontColor.B.ToString());
            //pRgbColor.Green = int.Parse(fontColor.G.ToString());
            //pTextSymbol.Font = pFontDisp;
            //pTextSymbol.Color = pRgbColor;
            //aLELayerProps.Symbol = pTextSymbol;
            //annoLayerProps = aLELayerProps as IAnnotateLayerProperties;
            //annoLayerProps.FeatureLayer = geoLayer;
            //annoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            //annoLayerPropsColl.Add(annoLayerProps);

            // 符号
            checkBoxCostomSymbol.Checked = EPSUtils.IsLayerRenderer(featureLayer);
        }