@@ -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,8 @@ 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 > ( ) ;
111
+
110
112
public bool IsNameValid => FilesystemHelpers . IsValidForFilename ( fileName ) ;
111
113
112
114
public bool ShowNameWarning => ! string . IsNullOrEmpty ( fileName ) && ! IsNameValid ;
@@ -125,33 +127,41 @@ public string FileName
125
127
}
126
128
}
127
129
128
- private FileFormatItem fileFormat ;
129
130
public FileFormatItem FileFormat
130
131
{
131
- get => fileFormat ;
132
+ get => FileFormats . First ( format => format . Key == GeneralSettingsService . ArchiveFormatsOption ) ;
132
133
set
133
134
{
134
- if ( SetProperty ( ref fileFormat , value ) )
135
+ if ( value . Key != GeneralSettingsService . ArchiveFormatsOption )
136
+ {
137
+ GeneralSettingsService . ArchiveFormatsOption = value . Key ;
135
138
OnPropertyChanged ( nameof ( CanSplit ) ) ;
139
+ }
136
140
}
137
141
}
138
142
139
- private CompressionLevelItem compressionLevel ;
140
143
public CompressionLevelItem CompressionLevel
141
144
{
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
+ }
144
151
}
145
152
146
153
public bool CanSplit => FileFormat . Key is ArchiveFormats . SevenZip ;
147
154
148
- private SplittingSizeItem splittingSize ;
149
155
public SplittingSizeItem SplittingSize
150
156
{
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
+ }
153
163
}
154
-
164
+
155
165
private int cpuThreads = Environment . ProcessorCount ;
156
166
public int CPUThreads
157
167
{
@@ -215,9 +225,7 @@ public string Password
215
225
216
226
public DialogViewModel ( )
217
227
{
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
+
221
229
}
222
230
223
231
private static string ToSizeText ( ulong megaBytes ) => ByteSize . FromMebiBytes ( megaBytes ) . ShortString ;
0 commit comments