Пример #1
0
 private void variety_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "SegmentFrequencyDistribution")
     {
         Segment curSeg = null;
         if (SelectedSegment != null)
         {
             curSeg = SelectedSegment.DomainSegment;
         }
         _segments.ReplaceAll(DomainVariety.SegmentFrequencyDistribution.ObservedSamples.Select(seg => new VarietySegmentViewModel(this, seg)));
         MaxSegmentProbability = _segments.Select(seg => seg.Probability).Concat(0).Max();
         if (curSeg != null)
         {
             SelectedSegment = _segments.FirstOrDefault(vm => vm.DomainSegment.Equals(curSeg));
         }
     }
 }
Пример #2
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);
        }
Пример #3
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);
        }