- 积分
- 987
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-5-5
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 jzd19851102 于 2016-6-29 22:47 编辑
依托MeteoInfoMap_CSharp-master程序框架,对代码进行了部分删减,同时根据自己的需求,进行了部分代码的修改。
原先的frmMeteoData.cs中的绘图方法代码如下:
- private void TSB_Draw_Click(object sender, EventArgs e)
- {
- string fieldName = CB_Variable.Text;
- Display();
- }
复制代码
增加了部分代码后为:
- private void TSB_Draw_Click(object sender, EventArgs e)
- {
- string fieldName = CB_Variable.Text;
- // 显示当前图层对应的变量和时次信息
- LayoutGraphic aTitle = frmMain.CurrentWin.MapDocument.MapLayout.GetTexts()[0];
- aTitle.SetLabelText("变量:" + CB_Variable.SelectedItem.ToString() + " "+"时次:" + CB_Time.SelectedItem.ToString());
- ////删除上一个图层
- frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.LockViewUpdate = true;
- frmMain.CurrentWin.MapDocument.ActiveMapFrame.RemoveLayerByHandle(_lastAddedLayerHandle);
- frmMain.CurrentWin.MapDocument.ActiveMapFrame.MapView.LockViewUpdate = false;
- Display();
- //添加图例
- LayoutLegend aLegend;
- if (frmMain.CurrentWin.MapDocument.MapLayout.GetLegends().Count > 0)
- aLegend = frmMain.CurrentWin.MapDocument.MapLayout.GetLegends()[0];
- else
- aLegend= frmMain.CurrentWin.MapDocument.MapLayout.AddLegend(650, 100);
- aLegend.LegendStyle=MeteoInfoC.Layout.LegendStyles.Normal;
- frmMain.CurrentWin.MapDocument.MapLayout.PaintGraphics();
- }
复制代码 如图1-2,增加的代码实现了如下功能
1、在版面可以显示图层对应的变量和时次信息
2、 在左边layerslegend中,不会出现图层的重叠,如图2,如果不增加代码,切换变量或者时次后,出现图层的重叠;
3、 自动添加图例,之前需要手动插入legend
本来今天准备收工了,将vs的调试模式由debug改成release,结果出现了图3的错误

|
|