- 积分
- 351
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-3-18
- 最后登录
- 1970-1-1

|
发表于 2015-2-11 15:26:25
|
显示全部楼层
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MeteoInfoC;
using MeteoInfoC.Layer;
using MeteoInfoC.Data;
using MeteoInfoC.Data.MapData;
using MeteoInfoC.Data.MeteoData;
using MeteoInfoC.Map;
using MeteoInfoC.Layout;
using MeteoInfoC.Global;
using MeteoInfoC.Legend;
using MeteoInfoC.Shape;
using MeteoInfoC.Drawing;
using MeteoInfoC.Projections;
namespace fy_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void LoadLayers()
{
layersLegend1.ActiveMapFrame.MapView.LockViewUpdate = true;
//Load country layer
string aFile = Application.StartupPath + "\\Map\\country1.shp";
MapLayer aLayer = MapDataManage.OpenLayer(aFile);
aLayer.LegendScheme.LegendBreaks[0].Color = Color.WhiteSmoke;
layersLegend1.ActiveMapFrame.AddLayer(aLayer);
//Load river layer
aFile = Application.StartupPath + "\\Map\\rivers.shp";
aLayer = MapDataManage.OpenLayer(aFile);
aLayer.LegendScheme.LegendBreaks[0].Color = Color.Aqua;
((PolyLineBreak)aLayer.LegendScheme.LegendBreaks[0]).Size = 2;
layersLegend1.ActiveMapFrame.AddLayer(aLayer);
//Load city layer
aFile = Application.StartupPath + "\\Map\\CITIES.shp";
aLayer = MapDataManage.OpenLayer(aFile);
((PointBreak)aLayer.LegendScheme.LegendBreaks[0]).Color = Color.Red;
aLayer.Expanded = true;
layersLegend1.ActiveMapFrame.AddLayer(aLayer);
//Label city name
VectorLayer cityLayer = (VectorLayer)aLayer;
cityLayer.LabelSet.FieldName = "NAME";
cityLayer.LabelSet.AvoidCollision = true;
cityLayer.LabelSet.LabelAlignType = MeteoInfoC.Legend.AlignType.Center;
cityLayer.LabelSet.XOffset = 0;
cityLayer.LabelSet.YOffset = 0;
cityLayer.LabelSet.LabelFont = new Font("Arial", 8);
cityLayer.LabelSet.LabelColor = Color.Red;
cityLayer.LabelSet.DrawShadow = false;
cityLayer.LabelSet.ShadowColor = Color.White;
cityLayer.LabelSet.ColorByLegend = false;
cityLayer.AddLabels();
//Set layout map size
mapLayout1.ActiveLayoutMap.Left = 40;
mapLayout1.ActiveLayoutMap.Top = 40;
mapLayout1.ActiveLayoutMap.Width = 600;
mapLayout1.ActiveLayoutMap.Height = 400;
//Refresh
layersLegend1.ActiveMapFrame.MapView.LockViewUpdate = false;
layersLegend1.ActiveMapFrame.MapView.ZoomToExtent(70, 140, 10, 60);
layersLegend1.Refresh();
}
private void Form1_Load(object sender, EventArgs e)
{
//Set width and height
this.Width = 1000;
this.Height = 625;
//Load layers
LoadLayers();
//Set initial tool
// TSB_Pan.PerformClick();
}
}
} |
|