Esempio n. 1
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            //Create root view with linear layout.
            root = new View()
            {
                Size            = new Size(1920, 1080),
                BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
                Layout          = new LinearLayout()
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                    CellPadding       = new Size(50, 50),
                    LinearAlignment   = LinearLayout.Alignment.Center,
                }
            };
            window.Add(root);

            ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
            parent1 = new View()
            {
                Size   = new Size(900, 800),
                Layout = new LinearLayout()
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                    CellPadding       = new Size(50, 50),
                    LinearAlignment   = LinearLayout.Alignment.Top,
                }
            };

            root.Add(parent1);
            // Create a description text.
            createText[0]           = new TextLabel();
            createText[0].Text      = "Create DropDown just by properties";
            createText[0].Size      = new Size(800, 100);
            createText[0].MultiLine = true;
            parent1.Add(createText[0]);

            //Create a dropdown by property.
            #region CreateByProperty
            dropDown = new DropDown();
            var style = dropDown.Style;
            style.Button.BackgroundImage  = "";
            style.Button.Icon.ResourceUrl = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png";
            style.Button.Text.PointSize   = 20;
            style.Button.Text.FontFamily  = "SamsungOneUI 500";
            style.Button.Text.TextColor   = new Color(0, 0, 0, 1);
            dropDown.ApplyStyle(style);
            dropDown.Size                            = new Size(900, 108);
            dropDown.HeaderText.Text                 = "TitleArea";
            dropDown.HeaderText.TextColor            = new Color(0, 0, 0, 1);
            dropDown.HeaderText.PointSize            = 28;
            dropDown.HeaderText.FontFamily           = "SamsungOneUI 500C";
            dropDown.HeaderText.PositionX            = 50;
            dropDown.Button.TextLabel.Text           = "DropDown Text";
            dropDown.Button.Icon.Size                = new Size(48, 48);
            dropDown.Button.IconRelativeOrientation  = Button.IconOrientation.Right;
            dropDown.Button.ParentOrigin             = ParentOrigin.CenterLeft;
            dropDown.Button.PivotPoint               = PivotPoint.CenterLeft;
            dropDown.Button.PositionX                = 56;
            dropDown.SpaceBetweenButtonTextAndIcon   = 8;
            dropDown.ListBackgroundImage.ResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png";
            dropDown.ListBackgroundImage.Border      = new Rectangle(51, 51, 51, 51);
            dropDown.ListBackgroundImage.Size        = new Size(360, 500);
            dropDown.ListMargin.Start                = 20;
            dropDown.ListMargin.Top                  = 20;
            dropDown.ListPadding                     = new Extents(4, 4, 4, 4);
            dropDown.BackgroundColor                 = new Color(1, 1, 1, 1);
            parent1.Add(dropDown);
            for (int i = 0; i < 8; i++)
            {
                DropDown.DropDownDataItem item = new DropDown.DropDownDataItem();
                item.Size            = new Size(360, 96);
                item.BackgroundColor = new Selector <Color>
                {
                    Pressed = new Color(0, 0, 0, 0.4f),
                    Other   = new Color(1, 1, 1, 0),
                };
                item.Text                    = "Normal list " + i;
                item.PointSize               = 18;
                item.FontFamily              = "SamsungOne 500";
                item.TextPosition            = new Position(28, 0);
                item.CheckImageSize          = new Size(40, 40);
                item.CheckImageResourceUrl   = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png";
                item.CheckImageGapToBoundary = 16;
                dropDown.AddItem(item);
            }

            dropDown.SelectedItemIndex = 3;

            ////////Attach scrollbar///////////
            scrollBar               = new ScrollBar();
            scrollBar.Direction     = ScrollBar.DirectionType.Vertical;
            scrollBar.Size          = new Size(4, 446);
            scrollBar.TrackColor    = Color.Green;
            scrollBar.ThumbSize     = new Size(4, 30);
            scrollBar.ThumbColor    = Color.Yellow;
            scrollBar.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            dropDown.AttachScrollBar(scrollBar);

            #endregion
            ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
            parent2 = new View()
            {
                Size   = new Size(900, 800),
                Layout = new LinearLayout()
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                    CellPadding       = new Size(50, 50),
                    LinearAlignment   = LinearLayout.Alignment.Top,
                }
            };
            root.Add(parent2);

            // Create a description text.
            createText[1]           = new TextLabel();
            createText[1].Text      = "Create DropDown just by Attributes";
            createText[1].Size      = new Size(800, 100);
            createText[1].MultiLine = true;
            parent2.Add(createText[1]);

            //Create a dropdown by style.
            #region CreateByStyle

            DropDownStyle dropDownStyle = new DropDownStyle
            {
                HeaderText = new TextLabelStyle
                {
                    Text = new Selector <string> {
                        All = "TitleArea"
                    },
                    PointSize = new Selector <float?> {
                        All = 28
                    },
                    TextColor = new Selector <Color> {
                        All = new Color(0, 0, 0, 1)
                    },
                    FontFamily = "SamsungOneUI 500C",
                    PositionX  = 50,
                },

                Button = new ButtonStyle
                {
                    Text = new TextLabelStyle
                    {
                        Text = new Selector <string> {
                            All = "DropDown Text"
                        },
                        PointSize = new Selector <float?> {
                            All = 20
                        },
                        TextColor = new Selector <Color> {
                            All = new Color(0, 0, 0, 1)
                        },
                        FontFamily = "SamsungOneUI 500",
                    },
                    Icon = new ImageViewStyle
                    {
                        Size        = new Size(48, 48),
                        ResourceUrl = new Selector <string> {
                            All = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png"
                        },
                    },
                    IconRelativeOrientation = Button.IconOrientation.Right,
                    PositionX       = 56,
                    BackgroundImage = "",
                },
                ListBackgroundImage = new ImageViewStyle
                {
                    ResourceUrl = new Selector <string> {
                        All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png"
                    },
                    Border = new Selector <Rectangle> {
                        All = new Rectangle(51, 51, 51, 51)
                    },
                    Size = new Size(360, 500),
                },
                SpaceBetweenButtonTextAndIcon = 8,
                ListMargin      = new Extents(20, 0, 20, 0),
                BackgroundColor = new Selector <Color> {
                    All = new Color(1, 1, 1, 1)
                },
                ListPadding = new Extents(4, 4, 4, 4),
            };

            dropDown2      = new DropDown(dropDownStyle);
            dropDown2.Size = new Size(900, 108);
            parent2.Add(dropDown2);

            DropDownItemStyle itemStyle = new DropDownItemStyle
            {
                BackgroundColor = new Selector <Color>
                {
                    Pressed = new Color(0, 0, 0, 0.4f),
                    Other   = new Color(1, 1, 1, 0),
                },
                Text = new TextLabelStyle
                {
                    PointSize = new Selector <float?> {
                        All = 18
                    },
                    FontFamily = "SamsungOne 500",
                    Position   = new Position(28, 0),
                },
                CheckImage = new ImageViewStyle
                {
                    Size        = new Size(40, 40),
                    ResourceUrl = new Selector <string> {
                        All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png"
                    },
                },
                CheckImageGapToBoundary = 16,
            };

            for (int i = 0; i < 8; i++)
            {
                DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(itemStyle);
                item.Size = new Size(360, 96);
                item.Text = "Normal list " + i;
                dropDown2.AddItem(item);
            }
            dropDown2.SelectedItemIndex = 0;

            ////////Attach scrollbar///////////
            scrollBar2               = new ScrollBar();
            scrollBar2.Direction     = ScrollBar.DirectionType.Vertical;
            scrollBar2.Size          = new Size(4, 446);
            scrollBar2.TrackColor    = Color.Green;
            scrollBar2.ThumbSize     = new Size(4, 30);
            scrollBar2.ThumbColor    = Color.Yellow;
            scrollBar2.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            dropDown2.AttachScrollBar(scrollBar2);

            #endregion
            //Add all views into root view.
            root.Add(parent1);
            root.Add(parent2);
        }