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);
}