Exemplo n.º 1
0
        /// <summary>
        /// Adds the field after.
        /// </summary>
        /// <param name="propertyPathField">The property path field.</param>
        public void AddFieldAfter(IPropertyPathFieldViewModel propertyPathField)
        {
            var newField = PropertyPathFieldEdit.NewPropertyPathField();
            newField.Index = Model.Subfields.Count > 0 ? Model.Subfields.Max(f => f.Index) + 1 : 1;

            Model.Subfields.Add(newField);

            var vm = FieldViewModelFactory.CreateExport().Value;
            vm.Initialize(newField, this);
            Subfields.Add(vm);

            propertyPathField.Subfield = vm;

            RaisePropertyChanged(() => CanSetSubfield);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes the fields after.
        /// </summary>
        /// <param name="propertyPathField">The property path field.</param>
        public void RemoveFieldsAfter(IPropertyPathFieldViewModel propertyPathField)
        {
            var position = Subfields.IndexOf(propertyPathField);
            var fieldsToRemove = new List<PropertyPathFieldEdit>();

            for (var i = Subfields.Count - 1; i > position; --i)
            {
                fieldsToRemove.Add(Subfields[i].Model);
                Subfields.RemoveAt(i);
            }

            Model.Subfields.RemoveRange(fieldsToRemove);

            propertyPathField.Subfield = null;

            RaisePropertyChanged(() => CanSetSubfield);
        }
        //private AvailableFieldsCriteria FieldsCriteria
        //{
        //    get
        //    {
        //        return _fieldsCriteria;
        //    }

        //    set
        //    {
        //        if (!_fieldsCriteria.Equals(value))
        //        {
        //            _fieldsCriteria = value;
        //            UpdateAvailableFields();
        //        }
        //    }
        //}

        #endregion Properties

        #region Public Methods

        /// <summary>
        /// Initializes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        public void Initialize(PropertyPathFieldEdit model, IPropertyPathViewModel parentViewModel)
        {
            Model = model;
            _fieldName = Model.FieldName;
            _subfield = null;
            ParentViewModel = parentViewModel;
            _hasSubfield = false;
        }