diff --git a/VECTO3GUI2020/App.config b/VECTO3GUI2020/App.config index 0251970b1f2003f57f84b520df97729776920158..f16f0863ce8b4ad80311d1e1bd0b5073a7cc3899 100644 --- a/VECTO3GUI2020/App.config +++ b/VECTO3GUI2020/App.config @@ -37,6 +37,9 @@ <setting name="SerializeVectoRunData" serializeAs="String"> <value>True</value> </setting> + <setting name="DefaultOutputPath" serializeAs="String"> + <value /> + </setting> </VECTO3GUI2020.Properties.Settings> </userSettings> <runtime> diff --git a/VECTO3GUI2020/Properties/Settings.Designer.cs b/VECTO3GUI2020/Properties/Settings.Designer.cs index 3bc037f81a86feca40ba4c55e737b1d9b27dfad0..78e0471711f38b352703436909e712ed7d3f3dd8 100644 --- a/VECTO3GUI2020/Properties/Settings.Designer.cs +++ b/VECTO3GUI2020/Properties/Settings.Designer.cs @@ -106,5 +106,17 @@ namespace VECTO3GUI2020.Properties { this["SerializeVectoRunData"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string DefaultOutputPath { + get { + return ((string)(this["DefaultOutputPath"])); + } + set { + this["DefaultOutputPath"] = value; + } + } } } diff --git a/VECTO3GUI2020/Properties/Settings.settings b/VECTO3GUI2020/Properties/Settings.settings index 2df355f46b83587c3384a61d670b4bfbc489731c..7d279b47c5819b8dfb73077904a27512a6487a87 100644 --- a/VECTO3GUI2020/Properties/Settings.settings +++ b/VECTO3GUI2020/Properties/Settings.settings @@ -23,5 +23,8 @@ <Setting Name="SerializeVectoRunData" Type="System.Boolean" Scope="User"> <Value Profile="(Default)">True</Value> </Setting> + <Setting Name="DefaultOutputPath" Type="System.String" Scope="User"> + <Value Profile="(Default)" /> + </Setting> </Settings> </SettingsFile> \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 70c23b77c853ba41eea6c099979a0a5cadf06c45..20b83f277ab7535ebda70e3f76b8643e0a3665c2 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -187,13 +187,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation Time = DateTime.Now, Type = MessageType.InfoMessage, }); + return; } } //TODO add output path to settings var outputPath = Settings.Default.DefaultFilePath; - var sumFileWriter = new FileOutputWriter(outputPath); + var sumFileWriter = new FileOutputWriter(GetOutputDirectory(Jobs.First(x => x.Selected).DataSource.SourceFile)); @@ -453,21 +454,17 @@ namespace VECTO3GUI2020.ViewModel.Implementation private string GetOutputDirectory(string jobFilePath) { var outFile = jobFilePath; - var OutputDirectory = Settings.Default.DefaultFilePath; - if (!string.IsNullOrWhiteSpace(OutputDirectory)) - { - if (Path.IsPathRooted(OutputDirectory)) - { - outFile = Path.Combine(OutputDirectory, Path.GetFileName(jobFilePath) ?? ""); - } - else - { - outFile = Path.Combine(Path.GetDirectoryName(jobFilePath) ?? "", OutputDirectory, Path.GetFileName(jobFilePath) ?? ""); - } - if (!Directory.Exists(Path.GetDirectoryName(outFile))) - { - Directory.CreateDirectory(Path.GetDirectoryName(outFile)); - } + var outputDirectory = Settings.Default.DefaultOutputPath; + if (string.IsNullOrWhiteSpace(outputDirectory)) { + return outFile; + } + + outFile = Path.IsPathRooted(outputDirectory) + ? Path.Combine(outputDirectory, Path.GetFileName(jobFilePath) ?? "") + : Path.Combine(Path.GetDirectoryName(jobFilePath) ?? "", outputDirectory, + Path.GetFileName(jobFilePath) ?? ""); + if (!Directory.Exists(Path.GetDirectoryName(outFile))) { + Directory.CreateDirectory(Path.GetDirectoryName(outFile)); } return outFile; diff --git a/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs index 7b25852acf3f4f95f6ff09a89df4c1e8afd67061..e1a1adcb5081ee54ec837f75d327609e0cc477ca 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/SettingsViewModel.cs @@ -17,19 +17,20 @@ namespace VECTO3GUI2020.ViewModel.Implementation private Settings _settings; private ICommand _changePath; - + private ICommand _changeOutPath; private IDialogHelper _dialogHelper; - private String _defaultFilePath; + private string _defaultFilePath; + private string _defaultOutputPath; private bool _writeModalResults; private bool _modalResults1Hz; private bool _validate; private bool _actualModalData; private bool _serializeVectoRunData; - public String DefaultFilePath + public string DefaultFilePath { get => _defaultFilePath; set @@ -40,7 +41,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } - + public string DefaultOutputPath { + get => _defaultOutputPath; + set { + _settings.DefaultOutputPath = value; + _settings.Save(); + SetProperty(ref _defaultOutputPath, value, "DefaultOutputPath"); + } + } public SettingsViewModel(IDialogHelper dialogHelper) { @@ -56,6 +64,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation } private ICommand _closeWindowCommand; + public ICommand CloseWindowCommand { get @@ -101,6 +110,21 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } + public ICommand ChangeOutputPath { + get { + return _changeOutPath ?? new RelayCommand(() => { + var new_path = _dialogHelper.OpenFolderDialog(DefaultFilePath); + if (new_path != null) { + DefaultOutputPath = new_path; + } + }, () => { return true; }); + } + private set { + _changeOutPath = value; + OnPropertyChanged(); + } + } + public bool SerializeVectoRunData { get => _serializeVectoRunData; @@ -167,5 +191,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } } + + } } diff --git a/VECTO3GUI2020/Views/SettingsView.xaml b/VECTO3GUI2020/Views/SettingsView.xaml index 3f8531f45b33c0e6b998e3a5ee58e71282ec22df..225d9506482e2c5aa0e773fb63623bc488f283da 100644 --- a/VECTO3GUI2020/Views/SettingsView.xaml +++ b/VECTO3GUI2020/Views/SettingsView.xaml @@ -29,6 +29,7 @@ <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> + <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="30"></RowDefinition> <RowDefinition Height="30"></RowDefinition> @@ -41,20 +42,42 @@ 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="0" DockPanel.Dock="Left">Default Path</Label> + <Grid Grid.Row="1" Grid.Column="1" Margin="4" VerticalAlignment="Stretch" Grid.ColumnSpan="3" DockPanel.Dock="Right"> + <Grid.RowDefinitions> + <RowDefinition></RowDefinition> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition></ColumnDefinition> + <ColumnDefinition Width="30px"></ColumnDefinition> + </Grid.ColumnDefinitions> + <TextBox x:Name="textBox" VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="false" + Text="{Binding DefaultOutputPath}" HorizontalAlignment="Stretch" TextWrapping="Wrap" + Style="{DynamicResource TextBoxStyle1}"/> + <Button x:Name="button" Padding="4" Margin="4 0 0 0" Grid.Column="1" ContentTemplate="{DynamicResource AddDocumentIcon}" + Command="{Binding ChangeOutputPath}" Style="{DynamicResource FilePickerButtonStyle}"> + + </Button> + </Grid> + <!--<customControls:FilePicker Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" DockPanel.Dock="Right" + Text="{Binding DefaultOutputPath}" + HorizontalAlignment="Stretch" Command="{Binding ChangeOutputPath}"/>--> + + + <Label Grid.Row="2" Grid.Column="0">Serialize Vecto Run Data</Label> + <CheckBox Grid.Row="2" 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="3" Grid.Column="2">Write Modal Results</Label> + <CheckBox Grid.Row="3" 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="3" Grid.Column="0">Validate</Label> + <CheckBox Grid.Row="3" 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="4" Grid.Column="2">Actual Modal Data</Label> + <CheckBox Grid.Row="4" 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> + <Label Grid.Row="4" Grid.Column="0">ModalResults1Hz</Label> + <CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding ModalResults1Hz}"></CheckBox> </Grid> <!--<DockPanel DockPanel.Dock="Bottom" LastChildFill="False"> <Button DockPanel.Dock="Right"