aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-30 20:38:49 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-30 20:38:49 +0200
commit2fa92ca3654ebb274482f9bad86231028d357e5a (patch)
tree2d5bbce513317f05f82726b74b0ad6cf78db96f6 /Software/Visual_Studio/MachineStudio
parentd3ba251f01ae987a14b6379e733a06dbcd77f9e4 (diff)
downloadTango-2fa92ca3654ebb274482f9bad86231028d357e5a.tar.gz
Tango-2fa92ca3654ebb274482f9bad86231028d357e5a.zip
Started working on job brush display.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs37
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs45
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs46
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml54
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml1
8 files changed, 181 insertions, 8 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
index 53efd50b8..62d678888 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
@@ -37,7 +37,7 @@ namespace Tango.MachineStudio.Developer.Converters
}
else
{
- return 100;
+ return 100d;
}
}
catch
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs
new file mode 100644
index 000000000..ac6e53be8
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class JobToColumnDefinitionsConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ Job job = value as Job;
+
+ List<ColumnDefinition> columns = new List<ColumnDefinition>();
+
+ double totalLength = job.Segments.Sum(x => x.Length);
+
+ foreach (var segment in job.Segments)
+ {
+ columns.Add(new ColumnDefinition() { Width = new GridLength(segment.Length / totalLength, GridUnitType.Star) });
+ }
+
+ return columns;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
new file mode 100644
index 000000000..959fb6410
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentLengthToWidthConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ if (values.Length == 4)
+ {
+ Job job = values[0] as Job;
+ double jobLength = System.Convert.ToDouble(values[1]);
+ double elementWidth = System.Convert.ToDouble(values[2]);
+ double segmentLength = System.Convert.ToDouble(values[3]);
+ double totalLength = job.Length;
+
+ return (segmentLength / totalLength) * elementWidth;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch
+ {
+ return 0;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
new file mode 100644
index 000000000..68ff95a9c
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentToGradientStopsConverterMulti : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Segment segment = values[0] as Segment;
+
+ if (segment != null)
+ {
+ GradientStopCollection stops = new GradientStopCollection();
+
+ foreach (var stop in segment.BrushStops)
+ {
+ stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
+ }
+
+ return stops;
+ }
+
+ return null;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
index 1865ff11a..7d6712318 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
@@ -77,6 +77,9 @@
<Compile Include="Converters\BrushStopToOffsetLimitConverter.cs" />
<Compile Include="Converters\DbRmlViewToEntityConverter.cs" />
<Compile Include="Converters\InkVolumeToLiquidRmlFactor.cs" />
+ <Compile Include="Converters\JobToColumnDefinitionsConverter.cs" />
+ <Compile Include="Converters\SegmentLengthToWidthConverter.cs" />
+ <Compile Include="Converters\SegmentToGradientStopsConverterMulti.cs" />
<Compile Include="Converters\SegmentToGradientStopsConverter.cs" />
<Compile Include="DeveloperModule.cs" />
<Compile Include="ViewModelLocator.cs" />
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
index 6e4d69d05..e0786a1ba 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
@@ -37,11 +37,16 @@
<localConverters:BrushStopLabToColorConverter x:Key="BrushStopLabToColorConverter" />
<localConverters:SegmentToGradientStopsConverter x:Key="SegmentToGradientStopsConverter" />
<localConverters:BrushStopToOffsetLimitConverter x:Key="BrushStopToOffsetLimitConverter" />
+ <localConverters:JobToColumnDefinitionsConverter x:Key="JobToColumnDefinitionsConverter" />
+ <localConverters:SegmentLengthToWidthConverter x:Key="SegmentLengthToWidthConverter" />
+ <localConverters:SegmentToGradientStopsConverterMulti x:Key="SegmentToGradientStopsConverterMulti" />
<SolidColorBrush x:Key="SideBarBackground" Color="#F9F9F9">
</SolidColorBrush>
+ <Color x:Key="dummyColor">Transparent</Color>
+
<Style x:Key="droppableGrid" TargetType="Grid">
<Setter Property="RenderTransform">
<Setter.Value>
@@ -599,7 +604,7 @@
<Setter Property="BorderBrush" Value="{StaticResource SideBarBackground}"></Setter>
<Setter Property="Background" Value="White"></Setter>
<Style.Triggers>
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True">
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected,FallbackValue=False}" Value="True">
<Setter Property="BorderBrush" Value="Gainsboro"></Setter>
<Setter Property="Background" Value="{StaticResource SideBarBackground}"></Setter>
</DataTrigger>
@@ -838,10 +843,10 @@
<DataGridTemplateColumn Header="IDS PACK">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
- <Grid>
- <Polygon Points="0,0 20,0 0,20 0,0" Margin="-15 -11 0 0">
+ <Grid x:Name="t0">
+ <Polygon x:Name="t1" Points="0,0 20,0 0,20 0,0" Margin="-15 -11 0 0">
<Polygon.Fill>
- <SolidColorBrush Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter}}" />
+ <SolidColorBrush x:Name="t2" Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter},FallbackValue={StaticResource dummyColor}}" />
</Polygon.Fill>
</Polygon>
<TextBlock TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding IdsPack.LiquidType.Name}"></TextBlock>
@@ -964,7 +969,45 @@
</Grid>
<Grid>
- <Rectangle VerticalAlignment="Center" Height="10" Margin="20 0 20 0" Stroke="Gainsboro" StrokeThickness="1"></Rectangle>
+ <Border VerticalAlignment="Center" Height="10" Margin="20 0 20 0" BorderBrush="Gainsboro" BorderThickness="1">
+ <Grid>
+ <ItemsControl ItemsSource="{Binding SelectedJob.Segments}" x:Name="jobBrushList">
+ <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="DataContext.SelectedJob"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding>
+ <Binding Path="Length"></Binding>
+ </MultiBinding>
+ </Grid.Width>
+ <Rectangle>
+ <Rectangle.Fill>
+ <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
+ <LinearGradientBrush.GradientStops>
+ <MultiBinding Converter="{StaticResource SegmentToGradientStopsConverterMulti}">
+ <Binding Path="."></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedBrushStop.Color"></Binding>
+ </MultiBinding>
+ </LinearGradientBrush.GradientStops>
+ </LinearGradientBrush>
+ </Rectangle.Fill>
+ </Rectangle>
+ </Grid>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Grid>
+ </Border>
</Grid>
</DockPanel>
</Grid>
@@ -1313,7 +1356,6 @@
<TextBox Style="{x:Null}" Background="Transparent" Foreground="Black" BorderThickness="0" Text="{Binding MaxNlPerCm}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontWeight="Bold" FontStyle="Italic"></TextBox>
</Grid>
- <!--<mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding MaxNlPerCm,Mode=TwoWay}"></mahapps:NumericUpDown>-->
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
index c9796fbe2..c76cf657f 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
@@ -73,6 +73,7 @@ namespace Tango.MachineStudio.Developer.Views
SegmentToGradientStopsConverter converter = new SegmentToGradientStopsConverter();
GradientStopCollection stops = converter.Convert(_vm.SelectedSegment, null, null, null) as GradientStopCollection;
gradientBrush.GradientStops = stops;
+ jobBrushList.UpdateLayout();
}
else
{
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
index 37ed4cd3c..56ffcd5d1 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
@@ -310,7 +310,6 @@
<Style TargetType="{x:Type ListBoxItem}" x:Key="basicListBoxItem">
<Setter Property="Background" Value="Transparent"/>
- <Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay}"></Setter>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>