From 07e686eb253ffd29f36dbe530b3a17633e02b353 Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 10 Feb 2018 02:13:37 +0200 Subject: Added support for motor controllers. --- .../Editors/MotorElementEditor.xaml | 267 +++++++++++++++++++++ .../Editors/MotorElementEditor.xaml.cs | 186 ++++++++++++++ .../Editors/SingleGraphElementEditor.xaml | 2 +- .../Images/engine.png | Bin 0 -> 800 bytes .../Tango.MachineStudio.Technician/Images/prop.png | Bin 0 -> 30883 bytes .../Tango.MachineStudio.Technician.csproj | 15 ++ .../TechItems/MotorActionType.cs | 18 ++ .../TechItems/MotorItem.cs | 117 +++++++++ .../ViewModels/MachineTechViewVM.cs | 170 +++++++++++-- .../Views/MachineTechView.xaml | 29 ++- .../Views/MachineTechView.xaml.cs | 22 ++ 11 files changed, 799 insertions(+), 27 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml new file mode 100644 index 000000000..bf7aaeff4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs new file mode 100644 index 000000000..6371cb83a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs @@ -0,0 +1,186 @@ +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.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.TechItems; + +namespace Tango.MachineStudio.Technician.Editors +{ + [ContentProperty("InnerContent")] + public partial class MotorElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public MotorElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public MotorElementEditor(MotorItem motorItem) + : this() + { + MotorItem = motorItem; + DataContext = MotorItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + public MotorElementEditor(MotorItem monitorItem, Rect bounds) + : this(monitorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MotorItem _monitorItem; + + public MotorItem MotorItem + { + get { return _monitorItem; } + set + { + _monitorItem = value; RaisePropertyChanged(nameof(MotorItem)); + + if (_monitorItem != null) + { + _monitorItem.HomingCompleted -= _monitorItem_HomingCompleted; + _monitorItem.HomingCompleted += _monitorItem_HomingCompleted; + } + } + } + + private void _monitorItem_HomingCompleted(object sender, EventArgs e) + { + StopAnimation(); + } + + + /// + /// Clones this instance. + /// + /// + public override IElementEditor Clone() + { + try + { + var clonedItem = MotorItem.Clone() as MotorItem; + MotorElementEditor cloned = new MotorElementEditor(clonedItem); + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// + /// Gets the hosted element. + /// + [ParameterIgnore] + public override Object HostedElement + { + get { return MotorItem; } + } + + private void OnForwardPressed(object sender, MouseButtonEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.ForwardPressed); + AnimateRight(); + } + + private void OnForwardReleased(object sender, MouseButtonEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.ForwardReleased); + StopAnimation(); + } + + private void OnBackwardPressed(object sender, MouseButtonEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.BackwardPressed); + AnimateLeft(); + } + + private void OnBackwardReleased(object sender, MouseButtonEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.BackwardReleased); + StopAnimation(); + } + + private void OnHomingStarted(object sender, RoutedEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.HomingStarted); + AnimateLeft(); + } + + private void OnHomingStopped(object sender, RoutedEventArgs e) + { + MotorItem.RaiseAction(MotorActionType.HomingStopped); + StopAnimation(); + } + + private void AnimateRight() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = 360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + private void AnimateLeft() + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(1); + ani.RepeatBehavior = RepeatBehavior.Forever; + ani.FillBehavior = FillBehavior.HoldEnd; + ani.To = -360; + propRotate.BeginAnimation(RotateTransform.AngleProperty, ani); + } + + public void StopAnimation() + { + this.Dispatcher.Invoke(() => + { + propRotate.BeginAnimation(RotateTransform.AngleProperty, null); + }); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml index 02acf5883..aa0ec24e8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/SingleGraphElementEditor.xaml @@ -28,7 +28,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png new file mode 100644 index 000000000..731ddc4f6 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/engine.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png new file mode 100644 index 000000000..268c1e557 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/prop.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 654c6b9c1..0f92b6275 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -81,6 +81,9 @@ + + MotorElementEditor.xaml + MeterElementEditor.xaml @@ -107,6 +110,8 @@ SingleGraphTemplate.xaml + + @@ -136,6 +141,10 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -296,5 +305,11 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs new file mode 100644 index 000000000..319345926 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorActionType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public enum MotorActionType + { + ForwardPressed, + ForwardReleased, + BackwardPressed, + BackwardReleased, + HomingStarted, + HomingStopped, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs new file mode 100644 index 000000000..a7088ac3f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MotorItem.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +using Tango.Core.Commands; +using Tango.Integration.Observables; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Technician.TechItems +{ + public class MotorItem : TechItem + { + public event EventHandler ActionExecuted; + public event EventHandler HomingCompleted; + + private TechMotor _techMotor; + [XmlIgnore] + public TechMotor TechMotor + { + get { return _techMotor; } + set { _techMotor = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Data)); } + } + + private bool _isHoming; + [XmlIgnore] + public bool IsHoming + { + get { return _isHoming; } + set + { + _isHoming = value; + RaisePropertyChangedAuto(); + } + } + + private bool _isHomingCompleted; + + public bool IsHomingCompleted + { + get { return _isHomingCompleted; } + set + { + _isHomingCompleted = value; + RaisePropertyChangedAuto(); + + if (value) + { + HomingCompleted?.Invoke(this, new EventArgs()); + } + } + } + + private double _homingProgress; + [XmlIgnore] + public double HomingProgress + { + get { return _homingProgress; } + set + { + _homingProgress = value; + RaisePropertyChangedAuto(); + } + } + + private double _homingMaximumProgress; + [XmlIgnore] + public double HomingMaximumProgress + { + get { return _homingMaximumProgress; } + set { _homingMaximumProgress = value; RaisePropertyChangedAuto(); } + } + + private bool _isForwardPressed; + [XmlIgnore] + public bool IsForwardPressed + { + get { return _isForwardPressed; } + set { _isForwardPressed = value; RaisePropertyChangedAuto(); } + } + + private bool _isBackwardPressed; + [XmlIgnore] + public bool IsBackwardPressed + { + get { return _isBackwardPressed; } + set { _isBackwardPressed = value; RaisePropertyChangedAuto(); } + } + + public override object Data => TechMotor; + + public MotorItem() : base() + { + Name = "Motor"; + Description = "Motor Controller"; + Image = ResourceHelper.GetImageFromResources("Images/engine.png"); + } + + public MotorItem(TechMotor techMotor) : this() + { + TechMotor = techMotor; + } + + public override TechItem Clone() + { + MotorItem cloned = base.Clone() as MotorItem; + cloned.TechMotor = TechMotor; + return cloned; + } + + public void RaiseAction(MotorActionType action) + { + ActionExecuted?.Invoke(this, action); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index b0c899f06..7bed3f441 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -6,6 +6,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; @@ -184,7 +185,7 @@ namespace Tango.MachineStudio.Technician.ViewModels return (value as RepeatedField).ToList(); } - private List> GetMultiGraphValues(TechMonitor monitor,object value) + private List> GetMultiGraphValues(TechMonitor monitor, object value) { DoubleArray[] arrayOfDoubles = Enumerable.ToArray(value as IEnumerable); return arrayOfDoubles.Select(x => x.Data.ToList()).ToList(); @@ -192,39 +193,105 @@ namespace Tango.MachineStudio.Technician.ViewModels public void AddElement(Rect bounds) { - lock (_elementsLock) + if (SelectedTechItem is MonitorItem) { - if (SelectedTechItem is MonitorItem) - { - var monitorItem = new MonitorItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); - MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds); - Elements.Add(editor); - } - else if (SelectedTechItem is MeterItem) + var monitorItem = new MonitorItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); + MonitorElementEditor editor = new MonitorElementEditor(monitorItem, bounds); + Elements.Add(editor); + } + else if (SelectedTechItem is MeterItem) + { + var meterItem = new MeterItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); + MeterElementEditor editor = new MeterElementEditor(meterItem, bounds); + Elements.Add(editor); + } + else if (SelectedTechItem is SingleGraphItem) + { + var graphItem = new SingleGraphItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); + SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds); + editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + graphItem.Editor = editor; + + + GraphController controller = new GraphController(); + editor.InnerGraph.Controller = controller; + + _singleControllers.Add(graphItem, controller); + + Elements.Add(editor); + } + else if (SelectedTechItem is MultiGraphItem) + { + var graphItem = new MultiGraphItem(Adapter.TechMonitors.Where(x => x.MultiChannel).FirstOrDefault()); + MultiGraphElementEditor editor = new MultiGraphElementEditor(graphItem, bounds); + editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + graphItem.Editor = editor; + + + GraphMultiController controller = new GraphMultiController(); + + for (int i = 0; i < graphItem.TechMonitor.ChannelCount; i++) { - var meterItem = new MeterItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); - MeterElementEditor editor = new MeterElementEditor(meterItem, bounds); - Elements.Add(editor); + controller.AddSeries(new RealTimeGraphEx.DataSeries.DataYSeries() + { + UseFillAndStroke = true, + Name = graphItem.TechMonitor.Name.First() + (i + 1).ToString(), + Stroke = new SolidColorBrush(ColorHelper.GetRandomColor()), + }); } - else if (SelectedTechItem is SingleGraphItem) + + editor.InnerGraph.Controller = controller; + + _multiControllers.Add(graphItem, controller); + + Elements.Add(editor); + } + else if (SelectedTechItem is MotorItem) + { + var motorItem = new MotorItem(Adapter.TechMotors.FirstOrDefault()); + MotorElementEditor editor = new MotorElementEditor(motorItem, bounds); + Elements.Add(editor); + InitMotorItem(motorItem); + } + } + + public void OnElementsRemoved(List elements) + { + //foreach (var element in elements) + //{ + // if (element.HostedElement is SingleGraphItem) + // { + // _singleControllers.Remove(element.HostedElement as SingleGraphItem); + // (element.HostedElement as SingleGraphItem).Editor.InnerGraph.InnerGraph.Dispose(); + // } + // else if (element.HostedElement is MultiGraphItem) + // { + // _multiControllers.Remove(element.HostedElement as MultiGraphItem); + // (element.HostedElement as MultiGraphItem).Editor.InnerGraph.InnerGraph.Dispose(); + // } + //} + } + + public void OnElementsPasted(List elements) + { + foreach (var element in elements) + { + if (element is SingleGraphElementEditor) { - var graphItem = new SingleGraphItem(Adapter.TechMonitors.Where(x => !x.MultiChannel).FirstOrDefault()); - SingleGraphElementEditor editor = new SingleGraphElementEditor(graphItem, bounds); - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + var graphItem = element.HostedElement as SingleGraphItem; + var editor = element as SingleGraphElementEditor; graphItem.Editor = editor; - + editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); GraphController controller = new GraphController(); editor.InnerGraph.Controller = controller; _singleControllers.Add(graphItem, controller); - - Elements.Add(editor); } - else if (SelectedTechItem is MultiGraphItem) + else if (element is MultiGraphElementEditor) { - var graphItem = new MultiGraphItem(Adapter.TechMonitors.Where(x => x.MultiChannel).FirstOrDefault()); - MultiGraphElementEditor editor = new MultiGraphElementEditor(graphItem, bounds); + var graphItem = element.HostedElement as MultiGraphItem; + var editor = element as MultiGraphElementEditor; editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); graphItem.Editor = editor; @@ -244,10 +311,65 @@ namespace Tango.MachineStudio.Technician.ViewModels editor.InnerGraph.Controller = controller; _multiControllers.Add(graphItem, controller); - - Elements.Add(editor); } } } + + private void InitMotorItem(MotorItem item) + { + item.ActionExecuted += async (x, action) => + { + if (action == MotorActionType.HomingStarted) + { + item.HomingProgress = 0; + item.IsHoming = true; + item.IsHomingCompleted = false; + + await Task.Factory.StartNew(() => + { + for (int i = 0; i < 101; i++) + { + item.HomingMaximumProgress = 100; + item.HomingProgress++; + + Thread.Sleep(60); + } + + item.IsHoming = false; + item.IsHomingCompleted = true; + }); + } + else if (action == MotorActionType.ForwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Forward, + }); + } + else if (action == MotorActionType.ForwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + else if (action == MotorActionType.BackwardPressed) + { + await MachineOperator.StartMotorJogging(new MotorJoggingRequest() + { + Code = item.TechMotor.Code, + Direction = MotorDirection.Backward, + }); + } + else if (action == MotorActionType.BackwardReleased) + { + await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() + { + Code = item.TechMotor.Code, + }); + } + }; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index f353c92d1..7cdd92e06 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -41,7 +41,7 @@ - + @@ -69,6 +69,17 @@ + + + + + + + + + + + @@ -87,6 +98,8 @@ x:Name="editor" Elements="{Binding Elements}" ElementCreation="ElementsEditor_ElementCreation" + ElementsRemoved="ElementsEditor_ElementsRemoved" + AfterPaste="ElementsEditor_AfterPaste" RulerHeight="32" EditorWidth="1920" EditorHeight="1080" @@ -98,7 +111,19 @@ SelectionFillBrush="#338D8D8D" SelectionStrokeBrush="{StaticResource AccentColorBrush}" BorderBrush="{StaticResource AccentColorBrush}" - BorderThickness="1" /> + BorderThickness="1"> + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs index 5944af1e2..6b84fb363 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -32,6 +32,13 @@ namespace Tango.MachineStudio.Technician.Views { _vm = DataContext as MachineTechViewVM; }; + + (editor.UndoRedoStatesProvider as ElementsEditorUndoRedoStatesProvider).StateExecuted += MachineTechView_StateExecuted; + } + + private void MachineTechView_StateExecuted(object sender, UndoRedoStateExecutedEventArgs e) + { + ElementsEditorUndoRedoState state = e.State as ElementsEditorUndoRedoState; } private void ElementsEditor_ElementCreation(object sender, ElementCreationEventArgs e) @@ -39,5 +46,20 @@ namespace Tango.MachineStudio.Technician.Views _vm.AddElement(e.Bounds); e.AppendUndoState = true; } + + private void ElementsEditor_ElementsRemoved(object sender, ElementsEventArgs e) + { + _vm.OnElementsRemoved(e.Elements); + } + + private void ElementsEditor_AfterPaste(object sender, ElementsEventArgs e) + { + _vm.OnElementsPasted(e.Elements); + } + + private void OnActionModeClicked(object sender, MouseButtonEventArgs e) + { + editor.DeselectElements(); + } } } -- cgit v1.3.1