예제 #1
0
 public void SetUp()
 {
     _busyService = Substitute.For<IBusyService>();
     _analysisService = Substitute.For<IAnalysisService>();
     _words = new ObservableList<WordViewModel>
     {
         new WordViewModel(_busyService, _analysisService, new Word("valid", _meaning)) {IsValid = true},
         new WordViewModel(_busyService, _analysisService, new Word("invalid", _meaning)) {IsValid = false}
     };
     _wordsViewModel = new WordsViewModel(_busyService, new ReadOnlyBindableList<WordViewModel>(_words));
     _meaning = new Meaning("gloss", "category");
 }
예제 #2
0
        public SegmentsViewModel(IProjectService projectService, IDialogService dialogService, IBusyService busyService, IExportService exportService, WordsViewModel.Factory wordsFactory,
                                 WordViewModel.Factory wordFactory)
            : base("Segments")
        {
            _projectService = projectService;
            _busyService    = busyService;
            _dialogService  = dialogService;
            _exportService  = exportService;
            _wordFactory    = wordFactory;

            _findCommand = new RelayCommand(Find);

            TaskAreas.Add(new TaskAreaCommandGroupViewModel("Syllable position",
                                                            new TaskAreaCommandViewModel("Onset", new RelayCommand(() => SyllablePosition   = SyllablePosition.Onset)),
                                                            new TaskAreaCommandViewModel("Nucleus", new RelayCommand(() => SyllablePosition = SyllablePosition.Nucleus)),
                                                            new TaskAreaCommandViewModel("Coda", new RelayCommand(() => SyllablePosition    = SyllablePosition.Coda))));

            TaskAreas.Add(new TaskAreaItemsViewModel("Common tasks",
                                                     new TaskAreaCommandViewModel("Find words", _findCommand),
                                                     new TaskAreaItemsViewModel("Sort words by", new TaskAreaCommandGroupViewModel(
                                                                                    new TaskAreaCommandViewModel("Meaning", new RelayCommand(() => SortWordsBy("Meaning.Gloss", ListSortDirection.Ascending))),
                                                                                    new TaskAreaCommandViewModel("Form", new RelayCommand(() => SortWordsBy("StrRep", ListSortDirection.Ascending)))))));

            TaskAreas.Add(new TaskAreaItemsViewModel("Other tasks",
                                                     new TaskAreaCommandViewModel("Export segment frequencies", new RelayCommand(() => _exportService.ExportSegmentFrequencies(this, _syllablePosition)))));

            _projectService.ProjectOpened += _projectService_ProjectOpened;

            Messenger.Default.Register <DomainModelChangedMessage>(this, msg =>
            {
                if (msg.AffectsComparison)
                {
                    PopulateSegments();
                }
            });

            _currentWords       = new BulkObservableList <WordViewModel>();
            _observedWords      = wordsFactory(new ReadOnlyBindableList <WordViewModel>(_currentWords));
            _domainSegments     = new BulkObservableList <Segment>();
            _segments           = new BulkObservableList <SegmentViewModel>();
            _readonlySegments   = new ReadOnlyBindableList <SegmentViewModel>(_segments);
            _categories         = new BulkObservableList <SegmentCategoryViewModel>();
            _readonlyCategories = new ReadOnlyBindableList <SegmentCategoryViewModel>(_categories);
        }
