public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var editor = new ValidationWarningDesignerElement(parent);

            editor.ApplyElementMeatadata((object)metadata);

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => editor.SetValue(a.Value);
                editor.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value);

                var sourceValueBinding = valueBinding as ISourceDataBinding;

                if (sourceValueBinding != null)
                {
                    // Передача контекста редактору

                    var dataSourceName = sourceValueBinding.GetDataSource();
                    var dataSource     = parent.GetDataSource(dataSourceName);

                    editor.SetConfigId(dataSource.GetConfigId);
                    editor.SetDocumentId(dataSource.GetDocumentId);
                }
            }

            return(editor);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var textBox = new TextBoxElement(parent);

            // Установка формата данных
            var valueFormat = context.Build(parent, metadata.Format);

            textBox.SetFormat(valueFormat);
            textBox.ApplyElementMeatadata((object)metadata);
            textBox.SetPlaceholder(metadata.Placeholder);
            textBox.SetReadOnly(Convert.ToBoolean(metadata.ReadOnly));
            textBox.SetMultiline(Convert.ToBoolean(metadata.Multiline));
            textBox.SetLineCount(Convert.ToInt32(metadata.LineCount));
            textBox.SetHorizontalTextAlignment(
                (metadata.HorizontalTextAlignment as string).ToEnum(HorizontalTextAlignment.Left));
            textBox.SetVerticalTextAlignment(
                (metadata.VerticalTextAlignment as string).ToEnum(VerticalTextAlignment.Center));

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => textBox.SetValue(a.Value);
                textBox.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(textBox);
        }
Beispiel #3
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var toggleButton = new ToggleButtonElement(parent);

            toggleButton.ApplyElementMeatadata((object)metadata);
            toggleButton.SetReadOnly(Convert.ToBoolean(metadata.ReadOnly));

            if (metadata.TextOn != null)
            {
                toggleButton.SetTextOn(metadata.TextOn);
            }

            if (metadata.TextOff != null)
            {
                toggleButton.SetTextOff(metadata.TextOff);
            }

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => toggleButton.SetValue(a.Value);
                toggleButton.OnValueChanged         += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(toggleButton);
        }
Beispiel #4
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var element = new DocumentSelectorElement(parent);

            element.ApplyElementMeatadata((object)metadata);
            element.SetDocumentsFunc(GetDocuments);

            // Привязка к источнику данных

            IElementDataBinding configIdBinding = context.Build(parent, metadata.ConfigId);

            if (configIdBinding != null)
            {
                configIdBinding.OnPropertyValueChanged += (c, a) => element.SetConfigId(a.Value);
            }

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => element.SetValue(a.Value);
                element.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(element);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var editor = new ReportDesignerElement(parent);

            editor.ApplyElementMeatadata((object)metadata);

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => editor.SetValue(a.Value);
                editor.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value, force: true);
            }

            return(editor);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var printViewDesigner = new PrintViewDesignerElement(parent);

            printViewDesigner.ApplyElementMeatadata((object)metadata);

            // Привязка к источнику данных представления

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => printViewDesigner.SetValue(a.Value);
                printViewDesigner.OnValueChanged    += (c, a) => valueBinding.SetPropertyValue(a.Value, force: true);
            }

            return(printViewDesigner);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var checkBox = new CheckBoxElement(parent);

            checkBox.ApplyElementMeatadata((object)metadata);
            checkBox.SetReadOnly(Convert.ToBoolean(metadata.ReadOnly));

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => checkBox.SetValue(a.Value);
                checkBox.OnValueChanged             += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(checkBox);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var codeEditor = new CodeEditorElement(parent);

            codeEditor.SetSyntax(BuildSyntax(metadata.Syntax));
            codeEditor.SetFormatter(BuildFormatter(metadata.Formatter));
            codeEditor.ApplyElementMeatadata((object)metadata);

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => codeEditor.SetValue(a.Value);
                codeEditor.OnValueChanged           += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(codeEditor);
        }
Beispiel #9
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var element = new ParameterElement(parent);

            element.SetName(metadata.Name);

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => element.SetValue(a.Value);
                element.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            if (metadata.OnValueChanged != null)
            {
                element.OnValueChanged += parent.GetScript(metadata.OnValueChanged);
            }

            return(element);
        }
