From 38ed93f95bb5af92bc84599ebb9c0c6895b0b989 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 2 Jul 2023 13:37:17 +0300 Subject: Job running progress bar. Set running background in progress bar by unit from right to left as auto reverse ( not animation). Bug in current segment in JobHandler. --- .../Controls/RunningJobViewerEureka.xaml | 15 ++- .../Controls/RunningJobViewerEureka.xaml.cs | 108 ++++++++++++++++++++- 2 files changed, 116 insertions(+), 7 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Controls') 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 39c032145..4c39bded0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml @@ -4,12 +4,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:converters="clr-namespace:Tango.PPC.UI.Converters" xmlns:local="clr-namespace:Tango.PPC.UI.Controls" xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" mc:Ignorable="d" + Name="RunningJobViewerEurekaContr" d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=local:RunningJobViewerEureka, IsDesignTimeCreatable=False}"> - + + MouseDown="SliderContentControl_MouseDown" TouchDown="SliderContentControl_TouchDown" SizeChanged="Slider_control_SizeChanged" > @@ -34,7 +36,9 @@ - + + + @@ -45,7 +49,7 @@ - + @@ -55,7 +59,8 @@ - + + 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 29efaad72..95fe5cd10 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 @@ -1,5 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,6 +25,24 @@ namespace Tango.PPC.UI.Controls /// public partial class RunningJobViewerEureka : UserControl { + List _segments; + + + + private double _prevOffset; + private double _addOffset; + private int _prevUnit; + + private double _controlWidth; + + public double ControlWidth + { + get { return _controlWidth; } + set { + _controlWidth = value;//for debug + } + } + /// /// Maybe not necessary! /// @@ -43,7 +64,7 @@ namespace Tango.PPC.UI.Controls } public static readonly DependencyProperty DisplayMarkersProperty = DependencyProperty.Register("DisplayMarkers", typeof(bool), typeof(RunningJobViewerEureka), new PropertyMetadata(true)); - + /// /// Gets or sets the job. /// @@ -53,7 +74,40 @@ namespace Tango.PPC.UI.Controls set { SetValue(JobProperty, value); } } public static readonly DependencyProperty JobProperty = - DependencyProperty.Register("Job", typeof(Job), typeof(RunningJobViewerEureka), new PropertyMetadata(null)); + DependencyProperty.Register("Job", typeof(Job), typeof(RunningJobViewerEureka), new PropertyMetadata(null, (d, e) => (d as RunningJobViewerEureka).OnUpdateJob())); + + private void OnUpdateJob() + { + if(Job != null) + { + _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)); + //} + _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 + IsHasMultipleColorsSegments = true; + } + else + IsHasMultipleColorsSegments = false; + + SegmentsItemsControl.ItemsSource = _segments; + SegmentsItemsControl.InvalidateVisual(); + + _prevOffset = _addOffset = 0.0; + _prevUnit = 0; + ItemsBorder.SetValue(Canvas.LeftProperty, 0.0); + ItemsBorder.InvalidateVisual(); + } + } /// /// Gets or sets the running job status. @@ -121,7 +175,19 @@ namespace Tango.PPC.UI.Controls // Using a DependencyProperty as the backing store for ThumbHeight. This enables animation, styling, binding, etc... public static readonly DependencyProperty ThumbHeightProperty = DependencyProperty.Register("ThumbHeight", typeof(double), typeof(RunningJobViewerEureka), new FrameworkPropertyMetadata(0.0)); + + public bool IsHasMultipleColorsSegments + { + get { return (bool)GetValue(IsHasMultipleColorsSegmentsProperty); } + set { SetValue(IsHasMultipleColorsSegmentsProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsHasMultipleColorsSegments. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsHasMultipleColorsSegmentsProperty = + DependencyProperty.Register("IsHasMultipleColorsSegments", typeof(bool), typeof(RunningJobViewerEureka), new PropertyMetadata(false)); + + /// /// Initializes a new instance of the class. /// @@ -139,11 +205,49 @@ namespace Tango.PPC.UI.Controls { e.Handled = true; } + private void OnSliderValueChanged() { if(slider_control != null) + { slider_control.Value = SliderValue; + if(RunningJobStatus != null && RunningJobStatus.IsSettingUp == false && IsHasMultipleColorsSegments && ColorCanvas != null && ControlWidth > 0) + { + double progress = RunningJobStatus.CurrentUnitProgress; + double total = RunningJobStatus.CurrentUnitTotalProgress; + + int currentUnit = RunningJobStatus.CurrentUnit; + int totalUnits = Job.NumberOfUnits; + + double simpleoffset = ((progress / total) * ControlWidth) ; + + double multiplier = (((double)(totalUnits - 1)) / (double)totalUnits); + double offset = simpleoffset * multiplier; + + if(_prevUnit < currentUnit) + { + _addOffset = _prevOffset; + } + + offset += _addOffset; + + if (offset >= ControlWidth) + { + offset -= ControlWidth;//round + } + _prevOffset = offset; + _prevUnit = currentUnit; + + ItemsBorder.SetValue(Canvas.LeftProperty, (-1) * offset); + ItemsBorder.InvalidateVisual(); + } + } + } + + private void Slider_control_SizeChanged(object sender, SizeChangedEventArgs e) + { + ControlWidth = e.NewSize.Width; } } } -- cgit v1.3.1