WorkspaceViewModel.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using CommunityToolkit.Mvvm.ComponentModel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using WechatBakTool.Model;
  9. namespace WechatBakTool.ViewModel
  10. {
  11. public partial class WorkspaceViewModel : ObservableObject
  12. {
  13. [ObservableProperty]
  14. [NotifyPropertyChangedFor(nameof(SelectContact))]
  15. [NotifyPropertyChangedFor(nameof(LabelStatus))]
  16. private WXContact? wXContact = null;
  17. [ObservableProperty]
  18. [NotifyPropertyChangedFor(nameof(LabelStatus))]
  19. private string exportCount = "";
  20. public string LabelStatus
  21. {
  22. get
  23. {
  24. if (WXContact == null)
  25. return ExportCount;
  26. string name = WXContact.NickName;
  27. if(WXContact.Remark != "")
  28. name = WXContact.Remark;
  29. return string.Format("{0}:{1}", name, ExportCount);
  30. }
  31. }
  32. public bool SelectContact
  33. {
  34. get
  35. {
  36. if (WXContact == null)
  37. return false;
  38. else
  39. return true;
  40. }
  41. }
  42. [ObservableProperty]
  43. private ObservableCollection<WXContact>? contacts;
  44. [ObservableProperty]
  45. private ObservableCollection<ExportItem>? exportItems;
  46. [ObservableProperty]
  47. private ExportItem? selectExportItem;
  48. private string searchString = "";
  49. public string SearchString
  50. {
  51. set
  52. {
  53. if (value == "搜索...")
  54. searchString = "";
  55. else
  56. searchString = value;
  57. OnPropertyChanged("SearchString");
  58. }
  59. get
  60. {
  61. if (searchString == "")
  62. return "搜索...";
  63. return searchString;
  64. }
  65. }
  66. }
  67. }