管道基础大数据平台系统开发-【CS】-ExportMap
95d9356edef73a1ad5b04e62b7aef6b77697a226..da528e999d6538a12f357b6c745974316d48c086
2024-09-09 13693261870
修改初始化fly
da528e 对比 | 目录
2024-09-07 13693261870
修改打开、保存、另存为功能
8d7a67 对比 | 目录
已修改3个文件
128 ■■■■■ 文件已修改
TEWin/FrmTool.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
TEWin/FrmWin.cs 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
TEWin/app.config 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
TEWin/FrmTool.cs
@@ -17,7 +17,7 @@
            "影像数据", "地形数据", "模型数据(osgb)", "模型数据(obj)", "编辑数据", "点量算", 
            "坡向分析", "线量算", "面量算", "体量算", "角量算", "空间统计", "空间分析", 
            "剖面分析", "坡度分析", "等值线", "剖切分析", "地理场景产品组装", "传统4D产品派生", 
            "打开fly", "加载shp", "读取shp", "按照属性显示", "按照属性设置颜色", "打开数据方案", "保存项目" };
            "打开fly", "加载shp", "读取shp", "按照属性显示", "按照属性设置颜色", "打开数据方案", "另存为" };
        public FrmTool(FrmWin win)
        {
TEWin/FrmWin.cs
@@ -80,13 +80,14 @@
                LogOut.Info("开始运行..");
                bool isTest = "1" == ConfigurationManager.AppSettings["isTest"];
                this.fly = ConfigurationManager.AppSettings["fly"] ?? ConfigurationManager.AppSettings["testFly"];
                this.fly = getFly();
                /*this.fly = ConfigurationManager.AppSettings["fly"] ?? ConfigurationManager.AppSettings["testFly"];
                if (!this.fly.Contains(":\\")) this.fly = Path.Combine(Application.StartupPath, this.fly);
                if (!File.Exists(this.fly))
                {
                    LogOut.Error("Fly文件不存在:" + this.fly);
                    return;
                }
                }*/
                SG = new SGWorld71();
                SG.OnLoadFinished += SG_OnLoadFinished;
@@ -101,7 +102,7 @@
                    tool = new FrmTool(this);
                    tool.Show();
                    SG.Open(this.fly);
                    //SG.Open(this.fly);
                }
                //else
                //{
@@ -232,9 +233,9 @@
                case 0xdb: // 按照属性设置颜色
                    DisplayByAttribute(1, "按照属性设置颜色"); break;
                case 0xdc: // 打开数据方案
                    OpenPrj(); break;
                case 0xdd: // 保存项目
                    SavePrj(); break;
                    Open(); break;
                case 0xdd: // 另存为
                    SaveAs(); break;
            }
        }
        #endregion
@@ -792,50 +793,7 @@
        {
            SaveLocation();
            this.SG.Command.Execute(1019, 0); // Capture Tree State
            SG.Command.Execute(1003, 0); // this.SG.Project.Save();
        }
        private void SaveAs(string flyPath)
        {
            SaveLocation();
            this.SG.Command.Execute(1019, 0); // Capture Tree State
            this.SG.Project.SaveAs(flyPath);
        }
        private void OpenPrj()
        {
            string flyPath = ReadPrjPath();
            if (String.IsNullOrEmpty(flyPath)) flyPath = this.fly; // flyPath = Path.Combine(mainUrl, "see.fly");
            if (!File.Exists(flyPath))
            {
                flyPath = ConfigurationManager.AppSettings["fly"] ?? ConfigurationManager.AppSettings["testFly"];
                if (!flyPath.Contains(":\\")) flyPath = Path.Combine(mainUrl, flyPath);
            }
            this.SG.Open(flyPath);
        }
        private void SavePrj()
        {
            try
            {
                string flyPath = ReadPrjPath();
                if (String.IsNullOrEmpty(flyPath)) flyPath = this.fly; // flyPath = Path.Combine(mainUrl, "see.fly");
                this.Save();
                //this.SG.Project.SaveAs(flyPath);
                if (this.fly.Equals(flyPath)) return;
                if (File.Exists(flyPath)) File.Delete(flyPath);
                //string cmd = string.Format("mklink \"{0}\" \"{1}\"", flyPath, this.fly);
                //ExecCmd(new List<string> { cmd });
                CreateShortcut(flyPath, this.fly);
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
            }
            SG.Command.Execute(1003, 0); // this.SG.Project.Save(); //
        }
        private void SaveLocation()
@@ -854,13 +812,28 @@
            }
        }
        private void Open()
        {
            this.fly = getFly();
            this.SG.Open(this.fly);
        }
        private String getFly()
        {
            string flyPath = ReadPrjPath();
            if (String.IsNullOrEmpty(flyPath)) flyPath = "empty.fly";
            if (!flyPath.Contains(":\\")) flyPath = Path.Combine(Application.StartupPath, "Resources", flyPath);
            return flyPath;
        }
        private String ReadPrjPath()
        {
            String txt = Path.Combine(mainUrl, "fly.txt");
            if (!File.Exists(txt)) return null;
            try
            {
                String txt = Path.Combine(mainUrl, "Resources", "fly.txt");
                if (!File.Exists(txt)) return null;
                using (StreamReader sr = new StreamReader(txt))
                {
                    return sr.ReadLine();
@@ -873,6 +846,51 @@
            }
        }
        private void SaveAs()
        {
            string flyPath = ReadPrjPath();
            string fileName = String.IsNullOrEmpty(flyPath) ? null : Path.GetFileName(flyPath);
            string dest = SaveAs(fileName);
            if (string.IsNullOrEmpty(dest)) return;
            this.fly = dest;
            string sourcePath = Path.Combine(mainUrl, "Resources");
            if (string.IsNullOrEmpty(flyPath) || (dest.Contains(sourcePath) && dest.IndexOf("\\", sourcePath.Length + 1) == -1)) return;
            CreateShortcut(flyPath, this.fly);
            //ExecCmd(new List<string> { string.Format("mklink \"{0}\" \"{1}\"", flyPath, this.fly) });
        }
        private String SaveAs(String fileName)
        {
            try
            {
                if (String.IsNullOrEmpty(fileName)) fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".fly";
                SaveLocation();
                this.SG.Command.Execute(1019, 0); // Capture Tree State
                this.SG.Project.SaveAs(fileName);
                string source = Path.Combine(GetSavePath(), fileName);
                if (!File.Exists(source))
                {
                    LogOut.Error(fileName + ",找不到");
                }
                string dest = Path.Combine(Application.StartupPath, "Resources", fileName);
                if (File.Exists(dest)) File.Delete(dest);
                File.Move(source, dest);
                return dest;
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                return null;
            }
        }
        private String GetSavePath()
        {
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
TEWin/app.config
@@ -3,7 +3,7 @@
  <appSettings>
    <add key="osgbLabTitle" value="OSGB数据处理工具"/>
    <add key="isTest" value="1"/>
    <add key="fly" value="Resources\sample.fly"/>
    <add key="fly" value="Resources\empty.fly"/>
    <add key="testFly" value="E:\data\opting\2022.fly"/>
    <!--<add key="tePath" value="C:\Program Files\Skyline\TerraExplorer Pro"/>-->
    <add key="tePath" value="C:\Program Files\SmartEarth\TerraExplorer Pro"/>