From 99b7ac840572a00cb1785849a0e89733152205cd Mon Sep 17 00:00:00 2001 From: "harald.martini@student.tugraz.at" <harald.martini@student.tugraz.at> Date: Mon, 24 May 2021 15:44:52 +0200 Subject: [PATCH] Added Simulation Settings --- VECTO3GUI2020/App.config | 17 ++- VECTO3GUI2020/App.xaml.cs | 12 +- VECTO3GUI2020/Properties/Settings.Designer.cs | 64 ++++++++++- VECTO3GUI2020/Properties/Settings.settings | 17 ++- .../Implementation/JobListViewModel.cs | 14 +-- .../Implementation/SettingsViewModel.cs | 105 +++++++++++++++++- VECTO3GUI2020/Views/SettingsView.xaml | 61 +++++++++- 7 files changed, 271 insertions(+), 19 deletions(-) diff --git a/VECTO3GUI2020/App.config b/VECTO3GUI2020/App.config index 55c4aebced..0251970b1f 100644 --- a/VECTO3GUI2020/App.config +++ b/VECTO3GUI2020/App.config @@ -20,7 +20,22 @@ <value>False</value> </setting> <setting name="DefaultFilePath" serializeAs="String"> - <value>../../../VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration</value> + <value /> + </setting> + <setting name="WriteModalResults" serializeAs="String"> + <value>True</value> + </setting> + <setting name="ModalResults1Hz" serializeAs="String"> + <value>True</value> + </setting> + <setting name="Validate" serializeAs="String"> + <value>True</value> + </setting> + <setting name="ActualModalData" serializeAs="String"> + <value>True</value> + </setting> + <setting name="SerializeVectoRunData" serializeAs="String"> + <value>True</value> </setting> </VECTO3GUI2020.Properties.Settings> </userSettings> diff --git a/VECTO3GUI2020/App.xaml.cs b/VECTO3GUI2020/App.xaml.cs index 6e8981f6a1..93284aafd7 100644 --- a/VECTO3GUI2020/App.xaml.cs +++ b/VECTO3GUI2020/App.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; using Ninject; using Ninject.Extensions.ChildKernel; using VECTO3GUI2020.ViewModel.Interfaces; @@ -10,7 +11,9 @@ using VECTO3GUI2020.Helper; using VECTO3GUI2020.Model.Implementation; using VECTO3GUI2020.Ninject; using VECTO3GUI2020.Ninject.Vehicle; +using VECTO3GUI2020.Properties; using VECTO3GUI2020.ViewModel; +using Application = System.Windows.Application; namespace VECTO3GUI2020 { @@ -22,6 +25,11 @@ namespace VECTO3GUI2020 protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); + + if (Settings.Default.DefaultFilePath == null) { + Settings.Default.DefaultFilePath = Environment.CurrentDirectory; + Settings.Default.Save(); + } ConfigureContainer(); ConfigureMainWindow(); @@ -51,6 +59,8 @@ namespace VECTO3GUI2020 container.Bind<IDialogHelper>().To<DialogHelper>().InSingletonScope(); container.Bind<IWindowHelper>().To<WindowHelper>(); + + } private void ConfigureMainWindow() diff --git a/VECTO3GUI2020/Properties/Settings.Designer.cs b/VECTO3GUI2020/Properties/Settings.Designer.cs index 9fa1af0705..3bc037f81a 100644 --- a/VECTO3GUI2020/Properties/Settings.Designer.cs +++ b/VECTO3GUI2020/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace VECTO3GUI2020.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -37,7 +37,7 @@ namespace VECTO3GUI2020.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("../../../VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration")] + [global::System.Configuration.DefaultSettingValueAttribute("")] public string DefaultFilePath { get { return ((string)(this["DefaultFilePath"])); @@ -46,5 +46,65 @@ namespace VECTO3GUI2020.Properties { this["DefaultFilePath"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool WriteModalResults { + get { + return ((bool)(this["WriteModalResults"])); + } + set { + this["WriteModalResults"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ModalResults1Hz { + get { + return ((bool)(this["ModalResults1Hz"])); + } + set { + this["ModalResults1Hz"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Validate { + get { + return ((bool)(this["Validate"])); + } + set { + this["Validate"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ActualModalData { + get { + return ((bool)(this["ActualModalData"])); + } + set { + this["ActualModalData"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SerializeVectoRunData { + get { + return ((bool)(this["SerializeVectoRunData"])); + } + set { + this["SerializeVectoRunData"] = value; + } + } } } diff --git a/VECTO3GUI2020/Properties/Settings.settings b/VECTO3GUI2020/Properties/Settings.settings index c23c435416..2df355f46b 100644 --- a/VECTO3GUI2020/Properties/Settings.settings +++ b/VECTO3GUI2020/Properties/Settings.settings @@ -6,7 +6,22 @@ <Value Profile="(Default)">False</Value> </Setting> <Setting Name="DefaultFilePath" Type="System.String" Scope="User"> - <Value Profile="(Default)">../../../VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration</Value> + <Value Profile="(Default)" /> + </Setting> + <Setting Name="WriteModalResults" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">True</Value> + </Setting> + <Setting Name="ModalResults1Hz" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">True</Value> + </Setting> + <Setting Name="Validate" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">True</Value> + </Setting> + <Setting Name="ActualModalData" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">True</Value> + </Setting> + <Setting Name="SerializeVectoRunData" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">True</Value> </Setting> </Settings> </SettingsFile> \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 0f83960537..53ef91bd26 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -289,13 +289,13 @@ namespace VECTO3GUI2020.ViewModel.Implementation var fileWriter = new FileOutputWriter(GetOutputDirectory(fullFileName)); var runsFactory = new SimulatorFactory(mode, input, fileWriter) - {/* - WriteModalResults = true, - ModalResults1Hz = true, - Validate = true, - ActualModalData = true, - SerializeVectoRunData = true - */ + { + WriteModalResults = Settings.Default.WriteModalResults, + ModalResults1Hz = Settings.Default.ModalResults1Hz, + Validate = Settings.Default.Validate, + ActualModalData = Settings.Default.ActualModalData, + SerializeVectoRunData = Settings.Default.SerializeVectoRunData, + }; foreach (var runId in jobContainer.AddRuns(runsFactory)) { diff --git a/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs index 7e8ab4110f..7b25852acf 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Windows; using System.Windows.Forms; using System.Windows.Input; using VECTO3GUI2020.Helper; @@ -22,7 +23,13 @@ namespace VECTO3GUI2020.ViewModel.Implementation private String _defaultFilePath; - public String DefaultFilePath + private bool _writeModalResults; + private bool _modalResults1Hz; + private bool _validate; + private bool _actualModalData; + private bool _serializeVectoRunData; + + public String DefaultFilePath { get => _defaultFilePath; set @@ -32,16 +39,41 @@ namespace VECTO3GUI2020.ViewModel.Implementation SetProperty(ref _defaultFilePath, value, "DefaultFilePath"); } } - public SettingsViewModel(IDialogHelper dialogHelper) + + + + public SettingsViewModel(IDialogHelper dialogHelper) { base.Title = "Settings"; _settings = Settings.Default; _defaultFilePath = _settings.DefaultFilePath; + _writeModalResults = _settings.WriteModalResults; + _modalResults1Hz = _settings.ModalResults1Hz; + _validate = _settings.Validate; + _actualModalData = _settings.ActualModalData; + _serializeVectoRunData = _settings.SerializeVectoRunData; _dialogHelper = dialogHelper; } + private ICommand _closeWindowCommand; + public ICommand CloseWindowCommand + { + get + { + return _closeWindowCommand ?? new RelayCommand<Window>(window => CloseWindow(window, _dialogHelper), window => true); + } + } + + private void CloseWindow(Window window, bool ask) + { + + } + + + + - public ICommand ChangeFilePath + public ICommand ChangeFilePath { get { @@ -69,6 +101,71 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } + public bool SerializeVectoRunData + { + get => _serializeVectoRunData; + set + { + if (SetProperty(ref _serializeVectoRunData, value)) { + _settings.SerializeVectoRunData = value; + _settings.Save(); + } + } + } - } + public bool ActualModalData + { + get => _actualModalData; + set + { + if (SetProperty(ref _actualModalData, value)) { + _settings.ActualModalData = value; + _settings.Save(); + + } + } + } + + public bool Validate + { + get => _validate; + set + { + if (SetProperty(ref _validate, value)) + { + _settings.Validate = value; + _settings.Save(); + + } + } + } + + public bool ModalResults1Hz + { + get => _modalResults1Hz; + set + { + if (SetProperty(ref _modalResults1Hz, value)) + { + _settings.ModalResults1Hz = value; + _settings.Save(); + + } + } + } + + public bool WriteModalResults + { + get => _writeModalResults; + set + { + if (SetProperty(ref _writeModalResults, value)) + { + _settings.WriteModalResults = value; + _settings.Save(); + + } + } + } + } } diff --git a/VECTO3GUI2020/Views/SettingsView.xaml b/VECTO3GUI2020/Views/SettingsView.xaml index b026ea4a7b..3f8531f45b 100644 --- a/VECTO3GUI2020/Views/SettingsView.xaml +++ b/VECTO3GUI2020/Views/SettingsView.xaml @@ -7,9 +7,64 @@ xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation" mc:Ignorable="d" Height="450" Width="800" d:DataContext="{d:DesignInstance implementation:SettingsViewModel }"> + <UserControl.Resources> + <Style TargetType="Label"> + <Setter Property="Margin" Value="4 4 4 4"></Setter> + <Setter Property="Padding" Value="4 4 4 4"></Setter> + </Style> + <Style TargetType="CheckBox"> + <Setter Property="Margin" Value="4 4 4 4"></Setter> + <Setter Property="Padding" Value="4 4 4 4"></Setter> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + </Style> + </UserControl.Resources> + <Grid> - <StackPanel> - <customControls:FilePicker Width="450" MinWidth="400" Text="{Binding DefaultFilePath}" HorizontalAlignment="Stretch" Command="{Binding ChangeFilePath}"/> - </StackPanel> + <DockPanel LastChildFill="False"> + <Grid DockPanel.Dock="Top"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"></ColumnDefinition> + <ColumnDefinition Width="1*"></ColumnDefinition> + <ColumnDefinition Width="1*"></ColumnDefinition> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"></RowDefinition> + <RowDefinition Height="30"></RowDefinition> + <RowDefinition Height="30"></RowDefinition> + <RowDefinition Height="30"></RowDefinition> + </Grid.RowDefinitions> + + + <Label Grid.Row="0" Grid.Column="0" DockPanel.Dock="Left">Default Path</Label> + <customControls:FilePicker Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" DockPanel.Dock="Right" + Text="{Binding DefaultFilePath}" + HorizontalAlignment="Stretch" Command="{Binding ChangeFilePath}"/> + + <Label Grid.Row="1" Grid.Column="0">Serialize Vecto Run Data</Label> + <CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding SerializeVectoRunData}"></CheckBox> + + <Label Grid.Row="1" Grid.Column="2">Write Modal Results</Label> + <CheckBox Grid.Row="1" Grid.Column="3" IsChecked="{Binding WriteModalResults}"></CheckBox> + + <Label Grid.Row="2" Grid.Column="0">Validate</Label> + <CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding Validate}"></CheckBox> + + <Label Grid.Row="2" Grid.Column="2">Actual Modal Data</Label> + <CheckBox Grid.Row="2" Grid.Column="3" IsChecked="{Binding ActualModalData}"></CheckBox> + + <Label Grid.Row="3" Grid.Column="0">ModalResults1Hz</Label> + <CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding ModalResults1Hz}"></CheckBox> + </Grid> + <!--<DockPanel DockPanel.Dock="Bottom" LastChildFill="False"> + <Button DockPanel.Dock="Right" + Width="100" + Command="{Binding CloseWindowCommand}" + CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" + Style="{DynamicResource MultiStageButtonStyle1}" + Margin="4" + Padding="4">Close</Button> + </DockPanel>--> + </DockPanel> </Grid> </UserControl> -- GitLab