示例#1
0
 /// <summary>
 /// 把PointPlacementPriorities属性解析成字符串
 /// </summary>
 /// <param name="pPointPlacementPriorities"></param>
 /// <returns>如"00100000"</returns>
 public static string GetPlacementPriorities(IPointPlacementPriorities pPointPlacementPriorities)
 {
     return(pPointPlacementPriorities.AboveLeft.ToString() + pPointPlacementPriorities.AboveCenter.ToString() +
            pPointPlacementPriorities.AboveRight.ToString() + pPointPlacementPriorities.CenterRight.ToString() +
            pPointPlacementPriorities.BelowRight.ToString() + pPointPlacementPriorities.BelowCenter.ToString() +
            pPointPlacementPriorities.BelowLeft.ToString() + pPointPlacementPriorities.CenterLeft.ToString());
 }
示例#2
0
 private void PointFeatureLabelCtrl_Load(object sender, EventArgs e)
 {
     if (this.m_OverLayerProperty != null)
     {
         int num;
         this.rdoPointPlacementMethod.SelectedIndex = (int)this.m_OverLayerProperty.PointPlacementMethod;
         if (this.m_OverLayerProperty.RotationType == esriLabelRotationType.esriRotateLabelGeographic)
         {
             this.rdoRotationType.SelectedIndex = 0;
         }
         else
         {
             this.rdoRotationType.SelectedIndex = 1;
         }
         this.chkPerpendicularToAngle.Checked = this.m_OverLayerProperty.PerpendicularToAngle;
         this.m_Priorities = this.m_OverLayerProperty.PointPlacementPriorities;
         string placementPrioritiesStr = this.GetPlacementPrioritiesStr(this.m_Priorities);
         for (num = 0; num < this.imageComboBoxEdit1.Properties.Items.Count; num++)
         {
             ImageComboBoxItem item = this.imageComboBoxEdit1.Properties.Items[num];
             if (item.Value.ToString() == placementPrioritiesStr)
             {
                 this.imageComboBoxEdit1.SelectedIndex = num;
                 break;
             }
         }
         double[] pointPlacementAngles = (double[])this.m_OverLayerProperty.PointPlacementAngles;
         for (num = 0; num < pointPlacementAngles.Length; num++)
         {
             this.listPointPlacementAngles.Items.Add(pointPlacementAngles[num]);
         }
         this.rdoPointPlacementMethod_SelectedIndexChanged(this, e);
         this.m_CanDo = true;
     }
 }
示例#3
0
 /// <summary>
 /// 读取字符串并设置PointPlacementPriorities属性
 /// </summary>
 /// <param name="pPointPlacementPriorities"></param>
 /// <param name="strPlacement">如"00100000"</param>
 public static void SetPlacementPriotities(IPointPlacementPriorities pPointPlacementPriorities, string strPlacement)
 {
     pPointPlacementPriorities.AboveLeft   = Convert.ToInt16(strPlacement.Substring(0, 1));
     pPointPlacementPriorities.AboveCenter = Convert.ToInt16(strPlacement.Substring(1, 1));
     pPointPlacementPriorities.AboveRight  = Convert.ToInt16(strPlacement.Substring(2, 1));
     pPointPlacementPriorities.CenterRight = Convert.ToInt16(strPlacement.Substring(3, 1));
     pPointPlacementPriorities.BelowRight  = Convert.ToInt16(strPlacement.Substring(4, 1));
     pPointPlacementPriorities.BelowCenter = Convert.ToInt16(strPlacement.Substring(5, 1));
     pPointPlacementPriorities.BelowLeft   = Convert.ToInt16(strPlacement.Substring(6, 1));
     pPointPlacementPriorities.CenterLeft  = Convert.ToInt16(strPlacement.Substring(7, 1));
 }
示例#4
0
 private void SetPlacementPriorities(string s, IPointPlacementPriorities Priorities)
 {
     Priorities.AboveLeft   = this.GetNumber(s[0]);
     Priorities.AboveCenter = this.GetNumber(s[1]);
     Priorities.AboveRight  = this.GetNumber(s[2]);
     Priorities.CenterLeft  = this.GetNumber(s[3]);
     Priorities.CenterRight = this.GetNumber(s[5]);
     Priorities.BelowLeft   = this.GetNumber(s[6]);
     Priorities.BelowCenter = this.GetNumber(s[7]);
     Priorities.BelowRight  = this.GetNumber(s[8]);
 }
