protected override EnumError AddNewDictItem(String pword, int pCnt) { char[] chars = pword.ToCharArray(); String prefix = ""; foreach (char ch in chars) { prefix += ch; if (dac.ContainsKey(prefix)) { WordItem wi = new WordItem(pword,pCnt); ListOfWordItemSorted lowi = dac[prefix]; lowi.Add(wi, null); //В списке TopN слов всегда храним не более topNWords слов. if (lowi.Count > base.topNWords) { lowi.RemoveAt(base.topNWords); } } else { ListOfWordItemSorted lowi = new ListOfWordItemSorted(); lowi.Capacity = base.topNWords+1; WordItem wi = new WordItem(pword,pCnt); lowi.Add(wi, null); dac.Add(prefix, lowi); } } return EnumError.NoError; }
protected override EnumError AddNewDictItem(String pword, int pCnt) { if (trie == null) { trie=new Trie<WordItem>(base.topNWords, ('z' - 'a') + 1); } WordItem wi = new WordItem(pword,pCnt); trie.Add(pword, wi); return EnumError.NoError; }
/// <summary> /// 把包含表情的字符串进行解析 /// </summary> /// <param name="text">文本消息内容</param> public static List <WordItem> ConvertTextToEmoji(string text) { List <WordItem> wordsList = new List <WordItem>(); int skip; int textLengthToProcess = text.Length; if (textLengthToProcess == 0) { return(null); } StringBuilder textBuilder = new StringBuilder(); // 文字消息 for (int i = 0; i < text.Length; i += skip) { skip = 0; string icon = string.Empty; int unicode = char.ConvertToUtf32(text, i); skip = char.IsSurrogatePair(text, i) ? 2 : 1; if (unicode > 0xff) { icon = "0x" + unicode.ToString("x2"); if (!DefaultsEmojis.Instance.EmojiToIcoDictionary.ContainsKey(icon)) { icon = string.Empty; } } if (icon.Equals(string.Empty) && i + skip < textLengthToProcess) { int followUnicode = char.ConvertToUtf32(text, i + skip); if (followUnicode == 0x20e3) { int followSkip = char.IsSurrogatePair(text, i + skip) ? 2 : 1; if ((unicode >= 0x0030 && unicode <= 0x0039) || 0x0023 == unicode) { icon = "0x" + unicode.ToString("x2") + "_0x20e3"; } else { followSkip = 0; } skip += followSkip; } else { int followSkip = char.IsSurrogatePair(text, i + skip) ? 2 : 1; switch (unicode) { case 0x1f1ef: icon = (followUnicode == 0x1f1f5) ? "0x1f1ef_0x1f1f5" : string.Empty; break; case 0x1f1fa: icon = (followUnicode == 0x1f1f8) ? "0x1f1fa_0x1f1f8" : string.Empty; break; case 0x1f1eb: icon = (followUnicode == 0x1f1f7) ? "0x1f1eb_0x1f1f7" : string.Empty; break; case 0x1f1e9: icon = (followUnicode == 0x1f1ea) ? "0x1f1e9_0x1f1ea" : string.Empty; break; case 0x1f1ee: icon = (followUnicode == 0x1f1f9) ? "0x1f1ee_0x1f1f9" : string.Empty; break; case 0x1f1ec: icon = (followUnicode == 0x1f1e7) ? "0x1f1ec_0x1f1e7" : string.Empty; break; case 0x1f1ea: icon = (followUnicode == 0x1f1f8) ? "0x1f1ea_0x1f1f8" : string.Empty; break; case 0x1f1f7: icon = (followUnicode == 0x1f1fa) ? "0x1f1f7_0x1f1fa" : string.Empty; break; case 0x1f1e8: icon = (followUnicode == 0x1f1f3) ? "0x1f1e8_0x1f1f3" : string.Empty; break; case 0x1f1f0: icon = (followUnicode == 0x1f1f7) ? "0x1f1f0_0x1f1f7" : string.Empty; break; default: followSkip = 0; break; } skip += followSkip; } } if (!icon.Equals(string.Empty)) { // 表情符号的场合 EmojiItem emojiItem = null; if (DefaultsEmojis.Instance.EmojiToIcoDictionary.TryGetValue(icon, out emojiItem)) { string iconPath = emojiItem.ImgPath; if (textBuilder.Length > 0) { // 把表情符号前面的文字创建出来 WordItem txtItem = new WordItem(); txtItem.Type = WordType.Text; txtItem.Content = textBuilder.ToString(); wordsList.Add(txtItem); textBuilder.Clear(); } // 找到表情图标,创建表情控件 WordItem imgItem = new WordItem(); imgItem.Type = WordType.Emoji; imgItem.Content = iconPath; wordsList.Add(imgItem); } else { // 没有找到表情图标,直接当作普通字符输出 textBuilder.Append(text.Substring(i, skip)); } } else { // 普通文字的场合 string currChar = text.Substring(i, 1); if (currChar.Equals(Environment.NewLine)) { // 换行符的场合 if (textBuilder.Length > 0) { // 生成前面的文字 WordItem txtItem = new WordItem(); txtItem.Type = WordType.Text; txtItem.Content = textBuilder.ToString(); wordsList.Add(txtItem); textBuilder.Clear(); } // 生成换行 LineBreak lineBreak = new LineBreak(); WordItem warpItem = new WordItem(); warpItem.Type = WordType.Wrap; warpItem.Content = string.Empty; wordsList.Add(warpItem); } else { // 除换行符意外的普通文字 textBuilder.Append(text.Substring(i, 1)); } } } if (textBuilder.Length > 0) { // 生成前面的文字 WordItem txtItem = new WordItem(); txtItem.Type = WordType.Text; txtItem.Content = textBuilder.ToString(); wordsList.Add(txtItem); textBuilder.Clear(); } return(wordsList); }
// Use this for initialization public void PrepareScene() { SW.Stop(); SW.Reset(); #region Inizialisierung der StartBox WordItem useWord = Words[wordItemCount]; //instantiate CheckButton var checkButtonGo = Instantiate(CheckButtonPrefab, CheckBox.transform) as GameObject; _checkButtonScript = checkButtonGo.GetComponent <CheckButtonScript>(); _checkButtonScript.SetInteractable(false); //instantiate release Button var releaseButtonGo = Instantiate(ReleaseButtonPrefab, ReleaseButtonBox.transform) as GameObject; _releaseButtonScript = releaseButtonGo.GetComponent <ReleaseButtonScript>(); _releaseButtonScript.SetInteractableRelease(false); //instantiate listen button var listenButtonGo = Instantiate(ListenButton, ListenBox.transform); _listenScript = listenButtonGo.GetComponent <ListenClickScript>(); _listenScript.SetInteractable(true); //instantiate menu button var menuButtonGo = Instantiate(MenuButton, MenuButtonBox.transform); _menuButtonScript = menuButtonGo.GetComponent <MenuButtonClickScript>(); _menuButtonScript.SetInteractable(true); //instantiate distractor buttons and add them to the lowerboxlist foreach (var distractorStr in useWord.Distractors) { //instantiate button holder in startBox var holderGo = Instantiate(ButtonHolderPrefab, StartBox.transform); //instantiate Button var letterGo = Instantiate(LetterButtonPrefab, holderGo.transform) as GameObject; var letterScript = letterGo.GetComponent <LetterButtonScript>(); //set textvalue of button to distractor char letterScript.LetterCharacter.text = distractorStr; //set button to the lower box and to a disctractor letterScript.LowerBox = true; letterScript.IsDistractor = true; //add distractor to letterlist _letterList.Add(letterGo.GetComponent <LetterButtonScript>()); //Set button position to occupied in lower box holderGo.GetComponent <LetterHolderScript>().IsTaken = true; //? ##tell the holderGo (and its script) that he is holding "letterScript" now. This is the button gameobject with the letter in it. So he knows that he is holding the letter, by setting the "takenletter" variable (if we need it later on) holderGo.GetComponent <LetterHolderScript>().TakenLetter = letterScript; //add button to holder lowerbox list _startHolderList.Add(holderGo.GetComponent <LetterHolderScript>()); } //instantiate wordletter buttons and add them to the lowerboxlist foreach (var letter in useWord.Word) { //instantiate lower button box var holderGo = Instantiate(ButtonHolderPrefab, StartBox.transform); //instantiate button var letterGo = Instantiate(LetterButtonPrefab, holderGo.transform) as GameObject; var letterScript = letterGo.GetComponent <LetterButtonScript>(); //set textvalue of button to wordletter char letterScript.LetterCharacter.text = letter.ToString(); //set button to lower box and to not a distractor letterScript.LowerBox = true; letterScript.IsDistractor = false; //add letter to letterlist _letterList.Add(letterGo.GetComponent <LetterButtonScript>()); //set buttonposition to occupied in lower box holderGo.GetComponent <LetterHolderScript>().IsTaken = true; //? ## same as above, but with the correctButtonLetter holderGo.GetComponent <LetterHolderScript>().TakenLetter = letterScript; //add button to lowerbox list _startHolderList.Add(holderGo.GetComponent <LetterHolderScript>()); } //shuffle the buttons foreach (Transform child in StartBox.transform) { child.SetSiblingIndex(Random.Range(0, StartBox.transform.childCount)); } #endregion #region Inizialisierung der TargetBox // creates an empty box in the upper box for each character in the word letter foreach (var letter in useWord.Word) { //instantiates the gameobjects var letterGo = Instantiate(ButtonHolderPrefab, TargetBox.transform) as GameObject; var targetButton = letterGo.GetComponent <LetterHolderScript>(); //sets the empty box to not yet occupied targetButton.IsTaken = false; //add an entry in the upperbox list _targetHolderList.Add(targetButton); } #endregion Listen(); SW.Start(); }
public void PrepareDragScene() { SW.Stop(); SW.Reset(); //use current Task of TaskItemList WordItem currentWord = Words[wordItemCount]; //instantiate CheckButton var checkButtonDrag = Instantiate(CheckButtonPrefab, CheckBox.transform) as GameObject; checkButtonScript = checkButtonDrag.GetComponent <CheckButtonDragScript>(); checkButtonScript.SetInteractable(false); //instantiate menu button var menuButtonGo = Instantiate(MenuButton, MenuButtonBox.transform); _menuButtonDragScript = menuButtonGo.GetComponent <MenuButtonDragScript>(); _menuButtonDragScript.SetInteractable(true); var listenButtonGo = Instantiate(ListenButton, ListenBox.transform); _listenScript = listenButtonGo.GetComponent <ListenDragScript>(); _listenScript.SetInteractable(true); foreach (var distractorStr in currentWord.Distractors) { //instantiate button holder in lowerBox var holderDrag = Instantiate(ButtonHolderPrefab, LowerBox.transform); var holderDragScript = holderDrag.GetComponent <LetterHolderDragScript>(); holderDragScript.Lower = true; //instantiate Button var letterDrag = Instantiate(LetterDragPrefab, holderDrag.transform) as GameObject; var letterScript = letterDrag.GetComponent <LetterTextScript>(); letterScript.Holder = holderDragScript; //set textvalue to distractor char letterScript.GetComponentInChildren <Text>().text = distractorStr; //set button to the lower box and to a disctractor letterScript.LowerBox = true; letterScript.IsDistractor = true; //add distractor to letterlist _letterList.Add(letterDrag.GetComponent <LetterTextScript>()); //Set button position to occupied in lower box holderDragScript.IsTaken = true; //? ##tell the holderGo (and its script) that he is holding "letterScript" now. This is the button gameobject with the letter in it. So he knows that he is holding the letter, by setting the "takenletter" variable (if we need it later on) holderDragScript.TakenLetter = letterScript; //add button to holder lowerbox list _startHolderDragList.Add(holderDragScript); } //instantiate wordletter buttons and add them to the lowerboxlist foreach (var letterChar in currentWord.Word) { //instantiate lower button box var holderDrag = Instantiate(ButtonHolderPrefab, LowerBox.transform); var holderDragScript = holderDrag.GetComponent <LetterHolderDragScript>(); holderDragScript.Lower = true; //instantiate button var letterDrag = Instantiate(LetterDragPrefab, holderDrag.transform) as GameObject; var letterScript = letterDrag.GetComponent <LetterTextScript>(); letterScript.Holder = holderDragScript; //set textvalue of button to wordletter char letterScript.GetComponentInChildren <Text>().text = letterChar.ToString(); //set button to lower box and to not a distractor letterScript.LowerBox = true; letterScript.IsDistractor = false; //add letter to letterlist _letterList.Add(letterDrag.GetComponent <LetterTextScript>()); //push true letters to list for finish function trueLetters.Add(letterDrag.GetComponent <LetterTextScript>()); //set buttonposition to occupied in lower box holderDragScript.IsTaken = true; //? ## same as above, but with the correctButtonLetter holderDragScript.TakenLetter = letterScript; //add button to lowerbox list _startHolderDragList.Add(holderDragScript); } //shuffle the buttons foreach (Transform child in LowerBox.transform) { child.SetSiblingIndex(Random.Range(0, LowerBox.transform.childCount)); } // creates an empty box in the upper box for each character in the word letter foreach (var letter in currentWord.Word) { //instantiates the gameobjects var letterDrag = Instantiate(ButtonHolderPrefab, UpperBox.transform) as GameObject; var targetDrag = letterDrag.GetComponent <LetterHolderDragScript>(); targetDrag.Lower = false; //sets the empty box to not yet occupied targetDrag.IsTaken = false; //add an entry in the upperbox list targetHolderDragList.Add(targetDrag); } Listen(); //start Stopwatch SW.Start(); }
public void WordItemConstructorTest() { WordItem target = new WordItem(); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// находит все исходные формы слова /// </summary> /// <param name="sParent">слово родитель</param> /// <param name="sAnyFormWord">слово из правой части словарной статьи</param> /// <param name="explChannel">канал толкового словаря</param> /// <param name="relGroupId">номер группы отношений. используется если одно слово имеет несколько равнозначных исходных форм</param> /// <returns>список потомков с снайденным типом связи</returns> List <WordLink> GetChildren(string sParent, string sAnyFormWord, IExplDic explChannel, short relGroupId) { Ilib5 wordFormsChannel = null; List <WordLink> listChildren = null; try { listChildren = new List <WordLink>(); if (sAnyFormWord.Length == 0) { return(listChildren); } wordFormsChannel = CreateWordFormsChannel(); WordUniAndPartAndOmon[] forms = wordFormsChannel.getAllFirstWFormsWithParts(sAnyFormWord); foreach (WordUniAndPartAndOmon form in forms) { string s = form.part; string sOriginalForm = form.forma; if (IsNoun(form.part)) { sOriginalForm = RemoveAccents(sOriginalForm); if (sOriginalForm.Length > 0) { //can this be equal to zero? int nVal = explChannel.ExplCheckReestr(sOriginalForm, form.omon, m_LsId); if (nVal < 0 && form.omon != 0) { nVal = explChannel.ExplCheckReestr(sOriginalForm, 0, m_LsId); sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, string.Empty); } else { sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, form.omon == 0 ? string.Empty : form.omon.ToString()); } lock (m_dbHelper) { RelationItem newItem = m_dbHelper.GetRelationItem(sParent, sOriginalForm); if (newItem == null) { RelationType relType = (nVal < 0) ? RelationType.Absent : (listChildren.Count > 0 ? RelationType.Tentative : RelationType.Normal); newItem = m_dbHelper.AddRelation(sParent, sOriginalForm, relType, relGroupId); } WordItem aWord = m_dbHelper.GetWord(sOriginalForm); WordLink aLink = new WordLink(newItem, aWord); if (!listChildren.Contains(aLink)) { listChildren.Add(aLink); } } } } } ((IClientChannel)wordFormsChannel).Close(); } catch (Exception ex) { if (wordFormsChannel != null) { ((IClientChannel)wordFormsChannel).Abort(); } MessageBox.Show(string.Format("{0} {1}", "GetChildren", ex.Message)); } return(listChildren); }
public MainViewModel() { MainModel = new MainModel(); TempModel = new TempModel(); RoamingModel = new RoamingModel(); AnswerCommand = new RelayCommand(() => { MainModel.ShowAnswer(); }); NextRememberCommand = new RelayCommand(() => { var canContinue = MainModel.NextWord(true); if (!canContinue) { Messenger.Default.Send <bool>(false, "GoResult"); } else { MainModel.Synthesize(); } }); NextNoRememberCommand = new RelayCommand(() => { var canContinue = MainModel.NextWord(false); if (!canContinue) { Messenger.Default.Send <bool>(false, "GoResult"); } else { MainModel.Synthesize(); } }); PickFileCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await MainModel.StartStudyAsync(); }, () => { Messenger.Default.Send <bool>(true, "FileLoadResult"); }, (e) => { Messenger.Default.Send <bool>(false, "FileLoadResult"); }); }); StartStudyCommand = new RelayCommand(() => { if (RoamingModel.PrevLearnDay.DayOfYear == (DateTime.Now - TimeSpan.FromDays(1)).DayOfYear) { RoamingModel.ContinueDays++; RoamingModel.PrevLearnDay = DateTime.Now; } else if (RoamingModel.PrevLearnDay.DayOfYear != DateTime.Now.DayOfYear) { RoamingModel.ContinueDays = 0; } RoamingModel.LearnCount++; MainModel.Synthesize(); }); RepeatStudyCommand = new RelayCommand(() => { MainModel.RepeatStudy(); }); SynthesizeCommand = new RelayCommand(() => { MainModel.Synthesize(); }); SearchWeblioCommand = new RelayCommand(() => { MainModel.ChangeWeblioUrl(); Messenger.Default.Send <string>(MainModel.BrowserUrl, "ShowBrowser"); }); SearchSynonymCommand = new RelayCommand(() => { MainModel.ChangeSynonymUrl(); Messenger.Default.Send <string>(MainModel.BrowserUrl, "ShowBrowser"); }); SearchExampleCommand = new RelayCommand(() => { MainModel.ChangeExampleUrl(); Messenger.Default.Send <string>(MainModel.BrowserUrl, "ShowBrowser"); }); SearchImageCommand = new RelayCommand(() => { MainModel.ChangeImageSearchUrl(); Messenger.Default.Send <string>(MainModel.BrowserUrl, "ShowBrowser"); }); SaveLearningResultCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { Messenger.Default.Send <bool>(true, "FileSaving"); await MainModel.SaveLearningResultAsync(); await TempModel.LearnedFileList.AddCsvRawAsync(MainModel.CurrentWordFile); await TempModel.TopNoRememberList.FetchAsync((str) => { string[] cols = str.Split(','); return(new WordItem(cols[0], cols[1], int.Parse(cols[2]), int.Parse(cols[3]))); }); if (TempModel.TopNoRememberList.Count + MainModel.TopNoRememberList.Count > 1000) { for (int i = 0; i < 5; i++) { await TempModel.TopNoRememberList.RemoveCsvRawAsync(TempModel.TopNoRememberList.ElementAt(i)); } } foreach (var item in MainModel.TopNoRememberList) { await TempModel.TopNoRememberList.AddCsvRawAsync(item); } await TempModel.TopNoRememberList.UnFetchAsync(); }, () => { Messenger.Default.Send <bool>(false, "FileSaving"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); SaveNoRememberCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { Messenger.Default.Send <bool>(true, "FileSaving"); await MainModel.SaveNoRememberAsync(); }, () => { Messenger.Default.Send <string>("ファイルを出力しました", "Success"); Messenger.Default.Send <bool>(false, "FileSaving"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); AddFavoriteCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.AddCsvRawAsync(MainModel.CurrentWord); }, () => { Messenger.Default.Send <string>("お気に入り登録完了しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); AddFavoriteWithItemCommand = new RelayCommand <WordItem>(async(word) => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.AddCsvRawAsync(word); }, () => { Messenger.Default.Send <string>("お気に入り登録完了しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); RemoveFavoriteWithItemCommand = new RelayCommand <WordItem>(async(word) => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.RemoveCsvRawAsync(word); }, () => { Messenger.Default.Send <string>("お気に入りに登録を解除しました", "Success"); FetchFavoriteCommand.Execute(null); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); ClearFavoriteCommand = new RelayCommand(async() => { var dialog = new MessageDialog("現在お気に入りに登録してる単語をすべてクリアしても大丈夫ですか?", "確認"); dialog.Commands.Add(new UICommand("OK", async(arg) => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.ClearCsvRawAsync(); }, () => { Messenger.Default.Send <string>("お気に入りに登録をすべて解除しました", "Success"); FetchFavoriteCommand.Execute(null); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); })); dialog.Commands.Add(new UICommand("Cancel", arg => { })); await dialog.ShowAsync(); }); FetchFavoriteCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.FetchAsync((str) => { var item = new WordItem("", "", 0, 0); item.SetCsvRaw(str); return(item); }); }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); UnFetchFavoriteCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.FavoriteList.UnFetchAsync(); }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); FetchNoRememberCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.TopNoRememberList.FetchAsync((str) => { var item = new WordItem("", "", 0, 0); item.SetCsvRaw(str); return(item); }); var list = TempModel.TopNoRememberList.OrderBy(q => q.RememberRate).ToList(); TempModel.TopNoRememberList.Clear(); foreach (var item in list) { TempModel.TopNoRememberList.Add(item); } }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); UnFetchNoRememberCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.TopNoRememberList.UnFetchAsync(); }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); FetchLearnedFileCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.LearnedFileList.FetchAsync((str) => { var item = new WordFile("", "", DateTime.Now, 0, 0); item.SetCsvRaw(str); return(item); }); await TempModel.UpdateLearnedDayDicAsync(); await TempModel.UpdateForgetFileListAsync(); }, () => { Messenger.Default.Send <bool>(true, "LearnFileFetched"); }, (e) => { Messenger.Default.Send <bool>(false, "LearnFileFetched"); Messenger.Default.Send <string>(e.Message, "Error"); }); }); UnFetchLearnedFileCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.LearnedFileList.UnFetchAsync(); TempModel.LearnedFileDayDic.Clear(); }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); SynthesizeWithWordCommand = new RelayCommand <WordItem>((item) => { MainModel.Synthesize(item.Word); }); ShareResultCommand = new RelayCommand(() => { Messenger.Default.Send <string>(MainModel.GetShareResult(), "ShareResult"); }); ChangeCurrentLearnedDayCommand = new RelayCommand <DateTime>((date) => { MainModel.ChangeCurrentLearnedDay(date, TempModel.LearnedFileList); }); ClearTopNoRememberCommand = new RelayCommand(async() => { var dialog = new MessageDialog("現在記録されている忘れている単語をすべて削除してもいいですか?", "確認"); dialog.Commands.Add(new UICommand("OK", async(arg) => { await ExecuteWithProgressAsync(async() => { await TempModel.TopNoRememberList.ClearCsvRawAsync(); }, () => { Messenger.Default.Send <string>("忘れている単語をすべて解除しました", "Success"); FetchNoRememberCommand.Execute(null); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); })); dialog.Commands.Add(new UICommand("Cancel", arg => { })); await dialog.ShowAsync(); }); ExportFavoriteCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.SaveFavoriteAsync(); }, () => { Messenger.Default.Send <string>("ファイルを出力しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); ExportTopNoRememberCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.SaveTopNoRememberAsync(); }, () => { Messenger.Default.Send <string>("ファイルを出力しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); AddEditingWordCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.EditingWordList.AddCsvRawAsync(MainModel.CurrentEditingWord); await TempModel.EditingWordList.FetchAsync((str) => { string[] cols = str.Split(','); return(new WordItem(cols[0], cols[1], int.Parse(cols[2]), int.Parse(cols[3]))); }); MainModel.CurrentEditingWord.Word = string.Empty; MainModel.CurrentEditingWord.Mean = string.Empty; }, () => { //Messenger.Default.Send<string>("単語登録完了しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); EditEditingWordCommand = new RelayCommand <int>(async(index) => { await ExecuteWithProgressAsync(async() => { var word = TempModel.EditingWordList.ElementAt(index); await TempModel.EditingWordList.RemoveCsvRawAsync(word); await TempModel.EditingWordList.AddCsvRawAsync(MainModel.CurrentEditingWord); await TempModel.EditingWordList.FetchAsync((str) => { string[] cols = str.Split(','); return(new WordItem(cols[0], cols[1], int.Parse(cols[2]), int.Parse(cols[3]))); }); }, () => { //Messenger.Default.Send<string>("単語登録完了しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); RemoveEditingWordCommand = new RelayCommand <string>(async(word) => { await ExecuteWithProgressAsync(async() => { await TempModel.EditingWordList.RemoveCsvRawAsync(new WordItem(word, "", 0, 0)); await TempModel.EditingWordList.FetchAsync((str) => { string[] cols = str.Split(','); return(new WordItem(cols[0], cols[1], int.Parse(cols[2]), int.Parse(cols[3]))); }); }, () => { Messenger.Default.Send <string>("単語削除完了しました", "Success"); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); ExportEditingWordCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.SaveEditingWordAsync(); }, async() => { var dialog = new MessageDialog("現在登録している単語をすべて削除しますか?", "正常にエクスポートできました"); dialog.Commands.Add(new UICommand("OK", async(arg) => { await ExecuteWithProgressAsync(async() => { await TempModel.EditingWordList.ClearCsvRawAsync(); }, () => { FetchEdittingWordCommand.Execute(null); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); })); dialog.Commands.Add(new UICommand("Cancel", arg => { })); await dialog.ShowAsync(); }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); FetchEdittingWordCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.EditingWordList.FetchAsync((str) => { var item = new WordItem("", "", 0, 0); item.SetCsvRaw(str); return(item); }); }, () => { Messenger.Default.Send <bool>(true, "LearnFileFetched"); }, (e) => { Messenger.Default.Send <bool>(false, "LearnFileFetched"); Messenger.Default.Send <string>(e.Message, "Error"); }); }); UnFetchEdittingWordCommand = new RelayCommand(async() => { await ExecuteWithProgressAsync(async() => { await TempModel.EditingWordList.UnFetchAsync(); }, () => { }, (e) => { Messenger.Default.Send <string>(e.Message, "Error"); }); }); }