Beispiel #10
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var element = new ViewPropertyEditorElement(parent);

            element.ApplyElementMeatadata((object)metadata);

            // Редакторы свойств

            if (metadata.Editors != null)
            {
                var editors = new List <PropertyEditor>();

                foreach (var editor in metadata.Editors)
                {
                    editors.Add(new PropertyEditor
                    {
                        Text              = editor.Text,
                        Image             = ImageRepository.GetImage(editor.Image),
                        Property          = editor.Property,
                        PropertyType      = editor.PropertyType,
                        PropertyValueType = editor.PropertyValueType,
                        EditView          = context.Build(parent, editor.EditView)
                    });
                }

                element.SetEditors(editors);
            }

            // Привязка к источнику данных

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => element.SetValue(a.Value);
                element.OnValueChanged += (c, a) => valueBinding.SetPropertyValue(a.Value, force: true);
            }

            return(element);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var schemaDesigner = new DocumentSchemaDesignerElement(parent);

            schemaDesigner.ApplyElementMeatadata((object)metadata);

            // Редакторы свойств модели данных

            if (metadata.Editors != null)
            {
                var editors = new List <ItemEditor>();

                foreach (var editor in metadata.Editors)
                {
                    editors.Add(new ItemEditor
                    {
                        Text         = editor.Text,
                        Image        = editor.Image,
                        Container    = editor.Container,
                        MetadataType = editor.MetadataType,
                        LinkView     = context.Build(parent, editor.LinkView)
                    });
                }

                schemaDesigner.SetEditors(editors);
            }

            // Привязка к источнику данных представления

            IElementDataBinding valueBinding = context.Build(parent, metadata.Value);

            if (valueBinding != null)
            {
                valueBinding.OnPropertyValueChanged += (c, a) => schemaDesigner.SetValue(a.Value);
                schemaDesigner.OnValueChanged       += (c, a) => valueBinding.SetPropertyValue(a.Value);
            }

            return(schemaDesigner);
        }
Beispiel #12
0
        private static void BindParameters(ObjectBuilderContext context, View parentView, View childView,
                                           dynamic parameters)
        {
            if (parameters != null)
            {
                foreach (var parameterLink in parameters)
                {
                    ParameterElement parameter = childView.GetParameter(parameterLink.Name);

                    if (parameter != null)
                    {
                        IElementDataBinding parameterValueBinding = context.Build(parentView, parameterLink.Value);

                        if (parameterValueBinding != null)
                        {
                            parameterValueBinding.OnPropertyValueChanged += (c, a) => parameter.SetValue(a.Value);
                            parameter.OnValueChanged += (c, a) => parameterValueBinding.SetPropertyValue(a.Value);
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var action = new BaseItemAction(parent);

            IElementDataBinding itemsDataBinding = context.Build(parent, metadata.Items);

            if (itemsDataBinding != null)
            {
                itemsDataBinding.OnPropertyValueChanged += (c, a) => action.SetItems(a.Value);
                action.OnValueChanged += (c, a) => itemsDataBinding.SetPropertyValue(a.Value);

                var sourceItemsDataBinding = itemsDataBinding as ISourceDataBinding;

                if (sourceItemsDataBinding != null)
                {
                    var dataSourceName = sourceItemsDataBinding.GetDataSource();
                    var propertyName   = sourceItemsDataBinding.GetProperty();

                    // Публикация сообщений в шину при возникновении событий

                    action.NotifyWhenEventAsync(i => i.OnSetSelectedItem, a =>
                    {
                        a.DataSource = dataSourceName;
                        a.Property   = propertyName;
                        return(true);
                    });

                    // Подписка на сообщения шины от внешних элементов

                    action.SubscribeOnEvent(OnSetSelectedItem, a => a.DataSource == dataSourceName &&
                                            a.Property == propertyName);
                }
            }

            action.SetAction(() => ExecuteAction(context, action, metadata));

            return(action);
        }
Beispiel #14
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var menuDesigner = new MenuDesignerElement(parent);

            menuDesigner.ApplyElementMeatadata((object)metadata);

            // Редактор элементов меню
            var menuItemEditor = context.Build(parent, metadata.Editor);

            menuDesigner.SetEditor(menuItemEditor);

            // Привязка к источнику данных представления

            IElementDataBinding itemsDataBinding = context.Build(parent, metadata.Items);

            if (itemsDataBinding != null)
            {
                itemsDataBinding.OnPropertyValueChanged += (c, a) => menuDesigner.SetItems(a.Value);
                menuDesigner.OnUpdateItems += (c, a) => itemsDataBinding.SetPropertyValue(a.Value);
            }

            return(menuDesigner);
        }