UCStandMain.xaml.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. using MeterVision.Config;
  2. using MeterVision.db;
  3. using MeterVision.Dlg;
  4. using MeterVision.model;
  5. using MeterVision.Util;
  6. using OfficeOpenXml;
  7. using OfficeOpenXml.Style;
  8. using Ookii.Dialogs.Wpf;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.ComponentModel;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Text.RegularExpressions;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Data;
  21. using System.Windows.Documents;
  22. using System.Windows.Input;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Navigation;
  26. //using System.Windows.Shapes;
  27. namespace MeterVision.Stand
  28. {
  29. /// <summary>
  30. /// UCStand.xaml 的交互逻辑
  31. /// </summary>
  32. public partial class UCStandMain : UserControl, INotifyPropertyChanged
  33. {
  34. private const int COLUMN_LEFT_WIDTH = 220;
  35. private const int COLUMN_RIGHT_WIDTH = 400;
  36. private bool LeftVisiable = true; //表示左侧的显示状态
  37. private bool RightVisiable = true; //表示右侧的显示状态
  38. public event PropertyChangedEventHandler PropertyChanged;
  39. protected void OnPropertyChanged(string propertyName)
  40. {
  41. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  42. }
  43. public PageModel StandPage { get; set; }
  44. //定义模板目录数据源
  45. public ObservableCollection<StandItem> StandItemList { get; set; }
  46. // 定义"标准答案编辑"依赖属性
  47. public static readonly DependencyProperty IsResultEditingProperty =
  48. DependencyProperty.Register("IsResultEditing", typeof(bool), typeof(UCStandMain), new PropertyMetadata(false));
  49. public bool IsResultEditing
  50. {
  51. get { return (bool)GetValue(IsResultEditingProperty); }
  52. set { SetValue(IsResultEditingProperty, value); }
  53. }
  54. private StandItem _selectedStandItem;
  55. public StandItem SelectedStandItem
  56. {
  57. get => _selectedStandItem;
  58. set
  59. {
  60. _selectedStandItem = value;
  61. OnPropertyChanged(nameof(SelectedStandItem)); //通知更新
  62. //ucStandGird.CurStandItem = value;
  63. if (_selectedStandItem != null)
  64. {
  65. ucStationGrid.ChangeFind(FindStationId, _selectedStandItem.StandId);
  66. }
  67. else
  68. {
  69. ucStationGrid.ChangeFind(FindStationId, "");
  70. }
  71. Apply_UCStandDetaisl_Title(value);
  72. }
  73. }
  74. private StationItem _selectedStationItem;
  75. public StationItem SelectedStationItem
  76. {
  77. get => _selectedStationItem;
  78. set
  79. {
  80. _selectedStationItem = value;
  81. OnPropertyChanged(nameof(SelectedStationItem));
  82. ucStandGird.CurStationItem = value;
  83. }
  84. }
  85. private int _totalStandRecords;
  86. public int TotalStandRecords
  87. {
  88. get => _totalStandRecords;
  89. set
  90. {
  91. if (_totalStandRecords != value)
  92. {
  93. _totalStandRecords = value;
  94. OnPropertyChanged(nameof(TotalStandRecords));
  95. }
  96. }
  97. }
  98. public CfginiItem mConfigItem { get; set; }
  99. private void Apply_UCStandDetaisl_Title(StandItem standItem)
  100. {
  101. if(standItem == null)
  102. {
  103. //pnlDetailsTitle.Visibility = Visibility.Hidden;
  104. pnlDetailsFunc.Visibility = Visibility.Hidden;
  105. //txtStandName.Text = "请选择左侧模板";
  106. txtStandName.Text = "";
  107. }
  108. else
  109. {
  110. ////pnlDetailsTitle.Visibility = Visibility.Visible;
  111. pnlDetailsFunc.Visibility = Visibility.Visible;
  112. ////txtStandName.Text = $"模板名称: {standItem.Index}. {standItem.StandName}[{standItem.StandCount}]";
  113. //txtStandName.Text = $"模板名称: {standItem.Index}. {standItem.StandName}";
  114. txtStandName.Text = $"{standItem.Index}.";
  115. }
  116. }
  117. private void InitRightControls(StandDetailItem standDetailsItem)
  118. {
  119. pnlImage.Visibility = txtRightItemIndex.Visibility =
  120. standDetailsItem == null ? Visibility.Collapsed : Visibility.Visible;
  121. //pnlResult.Visibility = Visibility.Hidden;
  122. }
  123. private string _findStationId;
  124. public string FindStationId
  125. {
  126. get => _findStationId;
  127. set
  128. {
  129. if (_findStationId != value)
  130. {
  131. _findStationId = value;
  132. OnPropertyChanged(nameof(FindStationId));
  133. //ucStationGrid.ChangeFindStationId(FindStationId);
  134. }
  135. }
  136. }
  137. public UCStandMain()
  138. {
  139. InitializeComponent();
  140. StandItemList = new ObservableCollection<StandItem>();
  141. dgStand.ItemsSource = StandItemList;
  142. //this.btnStandExport.Click += BtnStandExport_Click;
  143. ucStandGird.OnSelectedStandDetailItemChanged += UcStandGird_OnSelectedStandDetailsItemChanged;
  144. IsResultEditing = false;
  145. Apply_UCStandDetaisl_Title(null);
  146. //SelectedStandItem = null;
  147. txtFindStationId.Text = "";
  148. FindStationId = "";
  149. InitRightControls(null);
  150. mConfigItem = CfginiItem.GetConfigItem();
  151. StandPage = new PageModel
  152. {
  153. //PageSize = mConfigItem.CatalogPageSize,
  154. PageSize = mConfigItem.StandCatalogPageSize,
  155. PageNumber = 1,
  156. };
  157. //LoadStandItemList();
  158. ucStandGird.OnStandItemCountChanged += UcStandGird_OnStandItemCountChanged;
  159. ucStandGird.OnDeleteStandDetailItem += UcStandGird_OnDeleteStandDetailItem;
  160. mConfigItem.OnStandCatalogPageSizeChanged += MConfigItem_OnStandCatalogPageSizeChanged;
  161. this.DataContext = this;
  162. // 启动异步初始化,确保不会阻塞构造函数
  163. LoadStandItemListAsync();
  164. //控制左右2侧栏目的显示
  165. LeftVisiable = true;
  166. ChangeLeftVisiable(LeftVisiable);
  167. RightVisiable = true;
  168. ChangeRightVisiable(RightVisiable);
  169. ucStationGrid.OnStationItemChange += UcStationGrid_OnStationItemChange;
  170. //ucStationGrid.Station_Config += UcStationGrid_Station_Config;
  171. ucStandGird.OnStandDetailMark += UcStandGird_OnStandDetailMark;
  172. }
  173. private void UcStandGird_OnStandDetailMark(string standId, string stationId)
  174. {
  175. //throw new NotImplementedException();
  176. ucStationGrid.ChangeMarkCount();
  177. }
  178. //修改参数
  179. //private void UcStationGrid_Station_Config(StationItem item)
  180. //{
  181. // //第一条数据
  182. // EditStationDlg2 dialog = new EditStationDlg2(item)
  183. // {
  184. // Owner = Application.Current.MainWindow,
  185. // WindowStartupLocation = WindowStartupLocation.CenterOwner
  186. // };
  187. // if (dialog.ShowDialog() == true)
  188. // {
  189. // //stationItem = dialog.mStationItem;
  190. // item = dialog.mStationItem;
  191. // }
  192. //}
  193. private void UcStationGrid_OnStationItemChange(StationItem stationItem)
  194. {
  195. SelectedStationItem = stationItem;
  196. }
  197. private async void MConfigItem_OnStandCatalogPageSizeChanged(int pageSize)
  198. {
  199. //throw new NotImplementedException();
  200. StandPage.InitDefaulValue(pageSize);
  201. bool blLoad = await LoadStandItemList();
  202. if (blLoad)
  203. {
  204. SelectedStandItem = null;
  205. }
  206. }
  207. private async void LoadStandItemListAsync()
  208. {
  209. await LoadStandItemList();
  210. }
  211. private void UcStandGird_OnStandItemCountChanged(object sender, StandItemCountChangedEventArgs e)
  212. {
  213. //Detail的数量发生变化
  214. RefreshStandItemById(e.mStandItem.StandId);
  215. }
  216. private void UcStandGird_OnDeleteStandDetailItem(string standId)
  217. {
  218. RefreshStandItemById(standId);
  219. }
  220. private async void RefreshStandItemById(string standId)
  221. {
  222. if ( string.IsNullOrWhiteSpace(standId) ) return;
  223. VStand vStand = null;
  224. await Task.Run(() =>
  225. {
  226. vStand = DBStand.GetVStandById(standId);
  227. });
  228. if (vStand != null)
  229. {
  230. //var NewStandItem = new StandItem(vStand);
  231. foreach (var standItem in StandItemList)
  232. {
  233. if (standItem.StandId == vStand.StandId)
  234. {
  235. // ObjectHelper.CopyMatchingFields(NewStandItem, standItem);
  236. ObjectHelper.CopyMatchingFields(vStand, standItem);
  237. break;
  238. }
  239. }//foreach
  240. }//if vpatch!=null
  241. }
  242. private async Task<bool> LoadStandItemList()
  243. {
  244. StandItemList.Clear();
  245. try
  246. {
  247. var result = await Task.Run(() =>
  248. {
  249. return DBStand.GetPagedVStands(StandPage.PageNumber, StandPage.PageSize);
  250. });
  251. TotalStandRecords = result.Item1;
  252. StandPage.PageCount = result.Item2;
  253. List<VStand> stands = result.Item3;
  254. int index = 0;
  255. foreach (VStand vStand in stands)
  256. {
  257. index++;
  258. StandItem standItem = new StandItem(vStand);
  259. standItem.Index = index + (StandPage.PageNumber - 1) * StandPage.PageSize;
  260. StandItemList.Add(standItem);
  261. }
  262. if(StandItemList.Count > 0)
  263. {
  264. //dgStand.ScrollIntoView(StandItemList[0]);
  265. }
  266. return true;
  267. }
  268. catch (Exception ex)
  269. {
  270. MessageBox.Show(Application.Current.MainWindow,
  271. $"加载数据时发生错误:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  272. return false;
  273. }
  274. }
  275. private void UcStandGird_OnSelectedStandDetailsItemChanged(object sender, StandDetailItemChangedEventArgs e)
  276. {
  277. InitRightControls(e.SelectedDataItem);
  278. txtRightItemIndex.Text = string.Empty;
  279. if (e.SelectedDataItem != null)
  280. {
  281. ucImageSource.ImageSource = e.SelectedDataItem.SrcImage;
  282. ucImageSource.ImageName = "原始图片";
  283. //txtRightResult.Text = e.SelectedDataItem.StandValue;
  284. IsResultEditing = false;
  285. if(SelectedStandItem != null)
  286. {
  287. txtRightItemIndex.Text = $"{SelectedStandItem.Index}. - {e.SelectedDataItem.Index}.";
  288. }
  289. }
  290. }
  291. //导出模板
  292. private void BtnStandExport_Click(object sender, RoutedEventArgs e)
  293. {
  294. //查询所有的数据
  295. if (SelectedStandItem == null) return;
  296. List<TStandDetail> standDetails = DBStand.GetAllStandDetails(SelectedStandItem.StandId);
  297. if (standDetails.Count <= 0) return;
  298. string fileName = $"{SelectedStandItem.StandName}_{standDetails.Count}.xlsx";
  299. //创建保存文件对话框
  300. VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog
  301. {
  302. Filter = "Excel 文件 (*.xlsx)|*.xlsx",
  303. FileName = fileName,
  304. Title = "选择模板保存路径"
  305. };
  306. // 如果用户选择了路径并点击保存
  307. if (saveFileDialog.ShowDialog() == true){
  308. string titleInfo = "正在导出模板数据,请稍后...";
  309. WaitWindow waitWindow = new WaitWindow(titleInfo)
  310. {
  311. Owner = Application.Current.MainWindow,
  312. WindowStartupLocation = WindowStartupLocation.CenterOwner
  313. };
  314. waitWindow.Show();
  315. string filePath = saveFileDialog.FileName;
  316. try{
  317. // 创建Excel包
  318. using (ExcelPackage package = new ExcelPackage()){
  319. var worksheet = package.Workbook.Worksheets.Add("Sheet1");
  320. // 表头
  321. worksheet.Cells[1, 1].Value = "图像";
  322. worksheet.Cells[1, 2].Value = "标准答案";
  323. // 设置表头样式
  324. using (var range = worksheet.Cells[1, 1, 1, 2])
  325. {
  326. //range.Style.Font.Bold = false;
  327. range.Style.Font.Name = "等线";
  328. range.Style.Font.Size = 11;
  329. //range.Style.Fill.PatternType = ExcelFillStyle.Solid;
  330. //range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightBlue);
  331. range.AutoFitColumns();
  332. }
  333. // 填充数据
  334. for (int i = 0; i < standDetails.Count; i++)
  335. {
  336. worksheet.Cells[i + 2, 1].Value = standDetails[i].SrcImage;
  337. worksheet.Cells[i + 2, 2].Value = standDetails[i].StandValue;
  338. // 设置行字体
  339. worksheet.Cells[i + 2, 1, i + 2, 2].Style.Font.Name = "等线";
  340. worksheet.Cells[i + 2, 1, i + 2, 2].Style.Font.Size = 11;
  341. //worksheet.Cells[i + 2, 1, i + 2, 2].Style.Font.Color.SetColor(System.Drawing.Color.Black);
  342. }
  343. // 设置列宽
  344. worksheet.Column(1).Width = 50; // 姓名列
  345. worksheet.Column(2).Width = 20; // 年龄列
  346. // 或者自动调整列宽
  347. //worksheet.Cells.AutoFitColumns();
  348. // 保存到用户选择的路径
  349. FileInfo excelFile = new FileInfo(filePath);
  350. package.SaveAs(excelFile);
  351. MessageBox.Show("Excel导出成功!");
  352. }
  353. }
  354. catch (Exception ex){
  355. MessageBox.Show($"导出失败: {ex.Message}");
  356. }
  357. waitWindow.Close();
  358. }
  359. }
  360. private void BtnStandImport_Click(object sender, RoutedEventArgs e)
  361. {
  362. //throw new NotImplementedException();
  363. }
  364. private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
  365. {
  366. // 只允许数字输入
  367. e.Handled = !Regex.IsMatch(e.Text, @"^\d$");
  368. }
  369. private void TxtRightResult_PreviewTextInput(object sender, TextCompositionEventArgs e)
  370. {
  371. // 只允许数字输入
  372. e.Handled = !Regex.IsMatch(e.Text, @"^\d$");
  373. }
  374. private void BtnEditRightResult_Click(object sender, RoutedEventArgs e)
  375. {
  376. IsResultEditing = true;
  377. }
  378. private void BtnSubmitRightResult_Click(object sender, RoutedEventArgs e)
  379. {
  380. IsResultEditing = false;
  381. }
  382. private void BtnCancelRightResult_Click(object sender, RoutedEventArgs e)
  383. {
  384. IsResultEditing = false;
  385. }
  386. private async void BtnStandNextPage_Click(object sender, RoutedEventArgs e)
  387. {
  388. if(StandPage.PageNumber < StandPage.PageCount)
  389. {
  390. StandPage.PageNumber += 1;
  391. bool blLoad = await LoadStandItemList();
  392. if(blLoad && StandItemList.Count > 0)
  393. {
  394. dgStand.ScrollIntoView(StandItemList[0]);
  395. }
  396. }
  397. }
  398. private async void BtnStandPrePage_Click(object sender, RoutedEventArgs e)
  399. {
  400. if(StandPage.PageNumber > 1)
  401. {
  402. StandPage.PageNumber -= 1;
  403. bool blLoad = await LoadStandItemList();
  404. if(blLoad && StandItemList.Count > 0)
  405. {
  406. dgStand.ScrollIntoView(StandItemList[0]);
  407. }
  408. }
  409. }
  410. private void BtnStandDetailFirstPage_Click(object sender, RoutedEventArgs e)
  411. {
  412. ucStandGird.FirstPage();
  413. }
  414. private void BtnStandDetailNextPage_Click(object sender, RoutedEventArgs e)
  415. {
  416. ucStandGird.NextPage();
  417. }
  418. private void BtnStanddetailPrePage_Click(object sender, RoutedEventArgs e)
  419. {
  420. ucStandGird.PrePage();
  421. }
  422. private void BtnStandDetailLastPage_Click(object sender, RoutedEventArgs e)
  423. {
  424. ucStandGird.LastPage();
  425. }
  426. private void BtnStandDetailSpeciPage_Click(object sender, RoutedEventArgs e)
  427. {
  428. try
  429. {
  430. int pageNumber = int.Parse(txtStandDetailPageNumber.Text.ToString());
  431. ucStandGird.SpeciPage(pageNumber);
  432. }
  433. catch
  434. {
  435. }
  436. }
  437. private async void BtnAddStand_Click(object sender, RoutedEventArgs e)
  438. {
  439. //List<string> tableNames = SQLiteHelper.GetAllTables();
  440. var dialog = new AddStandDialog()
  441. {
  442. Owner = Application.Current.MainWindow,
  443. WindowStartupLocation = WindowStartupLocation.CenterOwner
  444. };
  445. if (dialog.ShowDialog() == true)
  446. {
  447. StandPage.InitDefaulValue();
  448. bool blLoad = await LoadStandItemList();
  449. if (blLoad && StandItemList.Count > 0)
  450. {
  451. SelectedStandItem = StandItemList[0];
  452. dgStand.ScrollIntoView(StandItemList[0]);
  453. }
  454. }
  455. }
  456. private async void BtnDelStand_Click(object sender, RoutedEventArgs e)
  457. {
  458. bool blDelete = await DeleteStandItem();
  459. }
  460. private async Task<bool> DeleteStandItem()
  461. {
  462. bool blDelete = false;
  463. if (SelectedStandItem == null) return blDelete;
  464. MessageBoxResult result = MessageBox.Show(
  465. $"您确定要删除[{SelectedStandItem.StandName}]任务吗?\n此操作无法撤销。",
  466. "确认删除",
  467. MessageBoxButton.YesNo, // 提供“是”和“否”按钮
  468. MessageBoxImage.Warning // 使用警告图标
  469. );
  470. if (result != MessageBoxResult.Yes)
  471. {
  472. return blDelete;
  473. }
  474. //开始删除操作
  475. string titleInfo = "正在删除,请稍候...";
  476. WaitWindow waitWindow = new WaitWindow(titleInfo)
  477. {
  478. Owner = Application.Current.MainWindow,
  479. WindowStartupLocation = WindowStartupLocation.CenterOwner
  480. };
  481. waitWindow.Show();
  482. try
  483. {
  484. //执行异步删除逻辑
  485. bool deleteSuccess = false;
  486. await Task.Run(() =>
  487. {
  488. deleteSuccess = DBStand.DeleteStandAndDetails(SelectedStandItem.StandId);
  489. //Task.Delay(200).Wait(); // 模拟延迟
  490. });
  491. if (deleteSuccess)
  492. {
  493. //await LoadStandItemList();
  494. // 在 UI 线程上更新 ObservableCollection
  495. Application.Current.Dispatcher.Invoke(() =>
  496. {
  497. StandItemList.Remove(SelectedStandItem);
  498. SelectedStandItem = null;
  499. TotalStandRecords -= 1;
  500. });
  501. blDelete = true;
  502. }
  503. }
  504. catch (Exception ex)
  505. {
  506. MessageBox.Show(Application.Current.MainWindow, $"删除失败:{ex.Message}", "错误",
  507. MessageBoxButton.OK, MessageBoxImage.Error);
  508. }
  509. finally
  510. {
  511. //关闭等待窗口
  512. waitWindow.Close();
  513. }
  514. return blDelete;
  515. }
  516. private async void BtnRefresh_Click(object sender, RoutedEventArgs e)
  517. {
  518. StandPage.InitDefaulValue();
  519. bool blLoad = await LoadStandItemList();
  520. if (blLoad && StandItemList.Count > 0)
  521. {
  522. dgStand.ScrollIntoView(StandItemList[0]);
  523. }
  524. }
  525. private async void MiDeleteStand_Click(object sender, RoutedEventArgs e)
  526. {
  527. bool blDelete = await DeleteStandItem();
  528. }
  529. private void MiUpdateStandname_Click(object sender, RoutedEventArgs e)
  530. {
  531. if (SelectedStandItem == null) return;
  532. EditNameDlg editNameDlg = new EditNameDlg("模板", SelectedStandItem.StandName)
  533. {
  534. Owner = Application.Current.MainWindow,
  535. WindowStartupLocation = WindowStartupLocation.CenterOwner
  536. };
  537. if (editNameDlg.ShowDialog() == true)
  538. {
  539. UpdateStandName(SelectedStandItem, editNameDlg.EditName);
  540. }
  541. }
  542. private async void UpdateStandName(StandItem standItem,string newStandName)
  543. {
  544. try
  545. {
  546. bool blUpdate = false;
  547. await Task.Run(() =>
  548. {
  549. blUpdate = DBStand.UpdateStandName(standItem.StandId, newStandName);
  550. });
  551. if (blUpdate)
  552. {
  553. standItem.StandName = newStandName;
  554. }
  555. else
  556. {
  557. MessageBox.Show(Application.Current.MainWindow, $"修改模板名称失败。", "警告",
  558. MessageBoxButton.OK, MessageBoxImage.Warning);
  559. }
  560. }
  561. catch(Exception ex)
  562. {
  563. MessageBox.Show(Application.Current.MainWindow, $"修改模板名称:{ex.Message}错误", "错误",
  564. MessageBoxButton.OK, MessageBoxImage.Error);
  565. }
  566. }
  567. private void BtnRefreshDetail_Click(object sender, RoutedEventArgs e)
  568. {
  569. //ucStandGird.CurStandItem = null;
  570. //ucStandGird.CurStandItem = SelectedStandItem;
  571. ucStandGird.CurStationItem = null;
  572. ucStandGird.CurStationItem = SelectedStationItem;
  573. }
  574. //private async void BtnSelectImageFloder_Click(object sender, RoutedEventArgs e)
  575. //{
  576. // // 创建 VistaFolderBrowserDialog 实例
  577. // var dialog = new VistaFolderBrowserDialog();
  578. // dialog.Description = "请选择模板图片文件夹";
  579. // dialog.UseDescriptionForTitle = true; // 使用 Description 作为窗口标题
  580. // // 显示对话框并检查用户是否点击了“确定”
  581. // if (dialog.ShowDialog() == true)
  582. // {
  583. // // 获取用户选择的文件夹路径
  584. // string selectedFolderPath = dialog.SelectedPath;
  585. // await ucStandGird.ImportStandImageFloder(selectedFolderPath);
  586. // }
  587. //}
  588. private void BtnLeftCtl_Click(object sender, RoutedEventArgs e)
  589. {
  590. bool visiable = !LeftVisiable;
  591. ChangeLeftVisiable(visiable);
  592. }
  593. private void BtnRightCtl_Click(object sender, RoutedEventArgs e)
  594. {
  595. bool visiable = !RightVisiable;
  596. ChangeRightVisiable(visiable);
  597. }
  598. private void ChangeLeftVisiable(bool visiable)
  599. {
  600. LeftVisiable = visiable;
  601. colLeft.Width = new GridLength(visiable ? COLUMN_LEFT_WIDTH : 0);
  602. btnLeftCtl.Content = visiable ? "◀️" : "▶️";
  603. btnLeftCtl.ToolTip = visiable ? "点击隐藏左侧栏" : "点击显示左侧栏";
  604. }
  605. private void ChangeRightVisiable(bool visiable)
  606. {
  607. RightVisiable = visiable;
  608. colRight.Width = new GridLength(visiable ? COLUMN_RIGHT_WIDTH : 0);
  609. btnRightCtl.Content = visiable ? "▶️" : "◀️";
  610. btnRightCtl.ToolTip = visiable ? "点击隐藏右侧栏" : "点击显示右侧栏";
  611. }
  612. private void BtnStationFirstPage_Click(object sender, RoutedEventArgs e)
  613. {
  614. ucStationGrid.FirstPage();
  615. }
  616. private void BtnStationPrePage_Click(object sender, RoutedEventArgs e)
  617. {
  618. ucStationGrid.PrePage();
  619. }
  620. private void BtnStationNextPage_Click(object sender, RoutedEventArgs e)
  621. {
  622. ucStationGrid.NextPage();
  623. }
  624. private void BtnStationLastPage_Click(object sender, RoutedEventArgs e)
  625. {
  626. ucStationGrid.LastPage();
  627. }
  628. private void BtnStationSpeciPage_Click(object sender, RoutedEventArgs e)
  629. {
  630. try
  631. {
  632. int pageNumber = int.Parse(txtStationPageNumber.Text.ToString());
  633. ucStationGrid.SpeciPage(pageNumber);
  634. }
  635. catch
  636. {
  637. }
  638. }
  639. private void BtnQuery_Click(object sender, RoutedEventArgs e)
  640. {
  641. FindStationId = txtFindStationId.Text.Trim();
  642. ucStationGrid.ChangeFind(FindStationId, SelectedStandItem.StandId);
  643. Apply_UCStandDetaisl_Title(SelectedStandItem);
  644. }
  645. private void BtnRefreshStation_Click(object sender, RoutedEventArgs e)
  646. {
  647. FindStationId = txtFindStationId.Text.Trim();
  648. ucStationGrid.ChangeFind(FindStationId, SelectedStandItem.StandId);
  649. Apply_UCStandDetaisl_Title(SelectedStandItem);
  650. }
  651. /////////////////////////////////////////////////////////////////////////////
  652. }
  653. }