aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs54
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml60
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs24
3 files changed, 67 insertions, 71 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
index 0da894aba..06a3c9ba4 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
@@ -33,27 +33,6 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
set { _currentVersion = value; RaisePropertyChangedAuto(); }
}
- private ObservableCollection<MotorType> _currentVersionMotorTypes;
- public ObservableCollection<MotorType> CurrentVersionMotorTypes
- {
- get { return _currentVersionMotorTypes; }
- set { _currentVersionMotorTypes = value; RaisePropertyChangedAuto(); }
- }
-
- private ObservableCollection<DancerType> _currentVersionDancerTypes;
- public ObservableCollection<DancerType> CurrentVersionDancerTypes
- {
- get { return _currentVersionDancerTypes; }
- set { _currentVersionDancerTypes = value; RaisePropertyChangedAuto(); }
- }
-
- private ObservableCollection<PidControl> _currentVersionPidControls;
- public ObservableCollection<PidControl> CurrentVersionPidControls
- {
- get { return _currentVersionPidControls; }
- set { _currentVersionPidControls = value; RaisePropertyChangedAuto(); }
- }
-
public RelayCommand SaveCommand { get; set; }
public MainViewVM()
@@ -66,47 +45,44 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
private void OnSelectedVersionChanged()
{
CurrentVersion = SelectedVersion.Clone();
- CurrentVersionDancerTypes = CurrentVersion.HardwareVersionsDancerTypes.Select(x => x.DancerType).ToObservableCollection();
- CurrentVersionMotorTypes = CurrentVersion.HardwareVersionsMotorTypes.Select(x => x.MotorType).ToObservableCollection();
- CurrentVersionPidControls = CurrentVersion.HardwareVersionsPidControls.Select(x => x.PidControl).ToObservableCollection();
}
- public void OnRemoveDancer(DancerType dancerType)
+ public void OnRemoveDancer(HardwareDancer dancer)
{
- CurrentVersionDancerTypes.Remove(dancerType);
+ CurrentVersion.HardwareDancers.Remove(dancer);
}
- public void OnRemoveMotor(MotorType motorType)
+ public void OnRemoveMotor(HardwareMotor motor)
{
- CurrentVersionMotorTypes.Remove(motorType);
+ CurrentVersion.HardwareMotors.Remove(motor);
}
- public void OnRemovePidControl(PidControl pidControl)
+ public void OnRemovePidControl(HardwarePidControl pidControl)
{
- CurrentVersionPidControls.Remove(pidControl);
+ CurrentVersion.HardwarePidControls.Remove(pidControl);
}
- public void OnMotorDrop(MotorType motorType)
+ public void OnMotorDrop(HardwareMotorType motorType)
{
- if (!CurrentVersionMotorTypes.Contains(motorType))
+ if (!CurrentVersion.HardwareMotors.ToList().Exists(x => x.HardwareMotorType == motorType))
{
- CurrentVersionMotorTypes.Add(motorType);
+ CurrentVersion.HardwareMotors.Add(new HardwareMotor() { HardwareMotorType = motorType });
}
}
- public void OnDropDancer(DancerType dancerType)
+ public void OnDropDancer(HardwareDancerType dancerType)
{
- if (!CurrentVersionDancerTypes.Contains(dancerType))
+ if (!CurrentVersion.HardwareDancers.ToList().Exists(x => x.HardwareDancerType == dancerType))
{
- CurrentVersionDancerTypes.Add(dancerType);
+ CurrentVersion.HardwareDancers.Add(new HardwareDancer() { HardwareDancerType = dancerType });
}
}
- public void OnDropPidControl(PidControl pidControl)
+ public void OnDropPidControl(HardwarePidControlType pidControlType)
{
- if (!CurrentVersionPidControls.Contains(pidControl))
+ if (!CurrentVersion.HardwarePidControls.ToList().Exists(x => x.HardwarePidControlType == pidControlType))
{
- CurrentVersionPidControls.Add(pidControl);
+ CurrentVersion.HardwarePidControls.Add(new HardwarePidControl() { HardwarePidControlType = pidControlType });
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
index e73ba2a1f..3e840467f 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
@@ -45,7 +45,13 @@
<TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">HARDWARE DESIGNER</TextBlock>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10 10 0 0">
<materialDesign:PackIcon Kind="Pencil" Width="32" Height="32" Foreground="Silver" />
- <ComboBox ItemsSource="{Binding Adapter.HardwareVersions}" SelectedItem="{Binding SelectedVersion}" DisplayMemberPath="Name" Width="300" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version"></ComboBox>
+ <ComboBox ItemsSource="{Binding Adapter.HardwareVersions}" SelectedItem="{Binding SelectedVersion}" Width="300" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version">
+ <ComboBox.ItemTemplate>
+ <DataTemplate>
+ <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="Gray" FontSize="14">v</Run><Run Foreground="Gray" FontSize="14" Text="{Binding Version}"></Run></TextBlock>
+ </DataTemplate>
+ </ComboBox.ItemTemplate>
+ </ComboBox>
</StackPanel>
</StackPanel>
</Grid>
@@ -63,14 +69,14 @@
<Border BorderThickness="1" BorderBrush="Gray" CornerRadius="0 0 20 20" Width="707" Height="132" Canvas.Left="50" Canvas.Top="378" Background="#ABFFFFFF">
<Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnDancerDrop">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG &amp; DROP DANCERS</TextBlock>
- <ListBox x:Name="listDancers" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionDancerTypes}" Margin="0 5 0 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
+ <ListBox x:Name="listDancers" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersion.HardwareDancers}" Margin="0 5 0 0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
- <DataTemplate DataType="{x:Type observables:DancerType}">
+ <DataTemplate DataType="{x:Type observables:HardwareDancer}">
<Grid Style="{StaticResource draggableGrid}">
<Border Margin="5" CornerRadius="5" Width="100" Height="100" BorderThickness="1" Padding="2" IsHitTestVisible="False">
<Border.Style>
@@ -92,7 +98,7 @@
<Grid>
<StackPanel>
<Image Source="../Images/compass.png" Width="32" Margin="5" />
- <TextBlock FontSize="8" TextAlignment="Center" TextWrapping="Wrap" Margin="0 5 0 0" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
+ <TextBlock FontSize="8" TextAlignment="Center" TextWrapping="Wrap" Margin="0 5 0 0" Text="{Binding HardwareDancerType.Name}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
</Border>
@@ -106,14 +112,14 @@
<Border BorderThickness="1 1 1 0" BorderBrush="Gray" Width="576" Height="157" Canvas.Left="114" Canvas.Top="224" Background="#ABFFFFFF">
<Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnMotorsDrop">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG &amp; DROP MOTORS</TextBlock>
- <ListBox x:Name="listMotors" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionMotorTypes}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
+ <ListBox x:Name="listMotors" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersion.HardwareMotors}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
- <DataTemplate DataType="{x:Type observables:MotorType}">
+ <DataTemplate DataType="{x:Type observables:HardwareMotor}">
<Grid Style="{StaticResource draggableGrid}">
<Grid.ToolTip>
<Border Padding="2">
@@ -150,7 +156,7 @@
<Grid>
<StackPanel Orientation="Horizontal">
<Image Source="../Images/engine.png" Width="16" />
- <TextBlock FontSize="8" Margin="5 0 0 0" TextTrimming="CharacterEllipsis" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
+ <TextBlock FontSize="8" Margin="5 0 0 0" TextTrimming="CharacterEllipsis" Text="{Binding HardwareMotorType.Name}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
</Border>
@@ -164,14 +170,14 @@
<Border BorderThickness="1 1 1 0" BorderBrush="Gray" Width="545" Height="120" Canvas.Left="130" Canvas.Top="105" Background="#ABFFFFFF" CornerRadius="20 20 0 0" Padding="5">
<Grid Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnPidControlDrop">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Silver" FontSize="20">DRAG &amp; DROP PID CONTROLS</TextBlock>
- <ListBox x:Name="listPid" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersionPidControls}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
+ <ListBox x:Name="listPid" ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding CurrentVersion.HardwarePidControls}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
- <DataTemplate DataType="{x:Type observables:PidControl}">
+ <DataTemplate DataType="{x:Type observables:HardwarePidControl}">
<Grid Style="{StaticResource draggableGrid}">
<Border Margin="4" CornerRadius="3" Height="25" IsHitTestVisible="False" MaxWidth="100" BorderThickness="1" Padding="5 2 9 2">
<Border.Style>
@@ -193,7 +199,7 @@
<Grid>
<StackPanel Orientation="Horizontal">
<Image Source="../Images/balance.png" Width="16" />
- <TextBlock FontSize="8" Margin="5 0 0 0" TextTrimming="CharacterEllipsis" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
+ <TextBlock FontSize="8" Margin="5 0 0 0" TextTrimming="CharacterEllipsis" Text="{Binding HardwarePidControlType.Name}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
</Border>
@@ -227,7 +233,7 @@
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
- <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+ <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0 0 0 10">
<Grid>
<StackPanel>
<materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}" Padding="20 10">
@@ -245,7 +251,7 @@
<materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}">
<StackPanel>
<Expander HorizontalAlignment="Stretch" Header="Motors">
- <ListBox ItemsSource="{Binding Adapter.MotorTypes}" HorizontalContentAlignment="Stretch">
+ <ListBox ItemsSource="{Binding Adapter.HardwareMotorTypes}" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
@@ -275,7 +281,7 @@
<materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}">
<StackPanel>
<Expander HorizontalAlignment="Stretch" Header="Dancers">
- <ListBox ItemsSource="{Binding Adapter.DancerTypes}" HorizontalContentAlignment="Stretch">
+ <ListBox ItemsSource="{Binding Adapter.HardwareDancerTypes}" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
@@ -305,7 +311,7 @@
<materialDesign:Card Margin="5,10,5,0" Background="{DynamicResource MaterialDesignBackground}">
<StackPanel>
<Expander HorizontalAlignment="Stretch" Header="PID Controls">
- <ListBox ItemsSource="{Binding Adapter.PidControls}" HorizontalContentAlignment="Stretch">
+ <ListBox ItemsSource="{Binding Adapter.HardwarePidControlTypes}" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
@@ -456,12 +462,26 @@
</ScrollViewer>
<Grid Grid.Row="1" Margin="10 0 10 10">
- <Button Height="Auto" Command="{Binding SaveCommand}" Margin="0 0 0 0">
- <StackPanel Orientation="Horizontal">
- <materialDesign:PackIcon Width="20" Height="20" VerticalAlignment="Center" Kind="ContentSaveSettings"></materialDesign:PackIcon>
- <TextBlock FontSize="14" Margin="10 0 0 0" VerticalAlignment="Center">SAVE</TextBlock>
- </StackPanel>
- </Button>
+ <UniformGrid Rows="1">
+ <Button Height="Auto" Grid.Column="1" Command="{Binding DeleteCommand}" Margin="2" Background="#FF8A8A" BorderBrush="#FF8A8A">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Width="20" Height="20" VerticalAlignment="Center" Kind="Delete"></materialDesign:PackIcon>
+ <TextBlock FontSize="14" Margin="10 0 0 0" VerticalAlignment="Center">DEL</TextBlock>
+ </StackPanel>
+ </Button>
+ <Button Height="Auto" Grid.Column="1" Command="{Binding NewCommand}" Margin="2" Background="#6BD16F" BorderBrush="#6BD16F">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Width="20" Height="20" VerticalAlignment="Center" Kind="Plus"></materialDesign:PackIcon>
+ <TextBlock FontSize="14" Margin="10 0 0 0" VerticalAlignment="Center">NEW</TextBlock>
+ </StackPanel>
+ </Button>
+ <Button Height="Auto" Command="{Binding SaveCommand}" Margin="2">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Width="20" Height="20" VerticalAlignment="Center" Kind="ContentSaveSettings"></materialDesign:PackIcon>
+ <TextBlock FontSize="14" Margin="10 0 0 0" VerticalAlignment="Center">SAVE</TextBlock>
+ </StackPanel>
+ </Button>
+ </UniformGrid>
</Grid>
</Grid>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs
index d18a8ac71..0a3c06344 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs
@@ -43,41 +43,41 @@ namespace Tango.MachineStudio.HardwareDesigner.Views
private void OnMotorsDrop(object sender, DropEventArgs e)
{
- if (e.Draggable.DataContext is MotorType)
+ if (e.Draggable.DataContext is HardwareMotorType)
{
- _vm.OnMotorDrop(e.Draggable.DataContext as MotorType);
+ _vm.OnMotorDrop(e.Draggable.DataContext as HardwareMotorType);
}
}
private void OnDancerDrop(object sender, DropEventArgs e)
{
- if (e.Draggable.DataContext is DancerType)
+ if (e.Draggable.DataContext is HardwareDancerType)
{
- _vm.OnDropDancer(e.Draggable.DataContext as DancerType);
+ _vm.OnDropDancer(e.Draggable.DataContext as HardwareDancerType);
}
}
private void OnPidControlDrop(object sender, DropEventArgs e)
{
- if (e.Draggable.DataContext is PidControl)
+ if (e.Draggable.DataContext is HardwarePidControlType)
{
- _vm.OnDropPidControl(e.Draggable.DataContext as PidControl);
+ _vm.OnDropPidControl(e.Draggable.DataContext as HardwarePidControlType);
}
}
private void OnTrashDrop(object sender, DropEventArgs e)
{
- if (e.Draggable.DataContext is MotorType)
+ if (e.Draggable.DataContext is HardwareMotor)
{
- _vm.OnRemoveMotor(e.Draggable.DataContext as MotorType);
+ _vm.OnRemoveMotor(e.Draggable.DataContext as HardwareMotor);
}
- else if (e.Draggable.DataContext is DancerType)
+ else if (e.Draggable.DataContext is HardwareDancer)
{
- _vm.OnRemoveDancer(e.Draggable.DataContext as DancerType);
+ _vm.OnRemoveDancer(e.Draggable.DataContext as HardwareDancer);
}
- else if (e.Draggable.DataContext is PidControl)
+ else if (e.Draggable.DataContext is HardwarePidControl)
{
- _vm.OnRemovePidControl(e.Draggable.DataContext as PidControl);
+ _vm.OnRemovePidControl(e.Draggable.DataContext as HardwarePidControl);
}
}
}