示例#5
0
 private void method_0(string string_1, IPointPlacementPriorities ipointPlacementPriorities_0)
 {
     ipointPlacementPriorities_0.AboveLeft   = this.method_3(string_1[0]);
     ipointPlacementPriorities_0.AboveCenter = this.method_3(string_1[1]);
     ipointPlacementPriorities_0.AboveRight  = this.method_3(string_1[2]);
     ipointPlacementPriorities_0.CenterLeft  = this.method_3(string_1[3]);
     ipointPlacementPriorities_0.CenterRight = this.method_3(string_1[5]);
     ipointPlacementPriorities_0.BelowLeft   = this.method_3(string_1[6]);
     ipointPlacementPriorities_0.BelowCenter = this.method_3(string_1[7]);
     ipointPlacementPriorities_0.BelowRight  = this.method_3(string_1[8]);
 }
示例#6
0
 private void InitialPointPlacementPriorities(IPointPlacementPriorities pointPlace)
 {
     pointPlace.AboveLeft   = 0;
     pointPlace.AboveCenter = 0;
     pointPlace.AboveRight  = 0;
     pointPlace.CenterLeft  = 0;
     pointPlace.CenterRight = 0;
     pointPlace.BelowLeft   = 0;
     pointPlace.BelowCenter = 0;
     pointPlace.BelowRight  = 0;
 }
示例#7
0
 private void imageComboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         IBasicOverposterLayerProperties4 basicOverposterLayerProperties =
             (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).BasicOverposterLayerProperties as
             IBasicOverposterLayerProperties4;
         IPointPlacementPriorities pointPlacementPriorities =
             basicOverposterLayerProperties.PointPlacementPriorities;
         ImageComboBoxItem item = this.imageComboBoxEdit1.Properties.Items[this.imageComboBoxEdit1.SelectedIndex];
         this.method_0(item.Value.ToString(), pointPlacementPriorities);
         basicOverposterLayerProperties.PointPlacementPriorities = pointPlacementPriorities;
     }
 }
示例#8
0
        private string GetPlacementPrioritiesStr(IPointPlacementPriorities Priorities)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(this.GetValue(Priorities.AboveLeft));
            builder.Append(this.GetValue(Priorities.AboveCenter));
            builder.Append(this.GetValue(Priorities.AboveRight));
            builder.Append(this.GetValue(Priorities.CenterLeft));
            builder.Append(this.GetValue(0));
            builder.Append(this.GetValue(Priorities.CenterRight));
            builder.Append(this.GetValue(Priorities.BelowLeft));
            builder.Append(this.GetValue(Priorities.BelowCenter));
            builder.Append(this.GetValue(Priorities.BelowRight));
            return(builder.ToString());
        }
示例#9
0
        private string method_2(IPointPlacementPriorities ipointPlacementPriorities_0)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(this.method_1(ipointPlacementPriorities_0.AboveLeft));
            builder.Append(this.method_1(ipointPlacementPriorities_0.AboveCenter));
            builder.Append(this.method_1(ipointPlacementPriorities_0.AboveRight));
            builder.Append(this.method_1(ipointPlacementPriorities_0.CenterLeft));
            builder.Append(this.method_1(0));
            builder.Append(this.method_1(ipointPlacementPriorities_0.CenterRight));
            builder.Append(this.method_1(ipointPlacementPriorities_0.BelowLeft));
            builder.Append(this.method_1(ipointPlacementPriorities_0.BelowCenter));
            builder.Append(this.method_1(ipointPlacementPriorities_0.BelowRight));
            return(builder.ToString());
        }
示例#10
0
 private void SetPointPlacementPriorities(IPointPlacementPriorities pointPlace)
 {
     InitialPointPlacementPriorities(pointPlace);
     if (radioAboveCenter.Checked)
     {
         pointPlace.AboveCenter = 1;
     }
     else if (radioAboveLeft.Checked)
     {
         pointPlace.AboveLeft = 1;
     }
     else if (radioAboveRight.Checked)
     {
         pointPlace.AboveRight = 1;
     }
     else if (radioCenterLeft.Checked)
     {
         pointPlace.CenterLeft = 1;
     }
     else if (radioCenterRight.Checked)
     {
         pointPlace.CenterRight = 1;
     }
     else if (radioBelowLeft.Checked)
     {
         pointPlace.BelowLeft = 1;
     }
     else if (radioBelowCenter.Checked)
     {
         pointPlace.BelowCenter = 1;
     }
     else if (radioBelowRight.Checked)
     {
         pointPlace.BelowRight = 1;
     }
 }
