AoItemEditor.xaml.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Aitex.Core.RT.IOCore;
  2. using MECF.Framework.Common.IOCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace MECF.Framework.UI.Core.Control
  18. {
  19. /// <summary>
  20. /// DIItemEditor.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class AoItemEditor : UserControl
  23. {
  24. public AoItemEditor()
  25. {
  26. InitializeComponent();
  27. }
  28. private void Button_Click(object sender, RoutedEventArgs e)
  29. {
  30. // (dataGrid.SelectedItem as NotifiableIoItem).ShortValue = 10;
  31. //(dataGrid.Columns[3].GetCellContent(dataGrid.SelectedItem) as TextBlock).Text = "20";
  32. var selectedItem = dataGrid.SelectedItem;
  33. DataGridTemplateColumn templeColumn = dataGrid.Columns[4] as DataGridTemplateColumn;
  34. FrameworkElement s = dataGrid.Columns[4].GetCellContent(selectedItem);
  35. TextBox tbOper = templeColumn.CellTemplate.FindName("tb1", s) as TextBox;
  36. AOAccessor t;
  37. if ((selectedItem as NotifiableIoItem).Name.Contains("PMA"))
  38. {
  39. t = IO.GetAoList("PMA.PLC").Where(x => x.Index == (selectedItem as NotifiableIoItem).Index).FirstOrDefault();
  40. }
  41. else
  42. {
  43. t = IO.GetAoList("PMB.PLC").Where(x => x.Index == (selectedItem as NotifiableIoItem).Index).FirstOrDefault();
  44. }
  45. t.Value = Convert.ToInt16(tbOper.Text);
  46. }
  47. }
  48. }