From dbed0354a00fde9db87862b9f03db0fbf0d3aabc Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 04 九月 2024 16:38:50 +0800 Subject: [PATCH] 1 --- DataLoader/MainWindow.xaml.cs | 134 +++++++++++++++++++++++++++++++------------- 1 files changed, 94 insertions(+), 40 deletions(-) diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index 012e33f..3b7ddd5 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/DataLoader/MainWindow.xaml.cs @@ -15,9 +15,13 @@ { public partial class MainWindow : Window { - private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>(); + private bool isBusy; - private LoginWin win; + public ResWin resWin; + + private LoginWin loginWin; + + private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>(); public MainWindow() { @@ -25,14 +29,14 @@ this.DataContext = this; } + // 绐楀彛鍔犺浇瀹屾垚 private void Window_Loaded(object sender, RoutedEventArgs e) { CommonProp.Owner = this; CommonProp.Init(); - //this.cbMetaType.ItemsSource= GetMetaTypes(); - //this.cbMetaType.SelectedIndex= 0; this.btnLoad.IsEnabled = false; + this.btnDel.IsEnabled = false; this.btnImport.IsEnabled = false; lvView.DataContext = viewDatas; @@ -42,6 +46,7 @@ LogOut.Info("************ 搴旂敤绋嬪簭鍚姩鎴愬姛锛� ************"); } + // 鑾峰彇鍏冩暟鎹被鍨� private List<MetaType> GetMetaTypes() { List<MetaType> list = new List<MetaType>(); @@ -57,27 +62,23 @@ return list; } - // 璁剧疆 + // 鐧诲綍 private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e) { - win = new LoginWin(); + loginWin = new LoginWin(); this.Hide(); - win.Show(); + loginWin.Show(); } + // 璁剧疆鐧诲綍淇℃伅 public void SetLoginInfo() { - if (win != null) win.Close(); + if (loginWin != null) loginWin.Close(); this.Show(); - //this.tbUid.Text = Tool.UserId.ToString(); - //this.tbToken.Text = Tool.Token; - - //string uidStr = this.tbUid.Text.Trim(); - //string didStr = this.tbDir.Text.Trim(); - - //int.TryParse(uidStr, out Common.UserId); - //int.TryParse(didStr, out Common.DirId); + this.tbUid.Text = CommonProp.UserId.ToString(); + this.tbUname.Text = CommonProp.Uname; + this.tbToken.Text = CommonProp.Token; this.btnLoad.IsEnabled = true; this.btnImport.IsEnabled = true; @@ -86,7 +87,21 @@ // 璧勬簮鐩綍 private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e) { + if (null == resWin) resWin = new ResWin(); + this.Hide(); + this.resWin.Show(); + } + // 璁剧疆璧勬簮淇℃伅 + public void SetRes(string dircode, string fullName) + { + this.Show(); + + if (!string.IsNullOrEmpty(dircode)) + { + CommonProp.Dircode = dircode; + this.tbDir.Text = fullName; + } } // 鏁版嵁鐩綍 @@ -116,40 +131,67 @@ // 鍔犺浇 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 (isBusy) return; + if (string.IsNullOrEmpty(CommonProp.Dircode)) + { + MessageBox.Show("璇烽�夋嫨璧勬簮鐩綍锛�", "鎻愮ず"); + return; + } - //string[] files = Directory.GetFiles(SourcePath); - //if (null == files || files.Length == 0) - //{ - // MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒", "鎻愮ず"); - // return; - //} + CommonProp.SourcePath = this.tbSource.Text.Trim(); + if (string.IsNullOrEmpty(CommonProp.SourcePath) || !Directory.Exists(CommonProp.SourcePath)) + { + MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍鎴栨暟鎹洰褰曚笉瀛樺湪锛�", "鎻愮ず"); + return; + } - //this.viewDatas.Clear(); - //Importor.GetFiles(viewDatas, SourcePath); + CommonProp.TargetPath = this.tbTarget.Text.Trim(); + if (string.IsNullOrEmpty(CommonProp.TargetPath) || !Directory.Exists(CommonProp.TargetPath)) + { + MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍鎴栧叆搴撶洰褰曚笉瀛樺湪锛�", "鎻愮ず"); + return; + } + + ContentControl ccSensor = this.tbSensorType.SelectedItem as ContentControl; + int.TryParse(ccSensor.Tag.ToString(), out CommonProp.SensorType); + + ContentControl ccMeta = this.cbMetaType.SelectedItem as ContentControl; + int.TryParse(ccMeta.Tag.ToString(), out CommonProp.MetaType); + + CommonProp.AcqTime = this.dpAcqTime.SelectedDate; + + this.isBusy = true; + this.viewDatas.Clear(); + Importor.Loading(viewDatas); + this.isBusy = false; + } + + // 鍒犻櫎 + private void Del_MouseLeftButtonDown(object sender, RoutedEventArgs e) + { + if (null == this.viewDatas || this.viewDatas.Count == 0) return; + + int i = 0; + while (i < this.viewDatas.Count) + { + if (this.viewDatas[i] != null && this.viewDatas[i].Checked) + { + this.viewDatas.RemoveAt(i); + continue; + } + i++; + } } // 瀵煎叆 private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e) { - if (viewDatas.Count == 0) return; + if (isBusy || viewDatas.Count == 0) return; - //string str = this.tbStart.Text.Trim(); - //int start = 1; - //int.TryParse(str, out start); - + this.isBusy = true; Thread thread = new Thread(new ThreadStart(() => { - //Importor.ImportFiles(viewDatas, TargetPath, start); + Importor.ImportFiles(viewDatas); lvView.Dispatcher.BeginInvoke((ThreadStart)delegate { @@ -157,9 +199,21 @@ view.Refresh(); }); + isBusy = false; MessageBox.Show("鏁版嵁瀵煎叆瀹屾垚锛�", "鎻愮ず"); })); thread.Start(); } + + // 绐楀彛鍏抽棴涓簨浠� + private void Window_Closing(object sender, CancelEventArgs e) + { + if (isBusy) + { + MessageBox.Show("姝e湪瀵煎叆鏁版嵁锛岃绋嶅悗~", "鎻愮ず"); + e.Cancel = true; + return; + } + } } } -- Gitblit v1.9.3