SettingView.xaml.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using TeamAAS.Robot.Models;
  5. using TeamAAS.Feeder.Models;
  6. using TeamAAS.ViewModels;
  7. namespace TeamAAS.Views
  8. {
  9. public partial class SettingView : UserControl
  10. {
  11. public SettingView()
  12. {
  13. InitializeComponent();
  14. Loaded += OnLoaded;
  15. _hasLoaded = false;
  16. }
  17. private bool _hasLoaded;
  18. private void OnLoaded(object sender, RoutedEventArgs e)
  19. {
  20. if (_hasLoaded) return;
  21. _hasLoaded = true;
  22. if (DataContext is SettingViewModel vm)
  23. {
  24. System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(
  25. new Action(() => vm.DelayedLoad()),
  26. System.Windows.Threading.DispatcherPriority.Background);
  27. }
  28. }
  29. private void RobotDataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
  30. {
  31. if (DataContext is SettingViewModel vm && vm.SelectedRobot is RobotInfo robot)
  32. {
  33. var copy = robot.Clone();
  34. if (DialogHelper.EditProperties(copy, "机器人属性"))
  35. vm.ApplyRobotEdit(copy);
  36. }
  37. }
  38. private void FeederDataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
  39. {
  40. if (DataContext is SettingViewModel vm && vm.SelectedFeeder is FeederInfo feeder)
  41. {
  42. var copy = feeder.Clone();
  43. if (DialogHelper.EditProperties(copy, "供料器属性(含四个方向振动参数)"))
  44. vm.ApplyFeederEdit(copy);
  45. }
  46. }
  47. }
  48. }