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.Designer.cs | 1 TEWin/FrmWin.cs | 144 ++++++++++++++++++++ TEWin/TEWin.csproj | 10 + TEWin/app.config | 2 TEWin/FrmTool.resx | 120 +++++++++++++++++ TEWin/FrmTree.Designer.cs | 1 TEWin/FrmTool.cs | 33 ++++ TEWin/FrmTool.Designer.cs | 74 ++++++++++ 8 files changed, 382 insertions(+), 3 deletions(-) diff --git a/TEWin/FrmTool.Designer.cs b/TEWin/FrmTool.Designer.cs new file mode 100644 index 0000000..d7f0af0 --- /dev/null +++ b/TEWin/FrmTool.Designer.cs @@ -0,0 +1,74 @@ +锘縩amespace TEWin +{ + partial class FrmTool + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.txtCode = new System.Windows.Forms.TextBox(); + this.btnTest = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtCode + // + this.txtCode.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtCode.Location = new System.Drawing.Point(13, 32); + this.txtCode.Name = "txtCode"; + this.txtCode.Size = new System.Drawing.Size(391, 26); + this.txtCode.TabIndex = 1; + this.txtCode.Text = "0xc0"; + // + // btnTest + // + this.btnTest.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnTest.Location = new System.Drawing.Point(417, 32); + this.btnTest.Name = "btnTest"; + this.btnTest.Size = new System.Drawing.Size(75, 26); + this.btnTest.TabIndex = 0; + this.btnTest.Text = "Test"; + this.btnTest.UseVisualStyleBackColor = true; + this.btnTest.Click += new System.EventHandler(this.btnTest_Click); + // + // FrmTool + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(504, 89); + this.Controls.Add(this.btnTest); + this.Controls.Add(this.txtCode); + this.Name = "FrmTool"; + this.Text = "FrmTool"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtCode; + private System.Windows.Forms.Button btnTest; + } +} \ No newline at end of file diff --git a/TEWin/FrmTool.cs b/TEWin/FrmTool.cs new file mode 100644 index 0000000..bb937e6 --- /dev/null +++ b/TEWin/FrmTool.cs @@ -0,0 +1,33 @@ +锘縰sing System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace TEWin +{ + public partial class FrmTool : Form + { + FrmWin win; + + public FrmTool(FrmWin win) + { + this.win = win; + InitializeComponent(); + } + + private void btnTest_Click(object sender, EventArgs e) + { + string str = this.txtCode.Text.Trim().Replace("0x", ""); + if (string.IsNullOrWhiteSpace(str)) return; + + + int code = Convert.ToInt32(str, 16); + + win.InvokeProc(code); + } + } +} diff --git a/TEWin/FrmTool.resx b/TEWin/FrmTool.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TEWin/FrmTool.resx @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/TEWin/FrmTree.Designer.cs b/TEWin/FrmTree.Designer.cs index b1074bf..c5a7b03 100644 --- a/TEWin/FrmTree.Designer.cs +++ b/TEWin/FrmTree.Designer.cs @@ -54,7 +54,6 @@ this.Margin = new System.Windows.Forms.Padding(2); this.Name = "FrmTree"; this.Text = "FrmTree"; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; ((System.ComponentModel.ISupportInitialize)(this.axTETree)).EndInit(); this.ResumeLayout(false); diff --git a/TEWin/FrmWin.Designer.cs b/TEWin/FrmWin.Designer.cs index 746efba..038514d 100644 --- a/TEWin/FrmWin.Designer.cs +++ b/TEWin/FrmWin.Designer.cs @@ -55,7 +55,6 @@ this.Name = "FrmWin"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "FrmWin"; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; ((System.ComponentModel.ISupportInitialize)(this.axTEWin)).EndInit(); this.ResumeLayout(false); 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; + } } } diff --git a/TEWin/TEWin.csproj b/TEWin/TEWin.csproj index 2d8f4b4..37f219b 100644 --- a/TEWin/TEWin.csproj +++ b/TEWin/TEWin.csproj @@ -69,6 +69,7 @@ <HintPath>Fly\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.configuration" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -81,6 +82,12 @@ </ItemGroup> <ItemGroup> <Compile Include="CS\LogOut.cs" /> + <Compile Include="FrmTool.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FrmTool.Designer.cs"> + <DependentUpon>FrmTool.cs</DependentUpon> + </Compile> <Compile Include="FrmTree.cs"> <SubType>Form</SubType> </Compile> @@ -95,6 +102,9 @@ </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <EmbeddedResource Include="FrmTool.resx"> + <DependentUpon>FrmTool.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="FrmTree.resx"> <DependentUpon>FrmTree.cs</DependentUpon> </EmbeddedResource> diff --git a/TEWin/app.config b/TEWin/app.config index 1b3e886..fa59af6 100644 --- a/TEWin/app.config +++ b/TEWin/app.config @@ -1,6 +1,8 @@ <?xml version="1.0"?> <configuration> <appSettings> + <add key="isTest" value="1"/> + <add key="tePath" value="C:\Program Files\Skyline\TerraExplorer Pro"/> </appSettings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> -- Gitblit v1.9.3