Exemplo n.º 1
0
        void TestVisualChilderenCounts()
        {
            var itemsControl = UIBuilder.Create <ItemsControl>();

            itemsControl.ItemTemplate = Template.CreateFromXml("<div>" +
                                                               "     <yt>{LastName}</yt>" +
                                                               "</div>");
            itemsControl.ItemsSource = new List <SimpleClass1>
            {
                new SimpleClass1
                {
                    LastName = "A"
                },
                new SimpleClass1
                {
                    LastName = "B"
                }
            };

            var div = new HtmlElement("div", "ttt");

            div.AddLogicalChild(itemsControl);

            MustEqual(2, itemsControl.VisualChilderenCount);
            MustEqual(2, itemsControl.LogicalChilderenCount);

            MustEqual("A", itemsControl.GetLogicalChildAt(0).GetLogicalChildAt(0).html());
            MustEqual("B", itemsControl.GetLogicalChildAt(1).GetLogicalChildAt(0).html());
        }
Exemplo n.º 2
0
        void TabItem_Content()
        {
            var tabItem = UIBuilder.Create <TabItem>();

            tabItem.Header = "my";
            var fe = tabItem.Content = new FrameworkElement("y");

            MustEqual("my", GetHeaderTextFromDOM(tabItem));
            MustEqualByReference(fe, GetContentFromDOM(tabItem));

            tabItem.Header  = "B";
            tabItem.Content = fe = new FrameworkElement("y2");

            MustEqual("B", GetHeaderTextFromDOM(tabItem));
            MustEqualByReference(fe, GetContentFromDOM(tabItem));

            var tabControl = UIBuilder.Create <ui_top_attached_tabular_menu>();

            tabControl.AddTab(tabItem);


            tabItem.Header  = "C";
            tabItem.Content = fe = new FrameworkElement("y3");

            MustEqual("C", GetHeaderTextFromDOM(tabItem));
            MustEqualByReference(fe, GetContentFromDOM(tabItem));
        }
Exemplo n.º 3
0
        void CreateSlide(FrameworkElement element)
        {
            var item = UIBuilder.Create <SwiperItemControl>();

            item.Content = element;

            _swiper_wrapper.AddLogicalChild(item);
        }
Exemplo n.º 4
0
        void SetErrorMessage(string message)
        {
            ClearOutput();

            var textBlock = UIBuilder.Create <TextBlock>();

            textBlock.Text = message;

            Container.AddLogicalChild(textBlock);
        }
Exemplo n.º 5
0
        void LogicalTreeTest2()
        {
            var model = new SimpleClass1
            {
                LastName = "A",
                Child    = new SimpleClass1
                {
                    LastName = "B",

                    Child = new SimpleClass1
                    {
                        LastName = "C"
                    }
                }
            };

            var userControl = UIBuilder.Create <UserControl2>();

            userControl.DataContext = model;

            UIBuilder.LoadComponent(userControl,
                                    "<div id='0' class='{LastName}'> " +
                                    "    <div id='1' class='{Child.LastName}'> " +
                                    "        <div id='2' class='{Child.Child.LastName}' />" +
                                    "    </div>" +
                                    "</div>");



            var ui = userControl.GetLogicalChildAt(0);

            MustEqual(1, ui.LogicalChilderen.Count);

            MustEqual("A", ui._root.Attr("class"));

            MustEqual("B", ui.GetLogicalChildAt(0)._root.Attr("class"));

            MustEqual(1, ui.GetLogicalChildAt(0).LogicalChilderen.Count);

            MustEqual("C", ui.GetLogicalChildAt(0).GetLogicalChildAt(0)._root.Attr("class"));
        }
Exemplo n.º 6
0
        void Simple()
        {
            var dataGridColumn = UIBuilder.Create <DataGridColumn>();

            dataGridColumn.Label = "Label_A";
            dataGridColumn.Name  = "LastName";


            var dataGridColumn2 = UIBuilder.Create <DataGridColumn>();

            dataGridColumn2.Label = "Label_Year";
            dataGridColumn2.Name  = "Year";

            var itemsSource = new List <SimpleClass1>
            {
                new SimpleClass1
                {
                    Year     = 5,
                    LastName = "A",
                },
                new SimpleClass1
                {
                    Year     = 6,
                    LastName = "B"
                }
            };

            var dataGrid = UIBuilder.Create <DataGrid>();

            dataGrid.Columns.Add(dataGridColumn);
            dataGrid.Columns.Add(dataGridColumn2);



            var div = new HtmlElement("div", "ttt");

            div.AddLogicalChild(dataGrid);

            dataGrid.ItemsSource = itemsSource;
        }
