1919using SmartImage . Mode . Shell . Assets ;
2020using SmartImage . Utilities ;
2121using Terminal . Gui ;
22+ using Clipboard = Novus . Win32 . Clipboard ;
2223using Window = Terminal . Gui . Window ;
2324
2425// ReSharper disable IdentifierTypo
@@ -305,7 +306,7 @@ public ShellMode(string[] args)
305306 m_cbCallbackTok = Application . MainLoop . AddTimeout ( TimeoutTimeSpan , ClipboardCallback ) ;
306307
307308 m_clipboard = new List < ustring > ( ) ;
308-
309+
309310 Mb_Menu . Menus = new MenuBarItem [ ]
310311 {
311312 new ( "_About" , null , AboutDialog ) ,
@@ -364,7 +365,7 @@ public ShellMode(string[] args)
364365
365366 Tv_Results . CellActivated += Result_CellActivated ;
366367 Btn_Run . Clicked += Run_Clicked ;
367- Btn_Restart . Clicked += Restart_Clicked ;
368+ Btn_Restart . Clicked += ( ) => Restart_Clicked ( false ) ;
368369 Btn_Clear . Clicked += Clear_Clicked ;
369370 Btn_Config . Clicked += ConfigDialog ;
370371 Btn_Cancel . Clicked += Cancel_Clicked ;
@@ -377,32 +378,18 @@ public ShellMode(string[] args)
377378 HttpUtilities . TryOpenUrl ( Query . Upload ) ;
378379 } ;
379380
380- Btn_Delete . Clicked += ( ) =>
381- {
382- var file = Tf_Input . Text . ToString ( ) ;
383-
384- if ( ! string . IsNullOrWhiteSpace ( file ) ) {
385- Query . Dispose ( ) ;
386- Debug . WriteLine ( $ "{ IsQueryReady ( ) } ") ;
387- FileSystem . DeleteFile ( file , UIOption . OnlyErrorDialogs , RecycleOption . SendToRecycleBin ) ;
388- Debug . WriteLine ( $ "deleted { file } ") ;
389- Clear ( ) ;
390- }
381+ Btn_Delete . Clicked += On_Delete ;
391382
392- } ;
393-
394383 Cb_Queue . Toggled += b =>
395384 {
396385 Btn_Queue . Enabled = ! b ;
397386 } ;
398387
399388 Btn_Queue . Clicked += ( ) =>
400389 {
401- if ( IsQueryReady ( ) ) {
402-
403- }
390+ if ( IsQueryReady ( ) ) { }
404391 } ;
405-
392+
406393 Btn_Queue . Enabled = false ;
407394
408395 Win . Add ( Lbl_Input , Tf_Input , Btn_Run , Lbl_InputOk ,
@@ -425,6 +412,23 @@ public ShellMode(string[] args)
425412 }
426413 }
427414
415+ private void On_Delete ( )
416+ {
417+ Clipboard . Close ( ) ;
418+ Restart_Clicked ( true ) ;
419+
420+ var file = Tf_Input . Text . ToString ( ) ;
421+
422+ if ( ! string . IsNullOrWhiteSpace ( file ) ) {
423+ Query . Dispose ( ) ;
424+ Debug . WriteLine ( $ "{ IsQueryReady ( ) } ") ;
425+ FileSystem . DeleteFile ( file , UIOption . OnlyErrorDialogs , RecycleOption . SendToRecycleBin ) ;
426+ Debug . WriteLine ( $ "deleted { file } ") ;
427+ Clear ( ) ;
428+ }
429+
430+ }
431+
428432 public Task < object ? > RunAsync ( object ? sender = null )
429433 {
430434 Application . Run ( ) ;
@@ -454,7 +458,8 @@ private void OnResult(object o, SearchResult result)
454458
455459 Application . MainLoop . Invoke ( ( ) =>
456460 {
457- Dt_Results . Rows . Add ( $ "{ result . Engine . Name } (Raw)", result . RawUrl , 0 , 0 , null , $ "{ result . Status } ",
461+ Dt_Results . Rows . Add ( $ "{ result . Engine . Name } (Raw)",
462+ result . RawUrl , 0 , 0 , null , $ "{ result . Status } ",
458463 null , null , null , null , null , null ) ;
459464
460465 for ( int i = 0 ; i < result . Results . Count ; i ++ ) {
@@ -618,6 +623,7 @@ private async Task<bool> SetQuery(ustring text)
618623 Lbl_QueryUpload . Text = ustring . Empty ;
619624 Pbr_Status . Fraction = 0 ;
620625 Lbl_Status2 . Text = ustring . Empty ;
626+ Btn_Delete . Enabled = false ;
621627
622628 return false ;
623629 }
@@ -637,7 +643,8 @@ private async Task<bool> SetQuery(ustring text)
637643 Pbr_Status . Fraction = 0 ;
638644 // Btn_Delete.Enabled = true;
639645
640- Tf_Input . ReadOnly = true ;
646+ Tf_Input . ReadOnly = true ;
647+ Btn_Delete . Enabled = true ;
641648
642649 return true ;
643650 }
0 commit comments