From 137e1aba5c31b24df51d801814c413c752c0d637 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 02 一月 2024 17:32:39 +0800 Subject: [PATCH] 添加基础工具栏 --- TEWin/FrmWin.cs | 144 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 143 insertions(+), 1 deletions(-) diff --git a/TEWin/FrmWin.cs b/TEWin/FrmWin.cs index 49392f0..2fb2951 100644 --- a/TEWin/FrmWin.cs +++ b/TEWin/FrmWin.cs @@ -1,7 +1,9 @@ 锘縰sing System; using System.Collections.Generic; using System.ComponentModel; +using System.Configuration; using System.Data; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -15,6 +17,10 @@ { public partial class FrmWin : Form { + FrmTree tree; + + FrmTool tool; + public SGWorld74 SG = null; public static string StartupPath @@ -49,8 +55,20 @@ SG.OnLoadFinished += SG_OnLoadFinished; SG.Open(fly); - FrmTree tree = new FrmTree(); + tree = new FrmTree(); tree.Show(this); + + string isTest = ConfigurationManager.AppSettings["isTest"]; + if ("1".Equals(isTest)) + { + tool = new FrmTool(this); + tool.Show(); + } + else + { + this.WindowState = FormWindowState.Maximized; + tree.WindowState = FormWindowState.Maximized; + } } catch (Exception ex) @@ -68,5 +86,129 @@ { LogOut.Info("鍏抽棴绋嬪簭."); } + + 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) + 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 0xd1: // 鐐归噺绠� + SG.Command.Execute(1023, null); + break; + case 0xd2: // 璺濈閲忕畻 + SG.Command.Execute(2356, null); + break; + case 0xd3: // 闈㈢Н閲忕畻 + if (SG.Command.IsChecked(2359, null)) + SG.Window.SetInputMode(0); + else + SG.Command.Execute(2359, null); + break; + + + /* + + +*/ + default: + base.DefWndProc(ref m); + break; + } + } + + public void InvokeProc(int code) + { + Message m = new Message(); + m.Msg = code; + + this.DefWndProc(ref m); + } + + public void RunExe(string path, string args, bool noWindow = true) + { + Process p = new Process(); + p.StartInfo.FileName = path; + p.StartInfo.Arguments = args; + p.StartInfo.CreateNoWindow = noWindow; + p.StartInfo.UseShellExecute = false; + p.Start(); + } + + public static string ExecCmd(List<string> list) + { + string str = null; + Process p = null; + try + { + p = new Process(); + p.StartInfo.FileName = "cmd.exe"; + p.StartInfo.UseShellExecute = false; + p.StartInfo.CreateNoWindow = true; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.Start(); + + StreamWriter si = p.StandardInput; + StreamReader se = p.StandardError; + + LogOut.Info("cmd = " + string.Join("锛�", list)); + si.AutoFlush = true; + foreach (string cmd in list) + { + si.WriteLine(cmd); + } + si.WriteLine("exit"); + + str = se.ReadToEnd(); + se.Close(); + si.Close(); + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + str = ex.Message; + } + finally + { + if (p != null) + { + p.Close(); + } + } + + return str; + } } } -- Gitblit v1.9.3