using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AxNVPWEBCONTROLLib;
using NVPWEBCONTROLLib;
using NVPX4TOOL;
using VRMap2Platform;
using VRMAP2EXNODE;
using GEOMETRYLib;
namespace FlyAndMeasure
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
INVPControl control = this.axNVPWebControl1.NVPControl;
control.LoadPlugin("VMStdViewer4.VRMapStdViewer.1");
}
private void button1_Click(object sender, EventArgs e)
{
MainsaveFileDialog.Filter = "文本文件 (*.flp)|*.flp";
MainsaveFileDialog.Title = "文件保存为";
MainsaveFileDialog.ShowDialog();
if (MainsaveFileDialog.FileName != "")
{
this.axNVPPathFlyControl1.SavePath(MainsaveFileDialog.FileName);
this.axNVPWebControl1.Refresh();
//tempDataset.WriteXml(MainsaveFileDialog.FileName);
}
}
private void Form1_Load(object sender, EventArgs e)
{
//1关联控件
this.axNVPBrowserControl1.MainControl = this.axNVPWebControl1.GetOcx(); //Set buddy control
this.axNVPPathFlyControl1.MainControl = this.axNVPWebControl1.GetOcx();
this.axNVPAnalysisControl1.MainControl = this.axNVPWebControl1.GetOcx();
//2加载插件
INVPControl mapControl = this.axNVPWebControl1.NVPControl;
mapControl.LoadPlugin("VMStdEditor.VRMapStdEditor.1");
mapControl.LoadPlugin("VMStdAnalyse.VMAnalyse.1");
mapControl.LoadPlugin("VMStdViewer4.VRMapStdViewer.1");
}
private void button5_Click(object sender, EventArgs e)
{
MainopenFileDialog.Filter = "vm2文件 (*.vm2)|*.vm2";
MainopenFileDialog.FilterIndex = 2;
MainopenFileDialog.RestoreDirectory = true;
if (MainopenFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
this.axNVPWebControl1.SceneFile = MainopenFileDialog.FileName;
this.axNVPWebControl1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show("错误: 不能够从硬盘上读取文件. 错误信息: " + ex.Message);
}
}
}
private void button6_Click(object sender, EventArgs e)
{
this.axNVPPathFlyControl1.Edit();
}
private void button7_Click(object sender, EventArgs e)
{
this.axNVPPathFlyControl1.Play();
}
private void button8_Click(object sender, EventArgs e)
{
this.axNVPPathFlyControl1.Stop();
}
private void button2_Click(object sender, EventArgs e)
{
MainopenFileDialog.Filter = "flp文件 (*.flp)|*.flp";
MainopenFileDialog.FilterIndex = 2;
MainopenFileDialog.RestoreDirectory = true;
if (MainopenFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
this.axNVPPathFlyControl1.LoadPath(MainopenFileDialog.FileName);
this.axNVPWebControl1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show("错误: 不能够从硬盘上读取文件. 错误信息: " + ex.Message);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
this.axNVPAnalysisControl1.SetCurrentToolIsAerialDist();
}
private void button4_Click(object sender, EventArgs e)
{
this.axNVPAnalysisControl1.SetCurrentToolIsArea();
}
private void axNVPAnalysisControl1_OnAerialDistanceFinished(object sender, INVPAnalysisControlEvents_OnAerialDistanceFinishedEvent e)
{
listBox1.Items.Clear();
listBox1.Items.Add("长度是:"+this.axNVPAnalysisControl1.AerialDistance.ToString());
}
private void axNVPAnalysisControl1_OnAreaFinished(object sender, INVPAnalysisControlEvents_OnAreaFinishedEvent e)
{
listBox1.Items.Clear();
listBox1.Items.Add("面积是:"+this.axNVPAnalysisControl1.area.ToString());
}
private void button9_Click(object sender, EventArgs e)
{
//启动时间控制
timer1.Enabled = true;
//定义矩形
//S_Vec3Geo[] points = new S_Vec3Geo(4);
}
private double height =0;
private void timer1_Tick(object sender, EventArgs e)
{
PointsClass points=new PointsClass();
PointClass point;
point = new PointClass();
point.x = 38273.4604468572;
point.y = 50851.8666261247;
point.Height = 180.218;
points.AddPoint(point);
point = new PointClass();
point.x = 37837.2554834319;
point.y = 50811.041801623;
point.Height = 180.47;
points.AddPoint(point);
point = new PointClass();
point.x = 37760.3603914019;
point.y = 51212.9856685915;
point.Height = 180.844;
points.AddPoint(point);
point = new PointClass();
point.x = 38269.2672953459;
point.y = 51230.3596246294;
point.Height = 182.021;
points.AddPoint(point);
IGeoRegion region = new GeoRegionClass();
region.AddPart(points);
VRMapGeometryObject geo = new VRMapGeometryObjectClass();
geo.Geometry = (Geometry)region;
geo.SkinClass = "VRMap.VRMapBlock2";
//定义楼块
VRMapBlock2 block = (VRMapBlock2)geo;
block.Translation_Y = (float)height;
// block.Pivot_Y = (float)height;
//IVRMapObject addObject;
//IVRMapNode selNode;
//object selObj;
//S_Vec3 vcMin;
//S_Vec3Geo vcMinGP;
//S_Vec3 vcMax;
//S_Vec3Geo vcMaxGP;
//double Scale_Y;
//addObject = (IVRMapObject)block;
//selNode = (IVRMapNode)block;
//if (addObject != null)
//{
// addObject.GetBoundBox(ref vcMin, ref vcMax);
// vcMax = selNode.LPToWP(ref vcMax, false);
// vcMin = selNode.LPToWP(ref vcMin, false);
// vcMaxGP = (this.axNVPWebControl1.SceneObject as IVRMapScene).WPToGP(ref vcMax, false);
// vcMinGP = (this.axNVPWebControl1.SceneObject as IVRMapScene).WPToGP(ref vcMin, false);
// Scale_Y = block.Scale_Y * (height / (vcMaxGP.y - vcMinGP.y));
//}
//定义颜色和添加节点
block.Color=200;
IVRMapObject ivmObj=(IVRMapObject)(this.axNVPWebControl1.SceneObject as IVRMapScene).GetNodeFromPath("Terrain");
ivmObj.AddChild((IVRMapNode)block);
IVRMapNode ivmNode = (IVRMapNode)block;
(this.axNVPWebControl1.SceneObject as IVRMapScene).SelectionSet.RemoveAll();
(this.axNVPWebControl1.SceneObject as IVRMapScene).SelectionSet.AddItem(ivmNode);
geo.UpdateGeometrySkin();
height = height + 4;
}
private void button10_Click(object sender, EventArgs e)
{
INVPControl control = this.axNVPWebControl1.NVPControl;
control.OnCommand("旋转场景");
}
}
}