交互式电子沙盘数字沙盘大数据系统开发第8课
这次我们完成的功能为拖动一个外部的UI对象到球球上:
private void Button_PreviewMouseMove(object sender, MouseEventArgs e)
{
if(e.LeftButton== MouseButtonState.Pressed)
DragDrop.DoDragDrop((Button)sender, sender, DragDropEffects.Move);
}
private void Gis3d_PreviewDrop(object sender, DragEventArgs e)
{
if (e.Data.GetData(typeof(Button)) != null)
{
MTGIS3D Pareant = ((MTGIS3D)IniRead.IniReadWrite.MPareant);
GisLib.GIS2D.UserCanvas y1 = new GisLib.GIS2D.UserCanvas();
Point3D va = ((MTGIS3D)IniRead.IniReadWrite.MPareant).GetJWForMouse(e.GetPosition(Pareant));
Button Data = (Button)e.Data.GetData(typeof(Button));
Button Y1 = new Button();
Y1.Content=Data.Content;
Y1.Width = Data.Width;
Y1.Height = Data.Height;
NewGisBiao.M3D.UserGisUI3dObject2 JuLiSechBiao = new NewGisBiao.M3D.UserGisUI3dObject2(); //新建一个承载UI对象的东东
JuLiSechBiao.PareantEarth = (NewGisBiao.Base.GISInterfaseForBiao)IniRead.IniReadWrite.MPareant;//设置它的GIS球对象
JuLiSechBiao.Manage = IniRead.IniReadWrite.BiaoManage;//设置它的标号管理器
JuLiSechBiao.MaxZoom = 9;//最大显示层,当小于9层的时候不显示
JuLiSechBiao.MUIValue = Y1;//UI对象
JuLiSechBiao.DHi = 0.01;//相对于地形的高度
JuLiSechBiao.ZScal = 0.6;//相对缩放
JuLiSechBiao.Scal.ScaleX = 1; //固定东东
JuLiSechBiao.Scal.ScaleY = 1;
JuLiSechBiao.Scal.ScaleZ = 1;
JuLiSechBiao.AutoScal = true;//是否自动缩放,不管在哪一层都是一样大
JuLiSechBiao.AutoAngle = true;//是否自动角度,使终对着摄像机
JuLiSechBiao.CenterType = JunBiao.CenteType.左下角;//中心点类型
IniRead.IniReadWrite.BiaoManage.AddJunBiao(JuLiSechBiao);//增加到军标管理对象中。也可以不加
JuLiSechBiao.MWidth = Data.Width;//三维面片的大小
JuLiSechBiao.MHeight = Data.Height;
JuLiSechBiao.MRX = 90;
if (IniRead.IniReadWrite.MPareant is MTGIS3D) //手动刷新一下自动角度。。。bug
{
((MTGIS3D)IniRead.IniReadWrite.MPareant).TextAxisAngleX.Angle += 0.001;
((MTGIS3D)IniRead.IniReadWrite.MPareant).TextAxisAngleX.Angle -= 0.001;
}
JuLiSechBiao.Center = new Point(va.X, va.Y);//设置中心点
JuLiSechBiao.ISShow = true;//显示
}
}
效果 如下: