diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-12-16 15:27:38 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-12-16 15:27:38 +0200 |
| commit | f4929c38abd1389377d30fca6c9304d2d6639d30 (patch) | |
| tree | ae788297462912e3fa27d866c5a0aaadaa2e996f /Software/Visual_Studio | |
| parent | 61fabd3e525954b941263e9724e8a267f58c6f01 (diff) | |
| download | Tango-f4929c38abd1389377d30fca6c9304d2d6639d30.tar.gz Tango-f4929c38abd1389377d30fca6c9304d2d6639d30.zip | |
Undo/Redo Length of segment.
Diffstat (limited to 'Software/Visual_Studio')
9 files changed, 106 insertions, 5 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs index 3730f56ac..3b4644a8d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs @@ -68,7 +68,17 @@ namespace Tango.PPC.Jobs.Models } } } + public void LengthBeforeChange(double value) + { + _lastLength = Length; + } + public void LengthChanged(double value) + { + UndoRedoManager.Instance.InsertAndExecuteCommand(new ChangeLengthCommand(this, _lastLength, value)); + _lastLength = Length; + } + protected Int32 _segmentindex; /// <summary> /// Gets or sets the index of the segment. @@ -439,6 +449,7 @@ namespace Tango.PPC.Jobs.Models RightOffset = 100; IsOffsetChanged = false; Length = 5; + _lastLength = 5; IsSelected = false; IsLast = false; _enableintersegment = false; @@ -680,10 +691,10 @@ namespace Tango.PPC.Jobs.Models /// <param name="length"></param> protected void OnLengthChanged(double length) { - if (_lastLength != length) + //if (_lastLength != length) { BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged()); - _lastLength = Length; + //_lastLength = Length; //RaisePropertyChanged(nameof(LengthWithFactor)); RaisePropertyChanged(nameof(LengthWithInterSegment)); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index 43959f144..a38818ffb 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -286,6 +286,7 @@ </Compile> <Compile Include="UndoRedoCommands\AddBrushStopCommand.cs" /> <Compile Include="UndoRedoCommands\AddNewSegmentCommand.cs" /> + <Compile Include="UndoRedoCommands\ChangeLengthCommand.cs" /> <Compile Include="UndoRedoCommands\ChangeOffsetCommand.cs" /> <Compile Include="UndoRedoCommands\CopySegmentCommand.cs" /> <Compile Include="UndoRedoCommands\DuplicateSegmentCommand.cs" /> @@ -626,7 +627,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs index 18211a5d1..35d1629e0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs @@ -24,6 +24,8 @@ namespace Tango.PPC.Jobs.UndoRedoCommands public void Execute() { + if (_segment == null) + return; //SolidColor if (_segment.BrushStops.Count == 0) { @@ -64,7 +66,10 @@ namespace Tango.PPC.Jobs.UndoRedoCommands public void UnExecute() { - if(_createdNewSegment != null) + if (_segment == null) + return; + + if (_createdNewSegment != null) { BrushStopModel secondbrush = _createdNewSegment.SecondBrushStop; _segment.AddOrReplaceSecondBrush(secondbrush); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeLengthCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeLengthCommand.cs new file mode 100644 index 000000000..558242c48 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeLengthCommand.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.UndoRedoCommands +{ + public class ChangeLengthCommand : IUndoRedoCommand + { + private SegmentModel _segment; + private double _oldValue; + private double _newValue; + + public ChangeLengthCommand(SegmentModel segment, double oldvalue, double newValue) + { + _segment = segment; + _oldValue = oldvalue; + _newValue = newValue; + } + + public void Execute() + { + if (_segment == null) + return; + + _segment.Length = _newValue; + } + + public void UnExecute() + { + if (_segment == null) + return; + + _segment.Length = _oldValue; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeOffsetCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeOffsetCommand.cs index f3776ecbe..d96817335 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeOffsetCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/ChangeOffsetCommand.cs @@ -25,6 +25,9 @@ namespace Tango.PPC.Jobs.UndoRedoCommands } public void Execute() { + if (_segment == null) + return; + switch (_type) { case OffsetType.Left: @@ -49,6 +52,9 @@ namespace Tango.PPC.Jobs.UndoRedoCommands public void UnExecute() { + if (_segment == null) + return; + switch (_type) { case OffsetType.Left: diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UndoRedoManager.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UndoRedoManager.cs index 9e8a2a351..3b926f4eb 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UndoRedoManager.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UndoRedoManager.cs @@ -32,6 +32,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands _UndoCommands.Push(command); command.Execute(); } + public void Redo() { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index 4d4714497..ee5a58264 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -223,7 +223,7 @@ </StackPanel> <StackPanel Margin="0 0 0 0" Orientation="Horizontal"> <controls:FastTextBlock VerticalAlignment="Bottom" DockPanel.Dock="Left" Text="Length (m):" FontSize="18"></controls:FastTextBlock> - <touch:TouchNumericTextBox Margin="20 0 0 0" Width="92" DockPanel.Dock="Right" Value="{Binding Length, UpdateSourceTrigger=LostFocus}" StringFormat="0.0" AutoCalculateJogStep="False" HasDecimalPoint="True" Minimum="1" Maximum="100000" KeyboardContainer="{Binding ElementName=Container}" FontSize="18"/> + <touch:TouchNumericTextBox Margin="20 0 0 0" Width="92" DockPanel.Dock="Right" Value="{Binding Length, UpdateSourceTrigger=LostFocus}" StringFormat="0.0" AutoCalculateJogStep="False" HasDecimalPoint="True" Minimum="1" Maximum="100000" KeyboardContainer="{Binding ElementName=Container}" FontSize="18" ValueChangedEnd="Length_ValueChanged" TextGotFocus="Length_BeforeChangeValue"/> </StackPanel> </StackPanel> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs index 66c497e29..31a7f7918 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Shapes; using Tango.BL; using Tango.BL.Entities; using Tango.Core.DI; +using Tango.PPC.Jobs.Models; using Tango.PPC.Jobs.ViewContracts; using Tango.PPC.Jobs.ViewModels; using static Tango.SharedUI.Controls.NavigationControl; @@ -137,5 +138,23 @@ namespace Tango.PPC.Jobs.Views //scrollViewer.ScrollToTop(); } + private void Length_ValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + var segmentModel = (sender as FrameworkElement).DataContext as SegmentModel; + if(segmentModel != null) + { + segmentModel.LengthChanged(e.Value); + } + + } + private void Length_BeforeChangeValue(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + var segmentModel = (sender as FrameworkElement).DataContext as SegmentModel; + if (segmentModel != null) + { + segmentModel.LengthBeforeChange(e.Value); + } + + } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index ad185f1a3..224f2d25b 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -33,6 +33,20 @@ namespace Tango.Touch.Controls remove { RemoveHandler(ValueChangedEvent, value); } } + public static readonly RoutedEvent ValueChangedEndEvent = EventManager.RegisterRoutedEvent("ValueChangedEnd", RoutingStrategy.Bubble, typeof(DoubleValueChangedEventHandler), typeof(TouchNumericTextBox)); + public event DoubleValueChangedEventHandler ValueChangedEnd + { + add { AddHandler(ValueChangedEndEvent, value); } + remove { RemoveHandler(ValueChangedEndEvent, value); } + } + + public static readonly RoutedEvent TextGotFocusEvent = EventManager.RegisterRoutedEvent("TextGotFocus", RoutingStrategy.Bubble, typeof(DoubleValueChangedEventHandler), typeof(TouchNumericTextBox)); + public event DoubleValueChangedEventHandler TextGotFocus + { + add { AddHandler(TextGotFocusEvent, value); } + remove { RemoveHandler(TextGotFocusEvent, value); } + } + public double Value { get { return (double)GetValue(ValueProperty); } @@ -155,6 +169,8 @@ namespace Tango.Touch.Controls { _text_box.CaretIndex = _text_box.Text.Length; } + DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(TextGotFocusEvent, this, Value); + RaiseEvent(args); } private object CoerceValue(DependencyObject d, object e) @@ -205,6 +221,9 @@ namespace Tango.Touch.Controls DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); RaiseEvent(args); + + DoubleValueChangedEventArgs args2 = new DoubleValueChangedEventArgs(ValueChangedEndEvent, this, Value); + RaiseEvent(args2); } private void _text_box_PreviewKeyDown(object sender, KeyEventArgs e) |
