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.
773 lines
30 KiB
773 lines
30 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.Geometry; |
|
using ESRI.ArcGIS.esriSystem; |
|
using KGIS.Plugin.LayerProperty.Utils; |
|
using System.Collections; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using DevExpress.XtraGrid.Views.Base; |
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo; |
|
using System.Runtime.InteropServices; |
|
using KGIS.Framework.Utils.Helper; |
|
|
|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls |
|
{ |
|
public partial class UCUniqueValueRenderer : XtraUserControl, IUCPropertyPageEx, IPropertyPage |
|
{ |
|
private const string CONST_SYMBOL = "F_Symbol"; |
|
private const string CONST_VALUE = "F_Value"; |
|
private const string CONST_LABEL = "F_Label"; |
|
private const string CONST_BITMAP = "F_BITMAP"; |
|
private DataTable m_SymbolTable; |
|
private IUniqueValueRenderer m_LyrRender; |
|
private ISymbol m_SelectedSymbol; |
|
private DataRow m_SelectedRow; |
|
private IStyleGalleryClass m_SymbologyStyleClass; |
|
private ISymbol m_DefaultSymbol; |
|
private IRotationRenderer mRotationrenderer; |
|
private IColorRamp m_ColorRamp; |
|
private IFeatureRenderer m_CurFeatureRenderer; |
|
private esriGeometryType GeometryType; |
|
private IFeatureLayer2 m_MatchLayer; |
|
private FormPointRatation frmPointRatation; |
|
private string m_ValueField = ""; |
|
private FormAddValue frmAddRendValue; |
|
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 UCUniqueValueRenderer() |
|
{ |
|
InitializeComponent(); |
|
} |
|
public void InitUC(object layerProperty) |
|
{ |
|
try |
|
{ |
|
this.m_MatchLayer = (layerProperty as IFeatureLayer2); |
|
if (this.m_MatchLayer != null) |
|
{ |
|
this.btnRotateSet.Enabled = false; |
|
this.GeometryType = this.m_MatchLayer.ShapeType; |
|
switch (this.GeometryType) |
|
{ |
|
case esriGeometryType.esriGeometryPoint: |
|
this.m_SymbologyStyleClass = new MarkerSymbolStyleGalleryClassClass(); |
|
this.btnRotateSet.Enabled = true; |
|
break; |
|
case esriGeometryType.esriGeometryPolyline: |
|
this.m_SymbologyStyleClass = new LineSymbolStyleGalleryClassClass(); |
|
break; |
|
case esriGeometryType.esriGeometryPolygon: |
|
this.m_SymbologyStyleClass = new FillSymbolStyleGalleryClassClass(); |
|
break; |
|
} |
|
this.InitSymbolTable(); |
|
this.BindGrid(); |
|
Utils.Util.InitFieldList(ref this.cmbFields, this.m_MatchLayer.FeatureClass.Fields, this.m_MatchLayer.FeatureClass.Fields.get_Field(0).Name, false, false, true, false); |
|
this.m_CurFeatureRenderer = (layerProperty as IGeoFeatureLayer).Renderer; |
|
this.m_LyrRender = (this.m_CurFeatureRenderer as IUniqueValueRenderer); |
|
if (this.m_LyrRender == null) |
|
{ |
|
this.m_LyrRender = new UniqueValueRendererClass(); |
|
this.InitDefaultRender(); |
|
this.ucCRColors.InitColorRamp(this.m_LyrRender.ColorScheme); |
|
try |
|
{ |
|
this.m_ValueField = this.m_LyrRender.get_Field(0); |
|
Utils.Util.InitFieldList(ref this.cmbFields, this.m_MatchLayer.FeatureClass.Fields, this.m_ValueField, false, false, true, false); |
|
goto IL_19E; |
|
} |
|
catch |
|
{ |
|
goto IL_19E; |
|
} |
|
} |
|
this.ucCRColors.InitColorRamp(this.m_LyrRender.ColorScheme); |
|
this.m_DefaultSymbol = this.m_LyrRender.DefaultSymbol; |
|
this.chkUseDefaultSymbol.Checked = this.m_LyrRender.UseDefaultSymbol; |
|
this.LoadDefaultRender(); |
|
IL_19E: |
|
this.RefreshDefaultSymbol(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
public void Write2Prop() |
|
{ |
|
try |
|
{ |
|
(this.m_MatchLayer as IGeoFeatureLayer).Renderer = this.m_CurFeatureRenderer; |
|
this.isDirty = false; |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
public bool CanWrite2Prop() |
|
{ |
|
this.SetUniqeRender(); |
|
return this.m_CurFeatureRenderer != null && this.isDirty; |
|
} |
|
public void SetDefaultValue(object value) |
|
{ |
|
this.m_LyrRender = (value as IUniqueValueRenderer); |
|
this.InitSymbolTable(); |
|
this.BindGrid(); |
|
this.LoadDefaultRender(); |
|
this.InvokeEditValueChanged(this, null); |
|
} |
|
private void InvokeEditValueChanged(object sender, System.EventArgs e) |
|
{ |
|
if (this.EditorChanged != null) |
|
{ |
|
this.EditorChanged(sender, e); |
|
} |
|
this.isDirty = true; |
|
} |
|
private void InitSymbolTable() |
|
{ |
|
this.m_SymbolTable = new DataTable(); |
|
DataColumn dataColumn = new DataColumn(); |
|
dataColumn.DataType = Type.GetType("System.Object"); |
|
dataColumn.ColumnName = "F_BITMAP"; |
|
dataColumn.Caption = "F_BITMAP"; |
|
this.m_SymbolTable.Columns.Add(dataColumn); |
|
dataColumn = new DataColumn(); |
|
dataColumn.DataType = Type.GetType("System.String"); |
|
dataColumn.ColumnName = "F_Value"; |
|
dataColumn.Caption = "F_Value"; |
|
this.m_SymbolTable.Columns.Add(dataColumn); |
|
dataColumn = new DataColumn(); |
|
dataColumn.DataType = Type.GetType("System.String"); |
|
dataColumn.ColumnName = "F_Label"; |
|
dataColumn.Caption = "F_Label"; |
|
this.m_SymbolTable.Columns.Add(dataColumn); |
|
dataColumn = new DataColumn(); |
|
dataColumn.DataType = Type.GetType("System.Object"); |
|
dataColumn.ColumnName = "F_Symbol"; |
|
dataColumn.Caption = "F_Symbol"; |
|
this.m_SymbolTable.Columns.Add(dataColumn); |
|
} |
|
private void BindGrid() |
|
{ |
|
this.gridSymCtrl.BeginInit(); |
|
this.gridSymCtrl.DataSource = this.m_SymbolTable; |
|
this.grdSymbol.FieldName = "F_BITMAP"; |
|
this.grdSymbolVal.FieldName = "F_Value"; |
|
this.grdLabel.FieldName = "F_Label"; |
|
this.gridSymCtrl.EndInit(); |
|
} |
|
private void InitDefaultRender() |
|
{ |
|
this.m_DefaultSymbol = RenderUtil.GetDefaultSymbol(this.m_MatchLayer.FeatureClass.ShapeType); |
|
} |
|
private void LoadDefaultRender() |
|
{ |
|
try |
|
{ |
|
try |
|
{ |
|
this.m_ValueField = this.m_LyrRender.get_Field(0); |
|
Utils.Util.InitFieldList(ref this.cmbFields, this.m_MatchLayer.FeatureClass.Fields, this.m_ValueField, false, false, true, false); |
|
} |
|
catch |
|
{ |
|
} |
|
this.m_DefaultSymbol = this.m_LyrRender.DefaultSymbol; |
|
this.RefreshDefaultSymbol(); |
|
RenderUtil.SetUniqueValuesToTable(this.m_LyrRender, this.m_SymbologyStyleClass, this.m_SymbolTable); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void InitRowData(Bitmap bp, string uValue, string uLabel, ISymbol symbol, ref DataRow pRow) |
|
{ |
|
pRow["F_BITMAP"] = bp; |
|
pRow["F_Value"] = uValue; |
|
pRow["F_Label"] = uLabel; |
|
pRow["F_Symbol"] = symbol; |
|
} |
|
private ISymbol GetSymbol(IColor pColor) |
|
{ |
|
ISymbol symbol = null; |
|
if (this.m_DefaultSymbol != null) |
|
{ |
|
IClone clone = this.m_DefaultSymbol as IClone; |
|
symbol = (clone.Clone() as ISymbol); |
|
} |
|
try |
|
{ |
|
esriGeometryType geometryType = this.GeometryType; |
|
switch (geometryType) |
|
{ |
|
case esriGeometryType.esriGeometryPoint: |
|
{ |
|
if (symbol == null) |
|
{ |
|
symbol = (new SimpleMarkerSymbolClass |
|
{ |
|
Color = pColor |
|
} as ISymbol); |
|
goto IL_F1; |
|
} |
|
IMarkerSymbol markerSymbol = symbol as IMarkerSymbol; |
|
if (markerSymbol == null) |
|
{ |
|
ISymbol result = symbol; |
|
return result; |
|
} |
|
markerSymbol.Color = pColor; |
|
goto IL_F1; |
|
} |
|
case esriGeometryType.esriGeometryMultipoint: |
|
goto IL_F1; |
|
case esriGeometryType.esriGeometryPolyline: |
|
break; |
|
case esriGeometryType.esriGeometryPolygon: |
|
{ |
|
if (symbol == null) |
|
{ |
|
symbol = (new SimpleFillSymbolClass |
|
{ |
|
Color = pColor |
|
} as ISymbol); |
|
goto IL_F1; |
|
} |
|
IFillSymbol fillSymbol = symbol as IFillSymbol; |
|
if (fillSymbol == null) |
|
{ |
|
ISymbol result = symbol; |
|
return result; |
|
} |
|
fillSymbol.Color = pColor; |
|
goto IL_F1; |
|
} |
|
default: |
|
if (geometryType != esriGeometryType.esriGeometryLine) |
|
{ |
|
goto IL_F1; |
|
} |
|
break; |
|
} |
|
if (symbol == null) |
|
{ |
|
symbol = (new SimpleLineSymbolClass |
|
{ |
|
Color = pColor |
|
} as ISymbol); |
|
} |
|
else |
|
{ |
|
ILineSymbol lineSymbol = symbol as ILineSymbol; |
|
if (lineSymbol == null) |
|
{ |
|
ISymbol result = symbol; |
|
return result; |
|
} |
|
lineSymbol.Color = pColor; |
|
} |
|
IL_F1:; |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
return symbol; |
|
} |
|
private void RefreshDefaultSymbol() |
|
{ |
|
this.picDefaultSymbol.Image = RenderUtil.GetSymbolBitMap(this.picDefaultSymbol.Width - 1, this.picDefaultSymbol.Height - 1, this.m_SymbologyStyleClass, this.m_DefaultSymbol); |
|
} |
|
private void SetUniqeRender() |
|
{ |
|
this.m_LyrRender.RemoveAllValues(); |
|
if (this.m_MatchLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint && this.mRotationrenderer != null) |
|
{ |
|
this.m_LyrRender = (IUniqueValueRenderer)this.mRotationrenderer; |
|
} |
|
this.m_LyrRender.FieldCount = 1; |
|
string valueField = this.m_ValueField; |
|
this.m_LyrRender.set_Field(0, valueField); |
|
if (this.chkUseDefaultSymbol.Checked) |
|
{ |
|
this.m_LyrRender.DefaultSymbol = this.m_DefaultSymbol; |
|
this.m_LyrRender.UseDefaultSymbol = this.chkUseDefaultSymbol.Checked; |
|
} |
|
else |
|
{ |
|
this.m_LyrRender.DefaultSymbol = null; |
|
this.m_LyrRender.UseDefaultSymbol = false; |
|
} |
|
RenderUtil.SetUniqueValuesFromTable(this.m_LyrRender, valueField, this.m_SymbolTable); |
|
if (this.m_ColorRamp == null) |
|
{ |
|
this.m_ColorRamp = this.ucCRColors.GetSelectColorRamp(); |
|
} |
|
if (this.m_ColorRamp != null) |
|
{ |
|
this.m_LyrRender.ColorScheme = this.m_ColorRamp.Name; |
|
} |
|
this.m_CurFeatureRenderer = (this.m_LyrRender as IFeatureRenderer); |
|
} |
|
private void ControlsEnable(bool enable) |
|
{ |
|
base.Enabled = enable; |
|
} |
|
private void btnAddAll_Click(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
this.ControlsEnable(false); |
|
if (this.m_MatchLayer == null) |
|
{ |
|
return; |
|
} |
|
ItemInfo<IField, string> itemInfo = this.cmbFields.SelectedItem as ItemInfo<IField, string>; |
|
if (itemInfo == null) |
|
{ |
|
return; |
|
} |
|
this.m_SymbolTable.Rows.Clear(); |
|
string name = itemInfo.InnerValue.Name; |
|
string text = null; |
|
IDisplayTable displayTable = (IDisplayTable)this.m_MatchLayer; |
|
ICursor cursor = displayTable.DisplayTable.Search(null, false); |
|
IDataStatistics dataStatistics = new DataStatisticsClass(); |
|
dataStatistics.Cursor = cursor; |
|
dataStatistics.Field = name; |
|
Application.DoEvents(); |
|
bool flag = false; |
|
IEnumerator uniqueValues = dataStatistics.UniqueValues; |
|
this.m_ColorRamp = this.ucCRColors.GetSelectColorRamp(); |
|
bool flag2 = false; |
|
bool flag3 = true; |
|
int num = 0; |
|
try |
|
{ |
|
this.m_ColorRamp.Size = dataStatistics.UniqueValueCount; |
|
Application.DoEvents(); |
|
if (dataStatistics.UniqueValueCount >= 500 && !flag) |
|
{ |
|
if (MessageHelper.ShowYesNoAndTips("找到的唯一值个数大于500个,是否继续生成唯一值的完整列表?这会消耗较长时间。") == DialogResult.No) |
|
{ |
|
flag3 = false; |
|
this.m_ColorRamp.Size = 500; |
|
} |
|
flag = true; |
|
} |
|
this.m_ColorRamp.CreateRamp(out flag2); |
|
} |
|
catch (Exception) |
|
{ |
|
this.ControlsEnable(true); |
|
return; |
|
} |
|
IColor color = null; |
|
ISymbol symbol = null; |
|
DataRow row = null; |
|
uniqueValues.Reset(); |
|
while (uniqueValues.MoveNext()) |
|
{ |
|
row = this.m_SymbolTable.NewRow(); |
|
try |
|
{ |
|
text = Convert.ToString(uniqueValues.Current); |
|
} |
|
catch (Exception) |
|
{ |
|
} |
|
try |
|
{ |
|
color = this.m_ColorRamp.get_Color(num); |
|
} |
|
catch (Exception) |
|
{ |
|
} |
|
if (color != null) |
|
{ |
|
symbol = this.GetSymbol(color); |
|
} |
|
if (symbol == null) |
|
{ |
|
symbol = this.m_DefaultSymbol; |
|
} |
|
Bitmap symbolBitMap = RenderUtil.GetSymbolBitMap(40, 20, this.m_SymbologyStyleClass, symbol); |
|
this.InitRowData(symbolBitMap, text, text, symbol, ref row); |
|
this.m_SymbolTable.Rows.Add(row); |
|
if (dataStatistics.UniqueValueCount >= 500 && !flag) |
|
{ |
|
if (MessageHelper.ShowYesNoAndTips("找到的唯一值个数大于500个,是否继续生成唯一值的完整列表?这会消耗较长时间。") == DialogResult.No) |
|
{ |
|
flag3 = false; |
|
} |
|
flag = true; |
|
} |
|
if (!flag3 && num >= 500) |
|
{ |
|
break; |
|
} |
|
num++; |
|
} |
|
this.InvokeEditValueChanged(sender, e); |
|
Marshal.ReleaseComObject(cursor); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
this.ControlsEnable(true); |
|
} |
|
private void btnDelAll_Click(object sender, System.EventArgs e) |
|
{ |
|
this.m_SymbolTable.Rows.Clear(); |
|
this.m_SymbolTable.AcceptChanges(); |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
private void btnDel_Click(object sender, System.EventArgs e) |
|
{ |
|
if (this.m_SelectedRow == null) |
|
{ |
|
return; |
|
} |
|
try |
|
{ |
|
this.m_SymbolTable.Rows.Remove(this.m_SelectedRow); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
private void gridSymView_MouseDown(object sender, MouseEventArgs e) |
|
{ |
|
try |
|
{ |
|
GridHitInfo gridHitInfo = this.gridSymView.CalcHitInfo(new System.Drawing.Point(e.X, e.Y)); |
|
if (gridHitInfo.HitTest == GridHitTest.RowCell) |
|
{ |
|
this.m_SelectedRow = this.gridSymView.GetDataRow(gridHitInfo.RowHandle); |
|
this.m_SelectedSymbol = (this.m_SelectedRow["F_Symbol"] as ISymbol); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void btnDefaultSymbol_Click(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
IDoStyleGalleryItem doStyleGalleryItem = RenderUtil.OpenStyleSelector(this.GeometryType); |
|
if (doStyleGalleryItem != null) |
|
{ |
|
this.m_DefaultSymbol = (doStyleGalleryItem.Item.Item as ISymbol); |
|
this.RefreshDefaultSymbol(); |
|
} |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void btnRotateSet_Click(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
IGeoFeatureLayer geoFeatureLayer = this.m_MatchLayer as IGeoFeatureLayer; |
|
IFeatureRenderer renderer = geoFeatureLayer.Renderer; |
|
if (this.frmPointRatation == null) |
|
{ |
|
this.frmPointRatation = new FormPointRatation(); |
|
} |
|
if (this.frmPointRatation.Init(this.m_MatchLayer, renderer)) |
|
{ |
|
if (this.frmPointRatation.ShowDialog() == DialogResult.OK) |
|
{ |
|
this.mRotationrenderer = this.frmPointRatation.RotationRenderer; |
|
} |
|
this.InvokeEditValueChanged(sender, e); |
|
this.btnRotateSet.Focus(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void gridSymView_DoubleClick(object sender, System.EventArgs e) |
|
{ |
|
} |
|
private void gridSymCtrl_MouseDoubleClick(object sender, MouseEventArgs e) |
|
{ |
|
try |
|
{ |
|
if (this.m_SelectedSymbol != null) |
|
{ |
|
if (this.m_MatchLayer != null) |
|
{ |
|
this.gridSymView.CalcHitInfo(System.Windows.Forms.Control.MousePosition); |
|
ISymbol symbol = this.m_SelectedSymbol; |
|
symbol = (RenderUtil.OpenStyleSelector(this.GeometryType, symbol) as ISymbol); |
|
if (symbol != null) |
|
{ |
|
this.m_SelectedRow["F_BITMAP"] = RenderUtil.GetSymbolBitMap(40, 20, this.m_SymbologyStyleClass, symbol); |
|
this.m_SelectedRow["F_Symbol"] = symbol; |
|
this.m_SymbolTable.AcceptChanges(); |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void cmbFields_EditValueChanged(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
this.m_SymbolTable.Rows.Clear(); |
|
this.m_SymbolTable.AcceptChanges(); |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void ucCRColors_SelectIndexChanged(IColorRamp pColorRamp, string name) |
|
{ |
|
try |
|
{ |
|
this.m_ColorRamp = pColorRamp; |
|
if (this.m_ColorRamp != null) |
|
{ |
|
bool flag = false; |
|
this.m_ColorRamp.Size = this.m_SymbolTable.Rows.Count; |
|
Application.DoEvents(); |
|
try |
|
{ |
|
this.m_ColorRamp.CreateRamp(out flag); |
|
} |
|
catch |
|
{ |
|
} |
|
if (flag) |
|
{ |
|
IColor color = null; |
|
ISymbol symbol = null; |
|
for (int i = 0; i < this.m_SymbolTable.Rows.Count; i++) |
|
{ |
|
DataRow dataRow = this.m_SymbolTable.Rows[i]; |
|
try |
|
{ |
|
color = this.m_ColorRamp.get_Color(i); |
|
} |
|
catch (Exception) |
|
{ |
|
} |
|
if (color != null) |
|
{ |
|
symbol = this.GetSymbol(color); |
|
} |
|
if (symbol == null) |
|
{ |
|
symbol = this.m_DefaultSymbol; |
|
} |
|
Bitmap symbolBitMap = RenderUtil.GetSymbolBitMap(40, 20, this.m_SymbologyStyleClass, symbol); |
|
this.InitRowData(symbolBitMap, dataRow["F_Value"].ToString(), dataRow["F_Label"].ToString(), symbol, ref dataRow); |
|
} |
|
this.m_SymbolTable.AcceptChanges(); |
|
this.InvokeEditValueChanged(null, null); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void gridSymView_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) |
|
{ |
|
try |
|
{ |
|
this.m_SelectedRow = this.gridSymView.GetDataRow(e.FocusedRowHandle); |
|
if (this.m_SelectedRow != null) |
|
{ |
|
this.btnDel.Enabled = true; |
|
} |
|
else |
|
{ |
|
this.btnDel.Enabled = false; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
} |
|
private void picDefaultSymbol_Click(object sender, System.EventArgs e) |
|
{ |
|
try |
|
{ |
|
this.Cursor = Cursors.WaitCursor; |
|
this.m_DefaultSymbol = (RenderUtil.OpenStyleSelector(this.GeometryType, this.m_DefaultSymbol) as ISymbol); |
|
if (this.m_DefaultSymbol == null) |
|
{ |
|
this.Cursor = Cursors.Default; |
|
return; |
|
} |
|
this.RefreshDefaultSymbol(); |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//RdbUtil.AddException(ex); |
|
} |
|
this.Cursor = Cursors.Default; |
|
} |
|
private void cmbFields_SelectedIndexChanged(object sender, System.EventArgs e) |
|
{ |
|
ItemInfo<IField, string> itemInfo = this.cmbFields.SelectedItem as ItemInfo<IField, string>; |
|
if (itemInfo != null) |
|
{ |
|
this.m_ValueField = itemInfo.InnerValue.Name; |
|
} |
|
} |
|
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 btnAddVal_Click(object sender, System.EventArgs e) |
|
{ |
|
if (this.cmbFields.Text.Length == 0) |
|
{ |
|
MessageHelper.ShowTips("未设置字段!"); |
|
return; |
|
} |
|
if (this.m_DefaultSymbol == null) |
|
{ |
|
MessageHelper.ShowTips("未设置缺省符号!"); |
|
return; |
|
} |
|
string text = this.cmbFields.Text.ToString().Trim(); |
|
IDisplayTable displayTable = (IDisplayTable)this.m_MatchLayer; |
|
IFeatureClass featureClass = (IFeatureClass)displayTable.DisplayTable; |
|
ITable mTable = (ITable)featureClass; |
|
if (this.frmAddRendValue == null) |
|
{ |
|
this.frmAddRendValue = new FormAddValue(); |
|
} |
|
this.frmAddRendValue.listValue.Items.Clear(); |
|
this.frmAddRendValue.mFieldName = text; |
|
this.frmAddRendValue.mTable = mTable; |
|
this.frmAddRendValue.mFeatrueLayer = this.m_MatchLayer; |
|
ICursor cursor = this.m_MatchLayer.Search(null, false) as ICursor; |
|
IDataStatistics dataStatistics = new DataStatisticsClass(); |
|
dataStatistics.Cursor = cursor; |
|
dataStatistics.Field = text; |
|
dataStatistics.SampleRate = -1; |
|
IEnumerator uniqueValues = dataStatistics.UniqueValues; |
|
uniqueValues.Reset(); |
|
while (uniqueValues.MoveNext()) |
|
{ |
|
this.m_SymbolTable.NewRow(); |
|
try |
|
{ |
|
string item = Convert.ToString(uniqueValues.Current); |
|
this.frmAddRendValue.listValue.Items.Add(item); |
|
} |
|
catch (Exception) |
|
{ |
|
} |
|
} |
|
this.frmAddRendValue.SetValues(dataStatistics.UniqueValueCount); |
|
if (this.frmAddRendValue.ShowDialog() == DialogResult.OK) |
|
{ |
|
string mFieldValue = this.frmAddRendValue.mFieldValue; |
|
DataRow[] array = this.m_SymbolTable.Select("F_Value = '" + mFieldValue + "'"); |
|
if (array.Length != 0) |
|
{ |
|
MessageHelper.ShowTips("添加的属性值 " + mFieldValue + "已经存在"); |
|
return; |
|
} |
|
DataRow row = this.m_SymbolTable.NewRow(); |
|
ISymbol symbol = null; |
|
if (this.m_DefaultSymbol != null) |
|
{ |
|
IClone clone = this.m_DefaultSymbol as IClone; |
|
symbol = (clone.Clone() as ISymbol); |
|
} |
|
Bitmap symbolBitMap = RenderUtil.GetSymbolBitMap(40, 20, this.m_SymbologyStyleClass, symbol); |
|
this.InitRowData(symbolBitMap, mFieldValue, mFieldValue, symbol, ref row); |
|
this.m_SymbolTable.Rows.Add(row); |
|
this.InvokeEditValueChanged(sender, e); |
|
} |
|
} |
|
private void gridSymView_RowCountChanged(object sender, System.EventArgs e) |
|
{ |
|
this.btnDelAll.Enabled = Convert.ToBoolean(this.gridSymView.RowCount); |
|
} |
|
} |
|
}
|
|
|