123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using TranslateTool.Model;
- namespace TranslateTool.ViewModel
- {
- class DuplicateRemovalViewModel
- {
- /// <summary>
- /// 所选内容
- /// </summary>
- public string _selectContent;
- /// <summary>
- /// 重复Key值
- /// </summary>
- private string _key;
- /// <summary>
- /// 重复Key列表
- /// </summary>
- private List<LanguageItem> _languageItems;
- /// <summary>
- /// 关闭当前窗口
- /// </summary>
- private Action _closeAction;
- /// <summary>
- /// 显示Key相关描述
- /// </summary>
- public string Key
- {
- get
- {
- return _key;
- }
- }
- /// <summary>
- /// 选择Content
- /// </summary>
- private ButtonCommand _submitCommand;
- /// <summary>
- /// 重复Key和Content
- /// </summary>
- public List<LanguageItem> RepeatList
- {
- get { return _languageItems; }
- }
- /// <summary>
- /// 选择Content
- /// </summary>
- public ButtonCommand SubmitCommand
- {
- get
- {
- return _submitCommand;
- }
- set
- {
- _submitCommand = value;
- }
- }
- /// <summary>
- /// 所选内容
- /// </summary>
- public LanguageItem SelectContent
- {
- set
- {
- if (_selectContent != value.Content)
- {
- _selectContent = value.Content;
- }
- }
- }
- /// <summary>
- /// 删除重复Key值
- /// </summary>
- public event EventHandler RemoveRepeatKey;
- public DuplicateRemovalViewModel(List<LanguageItem> languageItems,Action closeAction)
- {
- this._closeAction = closeAction;
- _languageItems = languageItems;
- _key = $"存在重复值{ _languageItems[0].Key},请选择一个最佳Content";
- _submitCommand = new ButtonCommand(OnSubmit, "Submit");
- }
- /// <summary>
- /// 选择后关闭当前窗口
- /// </summary>
- /// <param name="obj"></param>
- private void OnSubmit(object obj)
- {
- if(!string.IsNullOrWhiteSpace(_selectContent))
- {
- _closeAction.Invoke();
- }
- }
- }
- }
|