示例#11
0
        /// <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);
                    }
                }
            }
        }
示例#12
0
 private void method_4()
 {
     if (((this.igeoFeatureLayer_0 != null) && (this.iannotateLayerProperties_0 != null)) &&
         (this.igeoFeatureLayer_0.FeatureClass != null))
     {
         int num;
         this.bool_0 = false;
         IFields fields = this.igeoFeatureLayer_0.FeatureClass.Fields;
         for (num = 0; num < fields.FieldCount; num++)
         {
             IField field = fields.get_Field(num);
             if (((((field.Type == esriFieldType.esriFieldTypeDate) ||
                    (field.Type == esriFieldType.esriFieldTypeDouble)) ||
                   ((field.Type == esriFieldType.esriFieldTypeGlobalID) ||
                    (field.Type == esriFieldType.esriFieldTypeGUID))) ||
                  (((field.Type == esriFieldType.esriFieldTypeInteger) ||
                    (field.Type == esriFieldType.esriFieldTypeOID)) ||
                   ((field.Type == esriFieldType.esriFieldTypeSingle) ||
                    (field.Type == esriFieldType.esriFieldTypeSmallInteger)))) ||
                 (field.Type == esriFieldType.esriFieldTypeString))
             {
                 this.cboFields.Properties.Items.Add(field.AliasName);
             }
         }
         this.string_0 = (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).Expression.Trim();
         this.bool_1   = (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).IsExpressionSimple;
         this.iannotationExpressionEngine_0 =
             (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).ExpressionParser;
         if (this.string_0.IndexOf("[", 1) != -1)
         {
             this.cboFields.Enabled = false;
             this.cboFields.Text    = "表达式";
         }
         else
         {
             fields = this.igeoFeatureLayer_0.FeatureClass.Fields;
             string name  = this.string_0.Substring(1, this.string_0.Length - 2).Trim();
             int    index = fields.FindField(name);
             if (index == -1)
             {
                 this.cboFields.Enabled = false;
                 this.cboFields.Text    = "表达式";
             }
             else
             {
                 this.cboFields.Enabled = true;
                 this.cboFields.Text    = fields.get_Field(index).AliasName;
             }
         }
         this.symbolItem.ScaleRatio = 0.5;
         this.itextSymbol_0         = (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).Symbol;
         this.symbolItem.Symbol     = this.itextSymbol_0;
         this.symbolItem.Invalidate();
         this.rdoPointPlacementMethod.SelectedIndex =
             (int)
             (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).BasicOverposterLayerProperties
             .PointPlacementMethod;
         if (this.rdoPointPlacementMethod.SelectedIndex != 0)
         {
             if (this.rdoPointPlacementMethod.SelectedIndex == 2)
             {
                 this.btnAngles.Enabled          = true;
                 this.btnRotateField.Enabled     = false;
                 this.imageComboBoxEdit1.Enabled = false;
             }
             else if (this.rdoPointPlacementMethod.SelectedIndex == 3)
             {
                 this.btnAngles.Enabled          = false;
                 this.btnRotateField.Enabled     = true;
                 this.imageComboBoxEdit1.Enabled = false;
             }
             else
             {
                 this.btnAngles.Enabled          = false;
                 this.btnRotateField.Enabled     = false;
                 this.imageComboBoxEdit1.Enabled = false;
             }
         }
         else
         {
             IPointPlacementPriorities pointPlacementPriorities =
                 (this.iannotateLayerProperties_0 as ILabelEngineLayerProperties).BasicOverposterLayerProperties
                 .PointPlacementPriorities;
             string str2 = this.method_2(pointPlacementPriorities);
             for (num = 0; num < this.imageComboBoxEdit1.Properties.Items.Count; num++)
             {
                 ImageComboBoxItem item = this.imageComboBoxEdit1.Properties.Items[num];
                 if (item.Value.ToString() == str2)
                 {
                     this.imageComboBoxEdit1.SelectedIndex = num;
                     break;
                 }
             }
             this.btnAngles.Enabled          = false;
             this.btnRotateField.Enabled     = false;
             this.imageComboBoxEdit1.Enabled = true;
         }
         this.bool_0 = true;
     }
 }
