We are trying to give the translucency to all features in a particular feature layer while retaining the styles of each feature in that layer.
We tried following approach : http://testdrive.mapinfo.com/techsupp/miprod.nsf/59d125f456480edb852562b5004f2c33/00a4a56ebede26ff85256fe30054e255?OpenDocument
In this approach the Modify()
function is not getting hit and hence not working properly. Code inside the Modify()
function is not getting executed at all, as per the article that it should get called once the modifier is appended.
Following is the code snippet we are using:
Internal class SelectedAreaModifier : FeatureStyleModifier
{
private System.Collections.Hashtable features;
public SelectedAreaModifier(string name, string alias, IResultSetFeatureCollection irfc) : base(name, alias)
{
features = new System.Collections.Hashtable();
string[] exp = new string[] { "MI_KEY" };
this.Expressions = exp;
foreach (Feature f in irfc)
{
features.Add(f.Key.Value, f.Key.Value);
}
}
protected override bool Modify(FeatureStyleStack styles, object[] values)
{
MapInfo.Styles.CompositeStyle cs = styles.Current;
if (features.Contains((values[0] as MapInfo.Data.Key).Value))
{
(cs.AreaStyle.Interior as SimpleInterior).ForeColor = Color.FromArgb((int)(255 * .5), (cs.AreaStyle.Interior as SimpleInterior).ForeColor);
(cs.AreaStyle.Border as SimpleLineStyle).Color = Color.FromArgb((int)(255 * .5),(cs.AreaStyle.Border as SimpleLineStyle).Color);
(cs.AreaStyle.Border as SimpleLineStyle).Width = (cs.AreaStyle.Border as SimpleLineStyle).Width;
return true;
}
return false;
}
}
and this class is being used as :
protected void setTranslucency()
{
Map myMap = GetMapObj();
myMap.DrawingAttributes.EnableTranslucency = true;
myMap.DrawingAttributes.SmoothingMode = MapInfo.Mapping.SmoothingMode.AntiAlias;
myMap.DrawingAttributes.SpecialTransparentVectorHandling = false;
FeatureLayer ftrLyr = myMap.Layers["CELL_2G"] as FeatureLayer;
if (ftrLyr.Modifiers["CELL_2G_Translucent"] != null)
ftrLyr.Modifiers.Remove("CELL_2G_Translucent");
MapInfo.Data.MIConnection connection = new MIConnection();
connection.Open();
MapInfo.Data.MICommand command = connection.CreateCommand();
command.CommandText = "select * from CELL_3G";
command.Prepare();
IResultSetFeatureCollection irfc = command.ExecuteFeatureCollection();
SelectedAreaModifier sam = new SelectedAreaModifier("CELL_2G_Translucent", "CELL_2G_Translucent", irfc);
sam.Enabled = true;
ftrLyr.Modifiers.Append(sam);
irfc.Close();
command.Dispose();
connection.Close();
}
Any help would be highly appreciated.
Regards, Monu