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.
		
		
		
		
		
			
		
			
				
					
					
						
							198 lines
						
					
					
						
							6.8 KiB
						
					
					
				
			
		
		
	
	
							198 lines
						
					
					
						
							6.8 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.Geometry; | 
						|
using ESRI.ArcGIS.Carto; | 
						|
using ESRI.ArcGIS.Display; | 
						|
using ESRI.ArcGIS.esriSystem; | 
						|
using KGIS.Plugin.LayerProperty.Utils; | 
						|
 | 
						|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls | 
						|
{ | 
						|
    public partial class UCSimpleRender : XtraUserControl, IUCPropertyPageEx, IPropertyPage | 
						|
    { | 
						|
        private esriGeometryType GeometryType; | 
						|
        private ISimpleRenderer m_SimpleRenderer; | 
						|
        private IStyleGalleryClass m_SymbologyStyleClass; | 
						|
        private ISymbol m_Symbol; | 
						|
        private ILayer m_Layer; | 
						|
        private bool isDirty; | 
						|
        public event System.EventHandler EditorChanged; | 
						|
        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 UCSimpleRender() | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
        } | 
						|
        public void InitUC(object layerProperty) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.m_Layer = (layerProperty as ILayer); | 
						|
                IFeatureLayer2 featureLayer = layerProperty as IFeatureLayer2; | 
						|
                if (featureLayer != null) | 
						|
                { | 
						|
                    this.GeometryType = featureLayer.ShapeType; | 
						|
                    switch (this.GeometryType) | 
						|
                    { | 
						|
                        case esriGeometryType.esriGeometryPoint: | 
						|
                            this.m_SymbologyStyleClass = new MarkerSymbolStyleGalleryClassClass(); | 
						|
                            break; | 
						|
                        case esriGeometryType.esriGeometryPolyline: | 
						|
                            this.m_SymbologyStyleClass = new LineSymbolStyleGalleryClassClass(); | 
						|
                            break; | 
						|
                        case esriGeometryType.esriGeometryPolygon: | 
						|
                            this.m_SymbologyStyleClass = new FillSymbolStyleGalleryClassClass(); | 
						|
                            break; | 
						|
                    } | 
						|
                    ISimpleRenderer simpleRenderer = (featureLayer as IGeoFeatureLayer).Renderer as ISimpleRenderer; | 
						|
                    if (simpleRenderer != null) | 
						|
                    { | 
						|
                        this.m_Symbol = simpleRenderer.Symbol; | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        this.m_Symbol = RenderUtil.GetDefaultSymbol(this.GeometryType); | 
						|
                    } | 
						|
                    this.picSymbolSelecte.Image = RenderUtil.GetSymbolBitMap(this.picSymbolSelecte.Width - 1, this.picSymbolSelecte.Height - 1, this.m_SymbologyStyleClass, this.m_Symbol); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        public void Write2Prop() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IGeoFeatureLayer geoFeatureLayer = this.m_Layer as IGeoFeatureLayer; | 
						|
                if (geoFeatureLayer != null) | 
						|
                { | 
						|
                    geoFeatureLayer.Renderer = (this.m_SimpleRenderer as IFeatureRenderer); | 
						|
                    this.isDirty = false; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        public bool CanWrite2Prop() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.m_Symbol != null) | 
						|
                { | 
						|
                    this.m_SimpleRenderer = new SimpleRendererClass(); | 
						|
                    this.m_SimpleRenderer.Description = ""; | 
						|
                    this.m_SimpleRenderer.Symbol = this.m_Symbol; | 
						|
                } | 
						|
                bool result; | 
						|
                if (this.m_SimpleRenderer == null) | 
						|
                { | 
						|
                    result = false; | 
						|
                    return result; | 
						|
                } | 
						|
                result = this.isDirty; | 
						|
                return result; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
            return false; | 
						|
        } | 
						|
        public void SetDefaultValue(object value) | 
						|
        { | 
						|
            this.m_SimpleRenderer = (value as ISimpleRenderer); | 
						|
            if (this.m_SimpleRenderer != null) | 
						|
            { | 
						|
                this.picSymbolSelecte.Image = RenderUtil.GetSymbolBitMap(this.picSymbolSelecte.Width - 1, this.picSymbolSelecte.Height - 1, this.m_SymbologyStyleClass, this.m_SimpleRenderer.Symbol); | 
						|
                this.m_Symbol = this.m_SimpleRenderer.Symbol; | 
						|
            } | 
						|
        } | 
						|
        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 picSymbolSelecte_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.Cursor = Cursors.WaitCursor; | 
						|
                IClone clone = this.m_Symbol as IClone; | 
						|
                ISymbol symbol = clone.Clone() as ISymbol; | 
						|
                ISymbol symbol2 = RenderUtil.OpenStyleSelector(this.GeometryType, symbol) as ISymbol; | 
						|
                if (symbol2 == null) | 
						|
                { | 
						|
                    this.Cursor = Cursors.Default; | 
						|
                    return; | 
						|
                } | 
						|
                this.m_Symbol = symbol2; | 
						|
                this.picSymbolSelecte.Image = RenderUtil.GetSymbolBitMap(this.picSymbolSelecte.Width - 1, this.picSymbolSelecte.Height - 1, this.m_SymbologyStyleClass, this.m_Symbol); | 
						|
                this.InvokeEditValueChanged(sender, e); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
            this.Cursor = Cursors.Default; | 
						|
        } | 
						|
        private void InvokeEditValueChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.EditorChanged != null) | 
						|
            { | 
						|
                this.EditorChanged(sender, e); | 
						|
            } | 
						|
            this.isDirty = true; | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |