aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Controls')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs108
2 files changed, 116 insertions, 7 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 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}">
<UserControl.Resources>
-
+ <converters:DoubleWidthConverter x:Key="DoubleWidthConverter" />
</UserControl.Resources>
<Grid>
<touch:SliderContentControl x:Name="slider_control" ThumbColor="{StaticResource TangoPrimaryAccentColor}"
@@ -19,7 +21,7 @@
Minimum="{Binding RelativeSource={RelativeSource AncestorType=local:RunningJobViewerEureka}, Path=MinimumValue}"
Maximum="{Binding RelativeSource={RelativeSource AncestorType=local:RunningJobViewerEureka}, Path=MaximumValue}"
- MouseDown="SliderContentControl_MouseDown" TouchDown="SliderContentControl_TouchDown">
+ MouseDown="SliderContentControl_MouseDown" TouchDown="SliderContentControl_TouchDown" SizeChanged="Slider_control_SizeChanged" >
<Border x:Name="brush_border" ClipToBounds="False" CornerRadius="7" Margin="0 0 0 0" Background="{StaticResource TangoLightForegroundBrush}">
@@ -34,7 +36,9 @@
</RectangleGeometry>
</Border.Clip>
<Grid>
- <ItemsControl ClipToBounds="False" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:RunningJobViewerEureka},Path=RunningJobStatus.CurrentUnitSegments, Delay=100}">
+ <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>
@@ -45,7 +49,7 @@
<Grid>
<Grid.Width>
<MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}">
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="RunningJobStatus.CurrentUnitTotalProgress"></Binding>
+ <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>
@@ -55,7 +59,8 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
-
+ </Border>
+ </Canvas>
<Rectangle Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="1" StrokeDashArray="5 5 5 5" RadiusX="7" RadiusY="7" />
</Grid>
</Border>
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;
}
}
}