aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs108
1 files changed, 106 insertions, 2 deletions
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
/// </summary>
public partial class RunningJobViewerEureka : UserControl
{
+ List<Segment> _segments;
+
+
+
+ private double _prevOffset;
+ private double _addOffset;
+ private int _prevUnit;
+
+ private double _controlWidth;
+
+ public double ControlWidth
+ {
+ get { return _controlWidth; }
+ set {
+ _controlWidth = value;//for debug
+ }
+ }
+
/// <summary>
/// Maybe not necessary!
/// </summary>
@@ -43,7 +64,7 @@ namespace Tango.PPC.UI.Controls
}
public static readonly DependencyProperty DisplayMarkersProperty =
DependencyProperty.Register("DisplayMarkers", typeof(bool), typeof(RunningJobViewerEureka), new PropertyMetadata(true));
-
+
/// <summary>
/// Gets or sets the job.
/// </summary>
@@ -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();
+ }
+ }
/// <summary>
/// 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));
+
+
/// <summary>
/// Initializes a new instance of the <see cref="RunningJobViewerEureka"/> class.
/// </summary>
@@ -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;
}
}
}