diff --git a/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs b/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs index 581f2b6887558af6a22171a026ec7156693f4126..1656da5d2dc5b74ceb4a609ec74a9f137e00311c 100644 --- a/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs +++ b/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs @@ -32,6 +32,7 @@ namespace VECTO3GUI2020.Helper public interface IMultistageParameterViewModel { + bool IsReadOnly { get; set; } bool EditingEnabled { get; set; } object CurrentContent { get; set; } object DummyContent { get; set; } @@ -63,6 +64,8 @@ namespace VECTO3GUI2020.Helper private Type _underlyingTargetType; private readonly string _propertyName; + private bool _isReadOnly; + private bool _valueFieldIsEditable; public MultistageParameterViewModel ( string propertyName, @@ -192,6 +195,15 @@ namespace VECTO3GUI2020.Helper } + public bool IsReadOnly + { + get => _isReadOnly; + set + { + SetProperty(ref _isReadOnly, value); + UpdateValueFieldEditable(); + } + } public bool EditingEnabled { @@ -223,6 +235,24 @@ namespace VECTO3GUI2020.Helper } OnPropertyChanged(nameof(CurrentContent)); OnPropertyChanged(nameof(EditingEnabled)); + UpdateValueFieldEditable(); + } + } + + + public bool ValueFieldIsEditable + { + get => _valueFieldIsEditable; + private set => SetProperty(ref _valueFieldIsEditable, value); + } + + private void UpdateValueFieldEditable() + { + if (IsReadOnly) { + ValueFieldIsEditable = false; + return; + } else { + ValueFieldIsEditable = EditingEnabled; } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs index 6de4ff6bf64cb136fe22fb201892bbef0cc22e0c..997d39e5c4a2dfdc9b70c04b61df0dcbb300499e 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs @@ -52,7 +52,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation ConsolidatedHeatPumpConfigurationsPassenger.Add(new HeatPumpConfiguration() { HeatPumpMode = heatPumpMode, - HeatPumpType = heatPumpType + HeatPumpType = heatPumpType, + IsReadOnly = true, }); } } @@ -193,7 +194,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation HeatPumpConfigurationsPassenger.Add(new HeatPumpConfiguration() { HeatPumpType = heatPumpType, - HeatPumpMode = heatPumpMode + HeatPumpMode = heatPumpMode, }); } } @@ -467,6 +468,16 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation }); } + public bool IsReadOnly + { + get => HeatPumpModeVM.IsReadOnly && HeatPumpTypeVM.IsReadOnly; + set + { + HeatPumpTypeVM.IsReadOnly = value; + HeatPumpModeVM.IsReadOnly = value; + } + } + #region Implementation of ITuple int ITuple.Length => 2; diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/MultistageParameterComboBoxView.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/MultistageParameterComboBoxView.xaml index ddb9a253e4bcd5d23ea7fc9bff82ff0a80a90099..f9cd78e85b89989bf8459d383c49dd73d452821b 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/MultistageParameterComboBoxView.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/MultistageParameterComboBoxView.xaml @@ -20,7 +20,7 @@ <Label x:Name="label1"> <PriorityBinding> <Binding Path="Label" Converter="{StaticResource NullToUnsetValue}"></Binding> - <Binding Path="GeneratedLabelText"></Binding> + <!--<Binding Path="GeneratedLabelText"></Binding>--> </PriorityBinding> </Label> <CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="CheckBoxCombo" @@ -29,8 +29,9 @@ IsChecked="{Binding EditingEnabled, Mode=TwoWay}" Checked="CheckBoxCombo_OnChecked"/> - <ComboBox x:Name="comboBox" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" IsTabStop="False" Visibility="{Binding Optional, - Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False" Focusable="False" IsEditable="False" + <ComboBox x:Name="comboBox" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" IsTabStop="False" + Visibility="{Binding Optional, + Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False" Focusable="False" IsEditable="False" SelectedValue="{Binding PreviousContent, Mode=TwoWay}" ItemsSource="{Binding GeneratedListItems}"> <ComboBox.ItemTemplate> @@ -40,15 +41,13 @@ </ComboBox.ItemTemplate> </ComboBox> - <!--SelectedIndex="{Binding EditingEnabled, ElementName=MultistageParameterControl, Converter={StaticResource BoolToIntConverter}}"--> - <!--ItemsSource="{Binding ListItems, ElementName=MultistageParameterControl}"--> <ComboBox x:Name="comboBoxCurrent" Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2 0 2 0" SelectedValue="{Binding CurrentContent, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" - IsEnabled="{Binding EditingEnabled}" + IsEnabled="{Binding ValueFieldIsEditable}" IsEditable="False"> <ComboBox.ItemsSource> <PriorityBinding> @@ -63,9 +62,8 @@ </ComboBox.ItemTemplate> </ComboBox> - <Label x:Name="label2" Grid.Column="4" - Content="{Binding DummyContent, Converter={StaticResource SIToUnitStringConverter}}"> + Content="{Binding DummyContent, Converter={StaticResource SIToUnitStringConverter}}"> </Label> </Grid> </Grid>