using BPASmartClient.AGV.Feedback; using BPASmartClient.HubHelper; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace FryPot_DosingSystem.View { /// /// MainWindow.xaml 的交互逻辑 /// public partial class MainWindow : Window { ScrollViewer scrollViewer; double lastPointX; double distance; public MainWindow() { InitializeComponent(); Initialize(); HubHelper.GetInstance.Report = new Action((o) => { var res = JsonConvert.DeserializeObject(o.ToString()); }); HubHelper.GetInstance.Upstreamrequest = new Action((o) => { var res = JsonConvert.DeserializeObject(o.ToString()); }); HubHelper.GetInstance.Connect("192.168.1.40", 8089); } protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); // 获取鼠标相对控件位置 (grid_main为控件Name) Point position = Mouse.GetPosition(grid_main); // 如果鼠标位置在控件内,允许拖动 if (e.LeftButton == MouseButtonState.Pressed) { if (position.X >= 0 && position.X < grid_main.ActualWidth && position.Y >= 0 && position.Y < grid_main.ActualHeight) { this.DragMove(); } } } private void Initialize() { this.ButClose.Click += (obj, e) => { MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { this.Close(); } }; } } }