主要的海图调用过程和思路上一篇文章已经介绍
本文将介绍下该Demo中的一些函数和数值模式(源码比较乱,前后几种方式实现都在一起,仅供参考)
工程介绍:VS2013,C#实现,其中用到projNet库
1、通过程序运行的前后来介绍:
Form1_Load(初始化加载)
private void Form1_Load(object sender, EventArgs e)
{
//将窗口置顶并始终显示在右下角
SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2);
win_X = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width;
win_Y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height;
this.SetDesktopLocation(win_X, win_Y);
//设置界面
this.MinimizeBox = false;
// this.OnFormClosed = false;
this.MaximizeBox = true;
//设置加载皮肤
path = System.Environment.CurrentDirectory + "\\UAVShowWindow\\";
skin.SkinFile = path + "SportsBlack.ssk";
skin.Active = true;
//
image_file = System.Environment.CurrentDirectory +"\\"+ "20.PNG";
image_1 = Image.FromFile(image_file);
// Image
p_label_map = 0;
}
海图层级变化
public void ScaleLevel_ValueChanged(object sender, EventArgs e)//EventArgs e
{
//鼠标放大缩小地图
p_CenterX = p_LUpointX + 0.5 * (p_RUpointX - p_LUpointX);
p_CenterY = p_LDpointY + 0.5 * (p_LUpointY - p_LDpointY);
//m_Cpoint = Tran_TW.WorldToTilePos(p_CenterX, p_CenterY, (int)ScaleLevel.Value);
//鼠标放大缩小地图
double l_x = (double)p_picMou_x;
double l_y = (double)p_picMou_y;
p_CenterX = p_LUpointX + (l_x / pictureBox1.Width) * (p_RUpointX - p_LUpointX);
p_CenterY = p_LUpointY - (l_y / pictureBox1.Height) * (p_LUpointY - p_LDpointY);
//m_Cpoint = Tran_TW.WorldToTilePos(p_CenterX, p_CenterY, (int)ScaleLevel.Value);
Vector2D m_point = new Vector2D(0, 0);
m_point = TransformTileWorld.CalculationNum(p_CenterX, p_CenterY, (int)ScaleLevel.Value);
m_Cpoint.X = (float)m_point.X;
m_Cpoint.Y = (float)m_point.Y;
// p_TileIndex = TransformTileWorld.calculateTileIndex(p_CenterX, p_CenterY, (int)ScaleLevel.Value);
if (MapConfig != null)
{
int level = (int)ScaleLevel.Value;
MapConfig.DefaultLevel = level;
CreatCacheDir();
//DoMetho