From ebef215f46d2ec4c30247103ee655e83c685e96d Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 24 Aug 2022 16:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=84=E6=80=81=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6-=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=E6=A1=88?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPASmartClient.Compiler.csproj | 4 - .../IExecutable.cs | 2 +- .../Enum/物料仓/SilosRunEnum.cs | 27 ++++ .../Enum/运行状态/RunEnum.cs | 27 ++++ BPASmartClient.MessageName/MessageName.cs | 1 + BPASmartClient.SCADAControl/ArcGauge.cs | 3 +- .../BPASmartClient.SCADAControl.csproj | 1 + .../NewConveyorBelt.xaml.cs | 117 ++++++++++------ BPASmartClient.SCADAControl/Silos.xaml.cs | 108 +++++++++++--- SCADA.Test/App.xaml | 9 ++ SCADA.Test/App.xaml.cs | 17 +++ SCADA.Test/AssemblyInfo.cs | 10 ++ SCADA.Test/Converters/ZoomConverter.cs | 32 +++++ SCADA.Test/MainWindow.xaml | 18 +++ SCADA.Test/MainWindow.xaml.cs | 74 ++++++++++ SCADA.Test/RunCanvas.xaml | 32 +++++ SCADA.Test/RunCanvas.xaml.cs | 132 ++++++++++++++++++ SCADA.Test/SCADA.Test.csproj | 15 ++ SCADA.Test/物料布局.lay | Bin 0 -> 8656 bytes SmartClient.sln | 28 +++- 20 files changed, 588 insertions(+), 69 deletions(-) rename {BPASmartClient.SCADAControl => BPASmartClient.Compiler}/IExecutable.cs (92%) create mode 100644 BPASmartClient.MessageName/Enum/物料仓/SilosRunEnum.cs create mode 100644 BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs create mode 100644 SCADA.Test/App.xaml create mode 100644 SCADA.Test/App.xaml.cs create mode 100644 SCADA.Test/AssemblyInfo.cs create mode 100644 SCADA.Test/Converters/ZoomConverter.cs create mode 100644 SCADA.Test/MainWindow.xaml create mode 100644 SCADA.Test/MainWindow.xaml.cs create mode 100644 SCADA.Test/RunCanvas.xaml create mode 100644 SCADA.Test/RunCanvas.xaml.cs create mode 100644 SCADA.Test/SCADA.Test.csproj create mode 100644 SCADA.Test/物料布局.lay diff --git a/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj b/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj index f8198dde..aa52b3a8 100644 --- a/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj +++ b/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj @@ -6,10 +6,6 @@ enable - - - - DLL\Antlr3.Runtime.dll diff --git a/BPASmartClient.SCADAControl/IExecutable.cs b/BPASmartClient.Compiler/IExecutable.cs similarity index 92% rename from BPASmartClient.SCADAControl/IExecutable.cs rename to BPASmartClient.Compiler/IExecutable.cs index d48c9391..836f89f7 100644 --- a/BPASmartClient.SCADAControl/IExecutable.cs +++ b/BPASmartClient.Compiler/IExecutable.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BPASmartClient.SCADAControl +namespace BPASmartClient.Compiler { public interface IExecutable { diff --git a/BPASmartClient.MessageName/Enum/物料仓/SilosRunEnum.cs b/BPASmartClient.MessageName/Enum/物料仓/SilosRunEnum.cs new file mode 100644 index 00000000..f8ae2652 --- /dev/null +++ b/BPASmartClient.MessageName/Enum/物料仓/SilosRunEnum.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MessageName.Enum.物料仓 +{ + /// + /// 物料仓数据设置-Model + /// + public class SilosMessageModel + { + /// + /// 物料仓:仓号 + /// + public string id { get; set; } + /// + /// 物料仓:标题 + /// + public string Title { get; set; } + /// + /// 物料仓:重量(G) 35.23 + /// + public string Value { get; set; } + } +} diff --git a/BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs b/BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs new file mode 100644 index 00000000..54e2402f --- /dev/null +++ b/BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MessageName.Enum.运行状态 +{ + /// + /// 运行状态-枚举 + /// + public enum RunEnum + { + /// + /// 运行(滚动线默认右转) + /// + Run, + /// + /// 运行-左转(滚动线独有) + /// + Run_Left, + /// + /// 停止 + /// + Stop + } +} diff --git a/BPASmartClient.MessageName/MessageName.cs b/BPASmartClient.MessageName/MessageName.cs index 4eb5ea81..75754f00 100644 --- a/BPASmartClient.MessageName/MessageName.cs +++ b/BPASmartClient.MessageName/MessageName.cs @@ -66,6 +66,7 @@ namespace BPASmartClient.MessageName /// 物料仓数据设置 /// SilosSetData, + /// /// 滚动线运行状态 /// diff --git a/BPASmartClient.SCADAControl/ArcGauge.cs b/BPASmartClient.SCADAControl/ArcGauge.cs index 51fe9932..e5ee39a2 100644 --- a/BPASmartClient.SCADAControl/ArcGauge.cs +++ b/BPASmartClient.SCADAControl/ArcGauge.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.Compiler; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; diff --git a/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj b/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj index 5328e350..e8a17b2f 100644 --- a/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj +++ b/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj @@ -12,6 +12,7 @@ + diff --git a/BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs b/BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs index a0278b7d..443a1678 100644 --- a/BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs +++ b/BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs @@ -1,4 +1,8 @@ -using BPASmartClient.MessageName; +using BPASmartClient.Compiler; +using BPASmartClient.MessageCommunication; +using BPASmartClient.MessageCommunication.MsgControl; +using BPASmartClient.MessageName; +using BPASmartClient.MessageName.Enum.运行状态; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -24,10 +28,14 @@ namespace BPASmartClient.SCADAControl /// public partial class NewConveyorBelt : UserControl, IExecutable { + #region 临时变量 Path Path_mp = null; Path Path_cb = null; Storyboard storyboard = new Storyboard(); Storyboard storyboard1 = new Storyboard(); + #endregion + + public NewConveyorBelt() { InitializeComponent(); @@ -43,7 +51,6 @@ namespace BPASmartClient.SCADAControl } public string ControlType => "滚动线"; - private bool isExecuteState; public bool IsExecuteState { @@ -60,11 +67,7 @@ namespace BPASmartClient.SCADAControl } } - public void Register() - { - - } - + #region 内部函数 public void VisualStateManagerData() { storyboard.RepeatBehavior = RepeatBehavior.Forever; @@ -163,35 +166,13 @@ namespace BPASmartClient.SCADAControl } } } + #endregion + #region 属性 private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as NewConveyorBelt)?.Refursh(); } - - private void Refursh() - { - if (Direction == 1) - { - storyboard.Begin(); - storyboard1.Stop(); - // VisualStateManager.GoToState(this, "Left", false); - } - else if (Direction == 2) - { - storyboard.Stop(); - storyboard1.Begin(); - //VisualStateManager.GoToState(this, "Right", false); - } - else - { - storyboard.Stop(); - storyboard1.Stop(); - //VisualStateManager.GoToState(this, "Stop", false); - } - } - - public DoubleCollection StrokeDashArray { get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); } @@ -252,7 +233,7 @@ namespace BPASmartClient.SCADAControl DependencyProperty.Register("Direction", typeof(int), typeof(NewConveyorBelt), new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); - + [Category("主题订阅")] public string ConveyorBeltLeft { @@ -278,22 +259,68 @@ namespace BPASmartClient.SCADAControl public static readonly DependencyProperty ConveyorBeltStopProperty = DependencyProperty.Register("ConveyorBeltStop", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); - //[Category("事件名称集合")] - //public ObservableCollection EventList - //{ - // get { return (ObservableCollection)GetValue(EventListProperty); } - // set { SetValue(EventListProperty, value); } - //} - //public static readonly DependencyProperty EventListProperty = - // DependencyProperty.Register("EventList", typeof(ObservableCollection), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection())); + [Category("消息名称")] - public MessageNameEnum EventName + public MessageNameEnum EventRunName + { + get { return (MessageNameEnum)GetValue(EventRunNameProperty); } + set { SetValue(EventRunNameProperty, value); } + } + public static readonly DependencyProperty EventRunNameProperty = + DependencyProperty.Register("EventRunName", typeof(MessageNameEnum), typeof(NewConveyorBelt), new PropertyMetadata(MessageNameEnum.Null, onEventRunNameChanged)); + private static void onEventRunNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); + #endregion + + #region 属性变更事件 + public void Register() + { + Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler"); + } + + public void EventRunNameHandler(object sender, InnerMessageEventArgs e) + { + try + { + if (IsExecuteState = true) + { + if (e.obj_MessageObj is RunEnum) + { + RunEnum runEnum = (RunEnum)e.obj_MessageObj; + + Direction = runEnum == RunEnum.Run ? 1 : ((runEnum == RunEnum.Run_Left)?2:0); + } + } + } + catch (Exception ex) + { + + } + } + + private void Refursh() + { + if (Direction == 1) + { + storyboard.Begin(); + storyboard1.Stop(); + } + else if (Direction == 2) + { + storyboard.Stop(); + storyboard1.Begin(); + } + else + { + storyboard.Stop(); + storyboard1.Stop(); + } + } + + public void RunNameRefresh() { - get { return (MessageNameEnum)GetValue(EventNameProperty); } - set { SetValue(EventNameProperty, value); } + } - public static readonly DependencyProperty EventNameProperty = - DependencyProperty.Register("EventName", typeof(MessageNameEnum), typeof(NewConveyorBelt), new PropertyMetadata(MessageNameEnum.Null)); + #endregion } diff --git a/BPASmartClient.SCADAControl/Silos.xaml.cs b/BPASmartClient.SCADAControl/Silos.xaml.cs index 36ea3e46..4e54023a 100644 --- a/BPASmartClient.SCADAControl/Silos.xaml.cs +++ b/BPASmartClient.SCADAControl/Silos.xaml.cs @@ -1,4 +1,9 @@ -using BPASmartClient.MessageName; +using BPASmartClient.Compiler; +using BPASmartClient.MessageCommunication; +using BPASmartClient.MessageCommunication.MsgControl; +using BPASmartClient.MessageName; +using BPASmartClient.MessageName.Enum.物料仓; +using BPASmartClient.MessageName.Enum.运行状态; using System; using System.Collections.Generic; using System.ComponentModel; @@ -24,26 +29,26 @@ namespace BPASmartClient.SCADAControl /// public partial class Silos : UserControl, IExecutable { + #region 临时变量 TextBlock textBlockCLKZ = null; Ellipse ellipseControl = null; Storyboard storyboard = new Storyboard(); + #endregion + public Silos() { InitializeComponent(); this.DataContext = this; Width = 180; Height = 270; - Value = 25.23; + Value = "25.23"; Title = "香料"; Text = "1"; this.SizeChanged += Silos_SizeChanged; ; } - - public string ControlType => "物料仓"; - private bool isExecuteState; public bool IsExecuteState { @@ -127,16 +132,13 @@ namespace BPASmartClient.SCADAControl #region 属性 [Category("值设定")] - public double Value + public string Value { - get { return (double)GetValue(ValueProperty); } + get { return (string)GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } } public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value", typeof(double), typeof(Silos), new PropertyMetadata(0d, OnValueChanged)); - - private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.Refresh(); - + DependencyProperty.Register("Value", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty)); [Category("值设定")] public string Text { @@ -156,14 +158,23 @@ namespace BPASmartClient.SCADAControl DependencyProperty.Register("Title", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty)); [Category("消息名称")] - public MessageNameEnum EventName + public MessageNameEnum EventRunName { - get { return (MessageNameEnum)GetValue(EventNameProperty); } - set { SetValue(EventNameProperty, value); } + get { return (MessageNameEnum)GetValue(EventRunNameProperty); } + set { SetValue(EventRunNameProperty, value); } } - public static readonly DependencyProperty EventNameProperty = - DependencyProperty.Register("EventName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null,onEventValueChanged)); - private static void onEventValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.Refresh(); + public static readonly DependencyProperty EventRunNameProperty = + DependencyProperty.Register("EventRunName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null, onEventRunNameChanged)); + private static void onEventRunNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.RunNameRefresh(); + [Category("消息名称")] + public MessageNameEnum EventDataName + { + get { return (MessageNameEnum)GetValue(EventDataNameProperty); } + set { SetValue(EventDataNameProperty, value); } + } + public static readonly DependencyProperty EventDataNameProperty = + DependencyProperty.Register("EventDataName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null, onEventDataNameChanged)); + private static void onEventDataNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh(); [Category("值设定")] public int Direction { @@ -180,6 +191,9 @@ namespace BPASmartClient.SCADAControl #endregion #region 函数 + /// + /// 值变化刷新 + /// public void Refresh() { if (ellipseControl != null) @@ -204,12 +218,72 @@ namespace BPASmartClient.SCADAControl } } + } + /// + /// 运行名称变化事件 + /// + public void RunNameRefresh() + { + + } + /// + /// 数据名称变化事件 + /// + public void DataNameRefresh() + { + } #endregion + #region 运行事件 public void Register() { + Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler"); + Class_InnerMessageBus.GetInstance().ListenMessage(this, EventDataName.ToString(), "EventDataNameHandler"); + } + + public void EventRunNameHandler(object sender, InnerMessageEventArgs e) + { + try + { + if (IsExecuteState = true) + { + if (e.obj_MessageObj is RunEnum) + { + RunEnum runEnum = (RunEnum)e.obj_MessageObj; + Direction = runEnum == RunEnum.Run ? 1 : 2; + } + } + } + catch (Exception ex) + { + + } + } + + public void EventDataNameHandler(object sender, InnerMessageEventArgs e) + { + try + { + if (IsExecuteState = true) + { + if (e.obj_MessageObj is SilosMessageModel) + { + SilosMessageModel silosMessageModel = (SilosMessageModel)e.obj_MessageObj; + if (silosMessageModel.id == Text) + { + Title=silosMessageModel.Title; + Value= silosMessageModel.Value; + } + } + } + } + catch (Exception ex) + { + } } + #endregion + } } diff --git a/SCADA.Test/App.xaml b/SCADA.Test/App.xaml new file mode 100644 index 00000000..1d057a81 --- /dev/null +++ b/SCADA.Test/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/SCADA.Test/App.xaml.cs b/SCADA.Test/App.xaml.cs new file mode 100644 index 00000000..0dbc5dbf --- /dev/null +++ b/SCADA.Test/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace SCADA.Test +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/SCADA.Test/AssemblyInfo.cs b/SCADA.Test/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/SCADA.Test/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/SCADA.Test/Converters/ZoomConverter.cs b/SCADA.Test/Converters/ZoomConverter.cs new file mode 100644 index 00000000..ab3c2e40 --- /dev/null +++ b/SCADA.Test/Converters/ZoomConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + + +namespace SCADA.Test.Converters +{ + public class ZoomConverter : IValueConverter + { + public bool IsHeight { get; set; } + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (double.TryParse(value.ToString(), out double zoom)) + { + return IsHeight ? zoom * 1080 : zoom * 1920; + } + else + { + return IsHeight ? 1080 : 1920; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return value; + } + } +} diff --git a/SCADA.Test/MainWindow.xaml b/SCADA.Test/MainWindow.xaml new file mode 100644 index 00000000..9ffa5be9 --- /dev/null +++ b/SCADA.Test/MainWindow.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/SCADA.Test/MainWindow.xaml.cs b/SCADA.Test/MainWindow.xaml.cs new file mode 100644 index 00000000..fea14b6b --- /dev/null +++ b/SCADA.Test/MainWindow.xaml.cs @@ -0,0 +1,74 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +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.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SCADA.Test +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + List Children = new List(); + + public MainWindow() + { + InitializeComponent(); + } + + #region 加载数据 + /// + /// 加载数据 + /// + public void LoadingData(string path) + { + //加载控件 + Children.Clear(); + FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using (StreamReader sr = new StreamReader(fs, System.Text.Encoding.Unicode)) + { + while (sr.Peek() > -1) + { + string str = sr.ReadLine(); + //if (!str.Contains("NewConveyorBelt")) + { + var ele = XamlReader.Parse(str) as FrameworkElement; + Children.Add(ele); + } + + } + } + if (Children.Count > 0) + { + runCanvas.Run(Children); + } + + } + #endregion + + private void Button_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "布局文件|*.lay"; + if (ofd.ShowDialog() ==true) + { + LoadingData(ofd.FileName); + } + + } + } +} diff --git a/SCADA.Test/RunCanvas.xaml b/SCADA.Test/RunCanvas.xaml new file mode 100644 index 00000000..0746c6de --- /dev/null +++ b/SCADA.Test/RunCanvas.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SCADA.Test/RunCanvas.xaml.cs b/SCADA.Test/RunCanvas.xaml.cs new file mode 100644 index 00000000..c5d8e247 --- /dev/null +++ b/SCADA.Test/RunCanvas.xaml.cs @@ -0,0 +1,132 @@ +using BPASmartClient.Compiler; +using System; +using System.Collections.Generic; +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.Navigation; +using System.Windows.Shapes; + +namespace SCADA.Test +{ + /// + /// RunCanvas.xaml 的交互逻辑 + /// + public partial class RunCanvas : UserControl + { + public RunCanvas() + { + InitializeComponent(); + Unloaded += (s, e) => Destory(); + } + + /// + /// Dispose子集 + /// + public void Destory() + { + foreach (var item in RootCanvas.Children) + { + if (item is IDisposable disposable) + { + disposable.Dispose(); + } + } + } + + public void Run(List canvas) + { + RootCanvas.Children.Clear(); + foreach (FrameworkElement element in canvas) + { + if (element.GetType().GetInterface("IExecutable") != null) + { + element.GetType().GetProperty("IsExecuteState").SetValue(element, true); + } + + if (element is IExecutable executable) + executable.IsExecuteState = true; + + RootCanvas.Children.Add(element); + RegisterJsName(element); + } + } + + // 注册名称到Js + static void RegisterJsName(FrameworkElement element) + { + Config.GetInstance().SetVariable(element.Name, element); + if (element is Panel panel) + { + foreach (var item in panel.Children) + { + RegisterJsName(item as FrameworkElement); + } + } + } + + #region 拖动与缩放 + private void RootCanvas_MouseMove(object sender, MouseEventArgs e) + { + if (DragEnable.IsChecked == false) + { + return; + } + + if (e.LeftButton == MouseButtonState.Pressed && isPressed) + { + Point point = e.GetPosition(this); + var movex = (point.X - last.X); + var movey = (point.Y - last.Y); + + Translate.X += movex; + Translate.Y += movey; + last = point; + + } + } + + bool isPressed = false; + Point last;//记录上次鼠标坐标位置 + private void RootCanvas_MouseLeftButtoDown(object sender, MouseButtonEventArgs e) + { + last = e.GetPosition(this); + isPressed = true; + } + + private void RootCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + isPressed = false; + } + + // 缩放 + private void RootCanvas_MouseWheel(object sender, MouseWheelEventArgs e) + { + if (ZoomEnable.IsChecked == false) + { + return; + } + var zoomS = (e.Delta / 960d); + var zoom = zoomS + Scale.ScaleX; + if (zoom > 3 || zoom < 0.8) + { + return; + } + Scale.ScaleX = Scale.ScaleY = zoom; + + Point mouse = e.GetPosition(RootCanvas); + Point newMouse = new Point(mouse.X * zoomS, mouse.Y * zoomS); + + Translate.X -= newMouse.X; + Translate.Y -= newMouse.Y; + } + #endregion + } +} diff --git a/SCADA.Test/SCADA.Test.csproj b/SCADA.Test/SCADA.Test.csproj new file mode 100644 index 00000000..550bd4b5 --- /dev/null +++ b/SCADA.Test/SCADA.Test.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net6.0-windows + enable + true + + + + + + + + diff --git a/SCADA.Test/物料布局.lay b/SCADA.Test/物料布局.lay new file mode 100644 index 0000000000000000000000000000000000000000..7899db8760201b2377c7d514d413e4ca757a6d44 GIT binary patch literal 8656 zcmeHM+in{-5S^z!6zD$~3Q)9wql>SJ;{=d=O901CEZ0FFZFwULmL)?g+j9TJU(gTg zm-MMXAKIS7S%#!UNh>8t5x@{6?UJ*@xtzI>`|m%SQkOevNnaXrAvL+dRbRT&kp49wk2DPT6iQw>9Ri|cz__2dj!Z9H9;qHKd_&(QaAMSd@3NnXg0@&tUU zxH`prLz?)%!Ea)oI>B8V_X(&g7%2x&q~O#BuXOAR70?$T`7c=SOG{7Q`K4cz=K=k6 z*=Zfh{s#J4Thki}Jk*C>ctzXq8XKj!BlQ99uCkfb^W>T5$+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