diff options
| author | Roy <Roy.mail.net@gmail.com> | 2023-09-03 16:10:39 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2023-09-03 16:10:39 +0300 |
| commit | b271fe1c21172ed22a34b987a2cb9457b39ce8a3 (patch) | |
| tree | dc53a5a561a08874a3aeccbcb50f725b9b3f2507 /Software/Visual_Studio/PPC/Tango.PPC.UI/Controls | |
| parent | 96f130f14b92ed55251a143a4ded92910dd398a1 (diff) | |
| parent | f5382442f379b35f301c5e0f6871f19c004a48af (diff) | |
| download | Tango-b271fe1c21172ed22a34b987a2cb9457b39ce8a3.tar.gz Tango-b271fe1c21172ed22a34b987a2cb9457b39ce8a3.zip | |
Merge branch 'eureka' of https://twinetfs.visualstudio.com/Tango/_git/Tango into eureka
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Controls')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml | 72 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs | 66 |
2 files changed, 102 insertions, 36 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml index 4c39bded0..dfbd47514 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml @@ -12,6 +12,7 @@ d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=local:RunningJobViewerEureka, IsDesignTimeCreatable=False}"> <UserControl.Resources> <converters:DoubleWidthConverter x:Key="DoubleWidthConverter" /> + <converters:ProgressBorderWidthConverter x:Key="ProgressBorderWidthConverter" /> </UserControl.Resources> <Grid> <touch:SliderContentControl x:Name="slider_control" ThumbColor="{StaticResource TangoPrimaryAccentColor}" @@ -37,28 +38,59 @@ </Border.Clip> <Grid> <Canvas x:Name="ColorCanvas" Width="{Binding ElementName=slider_control, Path=ActualWidth}" Height="{Binding ElementName=slider_control, Path=ActualHeight}" ClipToBounds="True" > - <Border x:Name="ItemsBorder" ClipToBounds="False" Margin="0 0 0 0" Height="{Binding ElementName=slider_control, Path=ActualHeight}" Width="{Binding ElementName=brush_border, Path=ActualWidth, Converter={StaticResource DoubleWidthConverter}}" > - <ItemsControl x:Name="SegmentsItemsControl" ClipToBounds="False" > - <ItemsControl.ItemsPanel> - <ItemsPanelTemplate> - <StackPanel Orientation="Horizontal" ClipToBounds="False"></StackPanel> - </ItemsPanelTemplate> - </ItemsControl.ItemsPanel> - <ItemsControl.ItemTemplate> - <DataTemplate> + <Border x:Name="ItemsBorder" ClipToBounds="False" Margin="0 0 0 0" Height="{Binding ElementName=slider_control, Path=ActualHeight}" > + <Grid ClipToBounds="False" HorizontalAlignment="Stretch" > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> <Grid> - <Grid.Width> - <MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}"> - <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="RunningJobStatus.CurrentUnitTotalProgress" Converter="{StaticResource DoubleWidthConverter}"></Binding> - <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding> - <Binding Path="LengthWithFactor"></Binding> - </MultiBinding> - </Grid.Width> - <Rectangle Fill="{Binding SegmentBrush}"></Rectangle> + <ItemsControl HorizontalAlignment="Left" x:Name="SegmentsItemsControl" Width="{Binding ElementName=brush_border, Path=ActualWidth, Converter={StaticResource DoubleWidthConverter}}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" ></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Grid> + <Grid.Width> + <MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}"> + <Binding RelativeSource="{RelativeSource AncestorType=local:RunningJobViewerEureka}" Path="JobUnitLength" Converter="{StaticResource DoubleWidthConverter}"></Binding> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding> + <Binding Path="LengthWithFactor"></Binding> + </MultiBinding> + </Grid.Width> + <Rectangle Fill="{Binding SegmentBrush}"></Rectangle> + </Grid> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> </Grid> - </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> + <Grid Grid.Column="1"> + <ItemsControl x:Name="LastSegmentsItemsControl" HorizontalAlignment="Right" Margin="0 0 0 0" Width="{Binding ElementName=brush_border, Path=ActualWidth}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" ></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Grid> + <Grid.Width> + <MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}"> + <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="RunningJobStatus.CurrentUnitTotalProgress" ></Binding> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding> + <Binding Path="LengthWithFactor"></Binding> + </MultiBinding> + </Grid.Width> + <Rectangle Fill="{Binding SegmentBrush}"></Rectangle> + </Grid> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </Grid> + </Grid> </Border> </Canvas> <Rectangle Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="1" StrokeDashArray="5 5 5 5" RadiusX="7" RadiusY="7" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs index 95fe5cd10..60c5a0346 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Tango.BL.Entities; using Tango.Integration.Operation; +using Tango.Logging; namespace Tango.PPC.UI.Controls { @@ -26,9 +27,9 @@ namespace Tango.PPC.UI.Controls public partial class RunningJobViewerEureka : UserControl { List<Segment> _segments; + List<Segment> _lastsegments; + - - private double _prevOffset; private double _addOffset; private int _prevUnit; @@ -80,27 +81,36 @@ namespace Tango.PPC.UI.Controls { if(Job != null) { + JobUnitLength = Job.Length; _segments = Job.EffectiveSegments.ToList(); if (Job.NumberOfUnits > 1 && _segments.Count > 0 && (_segments.Count > 1 || _segments[0].BrushStops.Count > 1)) { - //if (Job.EnableInterSegment && Job.InterSegmentLength > 0) - //{ - // _segments.Add(Job.CreateInterSegment(Job.InterSegmentLength)); - //} + if (Job.EnableInterSegment && Job.InterSegmentLength > 0) + { + _segments.Add(Job.CreateInterSegment(Job.InterSegmentLength)); + } _segments.AddRange(Job.EffectiveSegments.ToList()); - //if (Job.EnableInterSegment && Job.InterSegmentLength > 0) - //{ - // _segments.Add(Job.CreateInterSegment(Job.InterSegmentLength)); - //}//without check if last segment and last unit + if(Job.NumberOfUnits > 2 && Job.EnableInterSegment && Job.InterSegmentLength > 0) + { + _segments.Add(Job.CreateInterSegment(Job.InterSegmentLength)); + JobUnitLength += Job.InterSegmentLength; + //_segments.AddRange(Job.EffectiveSegments.ToList());//third set to use in end printing without intersegment + } + _lastsegments = Job.EffectiveSegments.ToList();; + IsHasMultipleColorsSegments = true; } else + { IsHasMultipleColorsSegments = false; + } SegmentsItemsControl.ItemsSource = _segments; SegmentsItemsControl.InvalidateVisual(); + LastSegmentsItemsControl.ItemsSource = _lastsegments; + LastSegmentsItemsControl.InvalidateVisual(); _prevOffset = _addOffset = 0.0; _prevUnit = 0; @@ -188,6 +198,20 @@ namespace Tango.PPC.UI.Controls DependencyProperty.Register("IsHasMultipleColorsSegments", typeof(bool), typeof(RunningJobViewerEureka), new PropertyMetadata(false)); + + public double JobUnitLength + { + get { return (double)GetValue(JobUnitLengthProperty); } + set { SetValue(JobUnitLengthProperty, value); } + } + + // Using a DependencyProperty as the backing store for JobUnitLength. This enables animation, styling, binding, etc... + public static readonly DependencyProperty JobUnitLengthProperty = + DependencyProperty.Register("JobUnitLength", typeof(double), typeof(RunningJobViewerEureka), new FrameworkPropertyMetadata(0.0)); + + + + /// <summary> /// Initializes a new instance of the <see cref="RunningJobViewerEureka"/> class. /// </summary> @@ -212,14 +236,14 @@ namespace Tango.PPC.UI.Controls if(slider_control != null) { slider_control.Value = SliderValue; - if(RunningJobStatus != null && RunningJobStatus.IsSettingUp == false && IsHasMultipleColorsSegments && ColorCanvas != null && ControlWidth > 0) + if(RunningJobStatus != null && RunningJobStatus.IsSettingUp == false && IsHasMultipleColorsSegments && ColorCanvas != null && ControlWidth > 0 && RunningJobStatus.CurrentUnitProgress > 0.01 && RunningJobStatus.CurrentUnitTotalProgress > 0) { double progress = RunningJobStatus.CurrentUnitProgress; double total = RunningJobStatus.CurrentUnitTotalProgress; int currentUnit = RunningJobStatus.CurrentUnit; - int totalUnits = Job.NumberOfUnits; - + int totalUnits = RunningJobStatus.RemainingUnits + RunningJobStatus.CurrentUnit;//Job.NumberOfUnits; + double simpleoffset = ((progress / total) * ControlWidth) ; double multiplier = (((double)(totalUnits - 1)) / (double)totalUnits); @@ -227,15 +251,25 @@ namespace Tango.PPC.UI.Controls if(_prevUnit < currentUnit) { + if(_prevOffset == 0)//resume + { + _prevOffset = ControlWidth * (1-multiplier) * currentUnit; + } _addOffset = _prevOffset; } - + // Debug.WriteLine($"OnSliderValueChanged Offset: '{offset}' CurrentUnitProgress = {RunningJobStatus.CurrentUnitProgress} progress= {progress} currentUnit = {currentUnit}, total:{total}"); offset += _addOffset; - if (offset >= ControlWidth) + if (offset >= ControlWidth && currentUnit < (Job.NumberOfUnits - 2)) { - offset -= ControlWidth;//round + offset -= ControlWidth;//round + // Debug.WriteLine($"OnSliderValueChanged round!!! offset: '{offset}' currentUnit = {currentUnit}, total:{total}"); } + + //if(currentUnit == (Job.NumberOfUnits - 1)) + //{ + // Debug.WriteLine($"OnSliderValueChanged offset: '{offset}' currentUnit = {currentUnit}. ControlWidth = {ControlWidth} total:{total}"); + //} _prevOffset = offset; _prevUnit = currentUnit; |
