CreateCollectionURL.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.ComponentModel;
  7. using Test6_mod.Models;
  8. namespace Test6_mod.ViewModels.UI
  9. {
  10. public class CreateCollectionURL
  11. {
  12. public BindingList<ItemCollectionURL> CollectionURLs { get; private set; } = new BindingList<ItemCollectionURL>();
  13. private void Add(string url)
  14. {
  15. CollectionURLs.Add(new ItemCollectionURL()
  16. {
  17. IsName = Guid.NewGuid().ToString(),
  18. IsURL = url,
  19. IsStatus = false
  20. });
  21. }
  22. private void SetStatusTrue()
  23. {
  24. int i = -1;
  25. foreach (var item in CollectionURLs)
  26. {
  27. i += 1;
  28. if (!item.IsStatus)
  29. {
  30. CollectionURLs[i].IsStatus = true;
  31. }
  32. }
  33. }
  34. public CreateCollectionURL()
  35. {
  36. StartPage.AddURL += StartPage_AddURL;
  37. CreateCollectionInfo.CreateListIsUrlTrue += CreateCollectionInfo_CreateListIsUrlTrue;
  38. }
  39. private void CreateCollectionInfo_CreateListIsUrlTrue(object sender, Event.FinishScanEventArgs e)
  40. {
  41. SetStatusTrue();
  42. }
  43. private void StartPage_AddURL(object sender, Event.AddUrlEventArgs e)
  44. {
  45. Add(e.URL);
  46. }
  47. }
  48. }