private IEnumerable <IWordTreeViewItem> CreateItemsFromXml(XmlNode rootNode, IWordTreeViewItem rootNodeItem) { var result = new IWordTreeViewItem[rootNode.ChildNodes.Count]; for (int i = 0; i < rootNode.ChildNodes.Count; i++) { XmlNode node = rootNode.ChildNodes[i]; switch (node.Name) { case WordNode: result[i] = new WordViewModel(node.Attributes[TextAttribute].Value, rootNodeItem, _viewModel.DataService); break; case CategoryNode: var newNode = new WordCategoryViewModel(node.Attributes[TextAttribute].Value, rootNodeItem, _viewModel.DataService); var children = CreateItemsFromXml(node, newNode); newNode.Children = new System.Collections.ObjectModel.ObservableCollection <IWordTreeViewItem>(children); result[i] = newNode; break; default: throw new XmlException($"unknown node name {node.Name}"); } } return(result); }
public async Task <IActionResult> Index(WordViewModel model) { using (var ctx = new WordContext()) using (var t = await ctx.Database.BeginTransactionAsync()) { var state = new ListState(); var filters = new List <Func <Word, bool> >(); ViewBag.AppVer = App.Version; if (model.Keyword != null) { filters.Add(w => w.Content.Contains(model.Keyword)); } ViewBag.Data = await WordManipulator.LoadWords(ctx, state, w => w.Compact(), model, PageUtils.LimitPerPage, filters.ToArray()); ViewBag.State = state; return(View(model)); } }
public ActionResult Index() { Word word = _wordService.GetWordOfTheDay(); WordViewModel wordViewModel = new WordViewModel(word); return(View(wordViewModel)); }
private void Submit_Click(object sender, RoutedEventArgs e) { List <WordViewModel> words = new List <WordViewModel>(); if (StackOfWords.Children.Count == 0) { MessageBox.Show("Can't save empty topic!"); return; } if (TopicName.Text == String.Empty) { MessageBox.Show("Can't save nameless topic!"); return; } foreach (WordToAdd word in StackOfWords.Children) { if (word.English == String.Empty || word.Ukrainian == String.Empty) { MessageBox.Show("Can't have empty fields"); return; } WordViewModel wordViewModel = new WordViewModel(word.English, word.Ukrainian); words.Add(wordViewModel); } List <WordDTO> wordDTOs = new List <WordDTO>(); foreach (var item in words) { wordDTOs.Add(Mapper.MapWordDTO(item)); } _topicService.AddTopic(wordDTOs, TopicName.Text, 1); this.Close(); }
public ActionResult <WordViewModel> Get(string value) { var result = new WordModel(); result.SetValues(value); return(WordViewModel.FromModel(result)); }
public ActionResult list(string id = "Clothing") { Category category = db.Categories.Find(id); var CategoryName = category.CategoryName; ViewBag.titlefull = "http://www.wordpowerswahili.org/words/list/" + id; ViewBag.CategoryIDs = "/images/" + id + ".png"; ViewBag.CategoryName = CategoryName; var words = db.Words.Include(w => w.Category).Where(w => w.CategoryID == id).OrderBy(w => w.WordID); var cat = db.Categories.OrderBy(c => c.CategoryID); WordViewModel viewModel = new WordViewModel { Categories = cat.ToList(), tmpWords = words }; if (viewModel != null) { return(View(viewModel)); } else { return(View()); } }
public ActionResult WordOfTheDay() { WordViewModel word = KitBL.Instance.WordBL.WordOfTheDay(DateTime.Now); ViewData["word"] = word; return(View()); }
public WordPage() { InitializeComponent(); ViewModel = new WordViewModel(); BindingContext = ViewModel; notificationService = DependencyService.Get <INotificationService>(); }
//http://jesseliberty.com/2017/07/06/learning-xamarin-forms-part-2-mvvm/ public WordView() { InitializeComponent(); word = new Word_HSK(); word.Character = "好"; viewModel = new WordViewModel(word); BindingContext = viewModel; }
public List <WordViewModel> GetWordsWordviewmodels(Dictionary <string, string> words) { ////var words = new List<string>(); //words.Add("Bamidele"); //words.Add("station"); //words.Add("india"); //words.Add("Adams"); //words.Add("fards"); //words.Add("novemb"); //words.Add("belt"); //words.Add("train"); //words.Add("adeola"); //words.Add("amoeba"); //words.Add("moscow"); var board = new Board(12); board.ProcessWords(words.Keys.ToArray()); List <InsertWordResult> result = board.InsertWordResults; IEnumerable <InsertWordResult> wordsInserted = result.Where(x => x.Inserted); var wordviewmodels = new List <WordViewModel>(); foreach (InsertWordResult word in wordsInserted) { Debug.WriteLine(word); int position = (word.StartCell.Item1 * 12) + word.StartCell.Item2; var wordViewModel = new WordViewModel { Cells = new ObservableCollection <EmptyCellViewModel>(), Direction = word.Direction, Word = word.Word, WordHint = words.First(x => x.Key == word.Word.ToString()).Value, WordLength = "(" + word.Word.Length + ")", Index = position }; int row = word.StartCell.Item1; int col = word.StartCell.Item2; foreach (char character in word.Word) { var cell = new CellViewModel(col, row, character.ToString(), wordViewModel, string.Empty); if (word.Direction == Direction.Across) { col += 1; } else { row += 1; } wordViewModel.Cells.Add(cell); } wordviewmodels.Add((wordViewModel)); } return(wordviewmodels); }
public TrainingViewModel Create(Word rightWord) { var stackIndex = rightWord.TrainingHistories.Count(x => x.IsCorrect); var rightWordViewModel = new WordViewModel(rightWord); switch (stackIndex) { case 0: { return(new OneRightTrainingViewModel(OneRight.RepeatTranslation, rightWordViewModel)); } case 1: { return(new OneRightManyWrongViewModel( OneRightManyWrong.ChooseTranslation, rightWordViewModel, GetRandomWords(except: rightWord, amount: 5))); } case 2: { return(new OneRightManyWrongViewModel( OneRightManyWrong.ChooseOriginal, rightWordViewModel, GetRandomWords(except: rightWord, amount: 5))); } case 3: { var words = GetRandomWords(except: rightWord, amount: 4); words.Add(rightWordViewModel); return(new ManyRightTrainingViewModel(ManyRight.MatchWords, words)); } case 4: { return(new OneRightTrainingViewModel(OneRight.ComposeOriginal, rightWordViewModel)); } case 5: { return(new OneRightTrainingViewModel(OneRight.TypeTranslation, rightWordViewModel)); } case 6: { return(new OneRightTrainingViewModel(OneRight.TypeOriginal, rightWordViewModel)); } default: { return(new OneRightTrainingViewModel(OneRight.TypeOriginal, rightWordViewModel)); } } }
public ActionResult Edit(int id, WordViewModel wordViewModel) { if (ModelState.IsValid) { var wordModel = _mapper.Map <WordModel>(wordViewModel); _wordService.Update(wordModel); return(RedirectToAction("Index")); } return(View()); }
public IActionResult RemoveWord(WordViewModel request) { if (string.IsNullOrEmpty(request.Input)) { return(Empty()); } Response.Cookies.Append("lastRemovedWord", request.Input); _userInfoService.AddRemoveSearches((_wordService.HasWordBeenRemoved(request.Input))); return(View(request)); }
public ActionResult InfiniteScrolling() { var wordViewModel = new WordViewModel(_wordProxy, _db); wordViewModel.BuildModel(true, 8); ViewBag.Words = wordViewModel.Words; return(PartialView("_Word")); }
public ActionResult Index() { var wordViewModel = new WordViewModel(_wordProxy, _db); wordViewModel.BuildModel(true, 16); ViewBag.Words = wordViewModel.Words; return(View()); }
public void SoundSubmit() { var temp = new WordViewModel(); AppSettings.SetSound(false); Assert.AreEqual("/Data/Icons/nosound.png", temp.ImageSound); temp.ChangeValue(); Assert.AreEqual("/Data/Icons/sound.png", temp.ImageSound); temp.ChangeValue(); Assert.AreEqual("/Data/Icons/nosound.png", temp.ImageSound); }
public Word(WordViewModel value, string userId) { Id = Guid.NewGuid(); Text = value.Text; Transcription = value.Transcription; Translation = value.Transcription; Language = value.Language; AppUserId = userId; Collections = value.Collections ?? new List <Collection>(); }
public void Segments() { var segmentPool = new SegmentPool(); var busyService = Substitute.For <IBusyService>(); var projectService = Substitute.For <IProjectService>(); var dialogService = Substitute.For <IDialogService>(); var analysisService = new AnalysisService(_spanFactory, segmentPool, projectService, dialogService, busyService); var project = TestHelpers.GetTestProject(_spanFactory, segmentPool); project.Meanings.Add(new Meaning("gloss1", "cat1")); project.Varieties.Add(new Variety("variety1")); var w = new Word("gugəl", project.Meanings[0]); project.Varieties[0].Words.Add(w); projectService.Project.Returns(project); var word = new WordViewModel(busyService, analysisService, w); Assert.That(word.Segments, Is.Empty); Assert.That(word.IsValid, Is.False); project.Segmenter.Segment(w); Assert.That(word.IsValid, Is.True); Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] { "|", "g", "u", "g", "ə", "l", "|" })); word.Segments.Move(0, 2); Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] { "g", "u", "|", "g", "ə", "l", "|" })); Annotation <ShapeNode> prefixAnn = w.Prefix; Assert.That(prefixAnn, Is.Not.Null); Assert.That(w.Shape.GetNodes(prefixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] { "g", "u" })); Assert.That(w.Shape.GetNodes(w.Stem.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] { "g", "ə", "l" })); Assert.That(w.Suffix, Is.Null); Assert.That(w.StemIndex, Is.EqualTo(2)); Assert.That(w.StemLength, Is.EqualTo(3)); WordSegmentViewModel seg = word.Segments[6]; word.Segments.RemoveAt(6); word.Segments.Insert(5, seg); Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] { "g", "u", "|", "g", "ə", "|", "l" })); prefixAnn = w.Prefix; Assert.That(prefixAnn, Is.Not.Null); Assert.That(w.Shape.GetNodes(prefixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] { "g", "u" })); Assert.That(w.Shape.GetNodes(w.Stem.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] { "g", "ə" })); Annotation <ShapeNode> suffixAnn = w.Suffix; Assert.That(suffixAnn, Is.Not.Null); Assert.That(w.Shape.GetNodes(suffixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] { "l" })); Assert.That(w.StemIndex, Is.EqualTo(2)); Assert.That(w.StemLength, Is.EqualTo(2)); }
private async Task LookUpWordAsync() { if (string.IsNullOrEmpty(txtLookUp.StringValue)) { return; } string word = txtLookUp.StringValue; LookUpWord command = new LookUpWord(); (bool isValid, string errorMessage) = command.CheckThatWordIsValid(word); if (!isValid) { AlertManager.ShowWarningAlert("Invalid search term", errorMessage); return; } WordViewModel wordViewModel = null; try { WordModel wordModel = await command.LookUpWordAsync(word); wordViewModel = WordViewModel.CreateFromModel(wordModel); log.Translations.Clear(); foreach (RussianTranslation translation in wordViewModel.Translations) { log.Translations.Add(new RussianTranslation(translation.DanishWord, translation.Translation)); } ActivityLog.ReloadData(); if (wordModel == null) { AlertManager.ShowInfoAlert("Cannot find word", $"Den Danske Ordbog doesn't have a page for '{word}'"); } } catch (Exception ex) { AlertManager.ShowWarningAlert("Error occurred while searching word", ex.Message); return; } if (wordViewModel != null) { _wordViewModel = wordViewModel; UpdateControls(); return; } AlertManager.ShowWarningAlert("Cannot find word", $"Cannot find word {word} in DDO."); }
public IActionResult EditWord(WordViewModel request) { if (string.IsNullOrEmpty(request.Input)) { return(Empty()); } Response.Cookies.Append("lastEditedWord", request.Input); //_userInfoService.AddRemoveSearches(_wordRepository.EditWord(request.Input, request.EditWord)); return(View(request)); }
public WordViewModel WordOfTheDay(DateTime date) { var word = DAL.SDK.Kit.Instance.Words.GetWordOfTheDay(date); var wordDefinitions = GetWordDefinitionsById(word.lexemId); WordViewModel wordOfTheDay = new WordViewModel { LexemId = word.lexemId, Name = word.FormNoAcc, Definitions = wordDefinitions }; return(wordOfTheDay); }
public IActionResult Create(WordViewModel wordViewModel) { if (!ModelState.IsValid) { return(View(wordViewModel)); } _IWordAppService.Register(wordViewModel); //if (IsValidOperation()) // ViewBag.Sucesso = "Customer Registered!"; return(View(wordViewModel)); }
private void ClearWordSelection(WordViewModel word) { var item = (ListBoxItem)WordsListBox.ItemContainerGenerator.ContainerFromItem(word); if (item != null) { ListBox wordListBox = item.FindVisualDescendants <ListBox>().FirstOrDefault(); if (wordListBox != null) { wordListBox.UnselectAll(); } } }
public ActionResult Delete(int id, WordViewModel wordViewModel) { try { // TODO: Add delete logic here _wordService.Remove(id); return(RedirectToAction("Index")); } catch { return(View()); } }
private void ClearWordSelection(WordViewModel word) { var item = (ListBoxItem)WordsListBox.ItemContainerGenerator.ContainerFromItem(word); if (item != null) { var wordListBox = item.FindVisualChild <ListBox>(); if (wordListBox != null) { wordListBox.UnselectAll(); } } }
public async Task <IActionResult> Post([FromBody] WordViewModel value) { if (ModelState.IsValid && value != null) { //бля, и нахуя тут юзер был? icq -3 программист даун var newCollection = new Word(value, _userManager.GetUserId(User)); await _context.Words.AddAsync(newCollection); await _context.SaveChangesAsync(); return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> AddWord(WordViewModel wordModel) { //var user = await GetCurrentUser(); if (ModelState.IsValid) { Word word = _mapper.Map <Word>(wordModel); var list = Functions.StringToList(wordModel.MeaningsString); word.Meanings = list; wordRepository.Insert(word); } return(View("Index")); }
public StartCommand(WordViewModel wordViewModel) { config = new Config(); WordViewModel = wordViewModel; if (File.Exists("reports.json")) { Reports = config.DeserializeReportsFromJson(); } else { Reports = new Reports(); Reports.AllReports = new List <Report>(); } Reports.Top10FamousWord = new List <ForbiddenWord>(); }
public string JqGridAddTranslate(WordViewModel wordVM, int userWord_Id) { try { //Word word = wordVM.ToModel(); Word word = _mapper.Map <Word>(wordVM); _wordsService.AddTranslate(word, userWord_Id); } catch (Exception ex) { return(this.BadRequestAndCollectEx(ex)); } return(null); }
public string JqGridEdit(WordViewModel wordVM) { try { //Word word = wordVM.ToModel(); Word word = _mapper.Map <Word>(wordVM); _wordsService.Edit(word, this.GetAppUserId()); } catch (Exception ex) { return(this.BadRequestAndCollectEx(ex)); } return(null); }
public TrainingViewModel Create(Word rightWord) { var stackIndex = rightWord.TrainingHistories.Count(x => x.IsCorrect); var rightWordViewModel = new WordViewModel(rightWord); switch (stackIndex) { case 0: { return new OneRightTrainingViewModel(OneRight.RepeatTranslation, rightWordViewModel); } case 1: { return new OneRightManyWrongViewModel( OneRightManyWrong.ChooseTranslation, rightWordViewModel, GetRandomWords(except: rightWord, amount: 5)); } case 2: { return new OneRightManyWrongViewModel( OneRightManyWrong.ChooseOriginal, rightWordViewModel, GetRandomWords(except: rightWord, amount: 5)); } case 3: { var words = GetRandomWords(except: rightWord, amount: 4); words.Add(rightWordViewModel); return new ManyRightTrainingViewModel(ManyRight.MatchWords, words); } case 4: { return new OneRightTrainingViewModel(OneRight.ComposeOriginal, rightWordViewModel); } case 5: { return new OneRightTrainingViewModel(OneRight.TypeTranslation, rightWordViewModel); } case 6: { return new OneRightTrainingViewModel(OneRight.TypeOriginal, rightWordViewModel); } default: { return new OneRightTrainingViewModel(OneRight.TypeOriginal, rightWordViewModel); } } }
public MainWindow() { InitializeComponent(); wordViewModel = new WordViewModel(); Config = new Config(); if (File.Exists("words.json")) { wordViewModel.AllWords = Config.DeserializeWordsFromJson(); } else { wordViewModel.AllWords = new List <ForbiddenWord>(); } wordViewModel.ProgressBarMaximum = Convert.ToInt32(filesProgressBar.Maximum); DataContext = wordViewModel; }
public OneRightManyWrongViewModel(OneRightManyWrong type, WordViewModel right, IList<WordViewModel> wrong) : base(type) { RightWord = right; WrongWords = wrong; }
/// <summary> /// Select a word in the list /// </summary> /// <param name="wordViewModel"></param> /// <returns></returns> public string SelectWord(WordViewModel wordViewModel) { wordViewModel.IsRead = true; RaisePropertyChanged("Words"); return string.Format("/Views/DetailsPage.xaml?id={0}&type=words", wordViewModel.Id); }
/// <summary> /// Bufferize previous and buffer detail page /// </summary> /// <param name="currentId"></param> private void bufferNextAndPreviousPage(int currentId) { int index = m_dataList.IndexOf(currentId); m_isPreviousEnable = (index > 0); m_isNextEnable = (index + 1 < m_dataList.Count); if (m_isPreviousEnable) { var previousElement = CacheManager.Instance.GetCacheElementFromId<Element>(m_dataList[index - 1]); ElementViewModel previousElementViewModel = null; if (previousElement is Word) previousElementViewModel = new WordViewModel(previousElement as Word); else if (previousElement is Contrepeterie) previousElementViewModel = new ContrepeterieViewModel(previousElement as Contrepeterie); m_previousViewModel = new DetailsPageViewModel(previousElementViewModel); } if (m_isNextEnable) { var nextElement = CacheManager.Instance.GetCacheElementFromId<Element>(m_dataList[index + 1]); ElementViewModel nextElementViewModel = null; if (nextElement is Word) nextElementViewModel = new WordViewModel(nextElement as Word); else if (nextElement is Contrepeterie) nextElementViewModel = new ContrepeterieViewModel(nextElement as Contrepeterie); m_nextViewModel = new DetailsPageViewModel(nextElementViewModel); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { m_isFromLiveTile = false; m_type = ListType.Unknow; // Retrieve aimed id //------------------------------------------------------------------------------------ int elementId = -128; // Retrieve the element ID to get its details if (NavigationContext.QueryString.Keys.Contains("id")) { var number = NavigationContext.QueryString["id"]; try { elementId = Convert.ToInt32(number); } catch (Exception) { } } if (elementId == -128) { errorGoBack(); } else if (elementId == -1) { // Special id: element stored for live tile if (m_isFromLiveTile == false) { m_isFromLiveTile = true; } elementId = Settings.LiveTileElementId; } // Cache not loaded (we're coming from tile) ? Load it if (CacheManager.Instance.IsInitialized == false) { CacheManager.Instance.Initialize(InitializeLevel.Update); } // Get the element from WS Element element = getElementFromId(elementId); // Create view models ElementViewModel elementVM = null; if (element is Word) { elementVM = new WordViewModel(element as Word); } else if (element is Contrepeterie) { var ctpVM = new ContrepeterieViewModel(element as Contrepeterie); ctpVM.IsSolutionRevealed = false; elementVM = ctpVM; } else { errorGoBack(); return; } if (elementVM.IsRead == false) elementVM.IsRead = true; m_viewModel = new DetailsPageViewModel(elementVM); m_viewModel.Orientation = Orientation; // Load data fetcher //------------------------------------------------------------------------------------ string fetcherType = ""; string param = ""; if (NavigationContext.QueryString.Keys.Contains("type")) { fetcherType = NavigationContext.QueryString["type"]; if (NavigationContext.QueryString.Keys.Contains("param")) { param = NavigationContext.QueryString["param"]; } } else if (m_isFromLiveTile) { if (element is Word) fetcherType = ListType.Words.ToString(); else fetcherType = ListType.Contrepeteries.ToString(); } else { throw new ArgumentException("fetcher type"); } m_dataList = getAllData((ListType)Enum.Parse(typeof(ListType), fetcherType, true), param); bufferNextAndPreviousPage(element.Id); // ------------------ m_viewModel.IsRead = true; setDataContext(m_viewModel); // Mark as read if from tile if (m_isFromLiveTile) { BackgroundWorker bworker = new BackgroundWorker(); bworker.DoWork += (o, args) => { // Delay Thread.Sleep(1000); Dispatcher.BeginInvoke(() => { TileData.FindAndUpdateTile(); }); }; bworker.RunWorkerAsync(); } // Dynamically load app bar icons updateAppBar(); base.OnNavigatedTo(e); }
public OneRightTrainingViewModel(OneRight type, WordViewModel word) : base(type) { Word = word; }