Exemplo n.º 7
0
        void CheckTemplateIsSuccess()
        {
            var control = UIBuilder.Create <UserControl2>();

            MustEqual(1, control.VisualChilderenCount);
            MustEqual(3, control.GetVisualChildAt(0).VisualChilderenCount);
            MustEqual(3, control.GetVisualChildAt(0).LogicalChilderenCount);
            MustEqual("0", control.GetVisualChildAt(0).Attr("id"));
            MustEqual("1", control.GetVisualChildAt(0, 0).Attr("id"));
            MustEqual("2", control.GetVisualChildAt(0, 1).Attr("id"));
            MustEqual("3", control.GetVisualChildAt(0, 2).Attr("id"));

            AssertNotNull(control._contentPresenter);

            UIBuilder.LoadComponent(control, "<div id='x'>" +
                                    "     <div id='y'/>" +
                                    "     <div id='z' >qqq</div>" +
                                    "</div>");

            MustEqual(1, control.VisualChilderenCount);
            MustEqual(3, control.GetVisualChildAt(0).VisualChilderenCount);
            MustEqual(3, control.GetVisualChildAt(0).LogicalChilderenCount);
            MustEqual("0", control.GetVisualChildAt(0).Attr("id"));
            MustEqual("1", control.GetVisualChildAt(0, 0).Attr("id"));
            MustEqual("2", control.GetVisualChildAt(0, 1).Attr("id"));
            MustEqual("3", control.GetVisualChildAt(0, 2).Attr("id"));

            var contentPresenter = (ContentPresenter)control.GetVisualChildAt(0, 1);

            MustEqual("x", contentPresenter.GetVisualChildAt(0).Attr("id"));
            MustEqual("y", contentPresenter.GetVisualChildAt(0, 0).Attr("id"));
            MustEqual("z", contentPresenter.GetVisualChildAt(0, 1).Attr("id"));

            MustEqual(2, contentPresenter.GetVisualChildAt(0).LogicalChilderenCount);
            MustEqual(2, contentPresenter.GetVisualChildAt(0).VisualChilderenCount);
        }
Exemplo n.º 8
0
 static void RenderUIEditor()
 {
     UIBuilder.Create <UIEditor>().RenderInBody();
 }
Exemplo n.º 9
0
        void OnContentChanged()
        {
            if (_contentPresenter == null)
            {
                throw new InvalidOperationException("'ContentPresenter' element not found.");
            }

            _isContentChanging = true;

            var content = Content;

            if (content == null)
            {
                _isContentChanging          = false;
                _contentPresenter.InnerHTML = null;
                return;
            }

            var frameworkElement = content as FrameworkElement;

            if (frameworkElement != null)
            {
                if (_contentPresenter.LogicalChilderenCount == 1)
                {
                    _contentPresenter.RemoveLogicalChild(_contentPresenter.GetLogicalChildAt(0));
                }

                if (_contentPresenter.VisualChilderenCount == 1)
                {
                    _contentPresenter.RemoveVisualChild(_contentPresenter.GetVisualChildAt(0));
                }

                _contentPresenter.AddLogicalChild(frameworkElement);

                if (LogicalChilderenCount == 1)
                {
                    RemoveLogicalChild(GetLogicalChildAt(0));
                }

                AddLogicalChild(frameworkElement);

                _isContentChanging = false;
                return;
            }

            var contentAsString = content.ToString();

            var textBlock = UIBuilder.Create <TextBlock>();

            textBlock.Text = contentAsString;
            _contentPresenter.AddLogicalChild(textBlock);

            if (LogicalChilderenCount == 1)
            {
                RemoveLogicalChild(GetLogicalChildAt(0));
            }

            AddLogicalChild(textBlock);

            _isContentChanging = false;
        }