public EditViewModel(string id, IUpdater updater, Edit editPage) { if (id != null) { var word = Resource.getInstance().WordService.GetWord(id); if (word != null) { NewWord = new WordViewModel(word.Priority) { Id = word.Id, Name = word.Name, Translate = word.Translate, Example = word.Example, Level = word.Level, LastUpdateDate = word.LastUpdate, Picture = word.Picture, SourcePicture = word.Picture != null?Resource.getInstance().WordService.GetSourceImage(word.Picture) : null, }; if (NewWord.Picture == null) { NewWord.SourcePicture = Resource.getInstance().SourceNoImage; } } } else { NewWord = new WordViewModel(0) { SourcePicture = Resource.getInstance().SourceNoImage, }; } this.updater = updater; EditPage = editPage; }
public CreateViewModel(IUpdater updater, Create createPage) { NewWord = new WordViewModel() { SourcePicture = Resource.getInstance().SourceNoImage, }; this.updater = updater; CreatePage = createPage; }
public void Update() { int index = Words.IndexOf(SelectedWord); var word = new WordViewModel(Resource.getInstance().WordService.GetWord(SelectedWord.Id.ToString()), index); Words.RemoveAt(index); Words.Insert(index, word); SelectedWord = null; SelectedWord = Words[index]; TotalCount = Words.Count; }
public void KnowCommand(int percent) { if (selectedWord != null) { Resource.getInstance().WordService.SetKnow(SelectedWord.Id.ToString(), percent); int index = Words.IndexOf(SelectedWord); var word = new WordViewModel(Resource.getInstance().WordService.GetWord(SelectedWord.Id.ToString()), index); Words.RemoveAt(index); Words.Insert(index, word); SelectedWord = word; } else { (new Warning(Application.Current.Resources["FirstSelectWord"].ToString())).ShowDialog(); } }
private void KnowCommand(int percent) { if (SelectedWord != null) { Resource.getInstance().WordService.SetKnow(SelectedWord.Id.ToString(), percent); int index = Words.IndexOf(SelectedWord); var word = new WordViewModel(Resource.getInstance().WordService.GetWord(SelectedWord.Id.ToString()), index); Words.RemoveAt(index); Words.Insert(index, word); if (index + 1 != Words.Count) { ++IndexSelectedWord; SelectedWord = Words[++index]; } else { SelectedWord = null; SelectedWord = Words[index]; (new Warning(Application.Current.Resources["EndOfList"].ToString())).ShowDialog(); } } }