@@ -106,7 +106,7 @@ public MainWindow()
106106
107107 Logs = new ObservableCollection < LogEntry > ( ) ;
108108 Lv_Logs . ItemsSource = Logs ;
109- Lv_Results . ItemsSource = Results ;
109+ // Lv_Results.ItemsSource = CurrentQueueItem. Results;
110110 Lb_Queue . ItemsSource = Queue ;
111111
112112 Client . OnResult += OnResult ;
@@ -137,7 +137,7 @@ public MainWindow()
137137 Rb_UploadEngine_Litterbox . IsChecked = BaseUploadEngine . Default is LitterboxEngine ;
138138
139139 BindingOperations . EnableCollectionSynchronization ( Queue , m_lock ) ;
140- BindingOperations . EnableCollectionSynchronization ( Results , m_lock ) ;
140+ BindingOperations . EnableCollectionSynchronization ( CurrentQueueItem . Results , m_lock ) ;
141141 RenderOptions . SetBitmapScalingMode ( Img_Preview , BitmapScalingMode . HighQuality ) ;
142142
143143 Application . Current . Dispatcher . InvokeAsync ( CheckForUpdate ) ;
@@ -223,7 +223,7 @@ public SearchQuery Query
223223 set { CurrentQueueItem . Query = value ; }
224224 }
225225
226- public ObservableCollection < ResultItem > Results => CurrentQueueItem . Results ;
226+ // public ObservableCollection<ResultItem> Results => CurrentQueueItem.Results;
227227
228228 public bool UseContextMenu
229229 {
@@ -311,7 +311,7 @@ private void OnCurrentQueueItemChanged(object? sender, PropertyChangedEventArgs
311311 {
312312
313313 var ok = SearchQuery . IsValidSourceType ( CurrentQueueItem ? . Value ) ;
314-
314+ // var ok = true;
315315 // var ok = true;
316316
317317 if ( ok /*&& !IsInputReady()*/ ) {
@@ -325,7 +325,26 @@ private void OnCurrentQueueItemChanged(object? sender, PropertyChangedEventArgs
325325 }
326326
327327 Btn_Run . IsEnabled = ok ;
328+ /*if (CurrentQueueItem is { HasQuery: true } && Url.IsValid(CurrentQueueItem.Query.Upload)) {
329+ Tb_Upload.Text = CurrentQueueItem.Query.Upload;
330+
331+ }
332+ else {
333+ Tb_Upload.Text = null;
334+ }
335+
336+ Tb_Info.Text = CurrentQueueItem.Info;
337+ Tb_Status.Text = CurrentQueueItem.Status;
338+ Tb_Status2.Text = CurrentQueueItem.Status2;*/
339+
340+ if ( ! ok ) {
341+ ClearQueryControls ( ) ;
328342
343+ Dispatcher . InvokeAsync ( ( ) =>
344+ {
345+ CurrentQueueItem . UpdateProperties ( ) ;
346+ } ) ;
347+ }
329348 } ) ;
330349 // m_us.Release();
331350 }
@@ -564,21 +583,25 @@ void UpdateImage()
564583
565584 private void HandleQueryAsync ( )
566585 {
567- if ( ( Config . AutoSearch && ! Client . IsRunning ) && ! Results . Any ( ) && CurrentQueueItem . CanSearch ) {
586+
587+ if ( ( Config . AutoSearch && ! Client . IsRunning ) && ! CurrentQueueItem . Results . Any ( ) && CurrentQueueItem . CanSearch ) {
568588 Dispatcher . InvokeAsync ( RunAsync ) ;
569589 }
570590
571- else if ( Results . Any ( ) ) {
572- Tb_Status . Text = $ "Displaying { Results . Count } results";
591+ else if ( CurrentQueueItem . Results . Any ( ) ) {
592+ Tb_Status . Text = $ "Displaying { CurrentQueueItem . Results . Count } results";
573593 }
574- else {
594+ else if ( CurrentQueueItem . HasQuery && ! CurrentQueueItem . Results . Any ( ) ) {
575595 Tb_Status . Text = $ "Search ready";
576596
577597 }
598+ else {
599+ Tb_Status . Text = CurrentQueueItem . Status ;
578600
601+ }
579602 Tb_Info . Text = CurrentQueueItem . Info ;
580603 Tb_Status2 . Text = CurrentQueueItem . Status2 ;
581-
604+ // OnPropertyChanged(nameof(Results));
582605 }
583606
584607 private void AddToQueue ( IReadOnlyList < string > files )
@@ -809,14 +832,14 @@ private void AddResult(SearchResult result)
809832 Url = result . RawUrl ,
810833 } ;
811834
812- Results . Add ( new ResultItem ( sri1 , $ "{ sri1 . Root . Engine . Name } (Raw)") ) ;
835+ CurrentQueueItem . Results . Add ( new ResultItem ( sri1 , $ "{ sri1 . Root . Engine . Name } (Raw)") ) ;
813836
814837 foreach ( SearchResultItem sri in allResults ) {
815- Results . Add ( new ResultItem ( sri , $ "{ sri . Root . Engine . Name } #{ ++ i } ") ) ;
838+ CurrentQueueItem . Results . Add ( new ResultItem ( sri , $ "{ sri . Root . Engine . Name } #{ ++ i } ") ) ;
816839 int j = 0 ;
817840
818841 foreach ( var ssri in sri . Sisters ) {
819- Results . Add ( new ResultItem ( ssri , $ "{ ssri . Root . Engine . Name } #{ i } .{ ++ j } ") ) ;
842+ CurrentQueueItem . Results . Add ( new ResultItem ( ssri , $ "{ ssri . Root . Engine . Name } #{ i } .{ ++ j } ") ) ;
820843
821844 }
822845 }
@@ -1015,7 +1038,7 @@ private async Task ScanResultAsync(ResultItem ri)
10151038 CanOpen = true
10161039 } ;
10171040 // resultItems[i] = rii;
1018- Results . Insert ( Results . IndexOf ( ri ) + 1 + i , rii ) ;
1041+ CurrentQueueItem . Results . Insert ( CurrentQueueItem . Results . IndexOf ( ri ) + 1 + i , rii ) ;
10191042 }
10201043
10211044 int length = ri . Result . Uni . Length ;
@@ -1076,7 +1099,7 @@ private async Task ScanGalleryResultAsync(ResultItem cri)
10761099 CanScan = false ,
10771100 CanOpen = true
10781101 } ;
1079- Results . Insert ( Results . IndexOf ( cri ) + 1 + i , rii ) ;
1102+ CurrentQueueItem . Results . Insert ( CurrentQueueItem . Results . IndexOf ( cri ) + 1 + i , rii ) ;
10801103 }
10811104
10821105 Tb_Status . Text = "Scanned with gallery-dl" ;
@@ -1099,7 +1122,7 @@ private async Task FilterResultsAsync()
10991122 Pb_Status . IsIndeterminate = true ;
11001123 Tb_Status . Text = "Filtering" ;
11011124
1102- var cb = new ConcurrentBag < ResultItem > ( Results ) ;
1125+ var cb = new ConcurrentBag < ResultItem > ( CurrentQueueItem . Results ) ;
11031126 int c = 0 ;
11041127
11051128 await Parallel . ForEachAsync ( cb , async ( item , token ) =>
@@ -1116,7 +1139,7 @@ await Parallel.ForEachAsync(cb, async (item, token) =>
11161139 Dispatcher . Invoke ( ( ) =>
11171140 {
11181141 ++ c ;
1119- Results . Remove ( item ) ;
1142+ CurrentQueueItem . Results . Remove ( item ) ;
11201143 } ) ;
11211144 }
11221145 else { }
@@ -1144,9 +1167,9 @@ private async void RetryEngineAsync(ResultItem ri)
11441167 var idx = FindResultIndex ( r => r . Result . Root . Engine == eng ) ;
11451168 var fi = idx ;
11461169
1147- for ( int i = Results . Count - 1 ; i >= 0 ; i -- ) {
1148- if ( Results [ i ] . Result . Root . Engine == eng ) {
1149- Results . RemoveAt ( i ) ;
1170+ for ( int i = CurrentQueueItem . Results . Count - 1 ; i >= 0 ; i -- ) {
1171+ if ( CurrentQueueItem . Results [ i ] . Result . Root . Engine == eng ) {
1172+ CurrentQueueItem . Results . RemoveAt ( i ) ;
11501173 }
11511174 }
11521175
@@ -1156,16 +1179,16 @@ private async void RetryEngineAsync(ResultItem ri)
11561179 Tb_Status . Text = $ "{ eng . Name } → { result . Results . Count } ";
11571180 Pb_Status . IsIndeterminate = false ;
11581181
1159- for ( int i = 0 ; i < Results . Count ; i ++ ) {
1160- var cr = Results [ i ] ;
1182+ for ( int i = 0 ; i < CurrentQueueItem . Results . Count ; i ++ ) {
1183+ var cr = CurrentQueueItem . Results [ i ] ;
11611184
11621185 if ( cr . Result . Root . Engine == eng ) {
1163- Results . Move ( i , idx ++ ) ;
1186+ CurrentQueueItem . Results . Move ( i , idx ++ ) ;
11641187
11651188 }
11661189 }
11671190
1168- Lv_Results . ScrollIntoView ( Results [ fi ] ) ;
1191+ Lv_Results . ScrollIntoView ( CurrentQueueItem . Results [ fi ] ) ;
11691192 }
11701193
11711194 #endregion
0 commit comments