Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpecRelationTypeMappingDialogViewModel"/> class
        /// </summary>
        /// <param name="specRelationTypes"></param>
        /// <param name="specRelationTypeMap"></param>
        /// <param name="datatypeDefMap"></param>
        /// <param name="iteration"></param>
        /// <param name="session"></param>
        /// <param name="thingDialogNavigationService"></param>
        /// <param name="lang"></param>
        public SpecRelationTypeMappingDialogViewModel(IEnumerable <SpecRelationType> specRelationTypes, IReadOnlyDictionary <SpecRelationType, SpecRelationTypeMap> specRelationTypeMap, IReadOnlyDictionary <DatatypeDefinition, DatatypeDefinitionMap> datatypeDefMap, Iteration iteration, ISession session, IThingDialogNavigationService thingDialogNavigationService, string lang)
            : base(iteration, session, thingDialogNavigationService, lang)
        {
            this.BackCommand = ReactiveCommand.Create();
            this.BackCommand.Subscribe(_ => this.ExecuteBackCommand());

            var canExecuteOk = this.WhenAnyValue(x => x.CanOk);

            this.OkCommand = ReactiveCommand.Create(canExecuteOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOkCommand());

            this.CreateCategoryCommand = ReactiveCommand.Create();
            this.CreateCategoryCommand.Subscribe(_ => this.ExecuteCreateCategoryCommand());

            this.CreateBinaryRealationshipRuleCommand = ReactiveCommand.Create();
            this.CreateBinaryRealationshipRuleCommand.Subscribe(_ => this.ExecuteCreateBinaryRelationshipRuleCommand());

            this.SpecTypes = new ReactiveList <SpecRelationMappingRowViewModel>();

            foreach (var specRelationType in specRelationTypes)
            {
                var row = new SpecRelationMappingRowViewModel(specRelationType, iteration, datatypeDefMap, this.UpdateCanOk);
                this.SpecTypes.Add(row);
            }

            if (specRelationTypeMap != null)
            {
                this.PopulateRelationTypeMapProperties(specRelationTypeMap);
            }

            this.UpdateCanOk();
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpecRelationTypeMappingDialogViewModel"/> class
        /// </summary>
        /// <param name="specRelationTypes"></param>
        /// <param name="specRelationTypeMap"></param>
        /// <param name="datatypeDefMap"></param>
        /// <param name="iteration"></param>
        /// <param name="session"></param>
        /// <param name="thingDialogNavigationService"></param>
        /// <param name="lang"></param>
        public SpecRelationTypeMappingDialogViewModel(IEnumerable <SpecRelationType> specRelationTypes, IReadOnlyDictionary <SpecRelationType, SpecRelationTypeMap> specRelationTypeMap, IReadOnlyDictionary <DatatypeDefinition, DatatypeDefinitionMap> datatypeDefMap, Iteration iteration, ISession session, IThingDialogNavigationService thingDialogNavigationService, string lang)
            : base(iteration, session, thingDialogNavigationService, lang)
        {
            this.BackCommand = ReactiveCommand.Create();
            this.BackCommand.Subscribe(_ => this.ExecuteBackCommand());

            var canExecuteOk = this.WhenAnyValue(x => x.CanOk);

            this.OkCommand = ReactiveCommand.Create(canExecuteOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOkCommand());

            this.CreateCategoryCommand = ReactiveCommand.Create();
            this.CreateCategoryCommand.Subscribe(_ => this.ExecuteCreateCategoryCommand());

            this.CreateBinaryRealationshipRuleCommand = ReactiveCommand.Create();
            this.CreateBinaryRealationshipRuleCommand.Subscribe(_ => this.ExecuteCreateBinaryRelationshipRuleCommand());

            this.SpecTypes = new ReactiveList <SpecRelationMappingRowViewModel>();

            foreach (var specRelationType in specRelationTypes)
            {
                var row = new SpecRelationMappingRowViewModel(specRelationType, iteration, datatypeDefMap, this.UpdateCanOk);
                this.SpecTypes.Add(row);
            }

            if (specRelationTypeMap != null)
            {
                foreach (var pair in specRelationTypeMap)
                {
                    var row = this.SpecTypes.Single(x => x.Identifiable == pair.Key);
                    row.SelectedRules = new ReactiveList <ParameterizedCategoryRule>(row.PossibleRules.Where(r => pair.Value.Rules.Contains(r)));
                    row.SelectedBinaryRelationshipRules = new ReactiveList <BinaryRelationshipRule>(row.PossibleBinaryRelationshipRules.Where(r => pair.Value.BinaryRelationshipRules.Contains(r)));
                    row.SelectedCategories = new ReactiveList <CategoryComboBoxItemViewModel>(row.PossibleCategories.Where(c => pair.Value.Categories.Contains(c.Category)));
                }
            }

            this.UpdateCanOk();
        }