@@ -108,36 +108,22 @@ private bool LoadJsonProfile(string filePath)
108108 //拖拽输入
109109 private void SelectProjectFile_Drop ( object sender , System . Windows . DragEventArgs e )
110110 {
111- string FileName = ( ( string [ ] ) e . Data . GetData ( System . Windows . DataFormats . FileDrop ) ) [ 0 ] ;
112- //临时修复json输入过滤器
113- if ( Path . GetExtension ( FileName ) . ToLower ( ) != ".json" )
114- {
115- return ;
116- }
111+ string fileName = ( e . Data . GetData ( System . Windows . DataFormats . FileDrop ) as string [ ] ) [ 0 ] ;
117112
118- wizardInfo . ProjectFile = FileName ;
119- if ( LoadJsonProfile ( wizardInfo . ProjectFile ) )
120- {
121- SelectProjectFile . CanSelectNextPage = true ;
122- }
123- else
124- {
125- SelectProjectFile . CanSelectNextPage = false ;
126- }
127- return ;
113+ wizardInfo . ProjectFile = fileName ;
114+ SelectProjectFile . CanSelectNextPage = LoadJsonProfile ( wizardInfo . ProjectFile ) ;
128115 }
129116
130117
131- private void SelectProjectFile_PreviewDragEnter ( object sender , System . Windows . DragEventArgs e )
118+ private void SelectProjectFile_PreviewDrop ( object sender , System . Windows . DragEventArgs e )
132119 {
133- if ( e . Data . GetDataPresent ( System . Windows . DataFormats . FileDrop ) &&
134- Path . GetExtension ( ( ( string [ ] ) e . Data . GetData ( System . Windows . DataFormats . FileDrop ) ) [ 0 ] ) . ToLower ( ) == ".json" )
135- //理论上只允许json文件拖拽输入,但是不知道为什么文件过滤并没有生效
120+ string fileDrop = System . Windows . DataFormats . FileDrop ;
121+ if ( e . Data . GetDataPresent ( fileDrop ) &&
122+ Path . GetExtension ( ( e . Data . GetData ( fileDrop ) as string [ ] ) [ 0 ] ) . ToLower ( ) != ".json" )
136123 {
137124 e . Effects = System . Windows . DragDropEffects . Copy ;
138125 e . Handled = true ;
139126 }
140- return ;
141127 }
142128
143129
@@ -152,15 +138,7 @@ private void OpenProjectBtn_Click(object sender, RoutedEventArgs e)
152138 }
153139
154140 wizardInfo . ProjectFile = ofd . FileName ;
155- if ( LoadJsonProfile ( wizardInfo . ProjectFile ) )
156- {
157- SelectProjectFile . CanSelectNextPage = true ;
158- }
159- else
160- {
161- // 配置文件无效
162- SelectProjectFile . CanSelectNextPage = false ;
163- }
141+ SelectProjectFile . CanSelectNextPage = LoadJsonProfile ( wizardInfo . ProjectFile ) ;
164142 }
165143
166144 private void OpenInputFile_Click ( object sender , RoutedEventArgs e )
@@ -246,38 +224,29 @@ private void WizardFinish(object sender, RoutedEventArgs e)
246224 private void DeleteInput_Click ( object sender , RoutedEventArgs e )
247225 {
248226 DeleteInputVideoFiles ( ) ;
249-
250- return ;
251227 }
252228
253- private void InputList_PreviewDragEnter ( object sender , System . Windows . DragEventArgs e )
229+ private void InputList_PreviewDrop ( object sender , System . Windows . DragEventArgs e )
254230 {
255- if ( e . Data . GetDataPresent ( System . Windows . DataFormats . FileDrop ) )
256- {
257- e . Effects = System . Windows . DragDropEffects . Copy ;
258- e . Handled = true ;
259- }
260- return ;
231+ // nothing
261232 }
262233
263234 private void InputList_Drop ( object sender , System . Windows . DragEventArgs e )
264235 {
265- string [ ] InputPaths = ( string [ ] ) e . Data . GetData ( System . Windows . DataFormats . FileDrop ) ;
266- string [ ] AllowExts = { ".mkv" , ".m2ts" , ".mp4" } ;
236+ string [ ] inputPaths = e . Data . GetData ( System . Windows . DataFormats . FileDrop ) as string [ ] ;
237+ string [ ] allowedExts = { ".mkv" , ".m2ts" , ".mp4" } ;
267238
268- var InputFileList = from InputPath in InputPaths
269- from AllowExt in AllowExts
270- where ( Path . GetExtension ( InputPath ) ) == AllowExt
271- select InputPath ;
239+ string [ ] inputFileList = inputPaths . Where ( i => allowedExts . Contains ( Path . GetExtension ( i ) ) ) . ToArray ( ) ;
272240
273- foreach ( var InputFile in InputFileList )
241+ foreach ( string inputFile in inputFileList )
274242 {
275- if ( ! wizardInfo . InputFile . Contains ( InputFile ) )
276- wizardInfo . InputFile . Add ( InputFile ) ;
243+ if ( ! wizardInfo . InputFile . Contains ( inputFile ) )
244+ {
245+ wizardInfo . InputFile . Add ( inputFile ) ;
246+ }
277247 }
278248
279249 SelectInputFile . CanFinish = wizardInfo . InputFile . Count > 0 ;
280- return ;
281250 }
282251
283252 private void InputList_KeyDown ( object sender , System . Windows . Input . KeyEventArgs e )
@@ -286,8 +255,6 @@ private void InputList_KeyDown(object sender, System.Windows.Input.KeyEventArgs
286255 {
287256 DeleteInputVideoFiles ( ) ;
288257 }
289-
290- return ;
291258 }
292259
293260 private void DeleteInputVideoFiles ( )
0 commit comments