终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainWindow.xaml.cs 2.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using BPASmartClient.AGV.Feedback;
  2. using BPASmartClient.HubHelper;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Shapes;
  18. namespace FryPot_DosingSystem.View
  19. {
  20. /// <summary>
  21. /// MainWindow.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class MainWindow : Window
  24. {
  25. ScrollViewer scrollViewer;
  26. double lastPointX;
  27. double distance;
  28. public MainWindow()
  29. {
  30. InitializeComponent();
  31. Initialize();
  32. HubHelper.GetInstance.Report = new Action<object>((o) =>
  33. {
  34. var res = JsonConvert.DeserializeObject<AGVToUpSystem>(o.ToString());
  35. });
  36. HubHelper.GetInstance.Upstreamrequest = new Action<object>((o) =>
  37. {
  38. var res = JsonConvert.DeserializeObject<Upstreamrequest>(o.ToString());
  39. });
  40. HubHelper.GetInstance.Connect("192.168.1.56", 8089);
  41. }
  42. protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
  43. {
  44. base.OnMouseLeftButtonDown(e);
  45. // 获取鼠标相对控件位置 (grid_main为控件Name)
  46. Point position = Mouse.GetPosition(grid_main);
  47. // 如果鼠标位置在控件内,允许拖动
  48. if (e.LeftButton == MouseButtonState.Pressed)
  49. {
  50. if (position.X >= 0 && position.X < grid_main.ActualWidth && position.Y >= 0 && position.Y < grid_main.ActualHeight)
  51. {
  52. this.DragMove();
  53. }
  54. }
  55. }
  56. private void Initialize()
  57. {
  58. this.ButClose.Click += (obj, e) =>
  59. {
  60. MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel);
  61. if (res == MessageBoxResult.OK)
  62. {
  63. this.Close();
  64. }
  65. };
  66. }
  67. }
  68. }