///
/// 创建区域 /// ///区域信息 ///点集 private void CreateRect(RectInfo rectinfo,List
points) {
try {
//RectInfo 的定义请看下面 Catalog Cat = MapInfo.Engine.Session.Current.Catalog; Table tblTemp = Cat.GetTable(m_RectLayerName);
if (tblTemp ==
null)
return; FeatureGeometry geometry =
new MultiPolygon(
this.MapCoordSys, CurveSegmentType.Linear, points.ToArray()); CompositeStyle style = GetOpaqueStyle(OpaqueType.NoNe, Color.Red);
//GetOpaqueStyle在下面也有 Feature ftr =
new Feature(tblTemp.TableInfo.Columns); ftr.Geometry = geometry; ftr.Style = style; ftr[
"Name"] = rectinfo.FeatureName;
//字段一的内容 ftr[
"Remark"] = rectinfo.Remark;
//字段二的内容 ftr[
"Type"] = rectinfo.Type;
//字段二的内容 rectinfo.FeatureKey = tblTemp.InsertFeature(ftr).ToString(); tblTemp.TableInfo.WriteTabFile();
//保存到文件 }
catch (Exception ex) {
throw ex; } }
///
/// 自定义区域信息
///
public
class RectInfo {
private
string _FeatureKey =
string.Empty;
///
/// 图元的KEY值
///
public
string FeatureKey { get {
return _FeatureKey; } set {
if (_FeatureKey !=
value) { _FeatureKey =
value; } } }
private
string _FeatureName;
///
/// 图元名称
///
public
string FeatureName { get {
return _FeatureName; } set {
if (_FeatureName !=
value) { _FeatureName =
value; } } }
private
string _Type;
///
/// 类型
///
public
string Type { get {
return _Type; } set {
if (_Type !=
value) { _Type =
value; } } }
private
string _Remark;
///
/// 备注
///
public
string Remark { get {
return _Remark; } set {
if (_Remark !=
value) { _Remark =
value; } } }
///
/// 构造函数
///
public RectInfo() { }
///
/// 构造函数
///
/// 名称
/// 类型
/// 备注
public RectInfo(
string _FeatureName,
string _Type,
string _Remark) { FeatureName = _FeatureName; Type = _Type; Remark = _Remark; } }
///
/// 创建style
///
/// 不透明类型:ALL全部不透明(白色实心);BORDER边界不透明(填充部分透明);NONE全透明
/// 如果opaqueType=BORDER,此处设定边界颜色
///
组合style
private CompositeStyle GetOpaqueStyle(OpaqueType opaqueType, System.Drawing.Color borderColor) { MapInfo.Styles.SimpleInterior simpleInterior;
if (opaqueType == OpaqueType.ALL) simpleInterior =
new MapInfo.Styles.SimpleInterior();
//缺省构造函数是白色实心
else simpleInterior =
new MapInfo.Styles.SimpleInterior(1);
//0是线透明,1是面透明 MapInfo.Styles.LineWidth lineWidth =
new MapInfo.Styles.LineWidth(1, MapInfo.Styles.LineWidthUnit.Point); MapInfo.Styles.SimpleLineStyle simpleLineStyle;
if (opaqueType == OpaqueType.ALL) simpleLineStyle =
new MapInfo.Styles.SimpleLineStyle(lineWidth, 1, borderColor);
else
if (opaqueType == OpaqueType.BORDER) simpleLineStyle =
new MapInfo.Styles.SimpleLineStyle(lineWidth, 2, borderColor);
//2表示填充透明,即能够显示轮廓
else simpleLineStyle =
new MapInfo.Styles.SimpleLineStyle(lineWidth, 0);
//0表示全部透明,即连轮廓都看不到 MapInfo.Styles.AreaStyle areaStyle =
new MapInfo.Styles.AreaStyle(simpleLineStyle, simpleInterior); MapInfo.Styles.CompositeStyle compositeStyle =
new MapInfo.Styles.CompositeStyle(areaStyle,
null,
null,
null);
return compositeStyle; }
///
/// 区域,线路样式类型
///
public
enum OpaqueType {
///
/// 全部不透明
/// ALL,
///
/// 边界不透明
/// BORDER,
///
/// 全透明
/// NoNe }
2011年6月17日星期五
C# Mapxtream---创建面
订阅:
博文评论 (Atom)
没有评论:
发表评论