From 48c18a96f8c8022ec43691117f2472073895af71 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 21 八月 2023 16:16:02 +0800
Subject: [PATCH] 修改入库工具的界面

---
 DataLoader/MainWindow.xaml.cs |  133 +++++++++++++++-----------------------------
 1 files changed, 45 insertions(+), 88 deletions(-)

diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs
index b061622..e5dd13f 100644
--- a/DataLoader/MainWindow.xaml.cs
+++ b/DataLoader/MainWindow.xaml.cs
@@ -7,52 +7,17 @@
 using System.IO;
 using System.Linq;
 using System.Threading;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
-using System.Windows.Forms.VisualStyles;
-using System.Windows.Threading;
 
 namespace DataLoader
 {
-    public partial class MainWindow : Window, INotifyPropertyChanged
+    public partial class MainWindow : Window
     {
         private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
 
-        public event PropertyChangedEventHandler PropertyChanged;
-
-        private string _sourcePath = @"D:\LF\data\mdb";
-
-        private string _targetPath = @"\\LAPTOP-DRTGLTU2\share";
-
         private LoginWin win;
-
-        public string SourcePath
-        {
-            get { return _sourcePath; }
-            set
-            {
-                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
-                {
-                    _sourcePath = value;
-                    PropertyChanged(this, new PropertyChangedEventArgs("SourcePath"));
-                }
-            }
-        }
-
-        public string TargetPath
-        {
-            get { return _targetPath; }
-            set
-            {
-                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
-                {
-                    _targetPath = value;
-                    PropertyChanged(this, new PropertyChangedEventArgs("TargetPath"));
-                }
-            }
-        }
 
         public MainWindow()
         {
@@ -60,15 +25,10 @@
             this.DataContext = this;
         }
 
-        protected virtual void OnPropertyChanged(string propertyName = null)
-        {
-            //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
-            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
-        }
-
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
-            Common.Owner = this;
+            CommonProp.Owner = this;
+            CommonProp.Init();
 
             this.btnLoad.IsEnabled = false;
             this.btnImport.IsEnabled = false;
@@ -76,8 +36,7 @@
             lvView.DataContext = viewDatas;
             lvView.SetBinding(ListView.ItemsSourceProperty, new Binding());
 
-            //String file = "E:\\data\\mpt\\A4mpt20131125.mpt";
-            //string md5 = MD5Helper.GetMD5Hash(file);
+            // string md5 = MD5Helper.GetMD5Hash("E:\\data\\mpt\\A4mpt20131125.mpt");
             LogOut.Info("************  搴旂敤绋嬪簭鍚姩鎴愬姛锛� ************");
         }
 
@@ -87,9 +46,6 @@
             win = new LoginWin();
             this.Hide();
             win.Show();
-
-            //SetLoginInfo();
-            //GdalHelper.Instance.ReadTiff();
         }
 
         public void SetLoginInfo()
@@ -100,69 +56,69 @@
             //this.tbUid.Text = Tool.UserId.ToString();
             //this.tbToken.Text = Tool.Token;
 
-            string uidStr = this.tbUid.Text.Trim();
-            string didStr = this.tbDir.Text.Trim();
+            //string uidStr = this.tbUid.Text.Trim();
+            //string didStr = this.tbDir.Text.Trim();
 
-            int.TryParse(uidStr, out Common.UserId);
-            int.TryParse(didStr, out Common.DirId);
+            //int.TryParse(uidStr, out Common.UserId);
+            //int.TryParse(didStr, out Common.DirId);
 
             this.btnLoad.IsEnabled = true;
             this.btnImport.IsEnabled = true;
         }
 
-        // 婧愮洰褰�
+        // 璧勬簮鐩綍
+        private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        // 鏁版嵁鐩綍
         private void Source_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
             System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
-            if (!String.IsNullOrEmpty(SourcePath) && Directory.Exists(SourcePath)) dialog.SelectedPath = SourcePath;
+            if (!String.IsNullOrEmpty(CommonProp.SourcePath) && Directory.Exists(CommonProp.SourcePath)) dialog.SelectedPath = CommonProp.SourcePath;
 
             System.Windows.Forms.DialogResult result = dialog.ShowDialog();
-            if (result == System.Windows.Forms.DialogResult.Cancel)
-            {
-                return;
-            }
+            if (result == System.Windows.Forms.DialogResult.Cancel) return;
 
-            this.SourcePath = dialog.SelectedPath.Trim();
+            this.tbSource.Text = CommonProp.SourcePath = dialog.SelectedPath.Trim();
         }
 
         // 鐩爣鐩綍
         private void Target_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
             System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
-            if (!String.IsNullOrEmpty(TargetPath) && Directory.Exists(TargetPath)) dialog.SelectedPath = TargetPath;
+            if (!String.IsNullOrEmpty(CommonProp.TargetPath) && Directory.Exists(CommonProp.TargetPath)) dialog.SelectedPath = CommonProp.TargetPath;
 
             System.Windows.Forms.DialogResult result = dialog.ShowDialog();
-            if (result == System.Windows.Forms.DialogResult.Cancel)
-            {
-                return;
-            }
+            if (result == System.Windows.Forms.DialogResult.Cancel) return;
 
-            this.TargetPath = dialog.SelectedPath.Trim();
+            this.tbTarget.Text = CommonProp.TargetPath = dialog.SelectedPath.Trim();
         }
 
         // 鍔犺浇
         private void Load_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
-            if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath))
-            {
-                MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍锛�", "鎻愮ず");
-                return;
-            }
-            if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath))
-            {
-                MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍锛�", "鎻愮ず");
-                return;
-            }
+            //if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath))
+            //{
+            //    MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍锛�", "鎻愮ず");
+            //    return;
+            //}
+            //if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath))
+            //{
+            //    MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍锛�", "鎻愮ず");
+            //    return;
+            //}
 
-            string[] files = Directory.GetFiles(SourcePath);
-            if (null == files || files.Length == 0)
-            {
-                MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒", "鎻愮ず");
-                return;
-            }
+            //string[] files = Directory.GetFiles(SourcePath);
+            //if (null == files || files.Length == 0)
+            //{
+            //    MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒", "鎻愮ず");
+            //    return;
+            //}
 
-            this.viewDatas.Clear();
-            Importor.GetFiles(viewDatas, SourcePath);
+            //this.viewDatas.Clear();
+            //Importor.GetFiles(viewDatas, SourcePath);
         }
 
         // 瀵煎叆
@@ -170,15 +126,16 @@
         {
             if (viewDatas.Count == 0) return;
 
-            string str = this.tbStart.Text.Trim();
-            int start = 1;
-            int.TryParse(str, out start);
+            //string str = this.tbStart.Text.Trim();
+            //int start = 1;
+            //int.TryParse(str, out start);
 
             Thread thread = new Thread(new ThreadStart(() =>
             {
-                Importor.ImportFiles(viewDatas, TargetPath, start);
+                //Importor.ImportFiles(viewDatas, TargetPath, start);
 
-                lvView.Dispatcher.BeginInvoke((ThreadStart)delegate {
+                lvView.Dispatcher.BeginInvoke((ThreadStart)delegate
+                {
                     ICollectionView view = CollectionViewSource.GetDefaultView(viewDatas);
                     view.Refresh();
                 });

--
Gitblit v1.9.3