diff --git a/VECTO3GUI2020/App.xaml.cs b/VECTO3GUI2020/App.xaml.cs index b1e0c92422bfea0b053112b001f3d9574838dc58..6e8981f6a1197b223dcb1f7584750bb0766ce389 100644 --- a/VECTO3GUI2020/App.xaml.cs +++ b/VECTO3GUI2020/App.xaml.cs @@ -10,6 +10,7 @@ using VECTO3GUI2020.Helper; using VECTO3GUI2020.Model.Implementation; using VECTO3GUI2020.Ninject; using VECTO3GUI2020.Ninject.Vehicle; +using VECTO3GUI2020.ViewModel; namespace VECTO3GUI2020 { @@ -44,7 +45,7 @@ namespace VECTO3GUI2020 container.Bind<IMainWindowViewModel>().To<MainWindowViewModel>(); container.Bind<IMainViewModel>().To<JobListViewModel>(); container.Bind<ISettingsViewModel>().To<SettingsViewModel>(); - + container.Bind<IOutputViewModel>().To<OutputViewModel>().InSingletonScope(); container.Bind<ISettingsModel>().To<SettingsModel>(); container.Bind<IDialogHelper>().To<DialogHelper>().InSingletonScope(); diff --git a/VECTO3GUI2020/Helper/Converter/BoolToIntConverter.cs b/VECTO3GUI2020/Helper/Converter/BoolToIntConverter.cs new file mode 100644 index 0000000000000000000000000000000000000000..65b859ac7b9c022073d491d1cd4053e5d9da246e --- /dev/null +++ b/VECTO3GUI2020/Helper/Converter/BoolToIntConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace VECTO3GUI2020.Helper.Converter +{ + + public class BoolToIntConverter : IValueConverter + { + #region Implementation of IValueConverter + + + /// <summary> + /// Returns -1 if value is false, 0 if value is true + /// </summary> + /// <param name="value"></param> + /// <param name="targetType"></param> + /// <param name="parameter"></param> + /// <param name="culture"></param> + /// <returns></returns> + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (bool)value == false ? -1 : 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return Binding.DoNothing; + } + + #endregion + } +} \ No newline at end of file diff --git a/VECTO3GUI2020/Helper/IndexedStorage.cs b/VECTO3GUI2020/Helper/IndexedStorage.cs new file mode 100644 index 0000000000000000000000000000000000000000..65c5998a65667311d341fe6b1a06528edface780 --- /dev/null +++ b/VECTO3GUI2020/Helper/IndexedStorage.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VECTO3GUI2020.Helper +{ + //Helper class that can be used to store values of the same type that are identified by a string + public class IndexedStorage<T> where T : IEquatable<T> + { + private Dictionary<string, T> indexedStorageDictionary = new Dictionary<string, T>(); + private readonly Action _onValueChanged; + + + public IndexedStorage(Action onValueChanged = null) + { + _onValueChanged = onValueChanged; + } + + + public T this[string identifier] + { + get + { + if (!indexedStorageDictionary.ContainsKey(identifier)) + { + indexedStorageDictionary.Add(identifier, default(T)); + } + return indexedStorageDictionary[identifier]; + } + set + { + var oldValue = default(T); + if (indexedStorageDictionary.ContainsKey(identifier)) + { + oldValue = indexedStorageDictionary[identifier]; + } + else + { + indexedStorageDictionary.Add(identifier, default(T)); + } + indexedStorageDictionary[identifier] = value; + if (value.Equals(oldValue)) + { + _onValueChanged?.Invoke(); + } + } + } + } + +} diff --git a/VECTO3GUI2020/Helper/NameOfMarkUpExtension.cs b/VECTO3GUI2020/Helper/NameOfMarkUpExtension.cs new file mode 100644 index 0000000000000000000000000000000000000000..0e5218d4007204b9647b23db8c84464a098d8743 --- /dev/null +++ b/VECTO3GUI2020/Helper/NameOfMarkUpExtension.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows.Markup; + +namespace VECTO3GUI2020.Helper +{ + public class NameOfMarkUpExtension : MarkupExtension + { + #region Overrides of MarkupExtension + + public override object ProvideValue(IServiceProvider serviceProvider) + { + throw new NotImplementedException(); + return null; + } + + #endregion + } +} \ No newline at end of file diff --git a/VECTO3GUI2020/MainWindow.xaml b/VECTO3GUI2020/MainWindow.xaml index 12ce57b5c51ffc176482eb0305c839c88f4455fc..842bfa24aed0b4a9a5633d020a9ececf2031e69d 100644 --- a/VECTO3GUI2020/MainWindow.xaml +++ b/VECTO3GUI2020/MainWindow.xaml @@ -19,11 +19,11 @@ <Grid.RowDefinitions> <RowDefinition Height="40"/> <RowDefinition Height="1.5*"/> + <RowDefinition Height="5"></RowDefinition> <RowDefinition Height="1*"/> </Grid.RowDefinitions> - <Grid Grid.Row="0"> - <StackPanel Orientation="Vertical"> + <StackPanel Grid.Row="0" Orientation="Vertical"> <Menu x:Name="menu" IsMainMenu="True"> <MenuItem Header="File" VerticalAlignment="Stretch"> <MenuItem Header="Settings" Command="{Binding OpenSettings}"/> @@ -32,15 +32,11 @@ </MenuItem> </Menu> </StackPanel> - </Grid> - <Grid Grid.Row="1" Margin="0,4,0,0"> - <ContentControl Content="{Binding CurrentViewModelTop}"/> - </Grid> - - <Grid Grid.Row="2" Margin="0,0,0,0"> - <ContentControl Name="ContentControlBottom" Content="{Binding CurrentViewModelBottom}" Visibility="Collapsed"/> - </Grid> + <ContentControl Grid.Row="1" Margin="0, 4, 0 0" Content="{Binding CurrentViewModelTop}"/> + <GridSplitter Grid.Row="2" HorizontalAlignment="Stretch" Height="5"/> + <ContentControl Grid.Row="3" Margin="0,0,0,0" Name="ContentControlBottom" Content="{Binding CurrentViewModelBottom}"/> + </Grid> </Window> diff --git a/VECTO3GUI2020/Resources/Converter.xaml b/VECTO3GUI2020/Resources/Converter.xaml index 32b306aa638ed36e577f99cc2d95a75c02ac69c5..64ee2552e563fc1f46a041810268dca58ea3f03f 100644 --- a/VECTO3GUI2020/Resources/Converter.xaml +++ b/VECTO3GUI2020/Resources/Converter.xaml @@ -15,5 +15,6 @@ <converter:XToBoolConverter x:Key="XToBoolConverter"/> <converter:EnumConverter x:Key="EnumConverter"></converter:EnumConverter> <converter:NullToUnsetValueConverter x:Key="NullToUnsetValue"></converter:NullToUnsetValueConverter> + <converter:BoolToIntConverter x:Key="BoolToIntConverter"></converter:BoolToIntConverter> </ResourceDictionary> diff --git a/VECTO3GUI2020/Resources/ViewModelBindings.xaml b/VECTO3GUI2020/Resources/ViewModelBindings.xaml index 61a9527096e324c7471c91db8f99b8c17eda134f..7675556d63ab8b5807f8118246a106ca560ee2be 100644 --- a/VECTO3GUI2020/Resources/ViewModelBindings.xaml +++ b/VECTO3GUI2020/Resources/ViewModelBindings.xaml @@ -40,161 +40,161 @@ <!--#region HeavyLorry --> - <DataTemplate DataType="{x:Type vehicleimpl:VehicleViewModel_v1_0 }"> + <DataTemplate x:Shared="False" DataType="{x:Type vehicleimpl:VehicleViewModel_v1_0 }"> <vehicleviews:VehicleView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type vehicleimpl:VehicleViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type vehicleimpl:VehicleViewModel_v2_0}"> <vehicleviews:VehicleView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:CommonComponentViewModel}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:CommonComponentViewModel}"> <componentviews:CommonComponentView/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:EngineViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:EngineViewModel_v2_0}"> <componentviews:EngineView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:EngineViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:EngineViewModel_v1_0}"> <componentviews:EngineView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AirDragViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AirDragViewModel_v2_0}"> <componentviews:AirDragView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AirDragViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AirDragViewModel_v1_0}"> <componentviews:AirDragView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AxleWheelsViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AxleWheelsViewModel_v1_0}"> <componentviews:AxleWheelsView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AxleWheelsViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AxleWheelsViewModel_v2_0}"> <componentviews:AxleWheelsView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AxleGearViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AxleGearViewModel_v1_0}"> <componentviews:AxleGearView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentviews:AxleGearView_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentviews:AxleGearView_v2_0}"> <componentviews:AxleGearView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:RetarderViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:RetarderViewModel_v1_0}"> <componentviews:RetarderView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:RetarderViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:RetarderViewModel_v2_0}"> <componentviews:RetarderView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:GearboxViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:GearboxViewModel_v1_0}"> <componentviews:GearboxView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:GearboxViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:GearboxViewModel_v2_0}"> <componentviews:GearboxView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliariesViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliariesViewModel_v1_0}"> <componentviews:AuxiliariesView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliariesViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliariesViewModel_v2_0}"> <componentviews:AuxiliariesView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliariesViewModel_v2_3}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliariesViewModel_v2_3}"> <componentviews:AuxiliariesView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AxleViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AxleViewModel_v1_0}"> <componentviews:AxleView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AxleViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AxleViewModel_v2_0}"> <componentviews:AxleView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:TyreViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:TyreViewModel_v1_0}"> <componentviews:TyreView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:TyreViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:TyreViewModel_v2_0}"> <componentviews:TyreView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:TyreViewModel_v2_2}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:TyreViewModel_v2_2}"> <componentviews:TyreView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:TyreViewModel_v2_3}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:TyreViewModel_v2_3}"> <componentviews:TyreView_v2_3/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:GearViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:GearViewModel_v1_0}"> <componentviews:GearView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:GearViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:GearViewModel_v2_0}"> <componentviews:GearView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:PTOViewModel_V1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:PTOViewModel_V1_0}"> <componentviews:PTOView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:PTOViewModel_V2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:PTOViewModel_V2_0}"> <componentviews:PTOView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AngleDriveViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AngleDriveViewModel_v1_0}"> <componentviews:AngleDriveView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AngleDriveViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AngleDriveViewModel_v2_0}"> <componentviews:AngleDriveView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliaryViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliaryViewModel_v1_0}"> <componentviews:AuxiliaryView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliaryViewModel_v2_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliaryViewModel_v2_0}"> <componentviews:AuxiliaryView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:AuxiliaryViewModel_v2_3}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AuxiliaryViewModel_v2_3}"> <componentviews:AuxiliaryView_v2_0/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:ADASViewModel_v1_0}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:ADASViewModel_v1_0}"> <componentviews:ADASView_v2_3/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:ADASViewModel_v2_1}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:ADASViewModel_v2_1}"> <componentviews:ADASView_v2_3/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:ADASViewModel_v2_3}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:ADASViewModel_v2_3}"> <componentviews:ADASView_v2_3/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:EngineModeViewModelSingleFuel}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:EngineModeViewModelSingleFuel}"> <componentviews:EngineModeViewSingleFuel/> </DataTemplate> - <DataTemplate DataType="{x:Type componentimpl:EngineFuelViewModel}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:EngineFuelViewModel}"> <componentviews:EngineFuelView/> </DataTemplate> <!--#endregion--> - <DataTemplate DataType="{x:Type componentimpl:AirDragViewModel_v2_8}"> + <DataTemplate x:Shared="False" DataType="{x:Type componentimpl:AirDragViewModel_v2_8}"> <multistageviews:AirDragView_v2_8></multistageviews:AirDragView_v2_8> </DataTemplate> diff --git a/VECTO3GUI2020/Test.xaml b/VECTO3GUI2020/Test.xaml index d0a30c571dbb38c00615b6e6196b05c7854722c8..db10836895142d67547c5fc7631a171bd49846c2 100644 --- a/VECTO3GUI2020/Test.xaml +++ b/VECTO3GUI2020/Test.xaml @@ -13,12 +13,12 @@ <!--https://www.thomasclaudiushuber.com/2008/01/10/bind-to-methods-with-objectdataprovider/--> <StackPanel> - <customControls:MultiStageParameter Content="{Binding ConvertedSI}" DummyContent="{Binding Source={StaticResource milimeterDummy}}"/> + <!--<customControls:MultiStageParameter Content="{Binding ConvertedSI}" DummyContent="{Binding Source={StaticResource milimeterDummy}}"/> <customControls:MultiStageParameter Content="{Binding ConvertedSI1}" DummyContent="{Binding Source={StaticResource milimeterDummy}}"/> - <customControls:MultiStageParameter Content="{Binding Meter}"/> - <customControls:MultiStageParameter Mode="COMBOBOX" Content="{Binding HeatPumpMode}" ListItems="{Binding HeatPumpModeListItems}"></customControls:MultiStageParameter> - <customControls:MultiStageParameter Mode="COMBOBOX" Content="{Binding HeatPumpMode2}"></customControls:MultiStageParameter> - <customControls:MultiStageParameter Mode="TEXTBOX" Content="{Binding TestString, ValidatesOnExceptions=True}"></customControls:MultiStageParameter> + <customControls:MultiStageParameter Content="{Binding Meter}"/>--> + <customControls:MultiStageParameter Mode="COMBOBOX" Content="{Binding HeatPumpMode}" EditingEnabled="{Binding enabled}" ListItems="{Binding HeatPumpModeListItems}"></customControls:MultiStageParameter> + <!--<customControls:MultiStageParameter Mode="COMBOBOX" Content="{Binding HeatPumpMode2}" EditingEnabled="{Binding enabled}"></customControls:MultiStageParameter>--> + <!--<customControls:MultiStageParameter Mode="TEXTBOX" Content="{Binding TestString, ValidatesOnExceptions=True}"></customControls:MultiStageParameter>--> </StackPanel> </Grid> </UserControl> diff --git a/VECTO3GUI2020/TestViewModel.cs b/VECTO3GUI2020/TestViewModel.cs index 6a66b18a75787d54e94ad2a1c1d0f7911ca31bfa..2e5b1a9badb3db6139fb932f357bcdce0f5f86f1 100644 --- a/VECTO3GUI2020/TestViewModel.cs +++ b/VECTO3GUI2020/TestViewModel.cs @@ -59,7 +59,8 @@ namespace VECTO3GUI2020 }; private HeatPumpMode? _heatpumpMode2; - + private bool _enabled; + public bool enabled { get => _enabled; set => SetProperty(ref _enabled, value); } public HeatPumpMode? HeatPumpMode2 { get => _heatpumpMode2; @@ -86,7 +87,8 @@ namespace VECTO3GUI2020 public TestViewModel() { - + _enabled = true; + } } } diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index 609d62c169e619107a966753d14ab712434bad12..c8fad6b01ab52c6a7fe4b539eb2ae1e43d6679d1 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -148,6 +148,7 @@ <Compile Include="Helper\Converter\JobTypeStringConverter.cs" /> <Compile Include="Helper\Converter\LabledTextBoxLabelConverter.cs" /> <Compile Include="Helper\Converter\MultistageParameterModeToVisibilityConverter.cs" /> + <Compile Include="Helper\Converter\BoolToIntConverter.cs" /> <Compile Include="Helper\Converter\NullToUnsetValueConverter.cs" /> <Compile Include="Helper\Converter\NullToVisibilityConverter.cs" /> <Compile Include="Helper\Converter\LabledTextBoxConverter.cs" /> @@ -158,8 +159,10 @@ <Compile Include="Helper\DoubleValidation.cs" /> <Compile Include="Helper\Exceptions.cs" /> <Compile Include="Helper\EnumHelper.cs" /> + <Compile Include="Helper\IndexedStorage.cs" /> <Compile Include="Helper\IWindowHelper.cs" /> <Compile Include="Helper\DialogHelper.cs" /> + <Compile Include="Helper\NameOfMarkUpExtension.cs" /> <Compile Include="Helper\WindowHelper.cs" /> <Compile Include="Helper\XMLExtension.cs" /> <Compile Include="Helper\XmlHelper.cs" /> @@ -291,6 +294,7 @@ <Compile Include="ViewModel\MultiStage\Implementation\MultistageJobViewModel_v0_1.cs" /> <Compile Include="ViewModel\MultiStage\Interfaces\IMultistageAirdragViewModel.cs" /> <Compile Include="ViewModel\MultiStage\Interfaces\IMultiStageViewModelFactory.cs" /> + <Compile Include="ViewModel\Implementation\OutputViewModel.cs" /> <Compile Include="Views\CustomControls\ComboParameter.xaml.cs"> <DependentUpon>ComboParameter.xaml</DependentUpon> </Compile> diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 7e22eb3e0204d773bbe4a1104cb5cf72c9115175..0b1a04f02756a0e43c4435a7d81cfdd819874d36 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -4,6 +4,7 @@ using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; @@ -61,6 +62,8 @@ namespace VECTO3GUI2020.ViewModel.Implementation private IMultiStageViewModelFactory _multiStageViewModelFactory; private IAsyncRelayCommand _addJobAsync; private readonly IXMLInputDataReader _inputDataReader; + private IAsyncRelayCommand _simulationCommand; + private readonly IOutputViewModel _outputViewModel; #endregion @@ -79,13 +82,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation IXMLInputDataReader inputDataReader, IDialogHelper dialogHelper, IWindowHelper windowHelper, - IMultiStageViewModelFactory multiStageViewModelFactory) : this() + IMultiStageViewModelFactory multiStageViewModelFactory, IOutputViewModel outputViewModel) : this() { _documentViewModelFactory = documentViewModelFactory; _dialogHelper = dialogHelper; _windowHelper = windowHelper; _inputDataReader = inputDataReader; _multiStageViewModelFactory = multiStageViewModelFactory; + _outputViewModel = outputViewModel; } @@ -116,7 +120,21 @@ namespace VECTO3GUI2020.ViewModel.Implementation #region Commands - public ICommand NewManufacturingStageFile + + public IAsyncRelayCommand SimulationCommand + { + get => _simulationCommand ?? new AsyncRelayCommand(RunSimulationAsync, () => true); + } + + private Task RunSimulationAsync(CancellationToken arg) + { + + _outputViewModel.Messages.Add("hi"); + return null; + + } + + public ICommand NewManufacturingStageFile { get { diff --git a/VECTO3GUI2020/ViewModel/Implementation/MainWindowViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/MainWindowViewModel.cs index f1d16c06613bb306b61d69a04869a30f48ae7f7e..db7164a67121333f147e8591063fd954526e339d 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/MainWindowViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/MainWindowViewModel.cs @@ -50,7 +50,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation } - #region CommandImplementations + #region CommandImplementations #region CommandOpenSettings public ICommand OpenSettings { diff --git a/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..2de6894cfeb8e15aca5776e9303f1a416074433d --- /dev/null +++ b/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.ObjectModel; +using System.Windows.Data; +using VECTO3GUI2020.ViewModel.Implementation.Common; +using VECTO3GUI2020.ViewModel.Interfaces.Common; + +namespace VECTO3GUI2020.ViewModel +{ + + + public class OutputViewModel : ViewModelBase, IOutputViewModel + { + private object _messageLock = new Object(); + private ObservableCollection<string> _messages = new ObservableCollection<string>(); + + public ObservableCollection<string> Messages + { + get + { + return _messages; + } + } + + + public OutputViewModel() + { + BindingOperations.EnableCollectionSynchronization(Messages, _messageLock ); + } + + } + + public interface IOutputViewModel + { + ObservableCollection<string> Messages { get; } + } +} \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index 0db360ee01b0261ff54ffb291c5cbeb71d685f83..201f3a6e959daf1fa6f2a36a354707ca8267f54c 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Configuration; using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices.WindowsRuntime; using System.Text; using System.Threading.Tasks; @@ -139,6 +140,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _multiStageViewModelFactory.GetAuxiliariesViewModel(consolidatedVehicleData?.Components? .BusAuxiliaries); AirdragModifiedMultistageEditingEnabled = false; + + _editingEnabledDictionary = new IndexedStorage<bool>(() => OnPropertyChanged(nameof(EditingEnabledDictionary))); } public IVehicleDeclarationInputData ConsolidatedVehicleData @@ -418,6 +421,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } set { AirdragModifiedMultistage = value?.toNullableBool(); + } } @@ -874,5 +878,21 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } } #endregion + + private IndexedStorage<bool> _editingEnabledDictionary; + public IndexedStorage<bool> EditingEnabledDictionary + { + get + { + return _editingEnabledDictionary; + } + } + + + + + + + } } \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs index a4dd118e5b71a2321b0d447fde615d2a0531e78e..16fd6f488762a9a0c0537eed227a81934d0475de 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs @@ -76,6 +76,16 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _primaryVehicleHybridElectric, value); } + private IndexedStorage<bool> _editingEnabledDictionary; + public IndexedStorage<bool> EditingEnabledDictionary + { + get + { + return _editingEnabledDictionary; + } + } + + #region HVAC @@ -182,12 +192,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation if (value == HeatPumpType.none) { HeatPumpModeDriverCompartmentAllowedValues = EnumHelper.GetValuesAsObservableCollectionIncluding<Enum, HeatPumpMode>(items:HeatPumpMode.N_A); - //HeatPumpModeDriverCompartment = HeatPumpMode.N_A; + } else { HeatPumpModeDriverCompartmentAllowedValues = EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, HeatPumpMode>( items: HeatPumpMode.N_A); - //HeatPumpModeDriverCompartment = HeatPumpMode.cooling; + } @@ -421,6 +431,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public MultistageAuxiliariesViewModel(IBusAuxiliariesDeclarationData consolidatedAuxiliariesInputData) { ConsolidatedInputData = consolidatedAuxiliariesInputData; + HeatPumpGroupEditingEnabled = true; + _editingEnabledDictionary = new IndexedStorage<bool>(() => { + OnPropertyChanged(nameof(EditingEnabledDictionary)); + }); } #region Implementation of IElectricSupplyDeclarationData diff --git a/VECTO3GUI2020/Views/CustomControls/CustomControlExtensionMethods.cs b/VECTO3GUI2020/Views/CustomControls/CustomControlExtensionMethods.cs index 9e20a7d91150eef7b68948a48496b9e6ec322127..2ec0293c978e8bb63c3d7dcaec5299690c3ee1e0 100644 --- a/VECTO3GUI2020/Views/CustomControls/CustomControlExtensionMethods.cs +++ b/VECTO3GUI2020/Views/CustomControls/CustomControlExtensionMethods.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using VECTO3GUI2020.Annotations; @@ -27,12 +28,15 @@ namespace VECTO3GUI2020.Views.CustomControls /// <returns></returns> public static string GetLabelByPropertyName(this UserControl userControl, DependencyProperty dependencyProperty, params ResourceManager[] resourceManagers) { + string name = null; var binding = userControl.GetBindingExpression(dependencyProperty); var propertyName = binding?.ResolvedSourcePropertyName; - if (propertyName == null || binding == null) - { + + if (propertyName == null || binding == null) { + var status = binding?.Status; + throw new VectoException("Could not resolve binding"); return name; } diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/LabledTextBoxMultistage.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/LabledTextBoxMultistage.xaml index 8cbe4833020ab645120abad5c0ce701ea2a7c60f..9bd3572f1d5e855052e4ab90d30054417ef7751e 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/LabledTextBoxMultistage.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/LabledTextBoxMultistage.xaml @@ -16,8 +16,8 @@ <Label> <PriorityBinding> - <Binding ElementName="lableTextBoxMultistage" Path="Label" Converter="{StaticResource NullToUnsetValue}"></Binding> - <Binding ElementName="labledTextBoxMultistage" Path="GeneratedLabelText"></Binding> + <Binding Path="Label" ElementName="labledTextBoxMultistage" Converter="{StaticResource NullToUnsetValue}"></Binding> + <Binding Path="GeneratedLabelText" ElementName="labledTextBoxMultistage"></Binding> </PriorityBinding> </Label> diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml index 3a9a0549a89212bb77ae222e32629eea1a0683d9..2e0428f1e9fef66402e3c032ea6da910cd7a61b0 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml @@ -96,16 +96,17 @@ </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> - - <!--ItemsSource="{Binding ListItems, ElementName=MultistageParameterControl}"--> - <ComboBox x:Name="comboBox1" Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" - SelectedValue="{Binding Content, Mode=TwoWay, ElementName=MultistageParameterControl, ValidatesOnExceptions=True}" - IsEnabled="{Binding EditingEnabled, ElementName=MultistageParameterControl}" - IsEditable="False" MouseDoubleClick="Control_OnMouseDoubleClick"> + +<!--ItemsSource="{Binding ListItems, ElementName=MultistageParameterControl}"--> + <ComboBox x:Name="comboBoxCurrent" Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" + SelectedIndex="{Binding EditingEnabled, ElementName=MultistageParameterControl, Converter={StaticResource BoolToIntConverter}}" + SelectedItem="{Binding Content, Mode=TwoWay, ElementName=MultistageParameterControl, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" + IsEnabled="{Binding EditingEnabled, ElementName=MultistageParameterControl}" + IsEditable="False" MouseDoubleClick="Control_OnMouseDoubleClick"> <ComboBox.ItemsSource> <PriorityBinding> - <Binding Path="ListItems" ElementName="MultistageParameterControl" Converter="{StaticResource NullToUnsetValue}"/> - <Binding Path="GeneratedListItems" ElementName="MultistageParameterControl"/> + <Binding Path="ListItems" ElementName="MultistageParameterControl" Converter="{StaticResource NullToUnsetValue}" UpdateSourceTrigger="PropertyChanged"/> + <Binding Path="GeneratedListItems" ElementName="MultistageParameterControl" UpdateSourceTrigger="PropertyChanged"/> </PriorityBinding> </ComboBox.ItemsSource> <ComboBox.ItemTemplate> @@ -153,7 +154,7 @@ </CheckBox> <CheckBox x:Name="checkBox1" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="{Binding ElementName=MultistageParameterControl, - Path=EditingEnabled}"> + Path=EditingEnabled, UpdateSourceTrigger=PropertyChanged}"> </CheckBox> <Label x:Name="label4" Grid.Column="4" diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml.cs b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml.cs index 6c5bcd53d3e429cb7b6990608dff992dfa1b6e5e..a4e411f9ac04a8b89d3c1a5c91525258f17de0b1 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml.cs +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/MultiStageParameter.xaml.cs @@ -12,6 +12,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; +using System.Windows.Forms.VisualStyles; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -97,15 +98,27 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls } - public static readonly DependencyProperty GeneratedLabelTextProperty = DependencyProperty.Register( - "GeneratedLabelText", typeof(string), typeof(MultiStageParameter), new PropertyMetadata(null)); + //public static readonly DependencyProperty GeneratedLabelTextProperty = DependencyProperty.Register( + // "GeneratedLabelText", typeof(string), typeof(MultiStageParameter), new PropertyMetadata(null)); + //public string GeneratedLabelText + //{ + // get { return (string)GetValue(GeneratedLabelTextProperty); } + // set { SetValue(GeneratedLabelTextProperty, value); } + //} + + private string _generatedLabelText; public string GeneratedLabelText { - get { return (string)GetValue(GeneratedLabelTextProperty); } - set { SetValue(GeneratedLabelTextProperty, value); } + get { return _generatedLabelText; } + set + { + _generatedLabelText = value; + OnPropertyChanged(nameof(GeneratedLabelText)); + } } + public static readonly DependencyProperty NameLookUpResourceManagerProperty = DependencyProperty.Register( "NameLookUpResourceManager", typeof(ResourceManager), typeof(MultiStageParameter), new PropertyMetadata(default(ResourceManager), NameLookUpResourceManagerChanged)); @@ -145,7 +158,18 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls public object DummyContent { get { return (object)GetValue(DummyContentProperty); } - set { SetValue(DummyContentProperty, value); } + set { SetCurrentValue(DummyContentProperty, value); } + } + + private object _dummyContent = null; + public object DummyContentGenerated + { + get { return _dummyContent;} + set + { + _dummyContent = value; + OnPropertyChanged(nameof(DummyContentGenerated)); + } } @@ -164,7 +188,21 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls DependencyProperty.Register("Content", typeof(object), typeof(MultiStageParameter), - new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ContentChanged)); //TODO Default value null breaks it for SIs default value "" for strings + new FrameworkPropertyMetadata(defaultValue: null, + flags: FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, + propertyChangedCallback: OnContentChanged, + coerceValueCallback: ContentCoerced)); //TODO Default value null breaks it for SIs default value "" for strings + + private static object ContentCoerced(DependencyObject d, object basevalue) + { + ((MultiStageParameter)d).ContentChanged(); + + + + + + return basevalue; + } public new object Content { @@ -172,16 +210,27 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls set { SetCurrentValue(ContentProperty, value); + OnPropertyChanged(nameof(Content)); } } public static readonly DependencyProperty ListItemsProperty = DependencyProperty.Register( "ListItems", typeof(ObservableCollection<Enum>), typeof(MultiStageParameter), - new FrameworkPropertyMetadata(default(ObservableCollection<Enum>), ListItemsChanged)); + new FrameworkPropertyMetadata(defaultValue:default(ObservableCollection<Enum>), propertyChangedCallback:ListItemsChanged)); private static void ListItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - //throw new NotImplementedException(); + return; + + var listItems = e.NewValue as ObservableCollection<Enum>; + var multistageParameter = (MultiStageParameter)d; + if (multistageParameter.Mode == MultistageParameterViewMode.COMBOBOX && listItems != null) { + if (!listItems.Contains(multistageParameter.Content as Enum)) { + multistageParameter.Content = listItems[0]; + } + } + + } public ObservableCollection<Enum> ListItems @@ -194,22 +243,37 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls public static readonly DependencyProperty GeneratedListItemsProperty = DependencyProperty.Register( "GeneratedListItems", typeof(List<object>), typeof(MultiStageParameter), new PropertyMetadata(defaultValue:null)); + + public List<object> GeneratedListItems { get { return (List<object>)GetValue(GeneratedListItemsProperty); } - set { SetValue(GeneratedListItemsProperty, value); } + set { SetCurrentValue(GeneratedListItemsProperty, value); } } + private object StoredContent { get; set; } = null; + + + public bool resolvedContentProperty { get; set; } = false; + #endregion -#endregion + private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((MultiStageParameter)d).ContentChanged(); + } - private static void ContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + public void ContentChanged() { - var multiStageParameter = (CustomControls.MultiStageParameter) d; + var multiStageParameter = (CustomControls.MultiStageParameter)this; + var binding = multiStageParameter.GetBindingExpression(ContentProperty); + if (binding?.Status != BindingStatus.Active || resolvedContentProperty) { + return; + } + if (multiStageParameter.DummyContent == null) { - multiStageParameter.DummyContent = multiStageParameter.CreateDummyContent(e, multiStageParameter); + multiStageParameter.DummyContent = multiStageParameter.CreateDummyContent(); } if (multiStageParameter.Content != null) { @@ -217,7 +281,6 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls } if (multiStageParameter.Mode == MultistageParameterViewMode.COMBOBOX) { - multiStageParameter.GenerateListItemsAndSetComboboxValue(); } @@ -225,11 +288,16 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls if (multiStageParameter.GeneratedLabelText == null) { multiStageParameter.SetLabelText(); } + + resolvedContentProperty = true; + EditingEnabledChanged(EditingEnabled); } + public void SetLabelText() { - if (Label == null) { + var binding = this.GetBindingExpression(ContentProperty); + if (Label == null && binding != null) { this.GeneratedLabelText = this.GetLabelByPropertyName( MultiStageParameter.ContentProperty, this.NameLookUpResourceManager, @@ -243,36 +311,26 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls return; if (GeneratedListItems == null) { - if (DummyContent is Enum dummyEnum) - { + if (DummyContent is Enum dummyEnum) { var enType = dummyEnum.GetType(); GeneratedListItems = Enum.GetValues(enType).Cast<object>().ToList(); - } - - if (Content is Enum contentEnum) - { + }else if (Content is Enum contentEnum) { var enType = contentEnum.GetType(); GeneratedListItems = Enum.GetValues(enType).Cast<object>().ToList(); } - - //ListItems = GeneratedListItems; } } - private object CreateDummyContent(DependencyPropertyChangedEventArgs e, UserControl userControl) + private object CreateDummyContent() { - var type = userControl.GetPropertyType(e.Property); + var type = this.GetPropertyType(ContentProperty); if (type == null) { return null; } - if (type == typeof(ConvertedSI)) { - //var dummyContent = new ConvertedSI(0, (userControl.Content as ConvertedSI).Units); - return null; //dummyContent; - } try { dynamic dynType = type; var baseType = dynType.BaseType; @@ -285,22 +343,29 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls var createMethod = baseType.GetMethod("Create"); var dummyContent = createMethod?.Invoke(null, new object[] { (new double()) }); return dummyContent; - }else if(Mode == MultistageParameterViewMode.COMBOBOX) { - var bindingProperty = userControl.GetBindingExpression(e.Property); + } + + + + + if(Mode == MultistageParameterViewMode.COMBOBOX) { + var bindingProperty = this.GetBindingExpression(ContentProperty); var dataItemType = bindingProperty?.DataItem?.GetType(); var sourcePropertyType = dataItemType?.GetProperty(bindingProperty?.ResolvedSourcePropertyName)?.PropertyType; var underlyingType = Nullable.GetUnderlyingType(dynType); Enum dummyEnum; - if (underlyingType != null) { - dummyEnum = Enum.Parse(underlyingType, underlyingType.GetEnumNames()[0]); - } else { - dummyEnum = Enum.Parse(dynType, dynType.GetEnumNames()[0]); + try { + if (underlyingType != null) { + dummyEnum = Enum.Parse(underlyingType, underlyingType.GetEnumNames()[0]); + } else { + dummyEnum = Enum.Parse(dynType, dynType.GetEnumNames()[0]); + } + } catch (Exception ex) { + Debug.WriteLine(ex.Message); + return null; } - - - return dummyEnum; } @@ -314,26 +379,61 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls private static void EditingEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - MultiStageParameter multiStageParameter = (MultiStageParameter)d; - if((bool)e.NewValue == false) { - if (!Validation.GetHasError(multiStageParameter.TextBoxContent)) { - multiStageParameter.DummyContent = multiStageParameter.Content; + ((MultiStageParameter) d).EditingEnabledChanged((bool)e.NewValue); + } + + public void EditingEnabledChanged(bool editingEnabled) + { + if (GetBindingExpression(EditingEnabledProperty)?.Status != BindingStatus.Active) { + return; + } + + this.CoerceValue(ContentProperty); + this.CoerceValue(ListItemsProperty); + MultiStageParameter multistageParameter = this; + if (editingEnabled == false) + { + //Temporary store current value + if (!Validation.GetHasError(multistageParameter.TextBoxContent)) + { + multistageParameter.StoredContent = multistageParameter.Content; } - multiStageParameter.Content = null; - } else { - if (multiStageParameter.Content != null) { - multiStageParameter.DummyContent = multiStageParameter.Content; - }else if (multiStageParameter.DummyContent != null) { - if (multiStageParameter.Mode == MultistageParameterViewMode.COMBOBOX) { - if (multiStageParameter.ListItems != null && !multiStageParameter.ListItems.Contains(multiStageParameter.DummyContent)) { - multiStageParameter.Content = multiStageParameter.ListItems[0]; - } else { - multiStageParameter.Content = multiStageParameter.DummyContent; + + if (multistageParameter.Content != null) { + multistageParameter.Content = null; + } + } + else + { + if (Content == null) { + if (multistageParameter.StoredContent != null) + { + //Restore previous value + multistageParameter.Content = multistageParameter.StoredContent; + } + else + { + if (multistageParameter.Mode == MultistageParameterViewMode.COMBOBOX) + { + //Set default value; + multistageParameter.GetBindingExpression(ListItemsProperty)?.UpdateTarget(); + multistageParameter.GetBindingExpression(ContentProperty)?.UpdateTarget(); + + + /* + multistageParameter.Content = multistageParameter.ListItems?[0] ?? + multistageParameter.GeneratedListItems?[0]; + //Debug.Assert(false); + */ + } + else + { + if (multistageParameter.Content == null && multistageParameter.DummyContent != null) + { + multistageParameter.Content = multistageParameter.DummyContent; + } } - } else { - multiStageParameter.Content = multiStageParameter.DummyContent; } - } } } @@ -343,10 +443,10 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls - public MultiStageParameter() { InitializeComponent(); + } private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) diff --git a/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml b/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml index 0efa6ea2f18f2d296816507deeb731c2fa21b114..7fb94114a081a2ded31c2bd9b298d5a0fdd6ff80 100644 --- a/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml +++ b/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml @@ -16,44 +16,49 @@ <Label Background="{DynamicResource ButtonHighlightColor}" FontSize="15" HorizontalAlignment="Stretch">AUXILIARIES</Label> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.ElectricConsumers.InteriorLightsLED}" - Content="{Binding InteriorLightsLED}"/> + Content="{Binding InteriorLightsLED}" + EditingEnabled="{Binding EditingEnabledDictionary[InteriorLightsLED]}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.ElectricConsumers.DayrunninglightsLED}" - Content="{Binding DayrunninglightsLED}"/> + Content="{Binding DayrunninglightsLED}" + EditingEnabled="{Binding EditingEnabledDictionary[DayrunninglightsLED]}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.ElectricConsumers.PositionlightsLED}" - Content="{Binding PositionlightsLED}"/> + Content="{Binding PositionlightsLED}" + EditingEnabled="{Binding EditingEnabledDictionary[PositionLightsLED]}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.ElectricConsumers.BrakelightsLED}" - Content="{Binding BrakelightsLED}"/> + Content="{Binding BrakelightsLED}" + EditingEnabled="{Binding EditingEnabledDictionary[PositionLightsLED]}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.ElectricConsumers.HeadlightsLED}" - Content="{Binding HeadlightsLED}"/> + Content="{Binding HeadlightsLED}" + EditingEnabled="{Binding EditingEnabledDictionary[HeadLightsLED]}"/> <Separator/> <customControls:MultiStageParameter Mode="COMBOBOX" - EditingEnabled="{Binding HeatPumpGroupEditingEnabled}" + EditingEnabled="{Binding HeatPumpGroupEditingEnabled, Mode=TwoWay}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.SystemConfiguration}" Content="{Binding HVACAux.SystemConfiguration}"/> <customControls:MultiStageParameter Mode="COMBOBOX" - EditingEnabled="{Binding HeatPumpGroupEditingEnabled}" + EditingEnabled="{Binding HeatPumpGroupEditingEnabled, Mode=TwoWay}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.HeatPumpTypeDriverCompartment}" Content="{Binding HeatPumpTypeDriverCompartment}" ShowCheckBox="False"/> <customControls:MultiStageParameter Mode="COMBOBOX" - EditingEnabled="{Binding HeatPumpGroupEditingEnabled}" + EditingEnabled="{Binding HeatPumpGroupEditingEnabled, Mode=TwoWay}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.HeatPumpModeDriverCompartment}" Content="{Binding HeatPumpModeDriverCompartment}" ListItems="{Binding HeatPumpModeDriverCompartmentAllowedValues}" ShowCheckBox="False"/> <customControls:MultiStageParameter Mode="COMBOBOX" - EditingEnabled="{Binding HeatPumpGroupEditingEnabled}" + EditingEnabled="{Binding HeatPumpGroupEditingEnabled, Mode=TwoWay}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.HeatPumpTypePassengerCompartment}" Content="{Binding HeatPumpTypePassengerCompartment}" ShowCheckBox="False"/> <customControls:MultiStageParameter Mode="COMBOBOX" - EditingEnabled="{Binding HeatPumpGroupEditingEnabled}" + EditingEnabled="{Binding HeatPumpGroupEditingEnabled, Mode=TwoWay}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.HeatPumpModePassengerCompartment}" Content="{Binding HeatPumpModePassengerCompartment}" ListItems="{Binding HeatPumpModePassengerCompartmentAllowedValues}" @@ -62,29 +67,39 @@ <!--<customControls:MultiStageParameter Mode="COMBOBOX" PreviousContent="{Binding ConsolidatedInputData.PneumaticSupply.CompressorDrive}" Content="{Binding CompressorDrive}"></customControls:MultiStageParameter>--> + <customControls:MultiStageParameter Mode="TEXTBOX" Validation.ErrorTemplate="{DynamicResource multistageParameterControlErrorTemplate}" PreviousContent="{Binding ConsolidatedInputData.HVACAux.AuxHeaterPower}" - Content="{Binding AuxHeaterPower}"/> + Content="{Binding AuxHeaterPower}" + EditingEnabled="{Binding EditingEnabledDictionary[AuxHeaterPower]}"/> + <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.DoubleGlazing}" - Content="{Binding DoubleGlazing}"/> + Content="{Binding DoubleGlazing}" + EditingEnabled="{Binding EditingEnabledDictionary[DoubleGlazing]}"/> + <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.AdjustableAuxiliaryHeater}" + EditingEnabled="{Binding EditingEnabledDictionary[AdjustableAuxiliaryHeater]}" Content="{Binding AdjustableAuxiliaryHeater}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.SeparateAirDistributionDucts}" + EditingEnabled="{Binding EditingEnabledDictionary[SeparateAirDistributionDucts]}" Content="{Binding SeparateAirDistributionDucts}"/> <StackPanel Visibility="{Binding PrimaryVehicleHybridElectric, Converter={StaticResource BooleanToVisibilityConverter}}"> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.WaterElectricHeater}" - Content="{Binding WaterElectricHeater}"/> + Content="{Binding WaterElectricHeater}" + EditingEnabled="{Binding EditingEnabledDictionary[WaterElectricHeater]}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.AirElectricHeater}" + EditingEnabled="{Binding AirElectricHeater}" Content="{Binding AirElectricHeater}"/> <customControls:MultiStageParameter Mode="CHECKBOX" PreviousContent="{Binding ConsolidatedInputData.HVACAux.OtherHeatingTechnology}" + EditingEnabled="{Binding OtherHeatingTechnology}" Content="{Binding OtherHeatingTechnology}"/> </StackPanel> <Separator/> diff --git a/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml b/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml index 14fdd3e62ef2c5ad1ca3935b4181f9de347d5ef5..9d8137454ca38e97b76c0d0a162239683443eb07 100644 --- a/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml +++ b/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml @@ -29,7 +29,7 @@ </StackPanel> </DockPanel> - <ContentControl DockPanel.Dock="Top" Content="{Binding CurrentView}"/> + <ContentControl DockPanel.Dock="Top" Content="{Binding CurrentView}"/> </DockPanel> </Grid> </UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml index e10142f82367902087c5e473f7e81b48cbd052c0..b685d0e93706bbd56ae3e742dac5ef652f26e7b7 100644 --- a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml +++ b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml @@ -12,10 +12,12 @@ d:DesignHeight="450" d:DesignWidth="800" BorderBrush="{DynamicResource ButtonHighlightColor}" BorderThickness="2px" Margin="4px"> <UserControl.Resources> <Style TargetType="custom:MultiStageParameter"> - <!--<Setter Property="NameLookUpResourceManager" Value="{Binding Source=BusStringResourceManager}"></Setter>--> - <Setter Property="NameLookUpResourceManager" Value="{x:Static properties:BusStrings.ResourceManager}"></Setter> - </Style> + <Setter Property="NameLookUpResourceManager" Value="{x:Static properties:BusStrings.ResourceManager}"/> + </Style> </UserControl.Resources> + + <!--RelativeSource={x:Static RelativeSource.Self}, {Binding RelativeSource={x:Static RelativeSource.Self}, Path=Name}] + Path=(Validation.Errors)/ErrorContent}--> <Grid> <ScrollViewer> <DockPanel> @@ -23,52 +25,65 @@ <Label Content="VEHICLE DATA" HorizontalAlignment="Stretch" FontSize="15" VerticalAlignment="Stretch" Style="{DynamicResource LabelStyle1}"/> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + <custom:MultiStageParameter + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" Optional="False" - Content="{Binding Manufacturer, ValidatesOnDataErrors=True}"/> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + Content="{Binding Manufacturer, ValidatesOnDataErrors=True}" + PreviousContent="{Binding }"/> + <custom:MultiStageParameter + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" Optional="False" Content="{Binding ManufacturerAddress, ValidatesOnDataErrors=True}"/> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + <custom:MultiStageParameter + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" Optional="False" Content="{Binding VIN, ValidatesOnDataErrors=True}"/> <custom:MultiStageParameter PreviousContent="{Binding ConsolidatedVehicleData.Model}" - Content="{Binding Model}"/> + Content="{Binding Model}" + Tag="{Binding RelativeSource={RelativeSource Self}, Path=Content}" + EditingEnabled="{Binding EditingEnabledDictionary[Model]}"/> <custom:MultiStageParameter PreviousContent="{Binding ConsolidatedVehicleData.LegislativeClass}" + EditingEnabled="{Binding EditingEnabledDictionary[LegislativeClass]}" Content="{Binding LegislativeClass}" Mode="COMBOBOX" /> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" - PreviousContent="{Binding ConsolidatedVehicleData.CurbMassChassis}" - Content="{Binding CurbMassChassis}"/> + <custom:MultiStageParameter + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + PreviousContent="{Binding ConsolidatedVehicleData.CurbMassChassis}" + EditingEnabled="{Binding EditingEnabledDictionary[CurbMassChassis]}" + Content="{Binding CurbMassChassis}"/> - <custom:MultiStageParameter Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" - PreviousContent="{Binding ConsolidatedVehicleData.GrossVehicleMassRating}" - Content="{Binding GrossVehicleMassRating}"/> + <custom:MultiStageParameter + Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" + PreviousContent="{Binding ConsolidatedVehicleData.GrossVehicleMassRating}" + EditingEnabled="{Binding EditingEnabledDictionary[GrossVehicleMassRating]}" + Content="{Binding GrossVehicleMassRating}"/> - <custom:MultiStageParameter x:Name="AirdragModified" - Label="Airdrag modified" + <custom:MultiStageParameter + Label="Airdrag modified" Validation.ErrorTemplate="{StaticResource multistageParameterControlErrorTemplate}" - EditingEnabled="{Binding AirdragModifiedMultistageEditingEnabled}" - PreviousContent="{Binding ConsolidatedAirdragmodified}" - Content="{Binding AirdragModifiedEnum, ValidatesOnDataErrors=True}" - Mode="COMBOBOX"/> + EditingEnabled="{Binding AirdragModifiedMultistageEditingEnabled}" + PreviousContent="{Binding ConsolidatedAirdragmodified}" + Content="{Binding AirdragModifiedEnum, ValidatesOnDataErrors=True}" + Mode="COMBOBOX"/> <custom:MultiStageParameter PreviousContent="{Binding ConsolidatedVehicleData.TankSystem}" - Content="{Binding TankSystem}" - Mode="COMBOBOX" /> + Content="{Binding TankSystem}" + EditingEnabled="{Binding EditingEnabledDictionary[TankSystem]}" + Mode="COMBOBOX"> + </custom:MultiStageParameter> <custom:MultiStageParameter PreviousContent="{Binding ConsolidatedVehicleData.RegisteredClass}" Content="{Binding RegisteredClass}" + EditingEnabled="{Binding EditingEnabledDictionary[RegisteredClass]}" Mode="COMBOBOX" /> - <Separator/> <custom:MultiStageParameter EditingEnabled="{Binding NumberOfPassengersEditingEnabled}" @@ -84,12 +99,14 @@ PreviousContent="{Binding ConsolidatedVehicleData.VehicleCode}" ListItems="{Binding VehicleCodeAllowedValues}" Content="{Binding VehicleCode}" + EditingEnabled="{Binding EditingEnabledDictionary[VehicleCode]}" Mode="COMBOBOX" /> <custom:MultiStageParameter PreviousContent="{Binding ConsolidatedVehicleData.LowEntry}" Content="{Binding LowEntry}" + EditingEnabled="{Binding EditingEnabledDictionary[LowEntry]}" Mode="CHECKBOX" /> @@ -124,8 +141,9 @@ <custom:MultiStageParameter + x:Name="DoorDriveTechnology" PreviousContent="{Binding ConsolidatedVehicleData.DoorDriveTechnology}" - + EditingEnabled="{Binding EditingEnabledDictionary[DoorDriveTechnology]}" Content="{Binding DoorDriveTechnology}" Mode="COMBOBOX" /> @@ -140,7 +158,6 @@ EditingEnabled="{Binding AdasEditingEnabled}" PreviousContent="{Binding ConsolidatedVehicleData.ADAS.EngineStopStart}" Content="{Binding EngineStopStartNullable}" - Mode="CHECKBOX"/> <custom:MultiStageParameter EditingEnabled="{Binding AdasEditingEnabled}"