b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

mapxtreme pitney_mapxtreme_arcgis engine(3)

电脑杂谈  发布时间:2017-01-22 06:01:35  来源:网络整理

以下是构造Label的方法:

构造各Label

1     private System.Windows.Forms.Label CreateLevelLabel ( int zoomLevel,int yPosition )
2    {
3      System.Windows.Forms.Label label = new System.Windows.Forms.Label ();
4      label.BackColor = System.Drawing.Color.White;
5      label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
6      label.Font = new System.Drawing.Font ( "宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 134 ) ) );
7      label.Text = "   ";
8      label.Name = "lblLevel" + zoomLevel.ToString ();
9      label.Tag = zoomLevel;
10      label.Cursor = System.Windows.Forms.Cursors.Hand;
11      label.Location = new System.Drawing.Point ( xPosition, yPosition );
12      label.Size = new System.Drawing.Size ( 37, 11 );
13      label.Click += new EventHandler ( label_Click );
14      tt = new System.Windows.Forms.ToolTip ();
15      tt.ShowAlways = true;
16      tt.SetToolTip ( label, "缩放地图到"+zoomLevel.ToString()+"级" );
17      return label;
18    }
19

以上需要注意的是,我把该控件所关联的缩放等级设置到控件的Tag中,并注册了点击事件,那么在该事件中,我们只需要把该控件所保留的缩放等级设置到地图上就可以了:

Label事件

1    void label_Click ( object sender, EventArgs e )
2    {
3      System.Windows.Forms.Label label = (System.Windows.Forms.Label) sender;
4      MapControl mc = (MapControl) _control;
5      mc.SetZoomLevel ( Int32.Parse ( label.Tag.ToString () ) );
6    }

如此以上,我们的地图缩放工具就完成了。

当然,有了这个工具还是不够的,所以我又在MapControl上注册了鼠标双击事件,由双击鼠标来进行地图的缩放:

MapControl双击事件

1    public void mc_Map_MouseDoubleClick ( object sender, MouseEventArgs e )
2    {
3      switch ( e.Button )
4      {
5        case MouseButtons.Left:
6          ZoomIn ();
7          break;
8        case MouseButtons.Right:
9          ZoomOut ();
10          break;
11      }
12      _helper.SetCenter ( e.Location );
13    }
14

这是最后的效果,当点击任意的缩放等级,地图就会缩放到适当的大小


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-27980-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...