66using System . Collections . ObjectModel ;
77using System . ComponentModel ;
88using System . Diagnostics ;
9+ using System . Globalization ;
910using System . IO ;
1011using System . Linq ;
1112using System . Threading ;
1213using System . Threading . Tasks ;
1314using System . Windows ;
1415using System . Windows . Controls ;
1516using System . Windows . Controls . Primitives ;
17+ using System . Windows . Data ;
1618using System . Windows . Input ;
1719using System . Windows . Media ;
1820using System . Windows . Threading ;
21+ using Flurl ;
1922using Kantan . Text ;
2023using Kantan . Utilities ;
2124using Microsoft . VisualBasic . FileIO ;
@@ -79,7 +82,7 @@ private void Tb_Input_Drop(object sender, DragEventArgs e)
7982 var f1 = files1 . FirstOrDefault ( ) ;
8083
8184 if ( ! string . IsNullOrWhiteSpace ( f1 ) ) {
82- CurrentQueueItem = f1 ;
85+ SetQueue ( f1 ) ;
8386
8487 }
8588
@@ -181,7 +184,9 @@ private void Btn_Restart_Click(object sender, RoutedEventArgs e)
181184 {
182185 var ctrl = Keyboard . Modifiers . HasFlag ( ModifierKeys . Control ) ;
183186 Restart ( ctrl ) ;
184- Queue . Clear ( ) ;
187+ // ClearQueue();
188+ // ClearResults(true);
189+
185190 e . Handled = true ;
186191 }
187192
@@ -200,6 +205,8 @@ private void Btn_Cancel_Click(object sender, RoutedEventArgs e)
200205 Cancel ( ) ;
201206 ReloadToken ( ) ;
202207 Lb_Queue . IsEnabled = true ;
208+ Btn_Run . IsEnabled = true ;
209+ Btn_Remove . IsEnabled = true ;
203210 e . Handled = true ;
204211 }
205212
@@ -215,16 +222,16 @@ private void Btn_Remove_Click(object sender, RoutedEventArgs e)
215222
216223 var old = CurrentQueueItem ;
217224
218- if ( old == null ) {
225+ if ( old == null || old . IsPrimitive ) {
219226 goto ret ;
220227 }
221228 var i = Queue . IndexOf ( old ) ;
222229 Queue . Remove ( old ) ;
223-
230+ old ? . Dispose ( ) ;
224231 // TrySeekQueue(q);
225232 // AdvanceQueue(-1);
226233
227- if ( m_queries . TryRemove ( old , out var sq ) ) {
234+ /* if (m_queries.TryRemove(old, out var sq)) {
228235 m_resultMap.TryRemove(sq, out var result);
229236
230237 foreach (var r in result) {
@@ -233,28 +240,31 @@ private void Btn_Remove_Click(object sender, RoutedEventArgs e)
233240 result.Clear();
234241 /*foreach (var r in m_resultMap[sq]) {
235242 r.Dispose();
236- }*/
243+ }#1#
237244
238245 m_images.TryRemove(sq, out var img);
239246 img = null;
240- }
247+ }*/
248+
241249 // ClearQueryControls();
242250
243- var i2 = i - 1 ;
251+ /* var i2 = i - 1;
244252
245253 i2 = Math.Clamp(i2, 0, Queue.Count);
246- string n ;
254+ ResultModel n;
247255
248256 if (Queue.Count == 0)
249- n = String . Empty ;
257+ n = null ;
250258 else
251259 n = Queue[i2];
252- CurrentQueueItem = n ;
253-
260+ // SetQueue(n);
261+
262+ CurrentQueueItem = n;*/
254263 // Lb_Queue.ItemsSource. = n;
255264 // AdvanceQueue(i-1);
256265
257- sq ? . Dispose ( ) ;
266+ // n?.Dispose();
267+
258268 GC . Collect ( ) ;
259269 GC . WaitForPendingFinalizers ( ) ;
260270 GC . Collect ( ) ;
@@ -269,18 +279,19 @@ private void Btn_Delete_Click(object sender, RoutedEventArgs e)
269279 ClearResults ( ) ;
270280 m_cbDispatch . Stop ( ) ;
271281 var old = CurrentQueueItem ;
272- m_clipboardHistory . Remove ( old ) ;
273- CurrentQueueItem = String . Empty ;
274- m_queries . TryRemove ( old , out var q ) ;
275- m_resultMap . TryRemove ( Query , out var x ) ;
276- Query . Dispose ( ) ;
282+ m_clipboardHistory . Remove ( old . Value ) ;
283+ old . Dispose ( ) ;
284+ // CurrentQueueItem = null;
285+ // m_queries.TryRemove(old, out var q);
286+ // m_resultMap.TryRemove(Query, out var x);
287+ // Query.Dispose();
277288 Queue . Remove ( old ) ;
278289 Img_Preview . Source = m_image = null ;
279- Query = SearchQuery . Null ;
290+ // Query = SearchQuery.Null;
280291 bool ok ;
281292
282293 try {
283- VBFS . DeleteFile ( old , UIOption . OnlyErrorDialogs , RecycleOption . SendToRecycleBin ) ;
294+ VBFS . DeleteFile ( old . Value , UIOption . OnlyErrorDialogs , RecycleOption . SendToRecycleBin ) ;
284295 // FileSystem.SendFileToRecycleBin(old);
285296 ok = true ;
286297 }
@@ -290,8 +301,8 @@ private void Btn_Delete_Click(object sender, RoutedEventArgs e)
290301 }
291302
292303 m_cbDispatch . Start ( ) ;
293- Btn_Delete . IsEnabled = ! ok ;
294- Btn_Remove . IsEnabled = ! ok ;
304+ Btn_Delete . IsEnabled = ok ;
305+ Btn_Remove . IsEnabled = ok ;
295306 AdvanceQueue ( ) ;
296307 // FileSystem.SendFileToRecycleBin(InputText);
297308 e . Handled = true ;
@@ -390,8 +401,9 @@ private void Lv_Results_KeyDown(object sender, KeyEventArgs e)
390401
391402 CurrentResultItem . Dispose ( ) ;
392403
393- Results . Remove ( CurrentResultItem ) ;
404+ // Results.Remove(CurrentResultItem);
394405
406+ CurrentQueueItem . Results . Remove ( CurrentResultItem ) ;
395407 Img_Preview . Source = m_image ;
396408 break ;
397409 case Key . C when ctrl :
@@ -538,7 +550,7 @@ private void Wnd_Main_Loaded(object sender, RoutedEventArgs e)
538550 }
539551
540552 // todo: not used for now
541- // m_trDispatch.Start();
553+ m_trDispatch . Start ( ) ;
542554 e . Handled = true ;
543555 Debug . WriteLine ( "Main loaded" ) ;
544556
@@ -703,8 +715,8 @@ private void Btn_Filter_Click(object sender, RoutedEventArgs e)
703715
704716 private void Tb_Search_TextChanged ( object sender , TextChangedEventArgs e )
705717 {
706- if ( string . IsNullOrWhiteSpace ( Tb_Search . Text ) && m_resultMap . TryGetValue ( Query , out var value ) ) {
707- Lv_Results . ItemsSource = value ;
718+ if ( string . IsNullOrWhiteSpace ( Tb_Search . Text ) ) /* && m_resultMap.TryGetValue(Query, out var value))*/ {
719+ Lv_Results . ItemsSource = CurrentQueueItem . Results ; //todo
708720 }
709721 else {
710722 var selected = ( string ) Cb_SearchFields . SelectionBoxItem ;
@@ -726,4 +738,27 @@ private void Tb_Search_TextChanged(object sender, TextChangedEventArgs e)
726738
727739 e . Handled = true ;
728740 }
741+ }
742+ [ ValueConversion ( typeof ( Url ) , typeof ( String ) ) ]
743+ public class UrlConverter : IValueConverter
744+ {
745+ public object Convert ( object ? value , Type targetType , object ? parameter , CultureInfo culture )
746+ {
747+ if ( value == null ) {
748+ return null ;
749+ }
750+ var date = ( Url ) value ;
751+ return date . ToString ( ) ;
752+ }
753+
754+ public object ConvertBack ( object ? value , Type targetType , object ? parameter , CultureInfo culture )
755+ {
756+ if ( value == null ) {
757+ return null ;
758+ }
759+ string strValue = value as string ;
760+ Url resultDateTime ;
761+
762+ return ( Url ) strValue ;
763+ }
729764}
0 commit comments