diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-29 18:45:10 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-29 18:45:10 +0200 |
| commit | 5cda8b0a3ab579dd6f33b1cb19a1d295dc661d28 (patch) | |
| tree | ef9408ca50840d407f3c62bbcd19147739fde145 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer | |
| parent | 7e8ff4c3ca798d426eb6f381c5312a747f1bb800 (diff) | |
| download | Tango-5cda8b0a3ab579dd6f33b1cb19a1d295dc661d28.tar.gz Tango-5cda8b0a3ab579dd6f33b1cb19a1d295dc661d28.zip | |
Added gradient display of color Brush Stops.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
5 files changed, 379 insertions, 219 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs new file mode 100644 index 000000000..1588b7740 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs @@ -0,0 +1,41 @@ +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.DAL.Observables; + +namespace Tango.MachineStudio.Developer.Converters +{ + public class SegmentToGradientStopsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + Segment segment = value as Segment; + + GradientStopCollection stops = new GradientStopCollection(); + + foreach (var stop in segment.BrushStops) + { + stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d)); + } + + return stops; + } + catch + { + return null; + } + } + + 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/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 2bbd57b86..47604e64d 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 @@ -75,6 +75,7 @@ <Compile Include="Converters\BrushStopCMYKToColorConverter.cs" /> <Compile Include="Converters\BrushStopToColorConverter.cs" /> <Compile Include="Converters\DbRmlViewToEntityConverter.cs" /> + <Compile Include="Converters\SegmentToGradientStopsConverter.cs" /> <Compile Include="DeveloperModule.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\DBViewContextWrapper.cs" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 4e3b4ec13..a3be7a2d6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -37,7 +37,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> public ObservablesEntitiesAdapter Adapter { get; set; } - private Machine _selectedMachine; + protected Machine _selectedMachine; /// <summary> /// Gets or sets the selected machine. /// </summary> @@ -90,6 +90,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } private ProcessParametersTablesGroup _selectedGroupHistory; + /// <summary> /// Gets or sets the selected process parameters tables group history. /// </summary> @@ -348,9 +349,12 @@ namespace Tango.MachineStudio.Developer.ViewModels private void SetSegmentBrushStopsInkVolumes(Segment segment) { - foreach (var stop in segment.BrushStops) + if (!DesignMode) { - stop.SetInkVolumes(SelectedMachine.Configuration); + foreach (var stop in segment.BrushStops) + { + stop.SetInkVolumes(SelectedMachine.Configuration); + } } } @@ -470,7 +474,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (SelectedJob != null) { Segment seg = new Segment(); - seg.Name = "New Seg"; + seg.Name = "Untitled Segment"; SelectedJob.Segments.Add(seg); } } @@ -496,7 +500,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { SelectedMachine.Jobs.Add(new Job() { - Name = "New Job", + Name = "Untitled Job", CreationDate = DateTime.UtcNow, }); } @@ -583,6 +587,16 @@ namespace Tango.MachineStudio.Developer.ViewModels } /// <summary> + /// Switch the brush stop position in the segment. + /// </summary> + /// <param name="draggedStop">The dragged stop.</param> + /// <param name="droppedStop">The dropped stop.</param> + public void OnDropBrushStop(BrushStop draggedStop, BrushStop droppedStop) + { + SelectedSegment.BrushStops.Swap(draggedStop, droppedStop); + } + + /// <summary> /// Removes the graph. /// </summary> /// <param name="graph">The graph.</param> 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 73c00fea8..9c761309c 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 @@ -19,7 +19,7 @@ xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - d:DesignHeight="1080" d:DesignWidth="1920" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=True}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="1080" d:DesignWidth="1920" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <UserControl.Resources> <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}"> @@ -35,6 +35,7 @@ <localConverters:BrushStopToColorConverter x:Key="BrushStopToColorConverter" /> <localConverters:BrushStopCMYKToColorConverter x:Key="BrushStopCMYKToColorConverter" /> <localConverters:BrushStopLabToColorConverter x:Key="BrushStopLabToColorConverter" /> + <localConverters:SegmentToGradientStopsConverter x:Key="SegmentToGradientStopsConverter" /> <SolidColorBrush x:Key="SideBarBackground" Color="#F9F9F9"> @@ -73,6 +74,40 @@ </Style.Triggers> </Style> + <Style x:Key="brushStopBorder" TargetType="Border"> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform> + </Setter.Value> + </Setter> + <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.Droppable" Value="True"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.Draggable" Value="True"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter> + <Style.Triggers> + <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True"> + <Setter Property="Opacity" Value="0.5"></Setter> + <Trigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation> + <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.EnterActions> + <Trigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation> + <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.ExitActions> + </Trigger> + </Style.Triggers> + </Style> + <Style x:Key="draggableGrid" TargetType="Grid"> <Setter Property="RenderTransform"> <Setter.Value> @@ -102,6 +137,18 @@ </Setter.Value> </Setter> </Style> + + <Style TargetType="ContentControl" x:Key="colorPicker"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate> + <colorPicker:ColorPickerCombo SelectedColorChanged="ColorPickerCombo_SelectedColorChanged" SelectedColor="{Binding Color,Mode=TwoWay}" Margin="30 0 0 0" VerticalAlignment="Center" Width="100" BorderBrush="{StaticResource AccentColorBrush}" Background="White"> + + </colorPicker:ColorPickerCombo> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> </UserControl.Resources> <Grid> @@ -295,7 +342,7 @@ <Grid> <Grid.RowDefinitions> <RowDefinition Height="234*"/> - <RowDefinition x:Name="graphRowDefinition" Height="161*"/> + <RowDefinition x:Name="graphRowDefinition" Height="440"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="173*"/> @@ -448,7 +495,7 @@ </Button> </StackPanel> - <ListBox ItemsSource="{Binding SelectedJob.Segments}" SelectedItem="{Binding SelectedSegment}"> + <ListBox SelectionChanged="ListBox_SelectionChanged" ItemsSource="{Binding SelectedJob.Segments}" SelectedItem="{Binding SelectedSegment}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="0 5 0 0"> @@ -503,10 +550,18 @@ <Grid Margin="0 20 0 0"> <DockPanel> - <StackPanel DockPanel.Dock="Top" Orientation="Horizontal"> - <Image Source="../Images/color-palette.png" Width="42"></Image> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">SEGMENT BRUSH</TextBlock> - </StackPanel> + <Grid DockPanel.Dock="Top"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <Image Source="../Images/color-palette.png" Width="42"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">SEGMENT BRUSH</TextBlock> + </StackPanel> + + <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="8" Margin="200 0 80 0" StrokeThickness="1" Stroke="Gainsboro"> + <Rectangle.Fill> + <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" x:Name="gradientBrush"></LinearGradientBrush> + </Rectangle.Fill> + </Rectangle> + </Grid> <Grid Margin="0 10 0 0"> <ListBox Style="{x:Null}" ScrollViewer.CanContentScroll="False" BorderThickness="0" ItemsSource="{Binding SelectedSegment.BrushStops}" SelectedItem="{Binding SelectedBrushStop}" HorizontalContentAlignment="Stretch"> <ListBox.ItemContainerStyle> @@ -516,224 +571,203 @@ </ListBox.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type observables:BrushStop}"> - <Border BorderThickness="1" CornerRadius="5" Margin="0 0 0 5" Padding="10"> - <Border.Style> - <Style TargetType="Border"> - <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"> - <Setter Property="BorderBrush" Value="Gainsboro"></Setter> - <Setter Property="Background" Value="{StaticResource SideBarBackground}"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </Border.Style> - <Grid> - <DockPanel> - <ContentControl DockPanel.Dock="Left"> - <ContentControl.Style> - <Style TargetType="ContentControl"> - <Setter Property="Content"> - <Setter.Value> - <Rectangle/> - </Setter.Value> - </Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding ColorSpace.Name}" Value="Volume"> - <Setter Property="Content"> - <Setter.Value> - <StackPanel VerticalAlignment="Center"> - <ItemsControl ItemsSource="{Binding InkVolumes}" VerticalAlignment="Center"> - <ItemsControl.ItemsPanel> - <ItemsPanelTemplate> - <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> - </ItemsPanelTemplate> - </ItemsControl.ItemsPanel> - <ItemsControl.ItemTemplate> - <DataTemplate> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0"> - <Border.BorderBrush> - <SolidColorBrush Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter}}"></SolidColorBrush> - </Border.BorderBrush> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Volume, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="0" Maximum="1000" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> - </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> - </StackPanel> - </Setter.Value> - </Setter> - </DataTrigger> - <DataTrigger Binding="{Binding ColorSpace.Name}" Value="RGB"> - <Setter Property="Content"> - <Setter.Value> - <StackPanel Orientation="Horizontal"> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FF6F6F"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Red, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + + <Border BorderThickness="1" CornerRadius="5" Margin="0 0 0 5" Padding="10" Background="Transparent" dragAndDrop:DragAndDropService.Drop="OnBrushStopBorderDrop"> + <Border.Style> + <Style TargetType="Border" BasedOn="{StaticResource brushStopBorder}"> + <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"> + <Setter Property="BorderBrush" Value="Gainsboro"></Setter> + <Setter Property="Background" Value="{StaticResource SideBarBackground}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Grid> + <DockPanel> + <ContentControl DockPanel.Dock="Left"> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content"> + <Setter.Value> + <Rectangle/> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ColorSpace.Name}" Value="Volume"> + <Setter Property="Content"> + <Setter.Value> + <StackPanel VerticalAlignment="Center"> + <ItemsControl ItemsSource="{Binding InkVolumes}" VerticalAlignment="Center"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" IsItemsHost="True"></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0"> + <Border.BorderBrush> + <SolidColorBrush Color="{Binding IdsPack.LiquidType.Color,Converter={StaticResource ColorToIntegerConverter}}"></SolidColorBrush> + </Border.BorderBrush> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Volume, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="0" Maximum="1000" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </StackPanel> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding ColorSpace.Name}" Value="RGB"> + <Setter Property="Content"> + <Setter.Value> + <StackPanel Orientation="Horizontal"> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FF6F6F"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Red, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#92FF92"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Green, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#92FF92"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Green, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#3C7EF4"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Blue, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#3C7EF4"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Blue, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="255" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <colorPicker:ColorPickerCombo Margin="30 0 0 0" VerticalAlignment="Center" Width="100" BorderBrush="{StaticResource AccentColorBrush}" Background="White"> - <colorPicker:ColorPickerCombo.SelectedColor> - <MultiBinding Converter="{StaticResource BrushStopToColorConverter}"> - <Binding Path="Red"></Binding> - <Binding Path="Green"></Binding> - <Binding Path="Blue"></Binding> - </MultiBinding> - </colorPicker:ColorPickerCombo.SelectedColor> - </colorPicker:ColorPickerCombo> - </StackPanel> - </Setter.Value> - </Setter> - </DataTrigger> - <DataTrigger Binding="{Binding ColorSpace.Name}" Value="CMYK"> - <Setter Property="Content"> - <Setter.Value> - <StackPanel Orientation="Horizontal"> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Cyan"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Cyan, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <ContentControl Style="{StaticResource colorPicker}"></ContentControl> + </StackPanel> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding ColorSpace.Name}" Value="CMYK"> + <Setter Property="Content"> + <Setter.Value> + <StackPanel Orientation="Horizontal"> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Cyan"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Cyan, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Magenta"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Magenta, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Magenta"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Magenta, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Yellow"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Yellow, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Yellow"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Yellow, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Black"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Black, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Black"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding Black, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0" HideUpDownButtons="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Rectangle Margin="30 0 0 0" Width="50" Height="50" StrokeThickness="1" Stroke="Gray"> - <Rectangle.Fill> - <SolidColorBrush> - <SolidColorBrush.Color> - <MultiBinding Converter="{StaticResource BrushStopCMYKToColorConverter}"> - <Binding Path="Cyan"></Binding> - <Binding Path="Magenta"></Binding> - <Binding Path="Yellow"></Binding> - <Binding Path="Black"></Binding> - </MultiBinding> - </SolidColorBrush.Color> - </SolidColorBrush> - </Rectangle.Fill> - </Rectangle> - </StackPanel> - </Setter.Value> - </Setter> - </DataTrigger> - <DataTrigger Binding="{Binding ColorSpace.Name}" Value="LAB"> - <Setter Property="Content"> - <Setter.Value> - <StackPanel Orientation="Horizontal"> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Gray"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding L, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Rectangle Margin="30 0 0 0" Width="50" Height="50" StrokeThickness="1" Stroke="Gray"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding Color}"> + </SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </StackPanel> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding ColorSpace.Name}" Value="LAB"> + <Setter Property="Content"> + <Setter.Value> + <StackPanel Orientation="Horizontal"> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="Gray"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding L, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FF8A8A"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding A, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FF8A8A"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding A, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FFFF8A"> - <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding B, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> - <mahapps:NumericUpDown.Resources> - <Style TargetType="TextBox"/> - </mahapps:NumericUpDown.Resources> - </mahapps:NumericUpDown> - </Border> + <Border BorderThickness="1" Width="50" Height="50" CornerRadius="50" Margin="10 0 0 0" BorderBrush="#FFFF8A"> + <mahapps:NumericUpDown FontSize="14" FontFamily="digital-7" HorizontalAlignment="Center" Value="{Binding B, Mode=TwoWay}" Background="Transparent" Width="40" StringFormat="0.0" HideUpDownButtons="True" Minimum="-100" Maximum="100" InterceptArrowKeys="True" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Center"> + <mahapps:NumericUpDown.Resources> + <Style TargetType="TextBox"/> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> + </Border> - <Rectangle Margin="30 0 0 0" Width="50" Height="50" StrokeThickness="1" Stroke="Gray"> - <Rectangle.Fill> - <SolidColorBrush> - <SolidColorBrush.Color> - <MultiBinding Converter="{StaticResource BrushStopLabToColorConverter}"> - <Binding Path="L"></Binding> - <Binding Path="A"></Binding> - <Binding Path="B"></Binding> - </MultiBinding> - </SolidColorBrush.Color> - </SolidColorBrush> - </Rectangle.Fill> - </Rectangle> - </StackPanel> - </Setter.Value> - </Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </ContentControl.Style> - </ContentControl> + <Rectangle Margin="30 0 0 0" Width="50" Height="50" StrokeThickness="1" Stroke="Gray"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding Color}"> + </SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </StackPanel> + </Setter.Value> + </Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + </ContentControl> - <Grid DockPanel.Dock="Right"> - <Border Style="{StaticResource JobFieldBorder}"> - <StackPanel Margin="5" Width="140"> - <StackPanel Orientation="Horizontal"> - <Image Source="../Images/colorspace.png" Width="24"></Image> - <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Color Space</TextBlock> + <Grid DockPanel.Dock="Right"> + <Border Style="{StaticResource JobFieldBorder}"> + <StackPanel Margin="5" Width="140"> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/colorspace.png" Width="24"></Image> + <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Color Space</TextBlock> + </StackPanel> + <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Adapter.ColorSpaces}" SelectedItem="{Binding ColorSpace}" DisplayMemberPath="Name"></ComboBox> </StackPanel> - <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Adapter.ColorSpaces}" SelectedItem="{Binding ColorSpace}" DisplayMemberPath="Name"></ComboBox> + </Border> + </Grid> + <Grid> + <StackPanel VerticalAlignment="Center"> + <TextBlock Width="150" TextAlignment="Center" HorizontalAlignment="Center"><Run FontWeight="Bold" FontStyle="Italic" Text="OFFSET:"></Run> <Run FontFamily="digital-7" Text="{Binding OffsetPercent,StringFormat={}{0:F1}%}"></Run></TextBlock> + <Slider ValueChanged="Offset_Slider_ValueChanged" Margin="0 5 0 0" HorizontalAlignment="Center" Width="150" Minimum="0" Maximum="100" Value="{Binding OffsetPercent}"></Slider> </StackPanel> - </Border> - </Grid> - <Grid> - <StackPanel VerticalAlignment="Center"> - <TextBlock Width="150" TextAlignment="Center" HorizontalAlignment="Center"><Run FontWeight="Bold" FontStyle="Italic" Text="OFFSET:"></Run> <Run FontFamily="digital-7" Text="{Binding OffsetPercent,StringFormat={}{0:F1}%}"></Run></TextBlock> - <Slider Margin="0 5 0 0" HorizontalAlignment="Center" Width="150" Minimum="0" Maximum="100" Value="{Binding OffsetPercent}"></Slider> - </StackPanel> - </Grid> - </DockPanel> - </Grid> - </Border> + </Grid> + </DockPanel> + </Grid> + </Border> + </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> @@ -821,6 +855,7 @@ </Grid> </Grid> + </Grid> <Grid Grid.Row="1" Grid.ColumnSpan="2" Background="{StaticResource SideBarBackground}"> @@ -940,7 +975,37 @@ <TextBlock VerticalAlignment="Center" Margin="5 -1 0 0" Foreground="Gray">Show Graphs</TextBlock> </StackPanel> </Border> - <dragAndDrop:DraggingSurface x:Name="draggingSurface" /> + </Grid> + + <Grid Grid.ColumnSpan="3" Background="White" Visibility="Collapsed"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleY="1" ScaleX="0"></ScaleTransform> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSideBarOpened}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.5"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0" Duration="00:00:0.5"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40">MONITORING</TextBlock> </Grid> </Grid> </Grid> @@ -1113,5 +1178,6 @@ </Button> </Grid> + <dragAndDrop:DraggingSurface x:Name="draggingSurface" /> </Grid> </UserControl> 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 c4e853433..52febe37b 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 @@ -14,6 +14,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Tango.DAL.Observables; using Tango.DragAndDrop; +using Tango.MachineStudio.Developer.Converters; using Tango.MachineStudio.Developer.ViewModels; namespace Tango.MachineStudio.Developer.Views @@ -43,7 +44,7 @@ namespace Tango.MachineStudio.Developer.Views _vm = DataContext as MainViewVM; }; - chkGraphs.Checked += (x, y) => { graphRowDefinition.Height = new GridLength(161, GridUnitType.Star); }; + chkGraphs.Checked += (x, y) => { graphRowDefinition.Height = new GridLength(440, GridUnitType.Pixel); }; chkGraphs.Unchecked += (x, y) => { graphRowDefinition.Height = new GridLength(80, GridUnitType.Pixel); }; } @@ -54,5 +55,42 @@ namespace Tango.MachineStudio.Developer.Views _vm.OnDropAvailableSensor(e.Draggable.DataContext as Sensor); } } + + private void ColorPickerCombo_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color?> e) + { + UpdateGradientBrushDisplay(); + } + + private void Offset_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) + { + UpdateGradientBrushDisplay(); + } + + private void UpdateGradientBrushDisplay() + { + if (_vm.SelectedSegment != null) + { + SegmentToGradientStopsConverter converter = new SegmentToGradientStopsConverter(); + GradientStopCollection stops = converter.Convert(_vm.SelectedSegment, null, null, null) as GradientStopCollection; + gradientBrush.GradientStops = stops; + } + else + { + gradientBrush.GradientStops = new GradientStopCollection(); + } + } + + private void OnBrushStopBorderDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is BrushStop) + { + _vm.OnDropBrushStop(e.Draggable.DataContext as BrushStop, e.Droppable.DataContext as BrushStop); + } + } + + private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + UpdateGradientBrushDisplay(); + } } } |
