From a9b99add3e1baa7fc49049247b8bf071e70a6005 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 03 九月 2024 15:13:57 +0800
Subject: [PATCH] 1

---
 SimuTools/FrmMain.cs |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/SimuTools/FrmMain.cs b/SimuTools/FrmMain.cs
index 62b2ed8..76264a9 100644
--- a/SimuTools/FrmMain.cs
+++ b/SimuTools/FrmMain.cs
@@ -1,5 +1,7 @@
-锘縰sing SimuTools.Tools;
+锘縰sing SimuTools.Domain;
+using SimuTools.Tools;
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.Windows.Forms;
 
@@ -34,11 +36,21 @@
 
         private void btnTerrainPath_Click(object sender, EventArgs e)
         {
+            selectFile(this.txtTerrainPath);
+        }
+
+        private void btnBuildingPath_Click(object sender, EventArgs e)
+        {
+            selectFile(this.txtBuildingPath);
+        }
+
+        private void selectFile(TextBox tb)
+        {
             OpenFileDialog dialog = new OpenFileDialog();
             dialog.Filter = "Tif files(*.tif)|*.tif|Tiff files (*.tiff)|*.tiff";
             dialog.RestoreDirectory = true;
 
-            string path = this.txtTerrainPath.Text.Trim();
+            string path = tb.Text.Trim();
             if (File.Exists(path))
             {
                 dialog.InitialDirectory = Path.GetDirectoryName(path);
@@ -46,7 +58,7 @@
 
             if (dialog.ShowDialog() == DialogResult.OK)
             {
-                this.txtTerrainPath.Text = dialog.FileName;
+                tb.Text = dialog.FileName;
             }
         }
 
@@ -87,6 +99,7 @@
         {
             string serviceName = this.txtServiceName.Text.Trim();
             string terrainFile = this.txtTerrainPath.Text.Trim();
+            string buildingFile = this.txtBuildingPath.Text.Trim();
             string waterPath = this.txtWaterPath.Text.Trim();
             string flowPath = this.txtFlowPath.Text.Trim();
             string outPath = this.txtOutPath.Text.Trim();
@@ -96,9 +109,9 @@
                 ShowErr("鏈嶅姟鍚嶇О锛岃姹傚繀濉紒");
                 return;
             }
-            if (!File.Exists(terrainFile))
+            if (!File.Exists(terrainFile) || !File.Exists(buildingFile))
             {
-                ShowErr("鍦板舰鏂囦欢锛岃姹傚繀椤诲瓨鍦紒");
+                ShowErr("鍦板舰鍜屽缓绛戞枃浠讹紝瑕佹眰蹇呴』瀛樺湪锛�");
                 return;
             }
             if (!Directory.Exists(waterPath) || !Directory.Exists(flowPath) || !Directory.Exists(outPath))
@@ -112,17 +125,14 @@
                 this.btnRun.Enabled = false;
                 LogOut.Info("寮�濮嬭繍琛� >>");
 
-                outPath = Path.Combine(outPath, serviceName);
-                if (!Directory.Exists(outPath))
-                {
-                    Directory.CreateDirectory(outPath);
-                }
-
-                Tools.Handle.Run(terrainFile, waterPath, flowPath, outPath);
+                Stopwatch stopWatch = new Stopwatch();
+                stopWatch.Start();
+                Tools.Handle.Run(new Args(serviceName, terrainFile, buildingFile, waterPath, flowPath, outPath));
+                stopWatch.Stop();
 
                 this.btnRun.Enabled = true;
                 LogOut.Info("杩愯缁撴潫 <<");
-                MessageBox.Show("杩愯缁撴潫锛�", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                MessageBox.Show("杩愯缁撴潫锛乗n鑰楁椂锛�" + GetSeconds(stopWatch.ElapsedMilliseconds) + " 绉�", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception ex)
             {
@@ -136,5 +146,10 @@
         {
             MessageBox.Show(message, "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
+
+        private string GetSeconds(long milliseconds)
+        {
+            return (milliseconds / 1000.0).ToString();
+        }
     }
 }

--
Gitblit v1.9.3