示例#1
0
        public void Activate()
        {
            Window window = Window.Instance;

            flexibleView1                 = new FlexibleView();
            flexibleView1.Name            = "RecyclerView";
            flexibleView1.Position2D      = new Position2D(500, 200);
            flexibleView1.Size2D          = new Size2D(400, 450);
            flexibleView1.Padding         = new Extents(10, 10, 10, 10);
            flexibleView1.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            List <ListItemData> dataList = new List <ListItemData>();

            for (int i = 0; i < 131; ++i)
            {
                dataList.Add(new ListItemData(i));
            }
            adapter = new ListBridge(dataList);
            flexibleView1.SetAdapter(adapter);

            LinearLayoutManager layoutManager1 = new LinearLayoutManager(LinearLayoutManager.VERTICAL);

            //GridLayoutManager layoutManager1 = new GridLayoutManager(3, LinearLayoutManager.VERTICAL);
            flexibleView1.SetLayoutManager(layoutManager1);

            flexibleView1.FocusedItemIndex = 0;

            window.Add(flexibleView1);

            flexibleView1.Focusable = true;

            flexibleView1.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView1.FocusGained += FlexibleView_FocusGained;
            flexibleView1.FocusLost   += FlexibleView_FocusLost;

            scrollBar1            = new ScrollBar();
            scrollBar1.Direction  = ScrollBar.DirectionType.Vertical;
            scrollBar1.Position2D = new Position2D(394, 2);
            scrollBar1.Size2D     = new Size2D(4, 446);
            scrollBar1.Style.Track.BackgroundColor = Color.Green;
            scrollBar1.Style.Thumb.Size            = new Size(4, 30);
            scrollBar1.Style.Thumb.BackgroundColor = Color.Yellow;
            scrollBar1.Style.Track.ResourceUrl     = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView1.AttachScrollBar(scrollBar1);


            flexibleView2                 = new FlexibleView();
            flexibleView2.Name            = "RecyclerView";
            flexibleView2.Position2D      = new Position2D(500, 800);
            flexibleView2.Size2D          = new Size2D(700, 200);
            flexibleView2.Padding         = new Extents(10, 10, 10, 10);
            flexibleView2.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            flexibleView2.SetAdapter(adapter);

            GridLayoutManager layoutManager2 = new GridLayoutManager(3, LinearLayoutManager.HORIZONTAL);

            flexibleView2.SetLayoutManager(layoutManager2);

            flexibleView2.FocusedItemIndex = 0;

            window.Add(flexibleView2);

            flexibleView2.Focusable = true;

            flexibleView2.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView2.FocusGained += FlexibleView_FocusGained;
            flexibleView2.FocusLost   += FlexibleView_FocusLost;

            scrollBar2            = new ScrollBar();
            scrollBar2.Position2D = new Position2D(2, 194);
            scrollBar2.Size2D     = new Size2D(696, 4);
            scrollBar2.Style.Track.BackgroundColor = Color.Green;
            scrollBar2.Style.Thumb.Size            = new Size(30, 4);
            scrollBar2.Style.Thumb.BackgroundColor = Color.Yellow;
            scrollBar2.Style.Track.ResourceUrl     = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView2.AttachScrollBar(scrollBar2);


            FocusManager.Instance.SetCurrentFocusView(flexibleView1);
        }
示例#2
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            root = new View()
            {
                Size            = new Size(1920, 1080),
                BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
            };
            window.Add(root);

            parent = new View()
            {
                Position = new Position(300, 300),
                Size     = new Size(1150, 450)
            };
            parent.Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Horizontal,
                LinearAlignment   = LinearLayout.Alignment.Bottom,
                CellPadding       = new Size(50, 50)
            };
            root.Add(parent);

            // Create vertical flexibleView
            flexibleView1      = new FlexibleView();
            flexibleView1.Name = "RecyclerView1";
            flexibleView1.WidthSpecification  = 400;
            flexibleView1.HeightSpecification = 450;
            flexibleView1.Padding             = new Extents(10, 10, 10, 10);
            flexibleView1.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            List <ListItemData> dataList = new List <ListItemData>();

            for (int i = 0; i < 131; ++i)
            {
                dataList.Add(new ListItemData(i));
            }
            adapter = new ListBridge(dataList);
            flexibleView1.SetAdapter(adapter);

            LinearLayoutManager layoutManager1 = new LinearLayoutManager(LinearLayoutManager.VERTICAL);

            flexibleView1.SetLayoutManager(layoutManager1);

            flexibleView1.FocusedItemIndex = 0;

            parent.Add(flexibleView1);

            flexibleView1.Focusable = true;

            flexibleView1.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView1.FocusGained += FlexibleView_FocusGained;
            flexibleView1.FocusLost   += FlexibleView_FocusLost;

            scrollBar1                     = new ScrollBar();
            scrollBar1.Direction           = ScrollBar.DirectionType.Vertical;
            scrollBar1.Position            = new Position(394, 2);
            scrollBar1.WidthSpecification  = 4;
            scrollBar1.HeightSpecification = 446;
            scrollBar1.TrackColor          = Color.Green;
            scrollBar1.ThumbSize           = new Size(4, 30);
            scrollBar1.ThumbColor          = Color.Yellow;
            scrollBar1.TrackImageURL       = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView1.AttachScrollBar(scrollBar1);

            // Create horizontal flexibleView
            flexibleView2      = new FlexibleView();
            flexibleView2.Name = "RecyclerView2";
            flexibleView2.WidthSpecification  = 700;
            flexibleView2.HeightSpecification = 200;
            flexibleView2.Padding             = new Extents(10, 10, 10, 10);
            flexibleView2.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            flexibleView2.SetAdapter(adapter);

            GridLayoutManager layoutManager2 = new GridLayoutManager(3, LinearLayoutManager.HORIZONTAL);

            flexibleView2.SetLayoutManager(layoutManager2);

            flexibleView2.FocusedItemIndex = 0;

            parent.Add(flexibleView2);

            flexibleView2.Focusable = true;

            flexibleView2.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView2.FocusGained += FlexibleView_FocusGained;
            flexibleView2.FocusLost   += FlexibleView_FocusLost;

            scrollBar2                     = new ScrollBar();
            scrollBar2.Direction           = ScrollBar.DirectionType.Horizontal;
            scrollBar2.Position            = new Position(2, 194);
            scrollBar2.WidthSpecification  = 696;
            scrollBar2.HeightSpecification = 4;
            scrollBar2.TrackColor          = Color.Green;
            scrollBar2.ThumbSize           = new Size(30, 4);
            scrollBar2.ThumbColor          = Color.Yellow;
            scrollBar2.TrackImageURL       = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView2.AttachScrollBar(scrollBar2);

            FocusManager.Instance.SetCurrentFocusView(flexibleView1);
            FocusManager.Instance.PreFocusChange += onPreFocusChange;
        }