Exemplo n.º 1
0
        private void SelectObjectProperty(object sender, ObjectProperty valueProperty)
        {
            var propertiesForm = new PropertiesForm();

            propertiesForm.ParentProperty = PropertiesView.FocusedColumn.FieldName;
            propertiesForm.SetPropertyEditors(_repository.Editors);

            propertiesForm.SetSimpleProperties(valueProperty.SimpleProperties);
            propertiesForm.SetCollectionProperties(valueProperty.CollectionProperties);
            propertiesForm.SetValidationRules(valueProperty.ValidationRules);

            if (propertiesForm.ShowDialog() == DialogResult.OK)
            {
                //долбаный грид заворачивает объект в строку при создании DataRow
                dynamic instance = PropertiesView.GetFocusedValue().ToString().ToDynamic();
                DesignerExtensions.SetSimplePropertiesToInstance(valueProperty.SimpleProperties, instance);
                DesignerExtensions.SetCollectionPropertiesToInstance(valueProperty.CollectionProperties, instance);

                ((ButtonEdit)sender).EditValue = instance.ToString();
                ((ButtonEdit)sender).Refresh();
            }
            else
            {
                propertiesForm.RevertChanges();
            }
        }
Exemplo n.º 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();
                }
            }
        }