Example #1
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);
                }
            }
        }
Example #2
0
        private void repositoryItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Delete)
            {
                ((BaseEdit)sender).EditValue = new DynamicWrapper();
            }
            else if (e.Button.Kind == ButtonPredefines.Glyph && e.Button.Tag == null)
            {
                var value = ((BaseEdit)sender).EditValue;
                var form  = new ValueEdit();
                form.ReadOnly = true;
                form.Value    = value != null?value.ToString() : string.Empty;

                form.ShowDialog();
            }
            else if (e.Button.Kind == ButtonPredefines.Ellipsis)
            {
                var properties = (ObjectProperty)((RepositoryItemButtonEdit)((ButtonEdit)sender).Tag).Tag;

                var propertiesForm = new PropertiesForm();

                DesignerExtensions.SetSimplePropertiesFromInstance(properties.SimpleProperties, properties.Value);
                DesignerExtensions.SetCollectionPropertiesFromInstance(properties.CollectionProperties, properties.Value);


                propertiesForm.ParentProperty = SimplePropertiesGrid.FocusedRow.Name;
                propertiesForm.SetValidationRules(properties.ValidationRules);
                propertiesForm.SetPropertyEditors(_repository.Editors);
                propertiesForm.SetSimpleProperties(properties.SimpleProperties);
                propertiesForm.SetCollectionProperties(properties.CollectionProperties);
                if (propertiesForm.ShowDialog() == DialogResult.OK)
                {
                    dynamic instance = ((ButtonEdit)sender).EditValue;

                    DesignerExtensions.SetSimplePropertiesToInstance(properties.SimpleProperties, instance);
                    DesignerExtensions.SetCollectionPropertiesToInstance(properties.CollectionProperties, instance);


                    ((ButtonEdit)sender).Refresh();
                }
                else
                {
                    propertiesForm.RevertChanges();
                }
            }
        }