管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-01-04 75ce904463b89dd8c311d90ea479fab877d9245c
TEWin/FrmWin.cs
@@ -17,19 +17,14 @@
{
    public partial class FrmWin : Form
    {
        #region 成员变量+构造函数+事件
        FrmTree tree;
        FrmTool tool;
        public SGWorld74 SG = null;
        string mainUrl;
        public static string StartupPath
        {
            get
            {
                return System.Windows.Forms.Application.StartupPath;
            }
        }
        public SGWorld74 SG;
        public FrmWin()
        {
@@ -43,8 +38,10 @@
            try
            {
                LogOut.Info("开始运行..");
                mainUrl = Application.StartupPath;
                bool isTest = "1" == ConfigurationManager.AppSettings["isTest"];
                string fly = Path.Combine(StartupPath, "Resources\\sample.fly");
                string fly = isTest ? ConfigurationManager.AppSettings["testFly"] : Path.Combine(Application.StartupPath, "Resources\\sample.fly");
                if (!File.Exists(fly))
                {
                    LogOut.Error("Fly文件不存在:" + fly);
@@ -58,9 +55,10 @@
                tree = new FrmTree();
                tree.Show(this);
                string isTest = ConfigurationManager.AppSettings["isTest"];
                if ("1".Equals(isTest))
                if (isTest)
                {
                    this.FormBorderStyle = FormBorderStyle.Sizable;
                    tree.FormBorderStyle = FormBorderStyle.Sizable;
                    tool = new FrmTool(this);
                    tool.Show();
                }
@@ -86,70 +84,131 @@
        {
            LogOut.Info("关闭程序.");
        }
        #endregion
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0xc0: // 重置鼠标模式
                    SG.Window.SetInputMode(0);
                    break;
                case 0xc1: // 打开数据方案/打开显示场景
                    SG.Command.Execute(1001, null);
                    break;
                case 0xc2: // 保存数据方案/保存显示场景
                    SG.Command.Execute(1003, null);
                    break;
                case 0xc3: // 矢量数据(默认为*.shp,支持Excel)
                    SG.Command.Execute(1013, 5);
                    break;
                case 0xc4: // 影像数据(默认为*.tif)
                    SG.Command.Execute(1014, 9);
                    break;
                case 0xc5: // 地形数据(默认为*.tif)
                    SG.Command.Execute(1014, 26);
                    break;
                case 0xc6: // 模型数据(*.osgb)
                    //SG.Command.Execute(2342, null);
                    string path = Path.Combine(ConfigurationManager.AppSettings["tePath"], "MeshLayerTool.exe");
                    string args = " -RunApp TerraExplorer -RunConvertor -Mode ImportMeshLayer -Type osgb";
                    ExecCmd(new List<string> { "taskkill /f /t /im MeshLayerTool.exe" });
                    RunExe(path, args, false);
                    break;
                case 0xc7: // 模型数据(*.obj)
                    SG.Command.Execute(1012, 13);
                    break;
                case 0xc8: // 基础编辑(选择对象)
                    SG.Command.Execute(1021, null);
                    break;
                case 0xc9: // 点量算(坐标+高程)
                    SG.Command.Execute(1023, null);
                    break;
                case 0xca: // 点量算(坡度+坡向)
                    //
                    break;
                case 0xcb: // 距离量算
                    SG.Command.Execute(2356, null);
                    break;
                case 0xcc: // 面积量算
                    if (SG.Command.IsChecked(2359, null))
                        SG.Window.SetInputMode(0);
                    else
                        SG.Command.Execute(2359, null);
                    break;
                case 0x64:
                    InvokeByCode(m.WParam.ToInt32()); break;
                case 0x4A:
                    MessageBox.Show("Test."); break;
                default:
                    base.DefWndProc(ref m);
                    break;
                    base.DefWndProc(ref m); break;
            }
        }
        public void InvokeProc(int code)
        {
            Message m = new Message();
            m.Msg = code;
            m.Msg = 0x64; // m.Msg = 0x4A;
            m.WParam = new IntPtr(code);
            this.DefWndProc(ref m);
        }
        public void InvokeByCode(int code)
        {
            switch (code)
            {
                case 0xc0: // 重置鼠标模式
                    SG.Window.SetInputMode(0); break;
                case 0xc1: // 打开数据方案/打开显示场景
                    SG.Command.Execute(1001, null); break;
                case 0xc2: // 保存数据方案/保存显示场景
                    SG.Command.Execute(1003, null); break;
                case 0xc3: // 矢量数据(默认为*.shp,支持Excel)
                    SG.Command.Execute(1013, 5); break;
                case 0xc4: // 影像数据(默认为*.tif)
                    SG.Command.Execute(1014, 9); break;
                case 0xc5: // 地形数据(默认为*.tif)
                    SG.Command.Execute(1014, 26); break;
                case 0xc6: // 模型数据(*.osgb)
                    ExecCmd(new List<string> { "taskkill /f /t /im MeshLayerTool.exe" }); // SG.Command.Execute(2342, null);
                    RunExe(Path.Combine(ConfigurationManager.AppSettings["tePath"], "MeshLayerTool.exe"), " -RunApp TerraExplorer -RunConvertor -Mode ImportMeshLayer -Type osgb", false);
                    break;
                case 0xc7: // 模型数据(*.obj)
                    SG.Command.Execute(1012, 13); break;
                case 0xc8: // 基础编辑(选择对象,开启编辑)
                    SG.Command.Execute(1021, null); break;
                case 0xc9: // 点量算(坐标+高程)
                    SG.Command.Execute(1023, null); break;
                case 0xca: // 点量算(坡度+坡向)
                    this.ShowHtmlByid(1149, 24); break;
                case 0xcb: // 线量算
                    this.ShowHtmlByid(1034, 0); break; // SG.Command.Execute(2356, null); break;
                case 0xcc: // 面量算
                    // if (SG.Command.IsChecked(2359, null)) SG.Window.SetInputMode(0); else SG.Command.Execute(2359, null); break;
                    this.ShowHtmlByid(1037, 0); break;
                case 0xcd: // 体量算(挖填方)
                    this.ShowHtmlByid(1045, 0); break;
                case 0xce: // 角量算
                    AngleMeasurement(); break;
                case 0xcf: // 空间统计
                    SpaceStatistics(); break;
                case 0xd0: // 空间分析
                    SpatialAnalysis(); break;
                case 0xd1: // DEM分析(剖面分析)
                    this.ShowHtmlByid(1149, 28); break;
                case 0xd2: // DEM分析(坡度分析)
                    this.ShowHtmlByid(1093, 0); break;
                case 0xd3: // DEM分析(等值线)
                    SG.Command.Execute(1039, null); break;
                case 0xd4: // 三维模型分析(剖面分析+剖切分析)
                    this.ShowHtmlByid(1149, 39); break;
                case 0xd5: // 地理场景产品组装(抽取指定区域并发布离线数据包)
                    SG.Command.Execute(1028, null); break;
                case 0xd6: // 传统4D产品派生(集成osgblab)
                    InvokeOsgbLab(); break;
            }
        }
        public void ShowHtmlByid(int id, int arg)
        {
            switch (id)
            {
                case 1034:
                    this.ShowHtml("距离测量", mainUrl + @"\Resources\DistanceMeasurement\distanceMeasurement.html", 20, 20, 400, 245);
                    break;
                case 1037:
                    this.ShowHtml("面积测量", mainUrl + @"/Resources\AreaMeasurement\AreaMeasurement.html", 20, 20, 400, 245);
                    break;
                case 1149:
                    switch (arg)
                    {
                        case 24:
                            this.ShowHtml("坡向分析", mainUrl + @"\Resources\SlopeCursor\SlopeCursor.html", 20, 20, 400, 330); break;
                        case 28:
                            this.ShowHtml("剖面分析", mainUrl + @"\Resources\TerrainProfile\TerrainProfile.html", 20, 20, 400, 290); break;
                        case 39:
                            this.ShowHtml("剖切分析", mainUrl + @"\Resources\CrossSection\CrossSection.html", 20, 20, 400, 225); break;
                    }
                    break;
                case 1093:
                    this.ShowHtml("坡度分析", mainUrl + @"\Resources\SlopeMapQuery\SlopeMapQuery.html", 20, 20, 350, 365);
                    break;
                case 1045:
                    this.ShowHtml("体积分析", mainUrl + @"\Resources\Volume\Volume.html", 20, 20, 350, 255);
                    break;
            }
        }
        public void ShowHtml(string tile, string url, int left, int top, int width, int height)
        {
            if (SG.Window.GetPopupByCaption(tile) != null)
            {
                SG.Window.RemovePopupByCaption(tile);
            }
            var popup = SG.Creator.CreatePopupMessage(tile, url, left, top, width, height);
            popup.AllowResize = true;
            popup.ShowCaption = true;
            popup.AllowDrag = true;
            popup.Width = width;
            popup.Height = height;
            SG.Window.ShowPopup(popup);
        }
        public void RunExe(string path, string args, bool noWindow = true)
@@ -207,5 +266,27 @@
            return str;
        }
        #region 角量算+空间统计+空间分析+osgblab
        public void AngleMeasurement()
        {
            //
        }
        public void SpaceStatistics()
        {
            //
        }
        private void SpatialAnalysis()
        {
            this.ShowHtml("空间分析", mainUrl + @"\Resources\SpatialQuery\SpatialQuery.html", 20, 20, 420, 285);
        }
        public void InvokeOsgbLab()
        {
            //
        }
        #endregion
    }
}