diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-30 18:33:30 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-30 18:33:30 +0200 |
| commit | 4760444d7276aec024dac5fbbc202becc41105dd (patch) | |
| tree | 5993065e325350e782415c07c41bda25f504d854 /Software/Visual_Studio/MachineStudio | |
| parent | 78895e61c773c785dd8d8e3ed4f17236cdcefcd0 (diff) | |
| download | Tango-4760444d7276aec024dac5fbbc202becc41105dd.tar.gz Tango-4760444d7276aec024dac5fbbc202becc41105dd.zip | |
Machine designer working with spools !
PMR of dispenser & spools changed.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
7 files changed, 165 insertions, 2 deletions
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 84fffcc74..8b0a89336 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 @@ -1695,6 +1695,9 @@ namespace Tango.MachineStudio.Developer.ViewModels WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection(); SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection(); + LogManager.Log("Loading machine spools..."); + _activeJobDbContext.Spools.Where(x => x.MachineGuid == SelectedMachine.Guid).Load(); + LogManager.Log("Setting active job..."); ActiveJob = new JobBuilder(_activeJobDbContext).Set(SelectedMachineJob.Guid).WithUser().WithSegments().WithBrushStops().WithConfiguration().WithRML().Build(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index a55d7e696..6857df3c7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -102,6 +102,9 @@ <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> + <Compile Include="Views\SpoolsView.xaml.cs"> + <DependentUpon>SpoolsView.xaml</DependentUpon> + </Compile> <Page Include="Views\MachineDetailsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -130,6 +133,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\SpoolsView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index b0b97d7d4..a5b54fed2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -101,6 +101,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } + private Spool _selectedSpool; + public Spool SelectedSpool + { + get { return _selectedSpool; } + set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + #endregion #region Commands @@ -140,6 +148,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// </summary> public RelayCommand BackToMachinesCommand { get; set; } + /// <summary> + /// Gets or sets the add spool command. + /// </summary> + public RelayCommand AddSpoolCommand { get; set; } + + /// <summary> + /// Gets or sets the remove spool command. + /// </summary> + public RelayCommand RemoveSpoolCommand { get; set; } + #endregion #region Constructors @@ -165,8 +183,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels SaveCommand = new RelayCommand(SaveMachine); AddMachineCommand = new RelayCommand(AddNewMachine); RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine,() => SelectedMachine != null); + AddSpoolCommand = new RelayCommand(AddNewSpool); + RemoveSpoolCommand = new RelayCommand(RemoveSpool,() => SelectedSpool != null); } + #endregion #region Application Ready @@ -489,6 +510,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + if (ActiveMachine.Spools.GroupBy(x => x.SpoolType).Any(x => x.Count() > 1)) + { + errors.Add($"Same spool type is registered multiple times."); + } + if (errors.Count > 0) { String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; @@ -508,6 +534,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.LastUpdated = DateTime.UtcNow; ActiveMachine.ProductionDate = DateTime.UtcNow; await ActiveMachineAdapter.Context.SaveChangesAsync(); + await SelectedMachine.Reload(MachinesAdapter.Context); } } catch (Exception ex) @@ -554,6 +581,23 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels #endregion + private void AddNewSpool() + { + _activeMachineAdapter.Context.Spools.Add(new Spool() + { + Machine = ActiveMachine, + }); + } + + private void RemoveSpool() + { + if (SelectedSpool != null) + { + _activeMachineAdapter.Context.Spools.Remove(SelectedSpool); + ActiveMachine.Spools.Remove(SelectedSpool); + } + } + private async void OnFilterChanged() { if (Filter != null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index 4b021e424..5db96a3a1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -50,7 +50,7 @@ <local:ConfigurationView/> </TabItem> <TabItem Header="SPOOLS"> - + <local:SpoolsView/> </TabItem> </TabControl> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml index 63d1d2305..afd52f38d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -28,7 +28,7 @@ <local:MachineView DataContext="{Binding ActiveMachine}" IsHitTestVisible="False" /> <Border Grid.Column="1" Margin="100 140" CornerRadius="5" Background="#68F6F6F6" Padding="10" BorderBrush="Silver" BorderThickness="1"> - <Grid> + <Grid TextElement.Foreground="#3E3E3E"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml new file mode 100644 index 000000000..d04389ae7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml @@ -0,0 +1,81 @@ +<UserControl x:Class="Tango.MachineStudio.MachineDesigner.Views.SpoolsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.MachineDesigner" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + <Grid Margin="20"> + <DockPanel> + <Grid DockPanel.Dock="Bottom"> + + </Grid> + + <Grid Margin="0 20"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="38*"/> + <ColumnDefinition Width="117*"/> + </Grid.ColumnDefinitions> + + <local:MachineView Margin="30 80 0 0" DataContext="{Binding ActiveMachine}" IsHitTestVisible="False" VerticalAlignment="Top" Height="241" /> + + <DockPanel Grid.Column="1" Margin="50 100"> + <Grid DockPanel.Dock="Bottom"> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 0 0"> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="#FF7575" BorderBrush="#FF7575" Command="{Binding RemoveSpoolCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock> + </StackPanel> + </Button> + <Button Margin="0 0 0 0" MinWidth="160" Height="50" Background="#65C682" BorderBrush="#65C682" Command="{Binding AddSpoolCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">NEW SPOOL</TextBlock> + </StackPanel> + </Button> + </StackPanel> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + + </StackPanel> + </Grid> + <Grid> + <DataGrid Margin="0 0 0 10" SelectionUnit="FullRow" BorderBrush="Silver" BorderThickness="1" Background="#93FFFFFF" AlternatingRowBackground="#C9F6F6F6" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding ActiveMachine.Spools}" SelectedItem="{Binding SelectedSpool}"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridComboBoxColumn Header="SPOOL TYPE" SelectedItemBinding="{Binding SpoolType}" DisplayMemberPath="Name" Width="Auto"> + <DataGridComboBoxColumn.ElementStyle> + <Style TargetType="ComboBox"> + <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid},Path=DataContext.ActiveMachineAdapter.SpoolTypes}"/> + </Style> + </DataGridComboBoxColumn.ElementStyle> + <DataGridComboBoxColumn.EditingElementStyle> + <Style TargetType="ComboBox"> + <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid},Path=DataContext.ActiveMachineAdapter.SpoolTypes}"/> + </Style> + </DataGridComboBoxColumn.EditingElementStyle> + </DataGridComboBoxColumn> + <DataGridTextColumn Header="START OFFSET PULSES" Binding="{Binding StartOffsetPulses}" Width="Auto" /> + <DataGridTextColumn Header="BACKING RATE" Binding="{Binding BackingRate}" Width="Auto" /> + <DataGridTextColumn Header="SEGMENT OFFSET PULSES" Binding="{Binding SegmentOffsetPulses}" Width="Auto" /> + <DataGridTextColumn Header="BOTTOM BACKING RATE" Binding="{Binding BottomBackingRate}" Width="1*" /> + </DataGrid.Columns> + </DataGrid> + </Grid> + </DockPanel> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml.cs new file mode 100644 index 000000000..90a0c37f2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// <summary> + /// Interaction logic for SpoolsView.xaml + /// </summary> + public partial class SpoolsView : UserControl + { + public SpoolsView() + { + InitializeComponent(); + } + } +} |