예제 #3
0
        public SegmentsViewModel(IProjectService projectService, IDialogService dialogService, IBusyService busyService, IExportService exportService, WordsViewModel.Factory wordsFactory,
			WordViewModel.Factory wordFactory)
            : base("Segments")
        {
            _projectService = projectService;
            _busyService = busyService;
            _dialogService = dialogService;
            _exportService = exportService;
            _wordFactory = wordFactory;

            _findCommand = new RelayCommand(Find);

            TaskAreas.Add(new TaskAreaCommandGroupViewModel("Syllable position",
                new TaskAreaCommandViewModel("Onset", new RelayCommand(() => SyllablePosition = SyllablePosition.Onset)),
                new TaskAreaCommandViewModel("Nucleus", new RelayCommand(() => SyllablePosition = SyllablePosition.Nucleus)),
                new TaskAreaCommandViewModel("Coda", new RelayCommand(() => SyllablePosition = SyllablePosition.Coda))));

            TaskAreas.Add(new TaskAreaItemsViewModel("Common tasks",
                new TaskAreaCommandViewModel("Find words", _findCommand),
                new TaskAreaItemsViewModel("Sort words by", new TaskAreaCommandGroupViewModel(
                    new TaskAreaCommandViewModel("Meaning", new RelayCommand(() => SortWordsBy("Meaning.Gloss", ListSortDirection.Ascending))),
                    new TaskAreaCommandViewModel("Form", new RelayCommand(() => SortWordsBy("StrRep", ListSortDirection.Ascending)))))));

            TaskAreas.Add(new TaskAreaItemsViewModel("Other tasks",
                new TaskAreaCommandViewModel("Export segment frequencies", new RelayCommand(ExportSegmentFrequencies, CanExportSegmentFrequencies))));

            _projectService.ProjectOpened += _projectService_ProjectOpened;

            Messenger.Default.Register<DomainModelChangedMessage>(this, msg =>
                {
                    if (msg.AffectsComparison)
                        PopulateSegments();
                });

            _currentWords = new BulkObservableList<WordViewModel>();
            _observedWords = wordsFactory(new ReadOnlyBindableList<WordViewModel>(_currentWords));
            _domainSegments = new BulkObservableList<Segment>();
            _segments = new BulkObservableList<SegmentViewModel>();
            _readonlySegments = new ReadOnlyBindableList<SegmentViewModel>(_segments);
            _categories = new BulkObservableList<SegmentCategoryViewModel>();
            _readonlyCategories = new ReadOnlyBindableList<SegmentCategoryViewModel>(_categories);
        }
예제 #4
0
        public VarietiesVarietyViewModel(IProjectService projectService, IDialogService dialogService, WordsViewModel.Factory wordsFactory, WordViewModel.Factory wordFactory, Variety variety)
            : base(variety)
        {
            _projectService = projectService;
            _dialogService = dialogService;

            IEnumerable<Segment> segments = variety.SegmentFrequencyDistribution == null ? Enumerable.Empty<Segment>() : variety.SegmentFrequencyDistribution.ObservedSamples;

            _segments = new BulkObservableList<VarietySegmentViewModel>(segments.Select(seg => new VarietySegmentViewModel(this, seg)));
            _maxSegProb = _segments.Select(seg => seg.Probability).Concat(0).Max();
            _readOnlySegments = new ReadOnlyBindableList<VarietySegmentViewModel>(_segments);
            variety.PropertyChanged += variety_PropertyChanged;
            _affixes = new MirroredBindableList<Affix, AffixViewModel>(DomainVariety.Affixes, affix => new AffixViewModel(affix), vm => vm.DomainAffix);
            _words = new MirroredBindableCollection<Word, WordViewModel>(variety.Words, word =>
                {
                    WordViewModel vm = wordFactory(word);
                    SelectWordSegments(vm);
                    return vm;
                }, vm => vm.DomainWord);
            _wordsViewModel = wordsFactory(_words);
            _newAffixCommand = new RelayCommand(NewAffix);
            _editAffixCommand = new RelayCommand(EditAffix, CanEditAffix);
            _removeAffixCommand = new RelayCommand(RemoveAffix, CanRemoveAffix);
        }
예제 #5
0
        public VarietiesVarietyViewModel(IProjectService projectService, IDialogService dialogService, WordsViewModel.Factory wordsFactory, WordViewModel.Factory wordFactory, Variety variety)
            : base(variety)
        {
            _projectService = projectService;
            _dialogService  = dialogService;

            IEnumerable <Segment> segments = variety.SegmentFrequencyDistribution == null?Enumerable.Empty <Segment>() : variety.SegmentFrequencyDistribution.ObservedSamples;

            _segments                = new BulkObservableList <VarietySegmentViewModel>(segments.Select(seg => new VarietySegmentViewModel(this, seg)));
            _maxSegProb              = _segments.Select(seg => seg.Probability).Concat(0).Max();
            _readOnlySegments        = new ReadOnlyBindableList <VarietySegmentViewModel>(_segments);
            variety.PropertyChanged += variety_PropertyChanged;
            _affixes = new MirroredBindableList <Affix, AffixViewModel>(DomainVariety.Affixes, affix => new AffixViewModel(affix), vm => vm.DomainAffix);
            _words   = new MirroredBindableCollection <Word, WordViewModel>(variety.Words, word =>
            {
                WordViewModel vm = wordFactory(word);
                SelectWordSegments(vm);
                return(vm);
            }, vm => vm.DomainWord);
            _wordsViewModel     = wordsFactory(_words);
            _newAffixCommand    = new RelayCommand(NewAffix);
            _editAffixCommand   = new RelayCommand(EditAffix, CanEditAffix);
            _removeAffixCommand = new RelayCommand(RemoveAffix, CanRemoveAffix);
        }