如何以编程方式应用 MapXtreme 主题
我使用 MapXtreme 7.0 维护一个桌面应用程序,并且我有 很难找到很多文档或有用的例子(我确实有 安装光盘上的 pdf、示例等)
目前我正在尝试以编程方式应用 individualValueTheme 到一个FeatureLayer。我可以应用标准默认主题,我也可以 显示ModifyIndValueThemeDlg并让用户更改主题。 然而我想做的是将我自己的主题应用到图层上,而不需要 用户干预。
以下代码尝试执行此操作,但结果是图层 使用默认的 individualValueTheme 显示(即不使用我的样式)
任何帮助将不胜感激
void ApplyTheme(FeatureLayer lyr)
{
if (lyr.Modifiers.Contains(HarvOpsTheme) || lyr.Modifiers.Contains(HarvOpsRangedTheme))
return;
HarvOpsTheme = new IndividualValueTheme(lyr, "iOperationType","HarvOpsTheme");
lyr.Modifiers.Append(HarvOpsTheme);
HarvOpsTheme.Bins[0].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(255, 255, 0)));
HarvOpsTheme.Bins[1].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 255, 0)));
HarvOpsTheme.Bins[2].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(128, 128, 0)));
HarvOpsTheme.Bins[3].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(192, 128, 0)));
HarvOpsTheme.Bins[4].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 128, 0)));
HarvOpsTheme.Bins[5].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 205, 128)));
HarvOpsTheme.Bins[6].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(255, 0, 0)));
HarvOpsTheme.Apply(HarvOpsTheme);
HarvOpsTheme.RecomputeStyles();
lyr.Invalidate();
}
AreaStyle GetHollowAreaStyle(Color color)
{
return new AreaStyle
{
Interior = StockStyles.HollowFillStyle(),
Border = new SimpleLineStyle(new LineWidth(1,LineWidthUnit.Pixel), 1, color)
};
}
I maintain a Desktop application using MapXtreme 7.0 and I have
trouble finding much documentation or useful examples (I do have the
pdfs, samples etc that come on the install discs)
Currently I am trying to programmaticly apply an IndividualValueTheme
to a FeatureLayer. I can apply a standard default theme, I can also
show a ModifyIndValueThemeDlg and let the user change the theme.
However what I want to do is apply my own theme to the layer without
user intervention.
The following code attempts to do this but results in the Layer
showing with the default IndividualValueTheme (ie not with my styles)
Any help would be greatly appreciated
void ApplyTheme(FeatureLayer lyr)
{
if (lyr.Modifiers.Contains(HarvOpsTheme) || lyr.Modifiers.Contains(HarvOpsRangedTheme))
return;
HarvOpsTheme = new IndividualValueTheme(lyr, "iOperationType","HarvOpsTheme");
lyr.Modifiers.Append(HarvOpsTheme);
HarvOpsTheme.Bins[0].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(255, 255, 0)));
HarvOpsTheme.Bins[1].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 255, 0)));
HarvOpsTheme.Bins[2].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(128, 128, 0)));
HarvOpsTheme.Bins[3].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(192, 128, 0)));
HarvOpsTheme.Bins[4].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 128, 0)));
HarvOpsTheme.Bins[5].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(0, 205, 128)));
HarvOpsTheme.Bins[6].Style.ApplyStyle(GetHollowAreaStyle(Color.FromArgb(255, 0, 0)));
HarvOpsTheme.Apply(HarvOpsTheme);
HarvOpsTheme.RecomputeStyles();
lyr.Invalidate();
}
AreaStyle GetHollowAreaStyle(Color color)
{
return new AreaStyle
{
Interior = StockStyles.HollowFillStyle(),
Border = new SimpleLineStyle(new LineWidth(1,LineWidthUnit.Pixel), 1, color)
};
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅对于个人主题,重新计算样式会导致重新生成第一个主题结果。用户通过[Bins]更改样式后,不需要再次重新计算它们。
简而言之,只需删除线,让奇迹发生
最好的祝福
For Individual Theme only,recomputing styles causes to regenerate the first theming result.After user changes styles by [Bins] you do not need to recompute them again.
In short, simply remove the line and let the magic happen
Best Regards