AddEntryWindow.xaml.cs 932 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. using System.Windows;
  3. using LocalizationTool.Models;
  4. using LocalizationTool.ViewModels;
  5. namespace LocalizationTool.Views
  6. {
  7. /// <summary>手动新增词条窗口:中文 key 必填,各语言译文可留空(= 缺译)。</summary>
  8. public partial class AddEntryWindow : Window
  9. {
  10. public AddEntryViewModel ViewModel { get; }
  11. public string EntryKey => ViewModel.Key?.Trim();
  12. public Dictionary<string, string> EntryTranslations => ViewModel.CollectTranslations();
  13. public AddEntryWindow(List<PackFile> langs)
  14. {
  15. InitializeComponent();
  16. Icon = App.AppIcon;
  17. ViewModel = new AddEntryViewModel(langs ?? new List<PackFile>());
  18. DataContext = ViewModel;
  19. ViewModel.RequestClose += ok =>
  20. {
  21. DialogResult = ok;
  22. Close();
  23. };
  24. }
  25. }
  26. }