SettingView.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Prism.Commands;
  2. using Prism.Events;
  3. using Prism.Ioc;
  4. using Prism.Regions;
  5. using System;
  6. using System.Windows.Controls;
  7. using TeamAAS_VP.Models;
  8. using TeamAAS_VP.Models.Feeder;
  9. using TeamAAS_VP.Models.Lights;
  10. using TeamAAS_VP.ViewModels;
  11. namespace TeamAAS_VP.Views
  12. {
  13. /// <summary>
  14. /// Interaction logic for SettingView
  15. /// </summary>
  16. public partial class SettingView : UserControl
  17. {
  18. public SettingView()
  19. {
  20. InitializeComponent();
  21. }
  22. private void TreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<object> e)
  23. {
  24. try
  25. {
  26. // 获取其 DataContext
  27. SettingViewModel viewModel = DataContext as SettingViewModel;
  28. if (e.NewValue is RobotInfo)
  29. {
  30. viewModel.SelectRobot = e.NewValue as RobotInfo;
  31. }
  32. else if (e.NewValue is FeederInfo)
  33. {
  34. viewModel.SelectFeeder = e.NewValue as FeederInfo;
  35. }
  36. else if (e.NewValue is CameraInfo)
  37. {
  38. viewModel.SelectCamera = e.NewValue as CameraInfo;
  39. }
  40. else if (e.NewValue is PlcInfo)
  41. {
  42. viewModel.SelectPlc = e.NewValue as PlcInfo;
  43. }
  44. else if (e.NewValue is LightControllerConfig)
  45. {
  46. viewModel.SelectLightController = e.NewValue as LightControllerConfig;
  47. }
  48. else if (e.NewValue is ScrewFeederInfo)
  49. {
  50. viewModel.SelectScrewFeeder = e.NewValue as ScrewFeederInfo;
  51. }
  52. else if (e.NewValue is DeviceInfo)
  53. {
  54. viewModel.SelectDeviceInfo = e.NewValue as DeviceInfo;
  55. }
  56. }
  57. catch (Exception)
  58. {
  59. }
  60. }
  61. }
  62. }