Skip to content

Commit

Permalink
fixed clear
Browse files Browse the repository at this point in the history
  • Loading branch information
BigSpice committed Oct 21, 2023
1 parent 522eb2f commit ba7b87d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 26 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 12 additions & 16 deletions VTOL_2.0.0/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Windows.Media;
using System.Windows.Media.Animation;
using VTOL.Pages;
using static VTOL.Pages.Page_Thunderstore;

namespace VTOL
{
Expand Down Expand Up @@ -82,6 +83,7 @@ public partial class MainWindow : Window

bool failed_folder = false;
public bool minimize_to_tray = false;
public DownloadQueue _downloadQueue;

// The enum flag for DwmSetWindowAttribute's second parameter, which tells the function what attribute to set.
// Copied from dwmapi.h
Expand Down Expand Up @@ -1073,17 +1075,12 @@ private void Cancel_Button_Click(object sender, RoutedEventArgs e)
Button = sender as Wpf.Ui.Controls.Button;


RootNavigation.Navigate(typeof(Pages.Page_Thunderstore));

Page_Thunderstore Page = RootFrame.Content as Page_Thunderstore;
if (Page != null)
{

if (Page._downloadQueue != null)
if (_downloadQueue != null)
{
Page._downloadQueue.CancelDownload(Button.Tag.ToString());
_downloadQueue.CancelDownload(Button.Tag.ToString());
}
}

});
}
catch (Exception ex)
Expand Down Expand Up @@ -1134,22 +1131,21 @@ private void Button_Click(object sender, RoutedEventArgs e)
Button = sender as Button;


RootNavigation.Navigate(typeof(Pages.Page_Thunderstore));
// RootNavigation.Navigate(typeof(Pages.Page_Thunderstore));

Page_Thunderstore Page = RootFrame.Content as Page_Thunderstore;
if (Page != null)
{
// Page_Thunderstore Page = RootFrame.Content as Page_Thunderstore;


if (Page._downloadQueue != null)
if (_downloadQueue != null)
{
Page._downloadQueue.CancelDownload("", true);
_downloadQueue.CancelDownload("", true);
}
}

});
}
catch (Exception ex)
{

Console.WriteLine(ex.ToString());

}

Expand Down
70 changes: 60 additions & 10 deletions VTOL_2.0.0/Pages/Page_Thunderstore.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -639,7 +640,6 @@ public partial class Page_Thunderstore : Page
public HashSet<string> Fave_Mods = new HashSet<string>();
private int Mod_Update_Counter = 0;
private List<Action_Card> Action_Center = new List<Action_Card>();
public DownloadQueue _downloadQueue;
private ObservableCollection<Grid_> thunderstoreItems = new ObservableCollection<Grid_>();

public Page_Thunderstore()
Expand Down Expand Up @@ -3872,24 +3872,74 @@ public void CancelDownload(string name, bool clear_all = false)
});
foreach (var mod in removedCards)
{
_inProgress.RemoveWhere(item => item == mod.URL);
_queue.RemoveAll(item => item.Name.ToLower().Contains(mod.Name.ToLower()));
_queue_List_Clear.RemoveAll(item => item.Name.ToLower().Contains(mod.Name.ToLower()));
_inProgress.RemoveWhere(i =>
{
string name__ = "";

string[] parts = i.Split('|');
if (parts.Length >= 2)
{

name__ = parts[4] + "-" + parts[1];
}


return mod.Name.ToLower().Contains(name__.ToLower());

});
_queue.RemoveAll(i =>
{
string name__ = "";

string[] parts = i.DownloadUrl.Split('|');
if (parts.Length >= 2)
{

name__ = parts[4] + "-" + parts[1];
}


return name__.ToLower().Contains(name.ToLower());

});
_queue_List_Clear.RemoveAll(i =>
{
string name__ = "";

string[] parts = i.DownloadUrl.Split('|');
if (parts.Length >= 2)
{

name__ = parts[4] + "-" + parts[1];
}


return name__.ToLower().Contains(name.ToLower());

});

}

return;
}

string name__ = "";

var item = _queue_List_Clear.FirstOrDefault(i =>
{
return i.Name.ToLower().Contains(name.ToLower());
{

string[] parts = i.DownloadUrl.Split('|');
if (parts.Length >= 2)
{

name__ = parts[4] + "-" + parts[1];
}
return name__.ToLower().Contains(name.ToLower());
});//todo fix clear

if (item != null)
{
Action_Card card = _myClass.Action_Center.FirstOrDefault(c => c.GetType() == typeof(Action_Card) && c.Name.ToLower() == item.Name.ToLower());

Action_Card card = _myClass.Action_Center.FirstOrDefault(c => c.GetType() == typeof(Action_Card) && c.Name.ToLower().Contains(name__.ToLower()));
if (card != null)
{
if (card.Completed == "Dismiss16"
Expand Down Expand Up @@ -3929,7 +3979,7 @@ public void CancelDownload(string name, bool clear_all = false)

public void InitializeDownloadQueue()
{
_downloadQueue = new DownloadQueue(this);
Main._downloadQueue = new DownloadQueue(this);
}

// create a new DownloadQueueItem for each download and add to the queue
Expand Down Expand Up @@ -3977,7 +4027,7 @@ private void Install_Bttn_Thunderstore_Click(object sender, RoutedEventArgs e)
Progress = Progress_Bar

};
_downloadQueue.Enqueue(item);
Main._downloadQueue.Enqueue(item);

}

Expand Down

0 comments on commit ba7b87d

Please sign in to comment.