示例#13
0
        private void ConvertAnnotation(IMap map, ILayer featureLayer, string annotationFeatureClassName, double scale,
                                       IWorkspace workspace, ILineLabelPosition lineLabelPosition,
                                       IPointPlacementPriorities pointPlacementPriorities,
                                       esriBasicOverposterWeight labelWeight, esriBasicOverposterWeight featureWeight, bool tagUnplaced,
                                       string fontName, double fontSize, IRgbColor rgbColor, string expression, bool featureLinked,
                                       esriLabelWhichFeatures labelWhichFeatures)
        {
            if (workspace.Type != esriWorkspaceType.esriFileSystemWorkspace && featureLayer is IGeoFeatureLayer)
            {
                IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
                IAnnotateLayerPropertiesCollection annotateLayerPropertiesCollectionClass =
                    geoFeatureLayer.AnnotationProperties;
                annotateLayerPropertiesCollectionClass.Clear();
                ILabelEngineLayerProperties     labelEngineLayerProperties     = new LabelEngineLayerPropertiesClass();
                IBasicOverposterLayerProperties basicOverposterLayerProperties =
                    new BasicOverposterLayerPropertiesClass();
                if (lineLabelPosition != null)
                {
                    basicOverposterLayerProperties.LineLabelPosition = lineLabelPosition;
                }
                else if (pointPlacementPriorities != null)
                {
                    basicOverposterLayerProperties.PointPlacementPriorities = pointPlacementPriorities;
                }
                basicOverposterLayerProperties.LabelWeight   = labelWeight;
                basicOverposterLayerProperties.FeatureWeight = featureWeight;

                IOverposterLayerProperties2 overposterLayerProperties2 =
                    basicOverposterLayerProperties as IOverposterLayerProperties2;
                overposterLayerProperties2.TagUnplaced = tagUnplaced;

                labelEngineLayerProperties.BasicOverposterLayerProperties = basicOverposterLayerProperties;
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = fontName;
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Size  = fontSize;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = rgbColor;
                labelEngineLayerProperties.Symbol     = pTextSymbol;
                labelEngineLayerProperties.Expression = expression;

                IAnnotateLayerProperties annotateLayerProperties =
                    labelEngineLayerProperties as IAnnotateLayerProperties;
                annotateLayerProperties.DisplayAnnotation = true;

                IAnnotationLayer annotationLayer =
                    CommonHelper.GetLayerByFeatureClassName(_context.FocusMap, annotationFeatureClassName) as
                    IAnnotationLayer;
                CommonHelper.SetReferenceScale(annotationLayer, scale);
                annotateLayerProperties.FeatureLayer      = geoFeatureLayer;
                annotateLayerProperties.GraphicsContainer = annotationLayer as IGraphicsContainer;
                annotateLayerProperties.AddUnplacedToGraphicsContainer = true;
                annotateLayerProperties.CreateUnplacedElements         = true;
                annotateLayerProperties.DisplayAnnotation  = true;
                annotateLayerProperties.FeatureLinked      = featureLinked;
                annotateLayerProperties.LabelWhichFeatures = labelWhichFeatures;
                annotateLayerProperties.UseOutput          = true;
                annotateLayerPropertiesCollectionClass.Add(annotateLayerProperties);

                annotateLayerPropertiesCollectionClass.Sort();
                IAnnotateMapProperties annotateMapPropertiesClass = new AnnotateMapPropertiesClass()
                {
                    AnnotateLayerPropertiesCollection = annotateLayerPropertiesCollectionClass
                };
                ITrackCancel          cancelTrackerClass   = new CancelTrackerClass();
                IAnnotateMap2         annotateMap2         = map.AnnotationEngine as IAnnotateMap2;
                IOverposterProperties overposterProperties = (map as IMapOverposter).OverposterProperties;
                annotateMap2.Label(overposterProperties, annotateMapPropertiesClass, map, cancelTrackerClass);
                map.AddLayer(annotationLayer as ILayer);
                geoFeatureLayer.DisplayAnnotation = false;
                map.ReferenceScale = scale;
                map.MapScale       = scale;
                IActiveView activeView = map as IActiveView;
                activeView.Refresh();
            }
        }