特定のフィーチャ レイヤー内のすべてのフィーチャに半透明性を与えながら、そのレイヤー内の各フィーチャのスタイルを保持しようとしています。
次のアプローチを試してみ ました:
このアプローチでは、Modify()
関数はヒットしないため、適切に機能しません。関数内のコードModify()
は、修飾子が追加されると呼び出される必要があるという記事に従って、まったく実行されません。
以下は、使用しているコード スニペットです。
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;
}
}
そして、このクラスは次のように使用されています:
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();
}
どんな助けでも大歓迎です。
よろしく、モヌ