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.
563 lines
26 KiB
563 lines
26 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 KGIS.Plugin.LayerProperty.Enum; |
|
using KGIS.Plugin.LayerProperty.Properties; |
|
using DevExpress.XtraTreeList.Nodes; |
|
using DevExpress.XtraTreeList; |
|
|
|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls |
|
{ |
|
public partial class UCFeatureRenderProperty : XtraUserControl, IUCPropertyPageEx, IPropertyPage |
|
{ |
|
private IPropertyPage ucSimpleRender; |
|
private IPropertyPage ucUniqueValueRenderer; |
|
private IPropertyPage ucSymbolMatch; |
|
private IPropertyPage ucGraduateColorsRenderer; |
|
private IPropertyPage ucUniqueValueManyFieldsRenderer; |
|
private ILayer m_LayerProperty; |
|
private List<IPropertyPage> ucList; |
|
private IPropertyPage m_CurrentProperty; |
|
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 UCFeatureRenderProperty() |
|
{ |
|
InitializeComponent(); |
|
this.ucList = new List<IPropertyPage>(); |
|
} |
|
public void InitUC(object layerProperty) |
|
{ |
|
try |
|
{ |
|
this.m_LayerProperty = (layerProperty as ILayer); |
|
this.InitRenderTree(); |
|
this.ucSimpleRender = null; |
|
this.ucUniqueValueRenderer = null; |
|
this.ucSymbolMatch = null; |
|
this.ucList = new List<IPropertyPage>(); |
|
IGeoFeatureLayer geoFeatureLayer = layerProperty as IGeoFeatureLayer; |
|
IFeatureRenderer renderer = geoFeatureLayer.Renderer; |
|
enumFeatureRendererType featureRendererType = this.GetFeatureRendererType(renderer); |
|
switch (featureRendererType) |
|
{ |
|
case enumFeatureRendererType.SimpleRenderer: |
|
if (this.ucSimpleRender == null) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
this.ucSimpleRender = new UCSimpleRender(); |
|
this.ucSimpleRender.Dock = DockStyle.Fill; |
|
this.ucSimpleRender.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.pnRenderPage.Controls.Add(this.ucSimpleRender as System.Windows.Forms.Control); |
|
this.AddUc(this.ucSimpleRender); |
|
this.picRenderType.Image = Resources.single; |
|
this.ucSimpleRender.IsPageDirty = false; |
|
} |
|
this.m_CurrentProperty = this.ucSimpleRender; |
|
break; |
|
case enumFeatureRendererType.UniqueValueRenderer: |
|
if (this.ucUniqueValueRenderer == null) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
this.ucUniqueValueRenderer = new UCUniqueValueRenderer(); |
|
this.ucUniqueValueRenderer.Dock = DockStyle.Fill; |
|
this.ucUniqueValueRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.pnRenderPage.Controls.Add(this.ucUniqueValueRenderer as System.Windows.Forms.Control); |
|
this.AddUc(this.ucUniqueValueRenderer); |
|
this.picRenderType.Image = Resources.unique; |
|
this.ucUniqueValueRenderer.IsPageDirty = false; |
|
} |
|
this.m_CurrentProperty = this.ucUniqueValueRenderer; |
|
break; |
|
case enumFeatureRendererType.UniqueValueManyFieldsRenderer: |
|
if (this.ucUniqueValueManyFieldsRenderer == null) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
this.ucUniqueValueManyFieldsRenderer = new UCUniqueValueManyFieldsRenderer(); |
|
this.ucUniqueValueManyFieldsRenderer.Dock = DockStyle.Fill; |
|
this.ucUniqueValueManyFieldsRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.pnRenderPage.Controls.Add(this.ucUniqueValueManyFieldsRenderer as System.Windows.Forms.Control); |
|
this.picRenderType.Image = Resources.unique; |
|
this.AddUc(this.ucUniqueValueManyFieldsRenderer); |
|
this.ucUniqueValueManyFieldsRenderer.IsPageDirty = false; |
|
} |
|
this.m_CurrentProperty = this.ucUniqueValueManyFieldsRenderer; |
|
break; |
|
case enumFeatureRendererType.MatchSymbolInStyleFieldRenderer: |
|
if (this.ucSymbolMatch == null) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
this.ucSymbolMatch = new UCSymbolMatch(); |
|
this.ucSymbolMatch.Dock = DockStyle.Fill; |
|
this.ucSymbolMatch.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.pnRenderPage.Controls.Add(this.ucSymbolMatch as System.Windows.Forms.Control); |
|
this.picRenderType.Image = Resources.unique; |
|
this.AddUc(this.ucSymbolMatch); |
|
this.ucSymbolMatch.IsPageDirty = false; |
|
} |
|
this.m_CurrentProperty = this.ucSymbolMatch; |
|
break; |
|
case enumFeatureRendererType.GraduatedColorsRenderer: |
|
if (this.ucGraduateColorsRenderer == null) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
this.ucGraduateColorsRenderer = new UCGraduateColorsRenderer(); |
|
this.ucGraduateColorsRenderer.Dock = DockStyle.Fill; |
|
this.ucGraduateColorsRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.pnRenderPage.Controls.Add(this.ucGraduateColorsRenderer as System.Windows.Forms.Control); |
|
this.picRenderType.Image = Resources.unique; |
|
this.AddUc(this.ucGraduateColorsRenderer); |
|
this.ucGraduateColorsRenderer.IsPageDirty = false; |
|
} |
|
this.m_CurrentProperty = this.ucGraduateColorsRenderer; |
|
break; |
|
} |
|
this.SelectNode(featureRendererType); |
|
this.m_CurrentProperty.InitUC(layerProperty); |
|
this.CurrentRenderChanged(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
public void Write2Prop() |
|
{ |
|
if (this.m_CurrentProperty != null) |
|
{ |
|
this.m_CurrentProperty.Write2Prop(); |
|
this.isDirty = false; |
|
} |
|
} |
|
private void ucRender_EditorChanged(object sender, System.EventArgs e) |
|
{ |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
public bool CanWrite2Prop() |
|
{ |
|
return this.m_CurrentProperty.CanWrite2Prop(); |
|
} |
|
public void SetDefaultValue(object value) |
|
{ |
|
} |
|
private void InvokeEditValueChanged(object sender, System.EventArgs e) |
|
{ |
|
if (this.EditorChanged != null) |
|
{ |
|
this.EditorChanged(sender, e); |
|
} |
|
this.m_CurrentProperty.IsPageDirty = true; |
|
this.isDirty = true; |
|
} |
|
private void AddUc(IPropertyPage uc) |
|
{ |
|
if (!this.ucList.Contains(uc)) |
|
{ |
|
this.ucList.Add(uc); |
|
} |
|
} |
|
private void InitRenderTree() |
|
{ |
|
try |
|
{ |
|
this.tlstRendererType.Nodes.Clear(); |
|
TreeListNode treeListNode = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"特征", |
|
enumFeatureRendererType.None |
|
}, null); |
|
treeListNode.Tag = null; |
|
TreeListNode treeListNode2 = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"单值", |
|
enumFeatureRendererType.SimpleRenderer |
|
}, treeListNode); |
|
treeListNode2.Tag = enumFeatureRendererType.SimpleRenderer; |
|
treeListNode = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"种类", |
|
enumFeatureRendererType.None |
|
}, null); |
|
treeListNode.Tag = null; |
|
treeListNode2 = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"唯一值", |
|
enumFeatureRendererType.UniqueValueRenderer |
|
}, treeListNode); |
|
treeListNode2.Tag = enumFeatureRendererType.UniqueValueRenderer; |
|
treeListNode2 = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"唯一值,多字段", |
|
enumFeatureRendererType.UniqueValueManyFieldsRenderer |
|
}, treeListNode); |
|
treeListNode2.Tag = enumFeatureRendererType.UniqueValueManyFieldsRenderer; |
|
treeListNode2 = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"符号匹配", |
|
enumFeatureRendererType.MatchSymbolInStyleFieldRenderer |
|
}, treeListNode); |
|
treeListNode2.Tag = enumFeatureRendererType.MatchSymbolInStyleFieldRenderer; |
|
treeListNode = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"数量", |
|
enumFeatureRendererType.None |
|
}, null); |
|
treeListNode.Tag = null; |
|
treeListNode2 = this.tlstRendererType.AppendNode(new object[] |
|
{ |
|
"等级颜色", |
|
enumFeatureRendererType.GraduatedColorsRenderer |
|
}, treeListNode); |
|
treeListNode2.Tag = enumFeatureRendererType.GraduatedColorsRenderer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void SelectNode(enumFeatureRendererType type) |
|
{ |
|
try |
|
{ |
|
TreeListNode focusedNode = this.tlstRendererType.FindNodeByFieldValue(this.colType.FieldName, type); |
|
this.tlstRendererType.FocusedNode = null; |
|
this.tlstRendererType.FocusedNode = focusedNode; |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void tlstRendererType_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) |
|
{ |
|
try |
|
{ |
|
if (e.Node != null) |
|
{ |
|
TreeListNode treeListNode = e.Node; |
|
if (e.Node.HasChildren) |
|
{ |
|
this.tlstRendererType.CollapseAll(); |
|
e.Node.ExpandAll(); |
|
e.Node.FirstNode.Selected = true; |
|
this.tlstRendererType.FocusedNode = e.Node.FirstNode; |
|
treeListNode = e.Node.FirstNode; |
|
} |
|
if (treeListNode.Tag == null) |
|
return; |
|
switch ((enumFeatureRendererType)treeListNode.Tag) |
|
{ |
|
case enumFeatureRendererType.SimpleRenderer: |
|
if (this.m_CurrentProperty != this.ucSimpleRender) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
if (this.ucSimpleRender == null) |
|
{ |
|
this.ucSimpleRender = new UCSimpleRender(); |
|
this.ucSimpleRender.Dock = DockStyle.Fill; |
|
this.ucSimpleRender.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.AddUc(this.ucSimpleRender); |
|
} |
|
this.ucSimpleRender.InitUC(this.m_LayerProperty); |
|
this.picRenderType.Image = Resources.unique; |
|
this.pnRenderPage.Controls.Add(this.ucSimpleRender as System.Windows.Forms.Control); |
|
this.m_CurrentProperty = this.ucSimpleRender; |
|
} |
|
break; |
|
case enumFeatureRendererType.UniqueValueRenderer: |
|
if (this.m_CurrentProperty != this.ucUniqueValueRenderer) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
if (this.ucUniqueValueRenderer == null) |
|
{ |
|
this.ucUniqueValueRenderer = new UCUniqueValueRenderer(); |
|
this.ucUniqueValueRenderer.Dock = DockStyle.Fill; |
|
this.ucUniqueValueRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.AddUc(this.ucUniqueValueRenderer); |
|
} |
|
this.ucUniqueValueRenderer.InitUC(this.m_LayerProperty); |
|
this.picRenderType.Image = Resources.unique; |
|
this.pnRenderPage.Controls.Add(this.ucUniqueValueRenderer as System.Windows.Forms.Control); |
|
this.m_CurrentProperty = this.ucUniqueValueRenderer; |
|
} |
|
break; |
|
case enumFeatureRendererType.UniqueValueManyFieldsRenderer: |
|
if (this.m_CurrentProperty != this.ucUniqueValueManyFieldsRenderer) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
if (this.ucUniqueValueManyFieldsRenderer == null) |
|
{ |
|
this.ucUniqueValueManyFieldsRenderer = new UCUniqueValueManyFieldsRenderer(); |
|
this.ucUniqueValueManyFieldsRenderer.Dock = DockStyle.Fill; |
|
this.ucUniqueValueManyFieldsRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.AddUc(this.ucUniqueValueManyFieldsRenderer); |
|
} |
|
this.ucUniqueValueManyFieldsRenderer.InitUC(this.m_LayerProperty); |
|
this.picRenderType.Image = Resources.unique; |
|
this.pnRenderPage.Controls.Add(this.ucUniqueValueManyFieldsRenderer as System.Windows.Forms.Control); |
|
this.m_CurrentProperty = this.ucUniqueValueManyFieldsRenderer; |
|
} |
|
break; |
|
case enumFeatureRendererType.MatchSymbolInStyleFieldRenderer: |
|
if (this.m_CurrentProperty != this.ucSymbolMatch) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
if (this.ucSymbolMatch == null) |
|
{ |
|
this.ucSymbolMatch = new UCSymbolMatch(); |
|
this.ucSymbolMatch.Dock = DockStyle.Fill; |
|
this.ucSymbolMatch.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.AddUc(this.ucSymbolMatch); |
|
} |
|
this.ucSymbolMatch.InitUC(this.m_LayerProperty); |
|
this.picRenderType.Image = Resources.unique; |
|
this.pnRenderPage.Controls.Add(this.ucSymbolMatch as System.Windows.Forms.Control); |
|
this.m_CurrentProperty = this.ucSymbolMatch; |
|
} |
|
break; |
|
case enumFeatureRendererType.GraduatedColorsRenderer: |
|
if (this.m_CurrentProperty != this.ucGraduateColorsRenderer) |
|
{ |
|
this.pnRenderPage.Controls.Clear(); |
|
if (this.ucGraduateColorsRenderer == null) |
|
{ |
|
this.ucGraduateColorsRenderer = new UCGraduateColorsRenderer(); |
|
this.ucGraduateColorsRenderer.Dock = DockStyle.Fill; |
|
this.ucGraduateColorsRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged); |
|
this.AddUc(this.ucGraduateColorsRenderer); |
|
} |
|
this.ucGraduateColorsRenderer.InitUC(this.m_LayerProperty); |
|
this.picRenderType.Image = Resources.unique; |
|
this.pnRenderPage.Controls.Add(this.ucGraduateColorsRenderer as System.Windows.Forms.Control); |
|
this.m_CurrentProperty = this.ucGraduateColorsRenderer; |
|
} |
|
break; |
|
} |
|
this.InvokeEditValueChanged(null, null); |
|
this.CurrentRenderChanged(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void CurrentRenderChanged() |
|
{ |
|
try |
|
{ |
|
if (this.m_CurrentProperty == this.ucSimpleRender) |
|
{ |
|
this.lblRenderDesc.Text = "简单符号化"; |
|
} |
|
else |
|
{ |
|
if (this.m_CurrentProperty == this.ucSymbolMatch) |
|
{ |
|
this.lblRenderDesc.Text = "根据字段值到符号库中进行符号匹配"; |
|
} |
|
else |
|
{ |
|
if (this.m_CurrentProperty == this.ucUniqueValueManyFieldsRenderer) |
|
{ |
|
this.lblRenderDesc.Text = "通过三个字段值的组合对图层要素进行分类符号化"; |
|
} |
|
else |
|
{ |
|
if (this.m_CurrentProperty == this.ucUniqueValueRenderer) |
|
{ |
|
this.lblRenderDesc.Text = "唯一值符号化:按照唯一字段的字段值对图层要素进行分类符号化"; |
|
} |
|
else |
|
{ |
|
if (this.m_CurrentProperty == this.ucGraduateColorsRenderer) |
|
{ |
|
this.lblRenderDesc.Text = "颜色分级"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void btnImportFormLayer_Click(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
FormImportFeatureSymbology formImportFeatureSymbology = new FormImportFeatureSymbology(); |
|
if (this.m_LayerProperty != null) |
|
{ |
|
formImportFeatureSymbology.Init(null, this.m_LayerProperty as IFeatureLayer); |
|
if (formImportFeatureSymbology.ShowDialog(base.FindForm()) == DialogResult.OK) |
|
{ |
|
IFeatureRenderer featureRenderer = formImportFeatureSymbology.FeatureRenderer; |
|
if (featureRenderer is ISimpleRenderer) |
|
{ |
|
this.SelectNode(enumFeatureRendererType.SimpleRenderer); |
|
} |
|
else |
|
{ |
|
if (featureRenderer is IUniqueValueRenderer) |
|
{ |
|
IUniqueValueRenderer uniqueValueRenderer = featureRenderer as IUniqueValueRenderer; |
|
if (uniqueValueRenderer.FieldCount > 1) |
|
{ |
|
this.SelectNode(enumFeatureRendererType.UniqueValueManyFieldsRenderer); |
|
} |
|
else |
|
{ |
|
if (uniqueValueRenderer.LookupStyleset != "") |
|
{ |
|
this.SelectNode(enumFeatureRendererType.MatchSymbolInStyleFieldRenderer); |
|
} |
|
else |
|
{ |
|
this.SelectNode(enumFeatureRendererType.UniqueValueRenderer); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if (!(featureRenderer is IClassBreaksRenderer) && !(featureRenderer is IProportionalSymbolRenderer)) |
|
{ |
|
IChartRenderer arg_AA_0 = featureRenderer as IChartRenderer; |
|
} |
|
} |
|
} |
|
if (this.m_CurrentProperty != null) |
|
{ |
|
this.m_CurrentProperty.SetDefaultValue(featureRenderer); |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private enumFeatureRendererType GetFeatureRendererType(IFeatureRenderer featureRenderer) |
|
{ |
|
enumFeatureRendererType result = enumFeatureRendererType.SimpleRenderer; |
|
try |
|
{ |
|
if (featureRenderer is IUniqueValueRenderer) |
|
{ |
|
IUniqueValueRenderer uniqueValueRenderer = featureRenderer as IUniqueValueRenderer; |
|
if (uniqueValueRenderer.FieldCount == 1 && uniqueValueRenderer.LookupStyleset == "") |
|
{ |
|
result = enumFeatureRendererType.UniqueValueRenderer; |
|
} |
|
else |
|
{ |
|
if (uniqueValueRenderer.FieldCount > 1) |
|
{ |
|
result = enumFeatureRendererType.UniqueValueManyFieldsRenderer; |
|
} |
|
else |
|
{ |
|
result = enumFeatureRendererType.MatchSymbolInStyleFieldRenderer; |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if (featureRenderer is IBivariateRenderer) |
|
{ |
|
result = enumFeatureRendererType.BiUniqueValueRenderer; |
|
} |
|
else |
|
{ |
|
if (featureRenderer is ISimpleRenderer) |
|
{ |
|
result = enumFeatureRendererType.SimpleRenderer; |
|
} |
|
else |
|
{ |
|
if (featureRenderer is IChartRenderer) |
|
{ |
|
result = enumFeatureRendererType.ChartRenderer; |
|
} |
|
else |
|
{ |
|
if (featureRenderer is IPieChartRenderer) |
|
{ |
|
result = enumFeatureRendererType.PieChartRenderer; |
|
} |
|
else |
|
{ |
|
if (featureRenderer is IClassBreaksRenderer) |
|
{ |
|
result = enumFeatureRendererType.GraduatedColorsRenderer; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
return result; |
|
} |
|
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."); |
|
} |
|
} |
|
}
|
|
|