public FileSetingViewModel() { RelayCommand = new RelayCommand(new Action <object>(ButtonClickFunc)); if (CaseNotifyService.MatchTypes == null) { return; } foreach (var item in CaseNotifyService.MatchTypes) { SettingFileItemViewModel model = new SettingFileItemViewModel(item); model.DeleteAction += () => { this.MatchFileCollection.Remove(model); }; this.MatchFileCollection.Add(model); } if (CaseNotifyService.MovieTypes == null) { return; } foreach (var item in CaseNotifyService.MovieTypes) { SettingFileItemViewModel model = new SettingFileItemViewModel(item); model.DeleteAction += () => { this.FileTypeCollection.Remove(model); }; this.FileTypeCollection.Add(model); } }
/// <summary> /// 按钮点击事件 /// </summary> /// <param name="obj"></param> private void ButtonClickFunc(object obj) { string buttonName = obj.ToString(); if (buttonName == "Btn_Sumit") { // Todo :保存 List <string> matchs = new List <string>(); foreach (var item in this.MatchFileCollection) { matchs.Add(item.FileName); } List <string> files = new List <string>(); foreach (var item in this.FileTypeCollection) { files.Add(item.FileName); } CaseNotifyService.MatchTypes = matchs; CaseNotifyService.MovieTypes = files; } else if (buttonName == "btn_AddMatch") { if (string.IsNullOrEmpty(this.AddMatchString)) { return; } SettingFileItemViewModel model = new SettingFileItemViewModel(this.AddMatchString); model.DeleteAction += () => { this.MatchFileCollection.Remove(model); }; this.MatchFileCollection.Add(model); } else if (buttonName == "btn_AddTypes") { if (string.IsNullOrEmpty(this.AddFileString)) { return; } SettingFileItemViewModel model = new SettingFileItemViewModel(this.AddFileString); model.DeleteAction += () => { this.FileTypeCollection.Remove(model); }; this.FileTypeCollection.Add(model); } else if (buttonName == "DeleteItem") { if (string.IsNullOrEmpty(this.AddFileString)) { return; } } }