@@ -60,16 +60,14 @@ public FormEditSettings(in ViewSettings viewSettings, in IFileSettingPhysicalFil
60
60
61
61
InitializeComponent ( ) ;
62
62
63
- if ( m_ViewSettings . LimitDuration == ViewSettings . Duration . Unlimited )
64
- domainUpDownLimit . SelectedIndex = 4 ;
65
- else if ( m_ViewSettings . LimitDuration == ViewSettings . Duration . TenSecond )
66
- domainUpDownLimit . SelectedIndex = 3 ;
67
- else if ( m_ViewSettings . LimitDuration == ViewSettings . Duration . TwoSecond )
68
- domainUpDownLimit . SelectedIndex = 2 ;
69
- else if ( m_ViewSettings . LimitDuration == ViewSettings . Duration . Second )
70
- domainUpDownLimit . SelectedIndex = 1 ;
71
- else
72
- domainUpDownLimit . SelectedIndex = 0 ;
63
+ domainUpDownLimit . SelectedIndex = m_ViewSettings . LimitDuration switch
64
+ {
65
+ ViewSettings . Duration . Unlimited => 0 ,
66
+ ViewSettings . Duration . TenSecond => 1 ,
67
+ ViewSettings . Duration . TwoSecond => 2 ,
68
+ ViewSettings . Duration . Second => 3 ,
69
+ ViewSettings . Duration . HalfSecond => 4
70
+ } ;
73
71
74
72
toolTip . SetToolTip ( checkBoxAllowRowCombining ,
75
73
@"Try to combine rows, it can happen if the column does contain a linefeed and is not properly quoted.
@@ -154,7 +152,7 @@ await buttonGuessCP.RunWithHourglassAsync(async () =>
154
152
#if NET5_0_OR_GREATER
155
153
await
156
154
#endif
157
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
155
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
158
156
var ( codepage , bom ) = await improvedStream . GuessCodePage ( m_CancellationTokenSource . Token ) ;
159
157
csvFile . CodePageId = codepage ;
160
158
csvFile . ByteOrderMark = bom ;
@@ -170,7 +168,7 @@ await buttonGuessDelimiter.RunWithHourglassAsync(async () =>
170
168
#if NET5_0_OR_GREATER
171
169
await
172
170
#endif
173
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
171
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
174
172
var res = await improvedStream . GuessDelimiter ( csvFile . CodePageId , csvFile . SkipRows ,
175
173
csvFile . EscapePrefix ,
176
174
m_CancellationTokenSource . Token ) ;
@@ -189,7 +187,7 @@ await buttonGuessTextQualifier.RunWithHourglassAsync(async () =>
189
187
#if NET5_0_OR_GREATER
190
188
await
191
189
#endif
192
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
190
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
193
191
qualifier = await improvedStream . GuessQualifier ( csvFile . CodePageId , csvFile . SkipRows ,
194
192
csvFile . FieldDelimiter , csvFile . EscapePrefix ,
195
193
m_CancellationTokenSource . Token ) ;
@@ -207,7 +205,7 @@ await buttonSkipLine.RunWithHourglassAsync(async () =>
207
205
#if NET5_0_OR_GREATER
208
206
await
209
207
#endif
210
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
208
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
211
209
csvFile . SkipRows = await improvedStream . GuessStartRow ( csvFile . CodePageId , csvFile . FieldDelimiter ,
212
210
csvFile . FieldQualifier , csvFile . CommentLine , m_CancellationTokenSource . Token ) ;
213
211
} ) ;
@@ -280,7 +278,7 @@ await buttonNewLine.RunWithHourglassAsync(async () =>
280
278
#if NET5_0_OR_GREATER
281
279
await
282
280
#endif
283
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
281
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
284
282
cboRecordDelimiter . SelectedValue = ( int ) await improvedStream . GuessNewline ( csvFile . CodePageId ,
285
283
csvFile . SkipRows ,
286
284
csvFile . FieldQualifier , m_CancellationTokenSource . Token ) ;
@@ -319,15 +317,15 @@ private void TextBoxFile_Validating(object? sender, CancelEventArgs e)
319
317
320
318
private void DomainUpDownTime_SelectedItemChanged ( object ? sender , EventArgs e )
321
319
{
322
- m_ViewSettings . LimitDuration = domainUpDownLimit . SelectedIndex switch
323
- {
324
- 4 => ViewSettings . Duration . Unlimited ,
325
- 3 => ViewSettings . Duration . TenSecond ,
326
- 2 => ViewSettings . Duration . TwoSecond ,
327
- 1 => ViewSettings . Duration . Second ,
328
- 0 => ViewSettings . Duration . HalfSecond ,
329
- _ => m_ViewSettings . LimitDuration
330
- } ;
320
+ if ( domainUpDownLimit . SelectedIndex != - 1 )
321
+ m_ViewSettings . LimitDuration = domainUpDownLimit . SelectedIndex switch
322
+ {
323
+ 0 => ViewSettings . Duration . Unlimited ,
324
+ 1 => ViewSettings . Duration . TenSecond ,
325
+ 2 => ViewSettings . Duration . TwoSecond ,
326
+ 3 => ViewSettings . Duration . Second ,
327
+ 4 => ViewSettings . Duration . HalfSecond
328
+ } ;
331
329
}
332
330
333
331
private async void ButtonGuessHeader_Click ( object ? sender , EventArgs e )
@@ -338,7 +336,7 @@ await buttonGuessHeader.RunWithHourglassAsync(async () =>
338
336
#if NET5_0_OR_GREATER
339
337
await
340
338
#endif
341
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
339
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
342
340
var res = await improvedStream . GuessHasHeader ( csvFile . CodePageId , csvFile . SkipRows , csvFile . CommentLine ,
343
341
csvFile . FieldDelimiter , m_CancellationTokenSource . Token ) ;
344
342
csvFile . HasFieldHeader = string . IsNullOrEmpty ( res ) ;
@@ -364,7 +362,7 @@ await buttonGuessLineComment.RunWithHourglassAsync(async () =>
364
362
#if NET5_0_OR_GREATER
365
363
await
366
364
#endif
367
- using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
365
+ using var improvedStream = new ImprovedStream ( new SourceAccess ( csvFile ) ) ;
368
366
csvFile . CommentLine = await improvedStream . GuessLineComment ( csvFile . CodePageId , csvFile . SkipRows ,
369
367
m_CancellationTokenSource . Token ) ;
370
368
} ) ;
0 commit comments