From 95869b034691c668ea854bc3e6315f0f1ff84b91 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期日, 01 一月 2023 09:21:43 +0800
Subject: [PATCH] 1

---
 DataLoader/MainWindow.xaml.cs |   77 ++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs
index 0615a44..26c564e 100644
--- a/DataLoader/MainWindow.xaml.cs
+++ b/DataLoader/MainWindow.xaml.cs
@@ -2,28 +2,60 @@
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.IO;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
 
 namespace DataLoader
 {
-    public partial class MainWindow : Window
+    public partial class MainWindow : Window, INotifyPropertyChanged
     {
         private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        private string _sourcePath;
+
+        private string _targetPath;
+
+        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()
         {
             InitializeComponent();
+            this.DataContext = this;
+        }
+
+        protected virtual void OnPropertyChanged(string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
 
         private void Window_Loaded(object sender, RoutedEventArgs e)
@@ -34,26 +66,45 @@
             lvView.SetBinding(ListView.ItemsSourceProperty, new Binding());
         }
 
+
         // 鐧诲綍
-        private void Login_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
 
         }
 
         // 婧愮洰褰�
-        private void Source_MouseLeftButtonDown(object sender, MouseButtonEventArgs 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;
 
+            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
+            if (result == System.Windows.Forms.DialogResult.Cancel)
+            {
+                return;
+            }
+
+            this.SourcePath = dialog.SelectedPath.Trim();
         }
 
         // 鐩爣鐩綍
-        private void Target_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        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;
 
+            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
+            if (result == System.Windows.Forms.DialogResult.Cancel)
+            {
+                return;
+            }
+
+            this.TargetPath = dialog.SelectedPath.Trim();
         }
 
         // 瀵煎叆
-        private void Import_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
             viewDatas.Add(new ViewData() { ID = 1, FilePath = "c:\\", Status = "鍔犺浇涓�" });
             viewDatas.Add(new ViewData() { ID = 2, FilePath = "c:\\", Status = "瀹屾垚" });

--
Gitblit v1.9.3