Hi Folks,
I am building by my own a legend control. So far it is going on a very good way.
But right now I have one issue…
I want to add to the legend only set styles… let`s say I have one shapes layer and I set only the AreaStyle and TextStyle…
When I render the legend I do not want to show the LineStyle and PointSyle, as they are completelly empty…
As they are not null, How can I check if the LineStyle and PointSyle are "empty"?
Kind regards,
Pedro
How to detect if a Style is set?
Hi Pedro,
Thanks for your post, would you please try to use following code to check if they are empty?
if (lineStyle.OuterPen.Color == GeoColor.StandardColors.Transparent && lineStyle.CenterPen.Color == GeoColor.StandardColors.Transparent
&& lineStyle.InnerPen.Color == GeoColor.StandardColors.Transparent)
{
////////////
}
if(pointStyle.Image==null&&pointStyle.CharacterFont.FontName=="Arial"&&pointStyle.CharacterFont.Size==9
&&pointStyle.CharacterIndex==0&&pointStyle.CharacterSolidBrush.Color==GeoColor.StandardColors.Transparent
&&pointStyle.PointType== PointType.Symbol&&pointStyle.SymbolType== PointSymbolType.Circle
&&pointStyle.SymbolSolidBrush.Color==GeoColor.StandardColors.Transparent
&&pointStyle.SymbolPen.Color==GeoColor.StandardColors.Transparent&&pointStyle.SymbolSize==3)
{
//////////////////////
}
Hope it helps
Summer
Hi Summer!
Thanks for the answer! It gave me some light! But, what about AreaStyle and TextStyle?
Can I assume something like:
- AreaStyle
(areaStyle.FillSolidBrush.Color == GeoColor.StandardColors.Transparent && areaStyle.OutlinePen.Color == GeoColor.StandardColors.Transparent);
-TextStyle
(string.IsNullOrWhiteSpace(textStyle.TextColumnName))
Is there any other condition that i should consider?
Thanks again for your help!
Pedro
Pedro,
From a programmer’s point of view, two other ideas, just quickly thought of and perhaps not practical for your needs. How about checking the layer data type to determine which styles to ignore? If the data is point, you can pretty much ignore AreaStyle and LineStyle. (Might still be hard to determine if TextStyle is empty but you might be setting TextStyle for all the layers so it’s not an issue.) Or maybe extending all of the style classes (something like PointStyleExtended, LineStyleExtended, etc.) which contains a new “Empty” Boolean member which is true by default, and then a new ZoomLevel class which by default assigns “…Extended” classes to all the styles. (You’re never going to change anything in the empty “Extended” classes but just use it as an “empty” signal. If you don’t do that you then might be able to use typeOf to determine which class is present and if it’s “…Extended” that’s an empty style. Or use the Extended style everywhere instead of the MapSuite style classes and check the “Empty” member.
Just some ideas that might lead to some better ideas.
Second thought: maybe “LineStyleEmpty” might be a more appropriate naming scheme than “LineStyleExtended”.
Allen
Hi Pedro and Allen,
Pedro: your idea for textstyle is right, but a little amendment is needed for areastyle:
if(area.OutlinePen.Color==GeoColor.StandardColors.Transparent&&
area.FillSolidBrush.Color == GeoColor.StandardColors.Transparent&&
area.PenBrushDrawingOrder == PenBrushDrawingOrder.BrushFirst)
{ }
Allen:Thanks for your sharing very much, and hope it could be helpful to Pedro.
Best Regards
Summer