示例#1
0
        public CollectionProperty Clone(bool newItem)
        {
            var cloneProperties = new Dictionary <string, IControlProperty>();

            foreach (var property in Properties)
            {
                if (property.Value is ObjectProperty)
                {
                    var objectProperty = property.Value as ObjectProperty;
                    cloneProperties.Add(property.Key, objectProperty.Clone(newItem));
                }
                else if (property.Value is CollectionProperty)
                {
                    var collectionProperty = property.Value as CollectionProperty;
                    cloneProperties.Add(property.Key, collectionProperty.Clone(newItem));
                }
                else
                {
                    var simpleProperty = property.Value as SimpleProperty;
                    if (simpleProperty != null)
                    {
                        simpleProperty.Value = simpleProperty.DefaultValue;
                    }
                    cloneProperties.Add(property.Key, property.Value);
                }
            }

            var cloneProperty = new CollectionProperty(cloneProperties);

            cloneProperty.Items = Items;
            return(cloneProperty);
        }
示例#2
0
        private void CustomizeColumns(CollectionProperty collectionProperty)
        {
            PropertiesView.Columns.Clear();
            foreach (var property in collectionProperty.Properties)
            {
                var column = new GridColumn();
                column.FieldName = property.Key;
                var objectProperty = property.Value as ObjectProperty;
                if (objectProperty != null)
                {
                    column.ColumnEdit = DesignerExtensions.CreateRepositoryItem(repositoryItemButtonEdit_ButtonClick);
                }
                else
                {
                    var innerCollectionProperty = property.Value as CollectionProperty;
                    if (innerCollectionProperty != null)
                    {
                        column.ColumnEdit = DesignerExtensions.CreateRepositoryItem(repositoryItemButtonEdit_ButtonClick);
                    }
                    else
                    {
                        column.ColumnEdit = _repository.GetRepositoryItem(property.Key, property.Value) ??
                                            (!string.IsNullOrEmpty(PropertyName)
                                                ? _repository.GetRepositoryItem(PropertyName + "." + property.Key,
                                                                                property.Value)
                                                : null);
                    }
                }

                column.Visible = true;
                PropertiesView.Columns.Add(column);
            }
        }
示例#3
0
        private void repositoryItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Delete)
            {
                ((BaseEdit)sender).EditValue = new DynamicWrapper().ToString();
            }
            else if (e.Button.Kind == ButtonPredefines.Glyph)
            {
                var value = ((BaseEdit)sender).EditValue;
                var form  = new ValueEdit();
                form.Value = value != null?value.ToString() : string.Empty;

                form.ShowDialog();
            }
            else if (e.Button.Kind == ButtonPredefines.Ellipsis)
            {
                var instance = _dataSource.ToArray()[PropertiesView.FocusedRowHandle];
                CollectionProperty property = _rows[instance];

                //если разбираем свойство являющееся объектом
                var valueProperty = property.Properties[PropertiesView.FocusedColumn.FieldName] as ObjectProperty;


                dynamic propertyValue = null;
                try
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamic(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                    DesignerExtensions.SetSimplePropertiesFromInstance(valueProperty.SimpleProperties, propertyValue);
                    DesignerExtensions.SetCollectionPropertiesFromInstance(valueProperty.CollectionProperties,
                                                                           propertyValue);
                }
                catch (Exception)
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamicList(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                }


                if (valueProperty != null)
                {
                    SelectObjectProperty(sender, valueProperty);
                }

                var collectionProperty =
                    property.Properties[PropertiesView.FocusedColumn.FieldName] as CollectionProperty;

                if (collectionProperty != null)
                {
                    SelectCollectionProperty(sender, collectionProperty);
                }
            }
        }
示例#4
0
        private void SelectCollectionProperty(object sender, CollectionProperty collectionProperty)
        {
            var collectionForm = new CollectionForm();

            collectionForm.CollectionEditor.SetPropertyEditors(_repository);
            collectionForm.CollectionEditor.PropertyName = PropertiesView.FocusedColumn.FieldName;
            var cloneProperty = collectionProperty;

            collectionForm.CollectionEditor.CollectionProperty = cloneProperty;
            collectionForm.ShowDialog();

            var array = collectionForm.CollectionEditor.CollectionProperty.Items;

            ((ButtonEdit)sender).EditValue = array.ToString();
        }