年度变更建库软件5.0版本
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.
 
 

469 lines
16 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using ESRI.ArcGIS.Carto;
using KGIS.Plugin.LayerProperty.Interface;
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
{
internal class UCRasterRenderProperty : XtraUserControl, IUCPropertyPageEx, IPropertyPage
{
private List<IPropertyPage> ucList;
private IPropertyPage ucRasterRGBRenderer;
private IPropertyPage UCRasterStretchRenderer;
private IRasterLayer m_RasterLayer;
private ILayer m_LayerProperty;
private IPropertyPage m_CurrentProperty;
private bool isDirty;
private IContainer components;
private PanelControl panelleft;
private TextEdit lblRenderDesc;
private SimpleButton btnImportFormLayer;
private PictureEdit picRenderType;
private TreeList tlstRendererType;
private TreeListColumn colName;
private TreeListColumn colType;
private Panel pnRenderPage;
public event System.EventHandler EditorChanged;
public bool IsPageDirty
{
get
{
return this.isDirty;
}
set
{
this.isDirty = value;
}
}
public int Priority
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public string Title
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public UCRasterRenderProperty()
{
this.InitializeComponent();
this.ucList = new List<IPropertyPage>();
}
public void InitUC(object layerProperty)
{
this.m_LayerProperty = (layerProperty as ILayer);
this.m_RasterLayer = (layerProperty as IRasterLayer);
if (this.m_RasterLayer == null)
{
return;
}
this.InitRenderTree();
this.ucRasterRGBRenderer = null;
this.ucList = new List<IPropertyPage>();
IRasterRenderer renderer = this.m_RasterLayer.Renderer;
enumRasterRendererType rasterRendererType = this.GetRasterRendererType(renderer);
switch (rasterRendererType)
{
case enumRasterRendererType.RasterRGBRenderer:
if (this.ucRasterRGBRenderer == null)
{
this.pnRenderPage.Controls.Clear();
this.AddRasterRGBRendererUC();
}
break;
case enumRasterRendererType.RasterStretchColorRampRenderer:
if (this.UCRasterStretchRenderer == null)
{
this.pnRenderPage.Controls.Clear();
this.AddRasterStretchRendererUC();
}
break;
}
this.SelectNode(rasterRendererType);
this.CurrentRenderChanged();
}
private void AddUc(IPropertyPage uc)
{
if (!this.ucList.Contains(uc))
{
this.ucList.Add(uc);
}
}
public bool CanWrite2Prop()
{
return this.m_CurrentProperty.CanWrite2Prop();
}
public void Write2Prop()
{
if (this.m_CurrentProperty != null)
{
this.m_CurrentProperty.Write2Prop();
this.isDirty = false;
}
}
public void SetDefaultValue(object value)
{
}
private void InitRenderTree()
{
try
{
this.tlstRendererType.Nodes.Clear();
TreeListNode treeListNode = this.tlstRendererType.AppendNode(new object[]
{
"拉伸",
enumRasterRendererType.RasterStretchColorRampRenderer
}, null);
treeListNode.Tag = enumRasterRendererType.RasterStretchColorRampRenderer;
if (this.m_RasterLayer.BandCount == 3)
{
TreeListNode treeListNode2 = this.tlstRendererType.AppendNode(new object[]
{
"RGB综合",
enumRasterRendererType.RasterRGBRenderer
}, null);
treeListNode2.Tag = enumRasterRendererType.RasterRGBRenderer;
}
}
catch
{
}
}
private enumRasterRendererType GetRasterRendererType(IRasterRenderer featureRenderer)
{
enumRasterRendererType result = enumRasterRendererType.RasterRGBRenderer;
try
{
if (featureRenderer is IRasterClassifyColorRampRenderer)
{
result = enumRasterRendererType.RasterClassifyColorRampRenderer;
}
else
{
if (featureRenderer is IRasterDiscreteColorRenderer)
{
result = enumRasterRendererType.RasterDiscreteColorRenderer;
}
else
{
if (featureRenderer is IRasterRGBRenderer)
{
result = enumRasterRendererType.RasterRGBRenderer;
}
else
{
if (featureRenderer is IRasterStretchColorRampRenderer)
{
result = enumRasterRendererType.RasterStretchColorRampRenderer;
}
else
{
if (featureRenderer is IRasterUniqueValueRenderer)
{
result = enumRasterRendererType.RasterUniqueValueRenderer;
}
}
}
}
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
return result;
}
private void SelectNode(enumRasterRendererType 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 ucRender_EditorChanged(object sender, System.EventArgs e)
{
this.InvokeEditValueChanged(sender, e);
}
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 CurrentRenderChanged()
{
try
{
if (this.m_CurrentProperty == this.ucRasterRGBRenderer)
{
this.lblRenderDesc.Text = "通过三原色合成进行图像显示";
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void tlstRendererType_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
{
try
{
if (e.Node != null)
{
TreeListNode node = e.Node;
if (node.Tag == null)
return;
switch ((enumRasterRendererType)node.Tag)
{
case enumRasterRendererType.RasterRGBRenderer:
if (this.m_CurrentProperty != this.ucRasterRGBRenderer)
{
this.pnRenderPage.Controls.Clear();
this.AddRasterRGBRendererUC();
}
break;
case enumRasterRendererType.RasterStretchColorRampRenderer:
if (this.m_CurrentProperty != this.UCRasterStretchRenderer)
{
this.pnRenderPage.Controls.Clear();
this.AddRasterStretchRendererUC();
}
break;
}
this.InvokeEditValueChanged(null, null);
this.CurrentRenderChanged();
}
}
catch
{
}
}
private void AddRasterRGBRendererUC()
{
if (this.ucRasterRGBRenderer == null)
{
this.ucRasterRGBRenderer = new UCRasterRGBRenderer();
this.ucRasterRGBRenderer.Dock = DockStyle.Fill;
this.ucRasterRGBRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged);
this.AddUc(this.ucRasterRGBRenderer);
}
this.m_CurrentProperty = this.ucRasterRGBRenderer;
this.ucRasterRGBRenderer.InitUC(this.m_LayerProperty);
this.pnRenderPage.Controls.Add(this.ucRasterRGBRenderer as System.Windows.Forms.Control);
}
private void AddRasterStretchRendererUC()
{
if (this.UCRasterStretchRenderer == null)
{
this.UCRasterStretchRenderer = new UCRasterStretchRenderer();
this.UCRasterStretchRenderer.Dock = DockStyle.Fill;
this.UCRasterStretchRenderer.EditorChanged += new System.EventHandler(this.ucRender_EditorChanged);
this.AddUc(this.UCRasterStretchRenderer);
}
this.m_CurrentProperty = this.UCRasterStretchRenderer;
this.UCRasterStretchRenderer.InitUC(this.m_LayerProperty);
this.pnRenderPage.Controls.Add(this.UCRasterStretchRenderer as System.Windows.Forms.Control);
}
public int Activate()
{
return 0;
}
public void Deactivate()
{
}
public void Cancel()
{
}
private void btnImportFormLayer_Click(object sender, System.EventArgs e)
{
FormImportRasterRender formImportRasterRender = new FormImportRasterRender();
formImportRasterRender.InitForm(this.m_RasterLayer);
DialogResult dialogResult = formImportRasterRender.ShowDialog();
if (dialogResult == DialogResult.OK)
{
IRasterRenderer rasterRenderer = formImportRasterRender.RasterRenderer;
this.m_RasterLayer.Renderer = rasterRenderer;
if (this.m_CurrentProperty != null)
{
this.m_CurrentProperty.SetDefaultValue(rasterRenderer);
}
}
}
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.panelleft = new DevExpress.XtraEditors.PanelControl();
this.tlstRendererType = new DevExpress.XtraTreeList.TreeList();
this.colName = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colType = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.picRenderType = new DevExpress.XtraEditors.PictureEdit();
this.lblRenderDesc = new DevExpress.XtraEditors.TextEdit();
this.btnImportFormLayer = new DevExpress.XtraEditors.SimpleButton();
this.pnRenderPage = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.panelleft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tlstRendererType)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picRenderType.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lblRenderDesc.Properties)).BeginInit();
this.SuspendLayout();
//
// panelleft
//
this.panelleft.Appearance.BackColor = System.Drawing.Color.Transparent;
this.panelleft.Appearance.Options.UseBackColor = true;
this.panelleft.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelleft.Controls.Add(this.tlstRendererType);
this.panelleft.Controls.Add(this.picRenderType);
this.panelleft.Dock = System.Windows.Forms.DockStyle.Left;
this.panelleft.Location = new System.Drawing.Point(0, 0);
this.panelleft.Name = "panelleft";
this.panelleft.Size = new System.Drawing.Size(157, 425);
this.panelleft.TabIndex = 1;
//
// tlstRendererType
//
this.tlstRendererType.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] {
this.colName,
this.colType});
this.tlstRendererType.Location = new System.Drawing.Point(6, 7);
this.tlstRendererType.Name = "tlstRendererType";
this.tlstRendererType.Size = new System.Drawing.Size(148, 299);
this.tlstRendererType.TabIndex = 5;
this.tlstRendererType.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(this.tlstRendererType_FocusedNodeChanged);
//
// colName
//
this.colName.Caption = "名称";
this.colName.FieldName = "F_Name";
this.colName.MinWidth = 46;
this.colName.Name = "colName";
this.colName.Visible = true;
this.colName.VisibleIndex = 0;
//
// colType
//
this.colType.Caption = "渲染类型";
this.colType.FieldName = "F_Type";
this.colType.Name = "colType";
//
// picRenderType
//
this.picRenderType.Location = new System.Drawing.Point(6, 309);
this.picRenderType.Name = "picRenderType";
//
//
//
this.picRenderType.Properties.Appearance.BackColor = System.Drawing.Color.Transparent;
this.picRenderType.Properties.Appearance.Options.UseBackColor = true;
this.picRenderType.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.picRenderType.Size = new System.Drawing.Size(145, 108);
this.picRenderType.TabIndex = 4;
//
// lblRenderDesc
//
this.lblRenderDesc.EditValue = "根据字段值到符号库中进行符号匹配";
this.lblRenderDesc.Location = new System.Drawing.Point(159, 3);
this.lblRenderDesc.Name = "lblRenderDesc";
//
//
//
this.lblRenderDesc.Properties.ReadOnly = true;
this.lblRenderDesc.Size = new System.Drawing.Size(385, 20);
this.lblRenderDesc.TabIndex = 39;
//
// btnImportFormLayer
//
this.btnImportFormLayer.Location = new System.Drawing.Point(551, 1);
this.btnImportFormLayer.Name = "btnImportFormLayer";
this.btnImportFormLayer.Size = new System.Drawing.Size(67, 27);
this.btnImportFormLayer.TabIndex = 40;
this.btnImportFormLayer.Text = "导入...";
this.btnImportFormLayer.Click += new System.EventHandler(this.btnImportFormLayer_Click);
//
// pnRenderPage
//
this.pnRenderPage.AutoScroll = true;
this.pnRenderPage.BackColor = System.Drawing.Color.Transparent;
this.pnRenderPage.Location = new System.Drawing.Point(157, 41);
this.pnRenderPage.Name = "pnRenderPage";
this.pnRenderPage.Size = new System.Drawing.Size(484, 384);
this.pnRenderPage.TabIndex = 41;
//
// UCRasterRenderProperty
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pnRenderPage);
this.Controls.Add(this.lblRenderDesc);
this.Controls.Add(this.btnImportFormLayer);
this.Controls.Add(this.panelleft);
this.Name = "UCRasterRenderProperty";
this.Size = new System.Drawing.Size(642, 425);
((System.ComponentModel.ISupportInitialize)(this.panelleft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tlstRendererType)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picRenderType.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lblRenderDesc.Properties)).EndInit();
this.ResumeLayout(false);
}
void IUCPropertyPageEx.Hide()
{
base.Hide();
}
void IUCPropertyPageEx.Show()
{
base.Show();
}
}
public enum enumRasterRendererType
{
RasterClassifyColorRampRenderer,
RasterColormapRenderer,
RasterRGBRenderer,
RasterStretchColorRampRenderer,
RasterUniqueValueRenderer,
RasterDiscreteColorRenderer
}
}