diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-28 13:32:33 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-28 13:32:33 +0200 |
| commit | 20f0dc40cdbe85ab7cfedd78a9bc883e4469e4ab (patch) | |
| tree | 7356c7beb47bfa4725980af29edc9f43b878d2c4 /Software/Visual_Studio | |
| parent | 08b6ea6e300ff8236594dd4f303387ef1366e49e (diff) | |
| download | Tango-20f0dc40cdbe85ab7cfedd78a9bc883e4469e4ab.tar.gz Tango-20f0dc40cdbe85ab7cfedd78a9bc883e4469e4ab.zip | |
DAL Observables are now also parameterized.
Diffstat (limited to 'Software/Visual_Studio')
13 files changed, 208 insertions, 251 deletions
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 b971d9124..572ebc785 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 @@ -14,6 +14,7 @@ xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:observables="clr-namespace:Tango.DAL.Observables;assembly=Tango.DAL.Observables" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" @@ -228,112 +229,23 @@ </WrapPanel.Resources> - - <ContentControl> - <StackPanel> - <TextBlock>Dyeing Speed:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DyeingSpeed,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Min Ink Uptake:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding MinInkUptake,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Mixer Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding MixerTemp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Head Zone1 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding HeadZone1Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Head Zone2 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding HeadZone2Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Head Zone3 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding HeadZone3Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Head Air Flow:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding HeadAirFlow,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Feeder Tension:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding FeederTension,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Puller Tension:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding PullerTension,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Dryer Buffer Length:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DryerBufferLength,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Dryer Zone1 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DryerZone1Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Dryer Zone2 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DryerZone2Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Dryer Zone3 Temp:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DryerZone3Temp,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - - <ContentControl> - <StackPanel> - <TextBlock>Dryer Air Flow:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding DryerAirFlow,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> - - <ContentControl> - <StackPanel> - <TextBlock>Winder Tension:</TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding WinderTension,Mode=TwoWay}"></mahapps:NumericUpDown> - </StackPanel> - </ContentControl> + <editors:ParameterizedEditor ParameterizedObject="{Binding}"> + <editors:ParameterizedEditor.ItemsPanel> + <ItemsPanelTemplate> + <WrapPanel IsItemsHost="True" Orientation="Vertical" /> + </ItemsPanelTemplate> + </editors:ParameterizedEditor.ItemsPanel> + <editors:ParameterizedEditor.DoubleTemplate> + <DataTemplate> + <ContentControl> + <StackPanel> + <TextBlock Text="{Binding Name}"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" StringFormat="0.0" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding Value,Mode=TwoWay}"></mahapps:NumericUpDown> + </StackPanel> + </ContentControl> + </DataTemplate> + </editors:ParameterizedEditor.DoubleTemplate> + </editors:ParameterizedEditor> </WrapPanel> </DockPanel> </Border> @@ -450,7 +362,7 @@ </StackPanel> </Grid> - <StackPanel Orientation="Horizontal" Margin="0 20 0 0" MaxWidth="800" HorizontalAlignment="Left"> + <StackPanel Orientation="Horizontal" Margin="0 20 0 0" MaxWidth="940" HorizontalAlignment="Left"> <Border Style="{StaticResource JobFieldBorder}"> <StackPanel Margin="5" Width="140"> <StackPanel Orientation="Horizontal"> @@ -495,22 +407,23 @@ </DockPanel> </StackPanel> </Border> - </StackPanel> + <StackPanel Width="180"> + <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> + <Image Source="../Images/description.png" Width="32"></Image> + <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Description</TextBlock> + </StackPanel> - <StackPanel Orientation="Horizontal" Margin="10 20 0 0"> - <Image Source="../Images/description.png" Width="32"></Image> - <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Description</TextBlock> + <Border BorderThickness="1" BorderBrush="Silver" CornerRadius="5" Margin="0 0 5 5"> + <TextBox Style="{x:Null}" BorderThickness="0" Margin="5" Height="40" Text="{Binding SelectedJob.Description}" VerticalAlignment="Stretch" materialDesign:HintAssist.Hint="Enter description" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox> + </Border> + </StackPanel> </StackPanel> - <Border BorderThickness="1" BorderBrush="Silver" CornerRadius="5" Margin="0 0 5 5"> - <TextBox Style="{x:Null}" BorderThickness="0" Margin="5" Height="80" Text="{Binding SelectedJob.Description}" VerticalAlignment="Stretch" materialDesign:HintAssist.Hint="Enter description" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox> - </Border> - </StackPanel> - <Grid Grid.Row="1" Margin="0 10 0 0"> + <Grid Grid.Row="1" Margin="0 20 0 0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="200"/> <ColumnDefinition Width="1*"/> @@ -573,9 +486,9 @@ </Border> </StackPanel> - <Grid> + <Grid> - </Grid> + </Grid> </DockPanel> </Grid> </DockPanel> 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 f4da7beaa..9077826a5 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 @@ -545,7 +545,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels machine.Name = Machine.Name; machine.SerialNumber = Machine.SerialNumber; - machine.Configuration = Configuration; machine.Organization = Machine.Organization; @@ -557,6 +556,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Machine = machine }); } + else + { + machine.Configuration.DefferedDelete(); + } + + machine.Configuration = Configuration; await machine.SaveAsync(); diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs index 565582318..3e7da4cfb 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs @@ -126,6 +126,25 @@ public static class DependencyObjectExtensions } /// <summary> + /// Binds the specified dependency property to a another object property. + /// </summary> + /// <param name="target">The target dependency object.</param> + /// <param name="targetDP">The target dependency property.</param> + /// <param name="source">The source object.</param> + /// <param name="sourcePath">The source dependency property name.</param> + /// <param name="mode">Binding mode.</param> + /// <returns></returns> + public static Binding Bind(this DependencyObject target, DependencyProperty targetDP, Object source, String sourcePath, BindingMode mode = BindingMode.Default) + { + Binding binding = new Binding(); + binding.Mode = mode; + binding.Source = source; + binding.Path = new PropertyPath(sourcePath); + BindingOperations.SetBinding(target, targetDP, binding); + return binding; + } + + /// <summary> /// Clears bindings from the specified dependency property. /// </summary> /// <param name="target">The target dependency object.</param> diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs index 7a7ae103d..7b8264cae 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs @@ -47,14 +47,17 @@ public static class IParameterizedExtensions { foreach (var prop in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { - var paramAtt = prop.GetCustomAttributes(typeof(ParameterItemAttribute), false).Cast<ParameterItemAttribute>().FirstOrDefault(); - var ignore = prop.GetCustomAttributes(typeof(ParameterIgnoreAttribute), false).Cast<ParameterIgnoreAttribute>().FirstOrDefault(); - - if (ignore == null && !properties.Exists(x => x.Name == prop.Name)) + if (prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(String) || prop.PropertyType == typeof(DateTime)) { - var item = instance.CreateParameterItem(prop, paramAtt, index++, mode); - ps.Add(item); - properties.Add(prop); + var paramAtt = prop.GetCustomAttributes(typeof(ParameterItemAttribute), false).Cast<ParameterItemAttribute>().FirstOrDefault(); + var ignore = prop.GetCustomAttributes(typeof(ParameterIgnoreAttribute), false).Cast<ParameterIgnoreAttribute>().FirstOrDefault(); + + if (ignore == null && !properties.Exists(x => x.Name == prop.Name)) + { + var item = instance.CreateParameterItem(prop, paramAtt, index++, mode); + ps.Add(item); + properties.Add(prop); + } } } } @@ -77,10 +80,10 @@ public static class IParameterizedExtensions item.Name = propertyInfo.Name.ToTitle(); item.Index = index; item.Type = propertyInfo.PropertyType; - item.Value = attribute.Default; if (attribute != null) { + item.Value = attribute.Default; item.Minimum = attribute.Minimum; item.Maximum = attribute.Maximum; item.CustomEditorTypeName = attribute.CustomEditorTypeName; @@ -101,9 +104,10 @@ public static class IParameterizedExtensions } else if (mode == ParameterItemMode.Binding) { - item.Bind(ParameterItem.ValueProperty, instance as DependencyObject, propertyInfo.Name, System.Windows.Data.BindingMode.TwoWay); + item.Bind(ParameterItem.ValueProperty, instance, propertyInfo.Name, System.Windows.Data.BindingMode.TwoWay); } + return item; } diff --git a/Software/Visual_Studio/Tango.Core/ParameterItem.cs b/Software/Visual_Studio/Tango.Core/ParameterItem.cs index f13dd8eb4..a1fd21826 100644 --- a/Software/Visual_Studio/Tango.Core/ParameterItem.cs +++ b/Software/Visual_Studio/Tango.Core/ParameterItem.cs @@ -117,7 +117,7 @@ namespace Tango.Core /// </summary> public bool HasCustomEditor { - get { return CustomEditorTypeName != null; } + get { return false; } } /// <summary> diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ExtensionMethods/ConfigurationExtensions.cs b/Software/Visual_Studio/Tango.DAL.Observables/ExtensionMethods/ConfigurationExtensions.cs index 842670e02..ec6ab2f7f 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ExtensionMethods/ConfigurationExtensions.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ExtensionMethods/ConfigurationExtensions.cs @@ -27,6 +27,7 @@ public static class ConfigurationExtensions clonedPack.DispenserType = idsPack.DispenserType; clonedPack.CartridgeType = idsPack.CartridgeType; clonedPack.MidTankType = idsPack.MidTankType; + clonedPack.IdsPackFormula = idsPack.IdsPackFormula; cloned.IdsPacks.Add(clonedPack); } diff --git a/Software/Visual_Studio/Tango.DAL.Observables/IObservableEntity.cs b/Software/Visual_Studio/Tango.DAL.Observables/IObservableEntity.cs index a957dacd1..9caa89223 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/IObservableEntity.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/IObservableEntity.cs @@ -6,13 +6,14 @@ using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; namespace Tango.DAL.Observables { /// <summary> /// Represents an observable database entity. /// </summary> - public interface IObservableEntity + public interface IObservableEntity : IParameterized { /// <summary> /// Occurs after this observable has been saved. diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs index b36577870..700db554b 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs @@ -71,6 +71,17 @@ namespace Tango.DAL.Observables set { _lastUpdated = value; RaisePropertyChanged(nameof(LastUpdated)); } } + private ReadOnlyObservableCollection<ParameterItem> _parameters; + /// <summary> + /// Gets a bind-able observable collection of the component properties. + /// </summary> + [NotMapped] + public ReadOnlyObservableCollection<ParameterItem> Parameters + { + get { return _parameters; } + set { _parameters = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Initializes a new instance of the <see cref="ObservableEntity{T}"/> class. /// </summary> @@ -82,6 +93,11 @@ namespace Tango.DAL.Observables (?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace); + + ThreadsHelper.InvokeUI(() => + { + Parameters = new ReadOnlyObservableCollection<ParameterItem>(this.CreateParametersCollection(ParameterItemMode.Binding)); + }); } /// <summary> diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Partials/Configuration.cs b/Software/Visual_Studio/Tango.DAL.Observables/Partials/Configuration.cs new file mode 100644 index 000000000..c5cfb693f --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Observables/Partials/Configuration.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DAL.Observables +{ + public partial class Configuration + { + public override void DefferedDelete() + { + IdsPacks.ToList().ForEach(x => x.DefferedDelete()); + var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this); + MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete()); + base.DefferedDelete(); + IdsPacks.Clear(); + } + + public override void Delete() + { + IdsPacks.ToList().ForEach(x => x.DefferedDelete()); + var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this); + MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete()); + base.Delete(); + IdsPacks.Clear(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj b/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj index f9aa7cc5d..d827f4bb1 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj +++ b/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj @@ -103,6 +103,7 @@ <Compile Include="IObservableEntity.cs" /> <Compile Include="LoadedEntitiesService.cs" /> <Compile Include="ObservablesContext.cs" /> + <Compile Include="Partials\Configuration.cs" /> <Compile Include="Partials\Machine.cs" /> <Compile Include="ObservableEntity.cs" /> <Compile Include="ObservablesEntitiesAdapter.cs" /> diff --git a/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml b/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml index d80852b73..2f150fa2f 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml +++ b/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml @@ -15,115 +15,79 @@ <converters:ParameterItemEditorTypeToEditorConverter x:Key="ParameterItemEditorTypeToEditorConverter"></converters:ParameterItemEditorTypeToEditorConverter> <converters:DoubleToIntConverter x:Key="DoubleToIntConverter"></converters:DoubleToIntConverter> <converters:IsNullConverter x:Key="IsNullConverter"></converters:IsNullConverter> + + <DataTemplate x:Key="nullTemplate"> + <Rectangle HorizontalAlignment="Stretch" Height="0" StrokeThickness="0" VerticalAlignment="Top" /> + </DataTemplate> </UserControl.Resources> <Grid> - <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Background="Transparent"> - <ItemsControl Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ParameterizedObject.Parameters}" HorizontalContentAlignment="Stretch"> - <ItemsControl.ItemTemplate> - <DataTemplate> - <ContentControl Content="{Binding}" Padding="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemPadding}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemMargin}" MinHeight="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemMinHeight}"> - <ContentControl.Style> - <Style TargetType="ContentControl"> - <Setter Property="ContentTemplate"> - <Setter.Value> - <DataTemplate> - <StackPanel> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <TextBox Text="{Binding Value,UpdateSourceTrigger=PropertyChanged}"></TextBox> - </StackPanel> - </DataTemplate> - </Setter.Value> - </Setter> - <Style.Resources> - <DataTemplate x:Key="slide"> - <StackPanel> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <Slider Orientation="Horizontal" HorizontalAlignment="Stretch" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding Value}" ToolTip="{Binding Value}"></Slider> - </StackPanel> - </DataTemplate> - <DataTemplate x:Key="slideInteger"> - <StackPanel> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <Slider TickFrequency="1" IsSnapToTickEnabled="True" Orientation="Horizontal" HorizontalAlignment="Stretch" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding Value,Converter={StaticResource DoubleToIntConverter}}"></Slider> - </StackPanel> - </DataTemplate> - <DataTemplate x:Key="numUpDown"> - <Grid Margin="0 0 0 4" x:Name="grid"> - <Grid.ColumnDefinitions> - <ColumnDefinition/> - <ColumnDefinition/> - </Grid.ColumnDefinitions> - <TextBlock VerticalAlignment="Center" Grid.Column="0" Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <local:ParameterItemNumericUpDownEditor Grid.Column="1" Minimum="-10000" Maximum="10000" Height="25" Value="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=DataContext.Value,Mode=TwoWay}"></local:ParameterItemNumericUpDownEditor> - </Grid> - </DataTemplate> - <DataTemplate x:Key="enum"> - <StackPanel Margin="0 0 0 4"> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <ComboBox Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=Foreground}" ItemsSource="{Binding Type,Converter={StaticResource EnumToItemsSourceConverter},Mode=OneTime}" SelectedValue="{Binding Value}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox> - </StackPanel> - </DataTemplate> - <DataTemplate x:Key="chk"> - <CheckBox Margin="0 5 0 5" IsChecked="{Binding Value}" Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=Foreground}" Content="{Binding Name}"></CheckBox> - </DataTemplate> - <DataTemplate x:Key="text"> - <StackPanel> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <TextBox Text="{Binding Value,UpdateSourceTrigger=PropertyChanged}"></TextBox> - </StackPanel> - </DataTemplate> - <DataTemplate x:Key="custom"> - <StackPanel> - <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> - <ContentPresenter> - <ContentPresenter.Content> - <MultiBinding Converter="{StaticResource ParameterItemEditorTypeToEditorConverter}"> - <Binding Path="DataContext" RelativeSource="{RelativeSource AncestorType=StackPanel}"></Binding> - <Binding Path="ParameterizedObject" RelativeSource="{RelativeSource AncestorType=local:ParameterizedEditor}"></Binding> - </MultiBinding> - </ContentPresenter.Content> - </ContentPresenter> - </StackPanel> - </DataTemplate> - </Style.Resources> - <Style.Triggers> - <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Double}"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=DoubleTemplate,FallbackValue={StaticResource slide},TargetNullValue={StaticResource slide}}"></Setter> - </DataTrigger> - <MultiDataTrigger> - <MultiDataTrigger.Conditions> - <Condition Binding="{Binding Type}" Value="{x:Type sys:Double}"></Condition> - <Condition Binding="{Binding Maximum,Converter={StaticResource IsNullConverter}}" Value="True"></Condition> - <Condition Binding="{Binding Minimum,Converter={StaticResource IsNullConverter}}" Value="True"></Condition> - </MultiDataTrigger.Conditions> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=DoubleUpDownTemplate,FallbackValue={StaticResource numUpDown},TargetNullValue={StaticResource numUpDown}}"></Setter> - </MultiDataTrigger> - <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Int32}"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=Int32Template,FallbackValue={StaticResource slideInteger},TargetNullValue={StaticResource slideInteger}}"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Single}"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=SingleTemplate,FallbackValue={StaticResource slide},TargetNullValue={StaticResource slide}}"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Type,Converter={StaticResource IsEnumConverter}}" Value="True"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=EnumTemplate,FallbackValue={StaticResource enum},TargetNullValue={StaticResource enum}}"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Boolean}"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=BooleanTemplate,FallbackValue={StaticResource chk},TargetNullValue={StaticResource chk}}"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:String}"> - <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=StringTemplate,FallbackValue={StaticResource text},TargetNullValue={StaticResource text}}"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding HasCustomEditor}" Value="True"> - <Setter Property="ContentTemplate" Value="{StaticResource custom}"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </ContentControl.Style> - </ContentControl> - </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> - </ScrollViewer> + <ItemsControl x:Name="itemsControl" ItemsPanel="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=ItemsPanel}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ParameterizedObject.Parameters}" HorizontalContentAlignment="Stretch"> + <ItemsControl.ItemTemplate> + <DataTemplate> + <ContentControl Content="{Binding}"> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="ContentTemplate" Value="{StaticResource nullTemplate}"> + + </Setter> + <Style.Resources> + <DataTemplate x:Key="enum"> + <StackPanel Margin="0 0 0 4"> + <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> + <ComboBox Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=Foreground}" ItemsSource="{Binding Type,Converter={StaticResource EnumToItemsSourceConverter},Mode=OneTime}" SelectedValue="{Binding Value}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox> + </StackPanel> + </DataTemplate> + <DataTemplate x:Key="custom"> + <StackPanel> + <TextBlock Text="{Binding Name}" Margin="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=ItemLabelMargin}"></TextBlock> + <ContentPresenter> + <ContentPresenter.Content> + <MultiBinding Converter="{StaticResource ParameterItemEditorTypeToEditorConverter}"> + <Binding Path="DataContext" RelativeSource="{RelativeSource AncestorType=StackPanel}"></Binding> + <Binding Path="ParameterizedObject" RelativeSource="{RelativeSource AncestorType=local:ParameterizedEditor}"></Binding> + </MultiBinding> + </ContentPresenter.Content> + </ContentPresenter> + </StackPanel> + </DataTemplate> + </Style.Resources> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Double}"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=DoubleTemplate,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </DataTrigger> + <MultiDataTrigger> + <MultiDataTrigger.Conditions> + <Condition Binding="{Binding Type}" Value="{x:Type sys:Double}"></Condition> + <Condition Binding="{Binding Maximum,Converter={StaticResource IsNullConverter}}" Value="True"></Condition> + <Condition Binding="{Binding Minimum,Converter={StaticResource IsNullConverter}}" Value="True"></Condition> + </MultiDataTrigger.Conditions> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=DoubleUpDownTemplate,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </MultiDataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Int32}"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=Int32Template,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Single}"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=SingleTemplate,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type,Converter={StaticResource IsEnumConverter}}" Value="True"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=EnumTemplate,FallbackValue={StaticResource enum},TargetNullValue={StaticResource enum}}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:Boolean}"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=BooleanTemplate,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Type sys:String}"> + <Setter Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ParameterizedEditor},Path=StringTemplate,TargetNullValue={StaticResource nullTemplate}}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding HasCustomEditor}" Value="True"> + <Setter Property="ContentTemplate" Value="{StaticResource custom}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + </ContentControl> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> </Grid> </UserControl> diff --git a/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml.cs index 80f888bb0..64bb1e9bd 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Editors/ParameterizedEditor.xaml.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; @@ -30,6 +31,20 @@ namespace Tango.SharedUI.Editors InitializeComponent(); } + + /// <summary> + /// Gets or sets the items panel. + /// </summary> + public ItemsPanelTemplate ItemsPanel + { + get { return (ItemsPanelTemplate)GetValue(ItemsPanelProperty); } + set { SetValue(ItemsPanelProperty, value); } + } + public static readonly DependencyProperty ItemsPanelProperty = + DependencyProperty.Register("ItemsPanel", typeof(ItemsPanelTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null)); + + + /// <summary> /// Gets or sets the parameterized object. /// </summary> @@ -176,17 +191,6 @@ namespace Tango.SharedUI.Editors DependencyProperty.Register("BrushTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null)); /// <summary> - /// Gets or sets the point template. - /// </summary> - public DataTemplate PointTemplate - { - get { return (DataTemplate)GetValue(PointTemplateProperty); } - set { SetValue(PointTemplateProperty, value); } - } - public static readonly DependencyProperty PointTemplateProperty = - DependencyProperty.Register("PointTemplate", typeof(DataTemplate), typeof(ParameterizedEditor), new PropertyMetadata(null)); - - /// <summary> /// Gets or sets the string template. /// </summary> public DataTemplate StringTemplate diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index ef0522e0a..e60e1e1a0 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.14 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf", "Tango.Protobuf\Tango.Protobuf.csproj", "{40073806-914E-4E78-97AB-FA9639308EBE}" EndProject @@ -884,8 +884,8 @@ Global {FC0FB4A1-360E-42B1-8372-9208A3098B2A}.Release|x64.Build.0 = Release|Any CPU {FC0FB4A1-360E-42B1-8372-9208A3098B2A}.Release|x86.ActiveCfg = Release|Any CPU {FC0FB4A1-360E-42B1-8372-9208A3098B2A}.Release|x86.Build.0 = Release|Any CPU - {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Release|Any CPU - {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Release|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|ARM.ActiveCfg = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|ARM.Build.0 = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|ARM64.ActiveCfg = Debug|Any CPU |
