From 95d9356edef73a1ad5b04e62b7aef6b77697a226 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 05 九月 2024 10:13:30 +0800
Subject: [PATCH] 1

---
 TEWin/FrmWin.cs |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/TEWin/FrmWin.cs b/TEWin/FrmWin.cs
index 3af8dcd..7b6c236 100644
--- a/TEWin/FrmWin.cs
+++ b/TEWin/FrmWin.cs
@@ -120,7 +120,7 @@
         {
             try
             {
-                this.SG.OnLoadFinished -= SG_OnLoadFinished;
+                //this.SG.OnLoadFinished -= SG_OnLoadFinished;
 
                 string id = this.SG.ProjectTree.FindItem(startName);
                 if (string.IsNullOrEmpty(id)) return;
@@ -166,6 +166,7 @@
 
         public void InvokeByCode(int code)
         {
+            LogOut.Info("InvokeByCode > 0x" + code.ToString("x"));
             switch (code)
             {
                 case 0xc0: // 閲嶇疆榧犳爣妯″紡
@@ -789,15 +790,22 @@
         #region 鏂规绠$悊
         private void Save()
         {
-            //SG.Command.Execute(1003, null);
             SaveLocation();
-            this.SG.Project.Save();
+            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 = Path.Combine(mainUrl, "see.fly");
+            if (String.IsNullOrEmpty(flyPath)) flyPath = this.fly; // flyPath = Path.Combine(mainUrl, "see.fly");
 
             if (!File.Exists(flyPath))
             {
@@ -813,15 +821,16 @@
             try
             {
                 string flyPath = ReadPrjPath();
-                if (String.IsNullOrEmpty(flyPath)) flyPath = Path.Combine(mainUrl, "see.fly");
+                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 });
+                //string cmd = string.Format("mklink \"{0}\" \"{1}\"", flyPath, this.fly);
+                //ExecCmd(new List<string> { cmd });
+                CreateShortcut(flyPath, this.fly);
             }
             catch (Exception ex)
             {
@@ -863,6 +872,26 @@
                 return null;
             }
         }
+
+        private String GetSavePath()
+        {
+            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+            string tePathName = ConfigurationManager.AppSettings["tePath"].Contains("SmartEarth") ? "SmartEarth" : "Skyline";
+
+            return Path.Combine(appData, tePathName, "TerraExplorer");
+        }
+
+        public static void CreateShortcut(string shortcutPath, string targetPath, string description = null, string iconLocation = null)
+        {
+            var shell = new IWshRuntimeLibrary.WshShell();
+            var shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutPath + ".lnk"); // 鍒涘缓蹇嵎鏂瑰紡瀵硅薄
+            shortcut.TargetPath = targetPath; // 鎸囧畾鐩爣璺緞
+            shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath); // 璁剧疆璧峰浣嶇疆
+            shortcut.WindowStyle = 1; // 璁剧疆杩愯鏂瑰紡锛岄粯璁や负甯歌绐楀彛
+            shortcut.Description = description; // 璁剧疆澶囨敞
+            shortcut.IconLocation = string.IsNullOrWhiteSpace(iconLocation) ? targetPath : iconLocation; // 璁剧疆鍥炬爣璺緞
+            shortcut.Save(); // 淇濆瓨蹇嵎鏂瑰紡
+        }
         #endregion
     }
 }

--
Gitblit v1.9.3