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

            var myViewModelSource = new GalleryViewModel(itemCount);

            selMode = ItemSelectionMode.SingleSelection;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Linear Sample Count[" + itemCount + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = myViewModelSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    var rand = new Random();
                    RecyclerViewItem item    = new RecyclerViewItem();
                    item.WidthSpecification  = LayoutParamPolicies.MatchParent;
                    item.HeightSpecification = 100;
                    item.BackgroundColor     = new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), 1);

                    /*
                     * DefaultLinearItem item = new DefaultLinearItem();
                     * //Set Width Specification as MatchParent to fit the Item width with parent View.
                     * item.WidthSpecification = LayoutParamPolicies.MatchParent;
                     * //Decorate Label
                     * item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                     * item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                     * //Decorate Icon
                     * item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                     * item.Icon.WidthSpecification = 80;
                     * item.Icon.HeightSpecification = 80;
                     * //Decorate Extra RadioButton.
                     * //[NOTE] This is sample of RadioButton usage in CollectionView.
                     * // RadioButton change their selection by IsSelectedProperty bindings with
                     * // SelectionChanged event with SingleSelection ItemSelectionMode of CollectionView.
                     * // be aware of there are no RadioButtonGroup.
                     * item.Extra = new RadioButton();
                     * //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                     * //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                     * item.Extra.WidthSpecification = 80;
                     * item.Extra.HeightSpecification = 80;
                     */

                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            var myViewModelSource = gallerySource = new GalleryViewModel(itemCount);

            // Add test menu options.
            gallerySource.Insert(0, moveMenu);
            gallerySource.Insert(0, deleteMenu);
            gallerySource.Insert(0, insertMenu);

            selMode = ItemSelectionMode.Multiple;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Grid Sample Count[" + itemCount + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = myViewModelSource,
                ItemsLayouter = new GridLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    DefaultGridItem item     = new DefaultGridItem();
                    item.WidthSpecification  = 180;
                    item.HeightSpecification = 240;
                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Center;
                    //Decorate Image
                    item.Image.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Image.WidthSpecification  = 170;
                    item.Image.HeightSpecification = 170;
                    //Decorate Badge checkbox.
                    //[NOTE] This is sample of CheckBox usage in CollectionView.
                    // Checkbox change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with Mulitple ItemSelectionMode of CollectionView.
                    item.Badge = new CheckBox();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Badge.SetBinding(CheckBox.IsSelectedProperty, "Selected");
                    item.Badge.WidthSpecification  = 30;
                    item.Badge.HeightSpecification = 30;

                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
Esempio n. 3
0
        private void SetMainPage()
        {
            var appBar = new AppBar()
            {
                Title = "NUI Tizen Gallery",
                AutoNavigationContent = false,
            };

            var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
            var moreButton  = new Button(((AppBarStyle)appBarStyle).BackButton);

            moreButton.Icon.ResourceUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "menu.png";
            appBar.NavigationContent    = moreButton;


            var pageContent = new View()
            {
                Layout = new LinearLayout()
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            field = new SearchField()
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };
            field.SearchButton.Clicked += OnSearchBtnClicked;

            testSource = new GalleryViewModel().CreateData();
            selMode    = ItemSelectionMode.SingleAlways;
            var myTitle = new DefaultTitleItem()
            {
                Text = "TestCase",
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };

            colView = new CollectionView()
            {
                ItemsSource   = testSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    DefaultLinearItem item = new DefaultLinearItem()
                    {
                        WidthSpecification = LayoutParamPolicies.MatchParent,
                    };
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode,
            };
            colView.SelectionChanged += OnSelectionChanged;

            pageContent.Add(field);
            pageContent.Add(colView);

            page = new ContentPage()
            {
                AppBar  = appBar,
                Content = pageContent,
            };
            navigator.Push(page);
        }
Esempio n. 4
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            albumSource = new AlbumViewModel();
            // Add test menu options.
            moveGroup.Add(moveMenu);
            albumSource.Insert(0, moveGroup);
            insertDeleteGroup.Add(insertMenu);
            insertDeleteGroup.Add(deleteMenu);
            albumSource.Insert(0, insertDeleteGroup);

            selMode = ItemSelectionMode.Single;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            //To Bind the Count property changes, need to create custom property for count.
            myTitle.Text = "Linear Sample Group[" + albumSource.Count + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = albumSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    DefaultLinearItem item = new DefaultLinearItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    item.WidthSpecification = LayoutParamPolicies.MatchParent;
                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                    //Decorate Icon
                    item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Icon.WidthSpecification  = 80;
                    item.Icon.HeightSpecification = 80;
                    //Decorate Extra RadioButton.
                    //[NOTE] This is sample of RadioButton usage in CollectionView.
                    // RadioButton change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with Single ItemSelectionMode of CollectionView.
                    // be aware of there are no RadioButtonGroup.
                    item.Extra = new RadioButton();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                    item.Extra.WidthSpecification  = 80;
                    item.Extra.HeightSpecification = 80;

                    return(item);
                }),
                GroupHeaderTemplate = new DataTemplate(() =>
                {
                    DefaultTitleItem group = new DefaultTitleItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    group.WidthSpecification = LayoutParamPolicies.MatchParent;

                    group.Label.SetBinding(TextLabel.TextProperty, "Date");
                    group.Label.HorizontalAlignment = HorizontalAlignment.Begin;

                    return(group);
                }),
                Header              = myTitle,
                IsGrouped           = true,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            var myViewModelSource = gallerySource = new GalleryViewModel(itemCount);

            // Add test menu options.
            gallerySource.Insert(0, moveMenu);
            gallerySource.Insert(0, deleteMenu);
            gallerySource.Insert(0, insertMenu);

            selMode = ItemSelectionMode.Single;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Linear Sample Count[" + itemCount + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = myViewModelSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    var rand = new Random();
                    DefaultLinearItem item = new DefaultLinearItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    item.WidthSpecification = LayoutParamPolicies.MatchParent;

                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;

                    //Decorate SubLabel
                    if ((rand.Next() % 2) == 0)
                    {
                        item.SubLabel.SetBinding(TextLabel.TextProperty, "Name");
                        item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
                    }

                    //Decorate Icon
                    item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Icon.WidthSpecification  = 48;
                    item.Icon.HeightSpecification = 48;

                    //Decorate Extra RadioButton.
                    //[NOTE] This is sample of RadioButton usage in CollectionView.
                    // RadioButton change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with Single ItemSelectionMode of CollectionView.
                    // be aware of there are no RadioButtonGroup.
                    item.Extra = new RadioButton();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                    item.Extra.WidthSpecification  = 48;
                    item.Extra.HeightSpecification = 48;

                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
Esempio n. 6
0
        /// <summary>
        /// Override to create the required scene
        /// </summary>
        protected override void OnCreate()
        {
            base.OnCreate();

            int ItemCount = 400;

            // Get the window instance and change background color
            Window window = Window.Instance;

            window.BackgroundColor = Color.White;

            View Box = new View()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent
            };

            Box.Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Vertical
            };
            window.Add(Box);
            View ButtonBox = new View()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = 0,
                Weight = 0.1F
            };

            ButtonBox.Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Horizontal
            };
            Box.Add(ButtonBox);

            Button NearestButton = new Button()
            {
                WidthSpecification  = 0,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Weight = 1,
                Text   = "Nearest"
            };

            NearestButton.Clicked += NearestClickedEvt;
            ButtonBox.Add(NearestButton);

            Button StartButton = new Button()
            {
                WidthSpecification  = 0,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Weight = 1,
                Text   = "Start"
            };

            StartButton.Clicked += StartClickedEvt;
            ButtonBox.Add(StartButton);
            Button CenterButton = new Button()
            {
                WidthSpecification  = 0,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Weight = 1,
                Text   = "Center"
            };

            CenterButton.Clicked += CenterClickedEvt;
            ButtonBox.Add(CenterButton);
            Button EndButton = new Button()
            {
                WidthSpecification  = 0,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Weight = 1,
                Text   = "End"
            };

            EndButton.Clicked += EndClickedEvt;
            ButtonBox.Add(EndButton);


            var Data = Example.DummyData.CreateDummyMenu(ItemCount);

            targetItem = Data[50];

            var titleStyle = new ViewItemStyle()
            {
                Name            = "titleStyle",
                BackgroundColor = new Selector <Color>()
                {
                    Normal   = new Color(0.972F, 0.952F, 0.749F, 1),
                    Pressed  = new Color(0.1F, 0.85F, 0.85F, 1),
                    Disabled = new Color(0.70F, 0.70F, 0.70F, 1),
                    Selected = new Color(0.701F, 0.898F, 0.937F, 1)
                }
            };

            ItemsLayouter    viewLayouter = new LinearLayouter(); // GridLayouter();
            RadioButtonGroup group        = new RadioButtonGroup();

            selectionMode = ItemSelectionMode.SingleSelection;

            if (viewLayouter is LinearLayouter)
            {
                colView = new CollectionView()
                {
                    SizingStrategy = ItemSizingStrategy.MeasureFirst,
                    ItemsSource    = Data,
                    ItemTemplate   = new DataTemplate(() =>
                    {
                        MyItem item = new MyItem();
                        item.Label.SetBinding(TextLabel.TextProperty, "IndexName");
                        item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                        item.LabelPadding = new Extents(10, 10, 10, 10);

                        item.Icon.SetBinding(ImageView.ResourceUrlProperty, "SubNameUrl");
                        item.Icon.WidthSpecification  = 50;
                        item.Icon.HeightSpecification = 50;
                        item.IconPadding = new Extents(10, 10, 10, 10);

                        var radio  = new RadioButton();
                        item.Extra = radio;
                        radio.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                        item.Extra.WidthSpecification  = 50;
                        item.Extra.HeightSpecification = 50;
                        item.ExtraPadding = new Extents(10, 10, 10, 10);
                        return(item);
                    }),
                    ItemsLayouter = viewLayouter,
                    Header        = new OneLineLinearItem(titleStyle)
                    {
                        WidthSpecification  = LayoutParamPolicies.MatchParent,
                        HeightSpecification = 50,
                        Text = "Header!"
                    },
                    Footer = new OneLineLinearItem()
                    {
                        WidthSpecification  = LayoutParamPolicies.MatchParent,
                        HeightSpecification = 50,
                        Text = "Count:[" + Data.Count + "]"
                    },
                    ScrollingDirection  = ScrollableBase.Direction.Vertical,
                    WidthSpecification  = LayoutParamPolicies.MatchParent,
                    HeightSpecification = 0,
                    Weight          = 0.5F,
                    SelectionMode   = selectionMode,
                    BackgroundColor = Color.Cyan
                };
            }
            else if (viewLayouter is GridLayouter)
            {
                colView = new CollectionView()
                {
                    SizingStrategy = ItemSizingStrategy.MeasureFirst,
                    ItemTemplate   = new DataTemplate(() =>
                    {
                        MyItem2 item = new MyItem2();
                        item.Label.SetBinding(TextLabel.TextProperty, "IndexName");
                        item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                        item.Label.PointSize           = 10;
                        item.LabelPadding = new Extents(5, 5, 5, 5);
                        item.Image.SetBinding(ImageView.ResourceUrlProperty, "SubNameUrl");
                        item.Image.WidthSpecification  = 110;
                        item.Image.HeightSpecification = 110;
                        item.ImagePadding              = new Extents(5, 5, 5, 5);
                        item.Badge                     = new CheckBox();
                        item.Badge.WidthSpecification  = 20;
                        item.Badge.HeightSpecification = 20;
                        item.BadgePadding              = new Extents(2, 2, 2, 2);
                        return(item);
                    }),
                    ItemsSource   = Data,
                    ItemsLayouter = viewLayouter,
                    Header        = new OneLineLinearItem(titleStyle)
                    {
                        WidthSpecification  = LayoutParamPolicies.MatchParent,
                        HeightSpecification = 80,
                        //WidthSpecification = 100,
                        //HeightSpecification = LayoutParamPolicies.MatchParent,
                        Text = "Header!"
                    },
                    Footer = new OneLineLinearItem()
                    {
                        WidthSpecification  = LayoutParamPolicies.MatchParent,
                        HeightSpecification = 80,
                        //WidthSpecification = 200,
                        //HeightSpecification = LayoutParamPolicies.MatchParent,
                        Text = "Count:[" + Data.Count + "]"
                    },
                    ScrollingDirection  = ScrollableBase.Direction.Vertical,
                    WidthSpecification  = LayoutParamPolicies.MatchParent,
                    HeightSpecification = 0,
                    Weight          = 0.4F,
                    SelectionMode   = selectionMode,
                    BackgroundColor = Color.Blue
                };
            }
            colView.SelectionChanged += SelectionEvt;
            Box.Add(colView);

            window.KeyEvent += OnKeyEvent;
        }