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

            popupButton.ApplyElementMeatadata((object)metadata);
            popupButton.SetImage(metadata.Image);

            var action = context.Build(parent, metadata.Action);

            popupButton.SetAction(action);

            if (parent != null && metadata.OnClick != null)
            {
                popupButton.OnClick += parent.GetScript(metadata.OnClick);
            }

            var items = context.BuildMany(parent, metadata.Items);

            if (items != null)
            {
                foreach (var item in items)
                {
                    popupButton.AddItem(item);
                }
            }

            return(popupButton);
        }
Exemplo n.º 2
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var element = new ContextMenuItem(parent);

            element.ApplyElementMeatadata((object)metadata);
            element.SetImage(metadata.Image);
            element.SetHotkey(metadata.Hotkey);

            var action = context.Build(parent, metadata.Action);

            element.SetAction(action);

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

            var subItems = context.BuildMany(parent, metadata.Items);

            if (subItems != null)
            {
                foreach (var subItem in subItems)
                {
                    element.AddItem(subItem);
                }
            }

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

            gridPanel.ApplyElementMeatadata((object)metadata);

            var columns = (metadata.Columns != null) ? Convert.ToInt32(metadata.Columns) : 12;

            gridPanel.SetColumns(columns);

            if (metadata.Rows != null)
            {
                foreach (var rowMetadata in metadata.Rows)
                {
                    var row = gridPanel.AddRow();

                    if (rowMetadata.Cells != null)
                    {
                        foreach (var cellMetadata in rowMetadata.Cells)
                        {
                            var columnSpan = (cellMetadata.ColumnSpan != null)
                                ? Convert.ToInt32(cellMetadata.ColumnSpan)
                                : 1;
                            GridPanelCellElement cell = row.AddCell(columnSpan);

                            var items = context.BuildMany(parent, cellMetadata.Items);

                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    cell.AddItem(item);
                                }
                            }
                        }
                    }
                }
            }

            if (parent != null && metadata.OnLoaded != null)
            {
                gridPanel.OnLoaded += parent.GetScript(metadata.OnLoaded);
            }

            return(gridPanel);
        }
Exemplo n.º 4
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var toolBar = new ToolBarElement(parent);

            toolBar.ApplyElementMeatadata((object)metadata);

            var items = context.BuildMany(parent, metadata.Items);

            if (items != null)
            {
                foreach (var item in items)
                {
                    toolBar.AddItem(item);
                }
            }

            return(toolBar);
        }
Exemplo n.º 5
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var panel = new PanelElement(parent);

            panel.ApplyElementMeatadata((object)metadata);

            panel.SetImage(metadata.Image);
            panel.SetCollapsible(Convert.ToBoolean(metadata.Collapsible));
            panel.SetCollapsed(Convert.ToBoolean(metadata.Collapsed));

            var items = context.BuildMany(parent, metadata.Items);

            if (items != null)
            {
                foreach (var item in items)
                {
                    panel.AddItem(item);
                }
            }

            if (parent != null)
            {
                if (metadata.OnLoaded != null)
                {
                    panel.OnLoaded += parent.GetScript(metadata.OnLoaded);
                }

                if (metadata.OnExpanded != null)
                {
                    panel.OnExpanded += parent.GetScript(metadata.OnExpanded);
                }

                if (metadata.OnCollapsed != null)
                {
                    panel.OnCollapsed += parent.GetScript(metadata.OnCollapsed);
                }
            }

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

            element.ApplyElementMeatadata((object)metadata);

            var items = context.BuildMany(parent, metadata.Items);

            if (items != null)
            {
                foreach (var item in items)
                {
                    element.AddItem(item);
                }
            }

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

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

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

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

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

            stackPanel.ApplyElementMeatadata((object)metadata);
            stackPanel.SetOrientation((metadata.Orientation as string).ToEnum(StackPanelOrientation.Vertical));

            var items = context.BuildMany(parent, metadata.Items);

            if (items != null)
            {
                foreach (var item in items)
                {
                    stackPanel.AddItem(item);
                }
            }

            if (parent != null && metadata.OnLoaded != null)
            {
                stackPanel.OnLoaded += parent.GetScript(metadata.OnLoaded);
            }

            return(stackPanel);
        }
Exemplo n.º 8
0
        public object Build(ObjectBuilderContext context, View parent, dynamic metadata)
        {
            var view = new View(parent);

            view.SetName(metadata.Name);
            view.SetImage(metadata.Image);

            // Прикладные скрипты

            var scripts = context.BuildScripts(view, (object)metadata.Scripts);

            if (scripts != null)
            {
                foreach (dynamic script in scripts)
                {
                    view.AddScript(script.Name, script.Action);
                }
            }

            // Параметры

            var parameters = context.BuildParameters(view, (object)metadata.Parameters);

            if (parameters != null)
            {
                foreach (dynamic parameter in parameters)
                {
                    view.AddParameter(parameter);
                }
            }

            // Источники данных

            var dataSources = context.BuildMany(view, metadata.DataSources);

            if (dataSources != null)
            {
                foreach (var dataSource in dataSources)
                {
                    view.AddDataSource(dataSource);
                }
            }

            // Общие свойства

            context.BuildOneWayBinding(view, view, "Text", (object)metadata.Text);

            // Элементы представления

            var layoutPanel = context.Build(view, metadata.LayoutPanel);

            view.SetLayoutPanel(layoutPanel);

            // Обработчики событий

            if (metadata.OnTextChanged != null)
            {
                view.OnTextChanged += view.GetScript(metadata.OnTextChanged);
            }

            if (metadata.OnOpening != null)
            {
                view.OnOpening += view.GetScript(metadata.OnOpening);
            }

            if (metadata.OnOpened != null)
            {
                view.OnOpened += view.GetScript(metadata.OnOpened);
            }

            if (metadata.OnClosing != null)
            {
                view.OnClosing += view.GetScript(metadata.OnClosing);
            }
            else
            {
                view.OnClosing += (c, a) => OnClosingDefaultHandler(view, a);
            }

            if (metadata.OnClosed != null)
            {
                view.OnClosed += view.GetScript(metadata.OnClosed);
            }

            if (metadata.OnLoaded != null)
            {
                view.OnLoaded += view.GetScript(metadata.OnLoaded);
            }

            // Публикация сообщений в шину при возникновении событий
            view.NotifyWhenEventAsync(i => i.OnLoaded);

            // Подписка на сообщения шины от внешних элементов
            view.SubscribeOnEvent(OnError);

            return(view);
        }