📄 clsrenderstatlayer.cs
字号:
{
pColor = pEnumColors.Next();
ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
//if(iBreakIndex < 1) pColor->put_NullColor(VARIANT_TRUE);
pFillSymbol.Color = pColor;
pFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
ILineSymbol pLine = new SimpleLineSymbolClass();
pLine.Color = pColor;
pLine.Width = 1;
pFillSymbol.Outline = pLine;
ISymbol pSym = pFillSymbol as ISymbol;
pClassBreaksRenderer.set_Symbol(iBreakIndex, pSym);
dbValue0 += dbMax / iSegNum;
pClassBreaksRenderer.set_Break(iBreakIndex, dbValue0);
string strTemp = "";
strTemp = dbValue0.ToString("0.00");
pClassBreaksRenderer.set_Label(iBreakIndex, strTemp);
pClassBreaksRenderer.set_Description(iBreakIndex, strTemp);
}
IFeatureRenderer pFRend = pClassBreaksRenderer as IFeatureRenderer;
pGeoFeatureLayer.Renderer = pFRend;
return true;
}
private double GetStatMax(IFeatureLayer pFLayer, string strField)
{
if(pFLayer == null) return 0;
IGeoFeatureLayer pGeoLayer = pFLayer as IGeoFeatureLayer;
if(pGeoLayer == null) return 0;
ITable pTable = pGeoLayer as ITable;
if(pTable == null) return 0;
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.AddField(strField);
IFeatureClass ipFeatureClass = pFLayer.FeatureClass;
if(ipFeatureClass.FindField(strField) <0) return 0;
IFeatureCursor ipFeatureCursor;
//------------------------------------------------------------------------
//这里有时返回零,和数据有一定的关系,如何来处理
ipFeatureCursor = ipFeatureClass.Search(pQueryFilter, false);
if(ipFeatureCursor == null) return 0;
ICursor pCursor = ipFeatureCursor as ICursor;
if(pCursor == null) return 0;
IDataStatistics pDataStatistics = new DataStatisticsClass();
pDataStatistics.Cursor = pCursor;
pDataStatistics.Field = strField;
IStatisticsResults pStatisticsResult;
pStatisticsResult = pDataStatistics.Statistics;
if(pStatisticsResult == null) return 0;
double dbMaxValue;
return pStatisticsResult.Maximum;
}
#endregion
#region "类的辅助函数"
private string GetRenField()//当有次分组时,只有一个照色字段起作用
{
foreach (StatItem var in StatTable.StatItemList)
{
if (var.isRenField) return var.fieldName;
}
return "";
}
private double GetStatMax(IFeatureClass pFClass)
{
if (pFClass == null) return 0.00;
IFeatureCursor FCursor = clsGISPub.SearchFeature(pFClass, "");
if (FCursor == null) return 0.00;
double dbTemp = 0.00;
while (true)
{
IFeature Feat = FCursor.NextFeature();
if (Feat == null) break;
if (StatEnv.SecondGroupField == "")//没有次分组
{
foreach (StatItem var in StatTable.StatItemList)
{
int iFieldIndex = Feat.Fields.FindField(var.fieldName);
double dd =0;
if (Feat.get_Value(iFieldIndex) == null || Feat.get_Value(iFieldIndex).ToString() == "") dd = 0;
else Convert.ToDouble(Feat.get_Value(iFieldIndex));
if (dd > dbTemp) dbTemp = dd;
}
}
else
{
string renFieldName = GetRenField().ToLower();
foreach (DataColumn var in StatTable.workTable.Columns)
{
if (var.ColumnName.ToLower().Contains(renFieldName))
{
int iFieldIndex = Feat.Fields.FindField(var.ColumnName);
double dd = 0;
if (Feat.get_Value(iFieldIndex) == null || Feat.get_Value(iFieldIndex).ToString() == "") dd = 0;
else Convert.ToDouble(Feat.get_Value(iFieldIndex));
if (dd > dbTemp) dbTemp = dd;
}
}
}
}
return dbTemp;
}
private double GetRowSumMin(IFeatureClass pFClass)
{
double dbRetun = 0.0001;
if (pFClass == null) return dbRetun;
IFeatureCursor FCursor = clsGISPub.SearchFeature(pFClass, "");
if (FCursor == null) return dbRetun;
double dbMin = 9999999;
while (true)
{
IFeature Feat = FCursor.NextFeature();
if (Feat == null) break;
double dbTemp = 0;
if (StatEnv.SecondGroupField == "")//没有次分组
{
foreach (StatItem var in StatTable.StatItemList)
{
int iFieldIndex = Feat.Fields.FindField(var.fieldName);
double dd = Convert.ToDouble(Feat.get_Value(iFieldIndex));
dbTemp += dd;
}
}
else
{
string renFieldName = GetRenField().ToLower();
foreach (DataColumn var in StatTable.workTable.Columns)
{
if (var.ColumnName.ToLower().Contains(renFieldName))
{
int iFieldIndex = Feat.Fields.FindField(var.ColumnName);
double dd = Convert.ToDouble(Feat.get_Value(iFieldIndex));
dbTemp += dd;
}
}
}
if (dbMin > dbTemp && dbMin > dbRetun) dbMin = dbTemp;
}
if (dbMin > dbRetun) return dbMin;
else return dbRetun;
}
IColor GetColor(int i)
{
#region "获取颜色"
IRgbColor pColor = new RgbColorClass();
switch(i)
{
case 1:
pColor.Red = 255;
pColor.Green = 0;
pColor.Blue = 0;
return pColor;
case 2:
pColor.Red = 0;
pColor.Green = 255;
pColor.Blue = 0;
return pColor;
case 3:
pColor.Red = 0;
pColor.Green = 0;
pColor.Blue = 255;
return pColor;
case 4:
pColor.Red = 0;
pColor.Green = 255;
pColor.Blue = 255;
return pColor;
case 5:
pColor.Red = 255;
pColor.Green = 0;
pColor.Blue = 255;
return pColor;
case 6:
pColor.Red = 128;
pColor.Green = 0;
pColor.Blue = 0;
return pColor;
case 7:
pColor.Red = 0;
pColor.Green = 0;
pColor.Blue = 128;
return pColor;
case 8:
pColor.Red = 255;
pColor.Green = 128;
pColor.Blue = 0;
return pColor;
case 9:
pColor.Red = 128;
pColor.Green = 0;
pColor.Blue = 255;
return pColor;
case 10:
pColor.Red = 128;
pColor.Green = 128;
pColor.Blue = 255;
return pColor;
case 11:
pColor.Red = 118;
pColor.Green = 21;
pColor.Blue = 6;
return pColor;
case 12:
pColor.Red = 187;
pColor.Green = 48;
pColor.Blue = 207;
return pColor;
case 13:
pColor.Red = 221;
pColor.Green = 0;
pColor.Blue = 255;
return pColor;
case 14:
pColor.Red = 128;
pColor.Green = 34;
pColor.Blue = 128;
return pColor;
case 15:
pColor.Red = 152;
pColor.Green = 225;
pColor.Blue = 30;
return pColor;
case 16:
pColor.Red = 253;
pColor.Green = 147;
pColor.Blue = 2;
return pColor;
case 17:
pColor.Red = 224;
pColor.Green = 200;
pColor.Blue = 30;
return pColor;
case 18:
pColor.Red = 236;
pColor.Green = 248;
pColor.Blue = 7;
return pColor;
case 19:
pColor.Red = 194;
pColor.Green = 61;
pColor.Blue = 194;
return pColor;
case 20:
pColor.Red = 83;
pColor.Green = 74;
pColor.Blue = 181;
return pColor;
default:
pColor.Red = 0;
pColor.Green = 0;
pColor.Blue = 0;
return pColor;
}
#endregion
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -