RowVm.cs 1.1 KB

12345678910111213141516171819202122232425
  1. using System.Collections.Generic;
  2. using System.ComponentModel;
  3. using System.Linq;
  4. namespace LocalizationTool.Models
  5. {
  6. /// <summary>表格行:一条中文源文 + 各语言译文单元格。</summary>
  7. public class RowVm : INotifyPropertyChanged
  8. {
  9. public int Index { get; set; }
  10. public string Key { get; set; }
  11. /// <summary>单元格字典,key = 语言代码(如 "en-US")。用 Dictionary 是为了支持 XAML 的 Cells[code] 字符串索引绑定。</summary>
  12. public Dictionary<string, CellVm> Cells { get; set; } = new Dictionary<string, CellVm>();
  13. public int MissingCount => Cells.Values.Count(c => c.IsMissing);
  14. public string MissingText => MissingCount == 0 ? "全译" : $"缺 {MissingCount}";
  15. public bool HasMissing => MissingCount > 0;
  16. public event PropertyChangedEventHandler PropertyChanged;
  17. public void Touch() => OnPropertyChanged(nameof(MissingCount));
  18. private void OnPropertyChanged(string n) =>
  19. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(n));
  20. }
  21. }