2
0

WorkspaceViewModel.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. private ObservableCollection<WXMsg> wXMsgs = new ObservableCollection<WXMsg>();
  19. [ObservableProperty]
  20. [NotifyPropertyChangedFor(nameof(LabelStatus))]
  21. private string exportCount = "";
  22. public string LabelStatus
  23. {
  24. get
  25. {
  26. if (WXContact == null)
  27. return ExportCount;
  28. string name = WXContact.NickName;
  29. if(WXContact.Remark != "")
  30. name = WXContact.Remark;
  31. return string.Format("{0}:{1}", name, ExportCount);
  32. }
  33. }
  34. public bool SelectContact
  35. {
  36. get
  37. {
  38. if (WXContact == null)
  39. return false;
  40. else
  41. return true;
  42. }
  43. }
  44. [ObservableProperty]
  45. private ObservableCollection<WXContact>? contacts;
  46. [ObservableProperty]
  47. private ObservableCollection<ExportItem>? exportItems;
  48. [ObservableProperty]
  49. private ExportItem? selectExportItem;
  50. private string searchString = "";
  51. public string SearchString
  52. {
  53. set
  54. {
  55. if (value == "搜索...")
  56. searchString = "";
  57. else
  58. searchString = value;
  59. OnPropertyChanged("SearchString");
  60. }
  61. get
  62. {
  63. if (searchString == "")
  64. return "搜索...";
  65. return searchString;
  66. }
  67. }
  68. }
  69. }