@@ -51,7 +51,7 @@ public ArchiveSplittingSizes SplittingSize
5151 get => ViewModel . SplittingSize . Key ;
5252 set => ViewModel . SplittingSize = ViewModel . SplittingSizes . First ( size => size . Key == value ) ;
5353 }
54-
54+
5555 public int CPUThreads
5656 {
5757 get => ViewModel . CPUThreads ;
@@ -107,6 +107,8 @@ private void ViewModel_PropertyChanged(object? _, PropertyChangedEventArgs e)
107107
108108 private sealed class DialogViewModel : ObservableObject
109109 {
110+ private readonly IGeneralSettingsService GeneralSettingsService = Ioc . Default . GetRequiredService < IGeneralSettingsService > ( ) ;
111+
110112 public bool IsNameValid => FilesystemHelpers . IsValidForFilename ( fileName ) ;
111113
112114 public bool ShowNameWarning => ! string . IsNullOrEmpty ( fileName ) && ! IsNameValid ;
@@ -125,33 +127,41 @@ public string FileName
125127 }
126128 }
127129
128- private FileFormatItem fileFormat ;
129130 public FileFormatItem FileFormat
130131 {
131- get => fileFormat ;
132+ get => FileFormats . First ( format => format . Key == GeneralSettingsService . ArchiveFormatsOption ) ;
132133 set
133134 {
134- if ( SetProperty ( ref fileFormat , value ) )
135+ if ( value . Key != GeneralSettingsService . ArchiveFormatsOption )
136+ {
137+ GeneralSettingsService . ArchiveFormatsOption = value . Key ;
135138 OnPropertyChanged ( nameof ( CanSplit ) ) ;
139+ }
136140 }
137141 }
138142
139- private CompressionLevelItem compressionLevel ;
140143 public CompressionLevelItem CompressionLevel
141144 {
142- get => compressionLevel ;
143- set => SetProperty ( ref compressionLevel , value ) ;
145+ get => CompressionLevels . First ( level => level . Key == GeneralSettingsService . ArchiveCompressionLevelsOption ) ;
146+ set
147+ {
148+ if ( value . Key != GeneralSettingsService . ArchiveCompressionLevelsOption )
149+ GeneralSettingsService . ArchiveCompressionLevelsOption = value . Key ;
150+ }
144151 }
145152
146153 public bool CanSplit => FileFormat . Key is ArchiveFormats . SevenZip ;
147154
148- private SplittingSizeItem splittingSize ;
149155 public SplittingSizeItem SplittingSize
150156 {
151- get => splittingSize ;
152- set => SetProperty ( ref splittingSize , value ) ;
157+ get => SplittingSizes . First ( size => size . Key == GeneralSettingsService . ArchiveSplittingSizesOption ) ;
158+ set
159+ {
160+ if ( value . Key != GeneralSettingsService . ArchiveSplittingSizesOption )
161+ GeneralSettingsService . ArchiveSplittingSizesOption = value . Key ;
162+ }
153163 }
154-
164+
155165 private int cpuThreads = Environment . ProcessorCount ;
156166 public int CPUThreads
157167 {
@@ -215,9 +225,7 @@ public string Password
215225
216226 public DialogViewModel ( )
217227 {
218- fileFormat = FileFormats . First ( format => format . Key is ArchiveFormats . Zip ) ;
219- compressionLevel = CompressionLevels . First ( level => level . Key is ArchiveCompressionLevels . Normal ) ;
220- splittingSize = SplittingSizes . First ( size => size . Key is ArchiveSplittingSizes . None ) ;
228+
221229 }
222230
223231 private static string ToSizeText ( ulong megaBytes ) => ByteSize . FromMebiBytes ( megaBytes ) . ShortString ;
0 commit comments