예제 #1
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 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);
        }
예제 #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);
        }
        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 documentDesigner = new DocumentDesignerElement(parent);

            documentDesigner.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)
                    });
                }

                documentDesigner.SetEditors(editors);
            }

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

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

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

                var sourceItemsDataBinding = itemsDataBinding as ISourceDataBinding;

                if (sourceItemsDataBinding != null)
                {
                    var dataSourceName = sourceItemsDataBinding.GetDataSource();
                    var dataSource     = parent.GetDataSource(dataSourceName);

                    // Установка идентификатора конфигурации
                    documentDesigner.SetConfigId(dataSource.GetConfigId);

                    // Оповещение источника об изменениях в редакторе
                    documentDesigner.NotifyWhenEventAsync(i => i.OnUpdateItems, arguments =>
                    {
                        arguments.DataSource = dataSourceName;
                        return(true);
                    });
                }
            }

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

            editor.ApplyElementMeatadata((object)metadata);

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

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

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

            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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #13
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);
                        }
                    }
                }
            }
        }
예제 #14
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);
        }
예제 #15
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);
        }
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var label = new LabelElement(parent);

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

            label.SetFormat(valueFormat);
            label.ApplyElementMeatadata((object)metadata);
            label.SetLineCount(Convert.ToInt32(metadata.LineCount));
            label.SetHorizontalTextAlignment(
                (metadata.HorizontalTextAlignment as string).ToEnum(HorizontalTextAlignment.Left));

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

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

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

            return(label);
        }
예제 #17
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var treeView = new TreeViewElement(parent);

            treeView.ApplyElementMeatadata((object)metadata);
            treeView.SetMultiSelect(Convert.ToBoolean(metadata.MultiSelect));
            treeView.SetShowNodeImages(Convert.ToBoolean(metadata.ShowNodeImages));
            treeView.SetKeyProperty(metadata.KeyProperty);
            treeView.SetParentProperty(metadata.ParentProperty);
            treeView.SetImageProperty(metadata.ImageProperty);
            treeView.SetValueProperty(metadata.ValueProperty);
            treeView.SetDisplayProperty(metadata.DisplayProperty);

            // Установка формата отображения элемента

            var itemFormat = context.Build(parent, metadata.ItemFormat) as DataFormat;

            if (itemFormat != null)
            {
                treeView.OnRenderItem += (c, a) => { a.Display = itemFormat.Format(a.Item); };
            }

            // Установка панели навигации по данным

            if (metadata.DataNavigation != null && metadata.DataNavigation.DataNavigation != null &&
                metadata.Items != null && metadata.Items.PropertyBinding != null)
            {
                metadata.DataNavigation.DataNavigation.DataSource = metadata.Items.PropertyBinding.DataSource;
            }

            var navigationPanel = context.Build(parent, metadata.DataNavigation);

            treeView.SetDataNavigation(navigationPanel);

            // Установка контекстного меню

            var contextMenu = context.Build(parent, metadata.ContextMenu);

            treeView.SetContextMenu(contextMenu);

            // Привязка к источнику данных списка элементов
            IElementDataBinding itemsDataBinding = context.Build(parent, metadata.Items);

            itemsDataBinding.OnPropertyValueChanged += (c, a) => treeView.SetItems(a.Value);

            // Todo: ReadOnly, Format, Value, OnValueChanged and etc.

            var sourceItemsDataBinding = itemsDataBinding as ISourceDataBinding;

            // Если источник данных для списка элементов определен
            if (sourceItemsDataBinding != null)
            {
                var dataSourceName = sourceItemsDataBinding.GetDataSource();
                var propertyName   = sourceItemsDataBinding.GetProperty();
                var dataSource     = parent.GetDataSource(dataSourceName);

                if (dataSource != null)
                {
                    treeView.SetIdProperty(dataSource.GetIdProperty());
                }

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

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

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

                Func <dynamic, bool> filter = a => !Equals(a.Source, treeView) &&
                                              a.DataSource == dataSourceName &&
                                              a.Property == propertyName;

                treeView.SubscribeOnEvent(OnItemDeleted, filter);
                treeView.SubscribeOnEvent(OnSetSelectedItem, filter);
            }

            if (metadata.OnDoubleClick != null)
            {
                treeView.OnDoubleClick += parent.GetScript(metadata.OnDoubleClick);
            }

            return(treeView);
        }