@@ -51,7 +51,7 @@ public ArchiveSplittingSizes SplittingSize
51
51
get => ViewModel . SplittingSize . Key ;
52
52
set => ViewModel . SplittingSize = ViewModel . SplittingSizes . First ( size => size . Key == value ) ;
53
53
}
54
-
54
+
55
55
public int CPUThreads
56
56
{
57
57
get => ViewModel . CPUThreads ;
@@ -107,6 +107,7 @@ private void ViewModel_PropertyChanged(object? _, PropertyChangedEventArgs e)
107
107
108
108
private sealed class DialogViewModel : ObservableObject
109
109
{
110
+ private readonly IGeneralSettingsService GeneralSettingsService = Ioc . Default . GetRequiredService < IGeneralSettingsService > ( ) ;
110
111
public bool IsNameValid => FilesystemHelpers . IsValidForFilename ( fileName ) ;
111
112
112
113
public bool ShowNameWarning => ! string . IsNullOrEmpty ( fileName ) && ! IsNameValid ;
@@ -125,33 +126,41 @@ public string FileName
125
126
}
126
127
}
127
128
128
- private FileFormatItem fileFormat ;
129
129
public FileFormatItem FileFormat
130
130
{
131
- get => fileFormat ;
131
+ get => FileFormats . First ( format => format . Key == GeneralSettingsService . ArchiveFormatsOption ) ;
132
132
set
133
133
{
134
- if ( SetProperty ( ref fileFormat , value ) )
134
+ if ( value . Key != GeneralSettingsService . ArchiveFormatsOption )
135
+ {
136
+ GeneralSettingsService . ArchiveFormatsOption = value . Key ;
135
137
OnPropertyChanged ( nameof ( CanSplit ) ) ;
138
+ }
136
139
}
137
140
}
138
141
139
- private CompressionLevelItem compressionLevel ;
140
142
public CompressionLevelItem CompressionLevel
141
143
{
142
- get => compressionLevel ;
143
- set => SetProperty ( ref compressionLevel , value ) ;
144
+ get => CompressionLevels . First ( level => level . Key == GeneralSettingsService . ArchiveCompressionLevelsOption ) ;
145
+ set
146
+ {
147
+ if ( value . Key != GeneralSettingsService . ArchiveCompressionLevelsOption )
148
+ GeneralSettingsService . ArchiveCompressionLevelsOption = value . Key ;
149
+ }
144
150
}
145
151
146
152
public bool CanSplit => FileFormat . Key is ArchiveFormats . SevenZip ;
147
153
148
- private SplittingSizeItem splittingSize ;
149
154
public SplittingSizeItem SplittingSize
150
155
{
151
- get => splittingSize ;
152
- set => SetProperty ( ref splittingSize , value ) ;
156
+ get => SplittingSizes . First ( size => size . Key == GeneralSettingsService . ArchiveSplittingSizesOption ) ;
157
+ set
158
+ {
159
+ if ( value . Key != GeneralSettingsService . ArchiveSplittingSizesOption )
160
+ GeneralSettingsService . ArchiveSplittingSizesOption = value . Key ;
161
+ }
153
162
}
154
-
163
+
155
164
private int cpuThreads = Environment . ProcessorCount ;
156
165
public int CPUThreads
157
166
{
@@ -215,9 +224,7 @@ public string Password
215
224
216
225
public DialogViewModel ( )
217
226
{
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 ) ;
227
+
221
228
}
222
229
223
230
private static string ToSizeText ( ulong megaBytes ) => ByteSize . FromMebiBytes ( megaBytes ) . ShortString ;
0 commit comments