You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							953 lines
						
					
					
						
							39 KiB
						
					
					
				
			
		
		
	
	
							953 lines
						
					
					
						
							39 KiB
						
					
					
				using System; | 
						|
using System.Collections.Generic; | 
						|
using System.ComponentModel; | 
						|
using System.Drawing; | 
						|
using System.Data; | 
						|
using System.Linq; | 
						|
using System.Text; | 
						|
using System.Threading.Tasks; | 
						|
using System.Windows.Forms; | 
						|
using DevExpress.XtraEditors; | 
						|
using KGIS.Plugin.LayerProperty.Interface; | 
						|
using ESRI.ArcGIS.Carto; | 
						|
using ESRI.ArcGIS.Display; | 
						|
using ESRI.ArcGIS.Geodatabase; | 
						|
using KGIS.Plugin.LayerProperty.Utils; | 
						|
using ESRI.ArcGIS.esriSystem; | 
						|
using stdole; | 
						|
using ESRI.ArcGIS.ADF; | 
						|
using ESRI.ArcGIS.Geometry; | 
						|
using DevExpress.XtraEditors.Controls; | 
						|
using KGIS.Plugin.LayerProperty.Enum; | 
						|
using KGIS.Framework.Utils.Helper; | 
						|
 | 
						|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls | 
						|
{ | 
						|
    public partial class UCLabelPropertyPage : XtraUserControl, IUCPropertyPageEx, IPropertyPage | 
						|
    { | 
						|
        private string m_FontName; | 
						|
        private string m_LabelFieldName; | 
						|
        private float m_FontSize = 10f; | 
						|
        private bool m_CanLabel; | 
						|
        private bool m_Bold; | 
						|
        private bool m_Italic; | 
						|
        private bool m_Underline; | 
						|
        private string m_FontColor; | 
						|
        private double m_LabelMinScale; | 
						|
        private double m_LabelMaxScale; | 
						|
        private IAnnotateLayerPropertiesCollection m_AnnotateLayerPropertiesCollection; | 
						|
        private ILabelEngineLayerProperties2 m_LabelEngineLayerProps; | 
						|
        private ILabelEngineLayerProperties2 m_CloneLabelEngineLayerProps; | 
						|
        private IBasicOverposterLayerProperties4 m_TempBasicOverposterLayerProperties; | 
						|
        private IStyleGalleryClass m_StyleGalleryClass; | 
						|
        private ILayer m_Layer; | 
						|
        private FormLabelScaleRangeSet m_frmLabelScaleRangeSet; | 
						|
        private List<IPropertyPage> PropertyList; | 
						|
        private FormPlacmentProps m_PlacmentSet; | 
						|
        private ITextSymbol m_TextSymbol; | 
						|
        private IFontDisp m_TextFont; | 
						|
        private IFields m_Fields; | 
						|
        private string m_LabelExpression; | 
						|
        private bool m_IsExpressionSimple = true; | 
						|
        private IGeoFeatureLayer geoFeaLyr; | 
						|
        private FormSQLCreator frmSQLCreator; | 
						|
        private IAnnotateLayerProperties m_CurrentAnnoLyrProp; | 
						|
        private bool m_ReadProp; | 
						|
        private bool isCustomLayer; | 
						|
        private bool isDirty; | 
						|
        public event System.EventHandler EditorChanged; | 
						|
        public bool IsCustomLayer | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return this.isCustomLayer; | 
						|
            } | 
						|
        } | 
						|
        public bool IsPageDirty | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return this.isDirty; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                this.isDirty = value; | 
						|
            } | 
						|
        } | 
						|
        public int Priority | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                throw new Exception("The method or operation is not implemented."); | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                throw new Exception("The method or operation is not implemented."); | 
						|
            } | 
						|
        } | 
						|
        public string Title | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                throw new Exception("The method or operation is not implemented."); | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                throw new Exception("The method or operation is not implemented."); | 
						|
            } | 
						|
        } | 
						|
        public UCLabelPropertyPage() | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
            PopupBaseAutoSearchEdit popupBaseAutoSearchEdit = this.cmbFontSize; | 
						|
            DevExpressControlCommand.SetAllEditorInteger2(ref popupBaseAutoSearchEdit, false, false, 3); | 
						|
        } | 
						|
        public void InitUC(object layerProperty) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.isCustomLayer = false; | 
						|
                this.m_Layer = (layerProperty as ILayer); | 
						|
                this.geoFeaLyr = (layerProperty as IGeoFeatureLayer); | 
						|
                this.PropertyList = new List<IPropertyPage>(); | 
						|
                this.m_TempBasicOverposterLayerProperties = null; | 
						|
                this.fontEdit2.EditValue = "宋体"; | 
						|
                this.chkBold.Checked = false; | 
						|
                this.chkItalic.Checked = false; | 
						|
                this.chkUnderline.Checked = false; | 
						|
                this.clrFontColor.Color = Color.Black; | 
						|
                this.btnDeleteClass.Enabled = true; | 
						|
                this.cmbAnnoLyrPropClass.Properties.Items.Clear(); | 
						|
                if (this.geoFeaLyr != null) | 
						|
                { | 
						|
                    this.chkLabelFeatures.Checked = this.geoFeaLyr.DisplayAnnotation; | 
						|
                    this.m_AnnotateLayerPropertiesCollection = this.geoFeaLyr.AnnotationProperties; | 
						|
                    if (this.m_AnnotateLayerPropertiesCollection == null) | 
						|
                    { | 
						|
                        this.CreateDefaultAnnonation(); | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        IAnnotateLayerProperties annotateLayerProperties = null; | 
						|
                        IElementCollection elementCollection = null; | 
						|
                        IElementCollection elementCollection2 = null; | 
						|
                        for (int i = 0; i < this.m_AnnotateLayerPropertiesCollection.Count; i++) | 
						|
                        { | 
						|
                            this.m_AnnotateLayerPropertiesCollection.QueryItem(i, out annotateLayerProperties, out elementCollection2, out elementCollection); | 
						|
                            IAnnotateLayerProperties innervalue = (annotateLayerProperties as IClone).Clone() as IAnnotateLayerProperties; | 
						|
                            ItemInfo<IAnnotateLayerProperties, string> item = new ItemInfo<IAnnotateLayerProperties, string>(innervalue, annotateLayerProperties.Class); | 
						|
                            this.cmbAnnoLyrPropClass.Properties.Items.Add(item); | 
						|
                        } | 
						|
                        this.cmbAnnoLyrPropClass.SelectedIndex = 0; | 
						|
                        if (this.m_AnnotateLayerPropertiesCollection.Count > 1) | 
						|
                        { | 
						|
                            this.cmbLabelType.SelectedIndex = 1; | 
						|
                        } | 
						|
                        else | 
						|
                        { | 
						|
                            this.cmbLabelType.SelectedIndex = 0; | 
						|
                        } | 
						|
                    } | 
						|
                    this.btnGetAnnoLyrPropBySymbol.Enabled = this.CanGetClassFromSymbols(); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        public void ReadAnnotateLayerProperties(IAnnotateLayerProperties pAnnotateLayerProperties) | 
						|
        { | 
						|
            if (pAnnotateLayerProperties == null) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
            this.m_CurrentAnnoLyrProp = pAnnotateLayerProperties; | 
						|
            this.m_LabelEngineLayerProps = (pAnnotateLayerProperties as ILabelEngineLayerProperties2); | 
						|
            IClone clone = this.m_LabelEngineLayerProps.BasicOverposterLayerProperties as IClone; | 
						|
            this.m_TempBasicOverposterLayerProperties = (clone.Clone() as IBasicOverposterLayerProperties4); | 
						|
            clone = (this.m_LabelEngineLayerProps as IClone); | 
						|
            this.m_CloneLabelEngineLayerProps = (clone.Clone() as ILabelEngineLayerProperties2); | 
						|
            this.m_LabelMaxScale = pAnnotateLayerProperties.AnnotationMaximumScale; | 
						|
            this.m_LabelMinScale = pAnnotateLayerProperties.AnnotationMinimumScale; | 
						|
            if (this.m_LabelEngineLayerProps == null) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
            this.chkDisplayAnnotation.Checked = pAnnotateLayerProperties.DisplayAnnotation; | 
						|
            this.m_LabelExpression = this.m_LabelEngineLayerProps.Expression; | 
						|
            this.m_IsExpressionSimple = this.m_LabelEngineLayerProps.IsExpressionSimple; | 
						|
            this.m_Fields = this.geoFeaLyr.FeatureClass.Fields; | 
						|
            this.SetCmbLabelField(this.m_LabelEngineLayerProps); | 
						|
            if (this.m_LabelEngineLayerProps.Symbol == null) | 
						|
            { | 
						|
                this.m_TextSymbol = this.ConvertToSymbol(); | 
						|
                this.m_LabelEngineLayerProps.Symbol = this.m_TextSymbol; | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                this.m_TextSymbol = this.m_LabelEngineLayerProps.Symbol; | 
						|
            } | 
						|
            this.SetBySymbol(this.m_TextSymbol); | 
						|
        } | 
						|
        private void GetLabelSet() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.GetCurrentLabelSet(); | 
						|
                this.m_AnnotateLayerPropertiesCollection.Clear(); | 
						|
                for (int i = 0; i < this.cmbAnnoLyrPropClass.Properties.Items.Count; i++) | 
						|
                { | 
						|
                    ItemInfo<IAnnotateLayerProperties, string> itemInfo = this.cmbAnnoLyrPropClass.Properties.Items[i] as ItemInfo<IAnnotateLayerProperties, string>; | 
						|
                    if (itemInfo != null) | 
						|
                    { | 
						|
                        if (this.cmbLabelType.SelectedIndex == 0) | 
						|
                        { | 
						|
                            itemInfo.InnerValue.WhereClause = ""; | 
						|
                            this.m_AnnotateLayerPropertiesCollection.Add(itemInfo.InnerValue); | 
						|
                            break; | 
						|
                        } | 
						|
                        this.m_AnnotateLayerPropertiesCollection.Add(itemInfo.InnerValue); | 
						|
                    } | 
						|
                } | 
						|
                (this.m_Layer as IGeoFeatureLayer).AnnotationProperties = this.m_AnnotateLayerPropertiesCollection; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void GetCurrentLabelSet() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.m_TempBasicOverposterLayerProperties != null) | 
						|
                { | 
						|
                    this.m_LabelEngineLayerProps.BasicOverposterLayerProperties = (this.m_TempBasicOverposterLayerProperties as IBasicOverposterLayerProperties); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    this.m_LabelEngineLayerProps.BasicOverposterLayerProperties = new BasicOverposterLayerPropertiesClass(); | 
						|
                } | 
						|
                this.m_LabelEngineLayerProps.Symbol = this.m_TextSymbol; | 
						|
                this.m_CloneLabelEngineLayerProps.Expression = (this.cmbLabelField.Tag as string); | 
						|
 | 
						|
                #region BUG10428修改 2018-09-03 郑英杰 注释,对象为引用类型不需要再次赋值 | 
						|
                //this.m_LabelEngineLayerProps.Expression = this.m_CloneLabelEngineLayerProps.Expression; | 
						|
                //this.m_LabelEngineLayerProps.ExpressionParser = this.m_CloneLabelEngineLayerProps.ExpressionParser; | 
						|
                //this.m_LabelEngineLayerProps.IsExpressionSimple = this.m_CloneLabelEngineLayerProps.IsExpressionSimple; | 
						|
                #endregion | 
						|
 | 
						|
                IAnnotateLayerProperties annotateLayerProperties = this.m_LabelEngineLayerProps as IAnnotateLayerProperties; | 
						|
                if (annotateLayerProperties != null) | 
						|
                { | 
						|
                    annotateLayerProperties.AnnotationMaximumScale = this.m_LabelMaxScale; | 
						|
                    annotateLayerProperties.AnnotationMinimumScale = this.m_LabelMinScale; | 
						|
                    annotateLayerProperties.DisplayAnnotation = this.chkDisplayAnnotation.Checked; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void SetCmbLabelField(ILabelEngineLayerProperties2 labelEngineLayerProps) | 
						|
        { | 
						|
            if (!this.IsExpression(labelEngineLayerProps)) | 
						|
            { | 
						|
                string text = labelEngineLayerProps.Expression.Replace("[", ""); | 
						|
                text = text.Replace("]", ""); | 
						|
                Utils.Util.InitFieldList(ref this.cmbLabelField, this.geoFeaLyr.FeatureClass.Fields, text, false, false, true); | 
						|
                this.cmbLabelField.Enabled = true; | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                this.cmbLabelField.Enabled = false; | 
						|
                this.cmbLabelField.Text = "表达式"; | 
						|
            } | 
						|
            this.cmbLabelField.Tag = labelEngineLayerProps.Expression; | 
						|
        } | 
						|
        public void Write2Prop() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.isCustomLayer) | 
						|
                { | 
						|
                    this.GetLabelSet(); | 
						|
                    IGeoFeatureLayer geoFeatureLayer = this.m_Layer as IGeoFeatureLayer; | 
						|
                    if (geoFeatureLayer != null) | 
						|
                    { | 
						|
                        geoFeatureLayer.DisplayAnnotation = this.chkLabelFeatures.Checked; | 
						|
                    } | 
						|
                } | 
						|
                this.isDirty = false; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        public bool CanWrite2Prop() | 
						|
        { | 
						|
            return this.isDirty; | 
						|
        } | 
						|
        private void InvokeEditValueChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.EditorChanged != null) | 
						|
            { | 
						|
                this.EditorChanged(sender, e); | 
						|
            } | 
						|
            this.isDirty = true; | 
						|
        } | 
						|
        public void SetDefaultValue(object value) | 
						|
        { | 
						|
        } | 
						|
        private void chkLabelFeatures_CheckedChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.m_CanLabel = this.chkLabelFeatures.Checked; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void ucFieldsCombox1_SelectedFieldChanged(IField field) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (field != null) | 
						|
                { | 
						|
                    this.m_LabelFieldName = field.Name; | 
						|
                } | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void cmbLabelField_SelectedIndexChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                ItemInfo<IField, string> itemInfo = this.cmbLabelField.SelectedItem as ItemInfo<IField, string>; | 
						|
                if (itemInfo != null) | 
						|
                { | 
						|
                    this.m_LabelFieldName = itemInfo.InnerValue.Name; | 
						|
                    this.m_LabelExpression = "[" + this.m_LabelFieldName + "]"; | 
						|
                    this.cmbLabelField.Tag = this.m_LabelExpression; | 
						|
 | 
						|
                    #region BUG9883修改 2018-09-03 郑英杰 | 
						|
                    this.m_LabelEngineLayerProps.Expression = this.m_LabelExpression; | 
						|
                    #endregion | 
						|
 | 
						|
                } | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void cmbFontSize_TextChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (Convert.ToDouble(this.cmbFontSize.Text) >= 0.0) | 
						|
                    { | 
						|
                        if (this.m_TextSymbol != null) | 
						|
                        { | 
						|
                            this.m_TextSymbol.Font = this.CreateFont(); | 
						|
                        } | 
						|
                        this.PreviewGalleryItem(); | 
						|
                        this.m_FontSize = Convert.ToSingle(this.cmbFontSize.Text); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void fontEdit2_SelectedIndexChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (this.m_TextSymbol != null) | 
						|
                    { | 
						|
                        this.m_TextSymbol.Font = this.CreateFont(); | 
						|
                    } | 
						|
                    this.PreviewGalleryItem(); | 
						|
                    this.m_FontName = this.fontEdit2.Text; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private IFontDisp CreateFont() | 
						|
        { | 
						|
            float value = Convert.ToSingle(this.cmbFontSize.EditValue); | 
						|
            this.m_TextFont = (new StdFontClass() as IFontDisp); | 
						|
            decimal size = Convert.ToDecimal(value); | 
						|
            this.m_TextFont.Size = size; | 
						|
            this.m_TextFont.Italic = this.chkItalic.Checked; | 
						|
            this.m_TextFont.Bold = this.chkBold.Checked; | 
						|
            this.m_TextFont.Underline = this.chkUnderline.Checked; | 
						|
            this.m_TextFont.Name = this.fontEdit2.Text; | 
						|
            return this.m_TextFont; | 
						|
        } | 
						|
        private void clrFontColor_EditValueChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (this.m_TextSymbol != null) | 
						|
                    { | 
						|
                        IColor color = this.m_TextSymbol.Color; | 
						|
                        color = Converter.ToRGBColor(this.clrFontColor.Color); | 
						|
                        color.Transparency = this.clrFontColor.Color.A; | 
						|
                        this.m_TextSymbol.Color = color; | 
						|
                    } | 
						|
                    this.PreviewGalleryItem(); | 
						|
                    this.m_FontColor = this.clrFontColor.Text; | 
						|
                    this.InvokeEditValueChanged(sender, e); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void chkBold_CheckedChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (this.m_TextSymbol != null) | 
						|
                    { | 
						|
                        this.m_TextSymbol.Font = this.CreateFont(); | 
						|
                    } | 
						|
                    this.PreviewGalleryItem(); | 
						|
                    this.m_Bold = this.chkBold.Checked; | 
						|
                    this.InvokeEditValueChanged(null, null); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void chkItalic_CheckedChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (this.m_TextSymbol != null) | 
						|
                    { | 
						|
                        this.m_TextSymbol.Font = this.CreateFont(); | 
						|
                    } | 
						|
                    this.PreviewGalleryItem(); | 
						|
                    this.m_Italic = this.chkItalic.Checked; | 
						|
                    this.InvokeEditValueChanged(null, null); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void chkUnderline_CheckedChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (!this.m_ReadProp) | 
						|
                { | 
						|
                    if (this.m_TextSymbol != null) | 
						|
                    { | 
						|
                        this.m_TextSymbol.Font = this.CreateFont(); | 
						|
                    } | 
						|
                    this.PreviewGalleryItem(); | 
						|
                    this.m_Underline = this.chkUnderline.Checked; | 
						|
                    this.InvokeEditValueChanged(null, null); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private FontStyle rtPadFontStyle() | 
						|
        { | 
						|
            FontStyle fontStyle = FontStyle.Regular; | 
						|
            if (this.chkBold.Checked) | 
						|
            { | 
						|
                fontStyle |= FontStyle.Bold; | 
						|
            } | 
						|
            if (this.chkItalic.Checked) | 
						|
            { | 
						|
                fontStyle |= FontStyle.Italic; | 
						|
            } | 
						|
            if (this.chkUnderline.Checked) | 
						|
            { | 
						|
                fontStyle |= FontStyle.Underline; | 
						|
            } | 
						|
            return fontStyle; | 
						|
        } | 
						|
        private void btnSelectSymbol_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IClone clone = this.m_TextSymbol as IClone; | 
						|
                if (clone != null) | 
						|
                { | 
						|
                    ISymbol symbol = clone.Clone() as ISymbol; | 
						|
                    symbol = (RenderUtil.OpenStyleSelector(esriStyleClass.TextSymbols, symbol) as ISymbol); | 
						|
                    if (symbol != null) | 
						|
                    { | 
						|
                        this.m_TextSymbol = (symbol as ITextSymbol); | 
						|
                        this.SetBySymbol(this.m_TextSymbol); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch | 
						|
            { | 
						|
            } | 
						|
        } | 
						|
        private void CreateDefaultAnnonation() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IFeatureLayer2 featureLayer = this.m_Layer as IFeatureLayer2; | 
						|
                Utils.Util.InitFieldList(ref this.cmbLabelField, featureLayer.FeatureClass.Fields, this.m_LabelFieldName, false, false, true); | 
						|
                esriFeatureType featureType = featureLayer.FeatureClass.FeatureType; | 
						|
                if (featureType != esriFeatureType.esriFTAnnotation) | 
						|
                { | 
						|
                    this.m_TempBasicOverposterLayerProperties = new BasicOverposterLayerPropertiesClass(); | 
						|
                    this.m_LabelEngineLayerProps = new LabelEngineLayerPropertiesClass(); | 
						|
                    this.m_AnnotateLayerPropertiesCollection.Clear(); | 
						|
                    this.m_LabelEngineLayerProps.BasicOverposterLayerProperties = (this.m_TempBasicOverposterLayerProperties as IBasicOverposterLayerProperties); | 
						|
                    this.m_LabelEngineLayerProps.Symbol = this.ConvertToSymbol(); | 
						|
                    this.m_LabelEngineLayerProps.IsExpressionSimple = true; | 
						|
                    this.m_LabelEngineLayerProps.Expression = "[" + this.m_LabelFieldName + "]"; | 
						|
                    IAnnotateLayerProperties annotateLayerProperties = this.m_LabelEngineLayerProps as IAnnotateLayerProperties; | 
						|
                    if (annotateLayerProperties != null) | 
						|
                    { | 
						|
                        annotateLayerProperties.AnnotationMaximumScale = this.m_LabelMaxScale; | 
						|
                        annotateLayerProperties.AnnotationMinimumScale = this.m_LabelMinScale; | 
						|
                    } | 
						|
                    this.m_AnnotateLayerPropertiesCollection.Add(annotateLayerProperties); | 
						|
                    (this.m_Layer as IGeoFeatureLayer).AnnotationProperties = this.m_AnnotateLayerPropertiesCollection; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private ITextSymbol ConvertToSymbol() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                ITextSymbol textSymbol = new TextSymbolClass(); | 
						|
                Color color = Color.Black; | 
						|
                string[] array = this.m_FontColor.Split(new char[] | 
						|
                { | 
						|
                    ',' | 
						|
                }); | 
						|
                if (array.Length == 3) | 
						|
                { | 
						|
                    int red = Convert.ToInt32(array[0]); | 
						|
                    int green = Convert.ToInt32(array[1]); | 
						|
                    int blue = Convert.ToInt32(array[2]); | 
						|
                    color = Color.FromArgb(red, green, blue); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    color = Color.FromName(this.m_FontColor); | 
						|
                } | 
						|
                textSymbol.Color = Converter.ToRGBColor(color); | 
						|
                System.Drawing.Font font = new System.Drawing.Font(this.m_FontName, this.m_FontSize, this.rtPadFontStyle()); | 
						|
                textSymbol.Font = Converter.ToStdFont(font); | 
						|
                textSymbol.Text = "AaBbYyZz"; | 
						|
                return textSymbol; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
            return null; | 
						|
        } | 
						|
        private void SetBySymbol(ITextSymbol Symbol) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.m_ReadProp = true; | 
						|
                if (Symbol != null) | 
						|
                { | 
						|
                    if (this.m_StyleGalleryClass == null) | 
						|
                    { | 
						|
                        this.m_StyleGalleryClass = new TextSymbolStyleGalleryClassClass(); | 
						|
                    } | 
						|
                    this.m_TextFont = Symbol.Font; | 
						|
                    this.fontEdit2.Text = this.m_TextFont.Name; | 
						|
                    this.cmbFontSize.Text = this.m_TextFont.Size.ToString(); | 
						|
                    this.chkBold.Checked = this.m_TextFont.Bold; | 
						|
                    Color color = Converter.FromRGBColor(Symbol.Color as IRgbColor); | 
						|
                    this.clrFontColor.Text = string.Concat(new object[] | 
						|
                    { | 
						|
                        color.R, | 
						|
                        ",", | 
						|
                        color.G, | 
						|
                        ",", | 
						|
                        color.B | 
						|
                    }); | 
						|
                    this.chkItalic.Checked = this.m_TextFont.Italic; | 
						|
                    this.chkUnderline.Checked = this.m_TextFont.Underline; | 
						|
                    this.m_FontName = this.fontEdit2.Text; | 
						|
                    this.m_FontSize = Convert.ToSingle(this.cmbFontSize.Text); | 
						|
                    this.m_CanLabel = this.chkLabelFeatures.Checked; | 
						|
                    this.m_Bold = this.chkBold.Checked; | 
						|
                    this.m_FontColor = this.clrFontColor.Text; | 
						|
                    this.m_Italic = this.chkItalic.Checked; | 
						|
                    this.m_Underline = this.chkUnderline.Checked; | 
						|
                    this.PreviewGalleryItem(); | 
						|
                } | 
						|
                this.m_ReadProp = false; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnScaleRange_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.m_frmLabelScaleRangeSet == null) | 
						|
            { | 
						|
                this.m_frmLabelScaleRangeSet = new FormLabelScaleRangeSet(); | 
						|
            } | 
						|
            this.m_frmLabelScaleRangeSet.InitForm(this.m_LabelMaxScale, this.m_LabelMinScale); | 
						|
            if (this.m_frmLabelScaleRangeSet.ShowDialog(base.FindForm()) == DialogResult.OK) | 
						|
            { | 
						|
                this.m_LabelMaxScale = this.m_frmLabelScaleRangeSet.MaxScale; | 
						|
                this.m_LabelMinScale = this.m_frmLabelScaleRangeSet.MinScale; | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
        } | 
						|
        private void btnPlacementSet_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.m_TempBasicOverposterLayerProperties == null) | 
						|
                { | 
						|
                    IClone clone = this.m_LabelEngineLayerProps.BasicOverposterLayerProperties as IClone; | 
						|
                    this.m_TempBasicOverposterLayerProperties = (clone.Clone() as IBasicOverposterLayerProperties4); | 
						|
                } | 
						|
                if (this.m_PlacmentSet == null) | 
						|
                { | 
						|
                    this.m_PlacmentSet = new FormPlacmentProps(); | 
						|
                } | 
						|
                this.m_PlacmentSet.Fields = this.m_Fields; | 
						|
                this.m_PlacmentSet.InitUC(this.m_TempBasicOverposterLayerProperties); | 
						|
                if (this.m_PlacmentSet.ShowDialog() == DialogResult.OK) | 
						|
                { | 
						|
                    this.InvokeEditValueChanged(null, null); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        public int Activate() | 
						|
        { | 
						|
            throw new Exception("The method or operation is not implemented."); | 
						|
        } | 
						|
        public void Deactivate() | 
						|
        { | 
						|
            throw new Exception("The method or operation is not implemented."); | 
						|
        } | 
						|
        public void Cancel() | 
						|
        { | 
						|
            throw new Exception("The method or operation is not implemented."); | 
						|
        } | 
						|
        private void PreviewGalleryItem() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.m_TextSymbol != null) | 
						|
                { | 
						|
                    Bitmap map = StyleGalleryItemView.GetSymbolBitMap(this.picView.Width - 1, this.picView.Height - 1, this.m_StyleGalleryClass, this.m_TextSymbol as ISymbol); | 
						|
                    this.picView.Image = map; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnExpression_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            FormLabelExpression formLabelExpression = new FormLabelExpression(); | 
						|
            formLabelExpression.InitForm(this.m_LabelEngineLayerProps, this.m_Fields); | 
						|
            if (formLabelExpression.ShowDialog(base.FindForm()) == DialogResult.OK) | 
						|
            { | 
						|
                this.SetCmbLabelField(this.m_LabelEngineLayerProps); | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
        } | 
						|
        private void btnLabelStyle_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                ILabelStyle labelStyle = RenderUtil.OpenStyleSelector(esriStyleClass.Labels, null) as ILabelStyle; | 
						|
                if (labelStyle != null) | 
						|
                { | 
						|
                    this.m_TextSymbol = labelStyle.Symbol; | 
						|
                    this.m_TempBasicOverposterLayerProperties = (labelStyle.BasicOverposterLayerProperties as IBasicOverposterLayerProperties4); | 
						|
                    IFeatureLayer2 featureLayer = this.m_Layer as IFeatureLayer2; | 
						|
                    if (featureLayer != null) | 
						|
                    { | 
						|
                        if (featureLayer.ShapeType == esriGeometryType.esriGeometryPoint) | 
						|
                        { | 
						|
                            this.m_TempBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint; | 
						|
                        } | 
						|
                        else | 
						|
                        { | 
						|
                            if (featureLayer.ShapeType == esriGeometryType.esriGeometryPolyline) | 
						|
                            { | 
						|
                                this.m_TempBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; | 
						|
                            } | 
						|
                            else | 
						|
                            { | 
						|
                                if (featureLayer.ShapeType == esriGeometryType.esriGeometryPolygon) | 
						|
                                { | 
						|
                                    this.m_TempBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon; | 
						|
                                } | 
						|
                            } | 
						|
                        } | 
						|
                    } | 
						|
                    this.SetBySymbol(this.m_TextSymbol); | 
						|
                } | 
						|
            } | 
						|
            catch | 
						|
            { | 
						|
            } | 
						|
        } | 
						|
        private bool IsExpression(ILabelEngineLayerProperties2 labelEngineLayerProps) | 
						|
        { | 
						|
            if (!labelEngineLayerProps.IsExpressionSimple) | 
						|
            { | 
						|
                return true; | 
						|
            } | 
						|
            if (labelEngineLayerProps.Expression.Contains("&\"")) | 
						|
            { | 
						|
                return true; | 
						|
            } | 
						|
            string expression = labelEngineLayerProps.Expression; | 
						|
            return expression.IndexOf("]") < expression.Length - 1; | 
						|
        } | 
						|
        private void cmbLabelType_SelectedIndexChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.cmbLabelType.SelectedIndex == 0) | 
						|
            { | 
						|
                this.pnlMutilClasses.Visible = false; | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                this.pnlMutilClasses.Visible = true; | 
						|
            } | 
						|
            this.InvokeEditValueChanged(null, null); | 
						|
        } | 
						|
        private bool ClassNameCanUse(string className) | 
						|
        { | 
						|
            if (className == string.Empty) | 
						|
            { | 
						|
                MessageHelper.Show("名称不能为空"); | 
						|
                return false; | 
						|
            } | 
						|
            for (int i = 0; i < this.cmbAnnoLyrPropClass.Properties.Items.Count; i++) | 
						|
            { | 
						|
                ItemInfo<IAnnotateLayerProperties, string> itemInfo = this.cmbAnnoLyrPropClass.Properties.Items[i] as ItemInfo<IAnnotateLayerProperties, string>; | 
						|
                if (itemInfo != null && itemInfo.DisplayValue == className) | 
						|
                { | 
						|
                    MessageHelper.Show("分类名称已经存在,不能重复!"); | 
						|
                    return false; | 
						|
                } | 
						|
            } | 
						|
            return true; | 
						|
        } | 
						|
        private bool ClassNameCanUse2(string className) | 
						|
        { | 
						|
            if (className == string.Empty) | 
						|
            { | 
						|
                return false; | 
						|
            } | 
						|
            for (int i = 0; i < this.cmbAnnoLyrPropClass.Properties.Items.Count; i++) | 
						|
            { | 
						|
                ItemInfo<IAnnotateLayerProperties, string> itemInfo = this.cmbAnnoLyrPropClass.Properties.Items[i] as ItemInfo<IAnnotateLayerProperties, string>; | 
						|
                if (itemInfo != null && itemInfo.DisplayValue == className) | 
						|
                { | 
						|
                    return false; | 
						|
                } | 
						|
            } | 
						|
            return true; | 
						|
        } | 
						|
        private void CreateNewAnnotateLayerProperties(string name) | 
						|
        { | 
						|
            IAnnotateLayerProperties annotateLayerProperties = (this.m_CurrentAnnoLyrProp as IClone).Clone() as IAnnotateLayerProperties; | 
						|
            annotateLayerProperties.Class = name; | 
						|
            annotateLayerProperties.DisplayAnnotation = false; | 
						|
            ItemInfo<IAnnotateLayerProperties, string> item = new ItemInfo<IAnnotateLayerProperties, string>(annotateLayerProperties, name); | 
						|
            this.cmbAnnoLyrPropClass.SelectedIndex = this.cmbAnnoLyrPropClass.Properties.Items.Add(item); | 
						|
            this.AnnoLyrPropClassChanged(); | 
						|
            this.InvokeEditValueChanged(null, null); | 
						|
        } | 
						|
        private void btnAddClass_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            string empty = string.Empty; | 
						|
            if (DevExpressInputBox.InputBox("分类名称:", "新建分类", "", out empty) == DialogResult.OK && this.ClassNameCanUse(empty)) | 
						|
            { | 
						|
                this.CreateNewAnnotateLayerProperties(empty); | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
        } | 
						|
        private void btnDeleteClass_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.cmbAnnoLyrPropClass.Properties.Items.Count > 1) | 
						|
            { | 
						|
                this.cmbAnnoLyrPropClass.Properties.Items.Remove(this.cmbAnnoLyrPropClass.SelectedItem); | 
						|
                this.cmbAnnoLyrPropClass.SelectedIndex = 0; | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
        } | 
						|
        private void btnRenameClass_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            string empty = string.Empty; | 
						|
            if (DevExpressInputBox.InputBox("分类名称:", "修改分类", this.m_CurrentAnnoLyrProp.Class, out empty) == DialogResult.OK && this.ClassNameCanUse(empty)) | 
						|
            { | 
						|
                this.m_CurrentAnnoLyrProp.Class = empty; | 
						|
                this.cmbAnnoLyrPropClass.Properties.Items.Remove(this.cmbAnnoLyrPropClass.SelectedItem); | 
						|
                ItemInfo<IAnnotateLayerProperties, string> item = new ItemInfo<IAnnotateLayerProperties, string>(this.m_CurrentAnnoLyrProp, this.m_CurrentAnnoLyrProp.Class); | 
						|
                this.cmbAnnoLyrPropClass.SelectedIndex = this.cmbAnnoLyrPropClass.Properties.Items.Add(item); | 
						|
                this.cmbAnnoLyrPropClass.Update(); | 
						|
                this.InvokeEditValueChanged(null, null); | 
						|
            } | 
						|
        } | 
						|
        private void cmbAnnoLyrPropClass_SelectedValueChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            ItemInfo<IAnnotateLayerProperties, string> itemInfo = this.cmbAnnoLyrPropClass.SelectedItem as ItemInfo<IAnnotateLayerProperties, string>; | 
						|
            if (itemInfo != null) | 
						|
            { | 
						|
                this.ReadAnnotateLayerProperties(itemInfo.InnerValue); | 
						|
            } | 
						|
            this.AnnoLyrPropClassChanged(); | 
						|
            this.InvokeEditValueChanged(null, null); | 
						|
        } | 
						|
        private void cmbAnnoLyrPropClass_EditValueChanging(object sender, ChangingEventArgs e) | 
						|
        { | 
						|
            ItemInfo<IAnnotateLayerProperties, string> param = e.OldValue as ItemInfo<IAnnotateLayerProperties, string>; | 
						|
            if (param != null) | 
						|
            { | 
						|
                this.GetCurrentLabelSet(); | 
						|
            } | 
						|
            this.InvokeEditValueChanged(null, null); | 
						|
        } | 
						|
        private void btnWhereClause_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.frmSQLCreator == null) | 
						|
                { | 
						|
                    this.frmSQLCreator = new FormSQLCreator(); | 
						|
                } | 
						|
                IFeatureLayer featureLayer = this.m_Layer as IFeatureLayer; | 
						|
                if (featureLayer != null) | 
						|
                { | 
						|
                    this.frmSQLCreator.InitForm(featureLayer); | 
						|
                    this.frmSQLCreator.SQL = this.m_CurrentAnnoLyrProp.WhereClause; | 
						|
                    if (this.frmSQLCreator.ShowDialog() == DialogResult.OK) | 
						|
                    { | 
						|
                        this.m_CurrentAnnoLyrProp.WhereClause = this.frmSQLCreator.SQL; | 
						|
                        this.InvokeEditValueChanged(null, null); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void AnnoLyrPropClassChanged() | 
						|
        { | 
						|
            if (this.cmbAnnoLyrPropClass.Properties.Items.Count == 1) | 
						|
            { | 
						|
                this.btnDeleteClass.Enabled = false; | 
						|
                this.chkDisplayAnnotation.Checked = true; | 
						|
                this.chkDisplayAnnotation.Enabled = false; | 
						|
                return; | 
						|
            } | 
						|
            this.btnDeleteClass.Enabled = true; | 
						|
            this.chkDisplayAnnotation.Enabled = true; | 
						|
        } | 
						|
        private bool CanGetClassFromSymbols() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IFeatureRenderer renderer = (this.m_Layer as IGeoFeatureLayer).Renderer; | 
						|
                IUniqueValueRenderer uniqueValueRenderer = renderer as IUniqueValueRenderer; | 
						|
                if (uniqueValueRenderer != null) | 
						|
                { | 
						|
                    return true; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
            } | 
						|
            return false; | 
						|
        } | 
						|
        private void btnGetAnnoLyrPropBySymbol_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            DialogResult dialogResult = MessageHelper.ShowYesNoCancelAndTips("是否要覆盖现有的标注分类?\n\r点击是将使用符号分类对现有的分类进行覆盖。\n\r点击否将跳过现有分类,将符号分类进行追加。"); | 
						|
            if (dialogResult == DialogResult.Yes) | 
						|
            { | 
						|
                this.cmbAnnoLyrPropClass.Properties.Items.Clear(); | 
						|
                IFeatureRenderer renderer = (this.m_Layer as IGeoFeatureLayer).Renderer; | 
						|
                IUniqueValueRenderer uniqueValueRenderer = renderer as IUniqueValueRenderer; | 
						|
                for (int i = 0; i < uniqueValueRenderer.ValueCount; i++) | 
						|
                { | 
						|
                    string name = uniqueValueRenderer.get_Value(i); | 
						|
                    this.CreateNewAnnotateLayerProperties(name); | 
						|
                } | 
						|
                return; | 
						|
            } | 
						|
            if (dialogResult == DialogResult.No) | 
						|
            { | 
						|
                IFeatureRenderer renderer2 = (this.m_Layer as IGeoFeatureLayer).Renderer; | 
						|
                IUniqueValueRenderer uniqueValueRenderer2 = renderer2 as IUniqueValueRenderer; | 
						|
                for (int j = 0; j < uniqueValueRenderer2.ValueCount; j++) | 
						|
                { | 
						|
                    string text = uniqueValueRenderer2.get_Value(j); | 
						|
                    if (this.ClassNameCanUse2(text)) | 
						|
                    { | 
						|
                        this.CreateNewAnnotateLayerProperties(text); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
        } | 
						|
        private void chkDisplayAnnotation_CheckedChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            this.InvokeEditValueChanged(null, null); | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |