Example #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);
        }
Example #2
0
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            //Tizen.Log.Debug("NUI", "LSH :: SelectionEvt called");

            //SingleSelection Only have 1 or nil object in the list.
            foreach (object item in ev.PreviousSelection)
            {
                if (item == null)
                {
                    break;
                }
                Gallery unselItem = (Gallery)item;

                unselItem.Selected = false;
                selectedItem       = null;
                //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
            }
            foreach (object item in ev.CurrentSelection)
            {
                if (item == null)
                {
                    break;
                }
                Gallery selItem = (Gallery)item;
                selItem.Selected = true;
                selectedItem     = selItem.Name;
                //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Linear Sample Count[" + itemCount + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
            }
        }
Example #3
0
        public async Task DefaultTitleItemIconNull()
        {
            tlog.Debug(tag, $"DefaultTitleItem START");

            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(false);
            EventHandler onRelayout         = (s, e) => { tcs.TrySetResult(true); };

            var testingTarget = new DefaultTitleItem("Tizen.NUI.Components.DefaultTitleItem");

            testingTarget.Relayout += onRelayout;

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <DefaultTitleItem>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Label = new TextLabel()
            {
                Text = "test",
            };
            Assert.IsNotNull(testingTarget.Label, "should be not null");

            Window.Instance.Add(testingTarget);
            var result = await tcs.Task;

            Assert.IsTrue(result, "Relayout event should be invoked");

            Assert.IsNotNull(testingTarget.Icon, "should be not null");

            if (testingTarget != null)
            {
                Window.Instance.Remove(testingTarget);
                testingTarget.Dispose();
                testingTarget = null;
            }
            tlog.Debug(tag, $"DefaultTitleItem END (OK)");
        }
        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);
        }
Example #5
0
        public void DefaultTitleItemConstructorWithStyle()
        {
            tlog.Debug(tag, $"DefaultTitleItem START");

            var testingTarget = new DefaultTitleItem("Tizen.NUI.Components.DefaultTitleItem");

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <DefaultTitleItem>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultTitleItem END (OK)");
        }
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            //Tizen.Log.Debug("NUI", "LSH :: SelectionEvt called");

            //SingleSelection Only have 1 or nil object in the list.
            foreach (object item in ev.PreviousSelection)
            {
                if (item == null)
                {
                    break;
                }
                Gallery unselItem = (Gallery)item;

                unselItem.Selected = false;
                selectedItem       = null;
                //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
            }
            foreach (object item in ev.CurrentSelection)
            {
                if (item == null)
                {
                    break;
                }
                Gallery selItem = (Gallery)item;
                //selItem.Selected = true;
                selectedItem = selItem.Name;

                // Check test menu options.
                if (selItem == insertMenu)
                {
                    // Insert new item to index 3.
                    Random rand = new Random();
                    int    idx  = rand.Next(1000);
                    gallerySource.Insert(3, new Gallery(idx, "Inserted Item"));
                }
                else if (selItem == deleteMenu)
                {
                    // Remove item in index 3.
                    gallerySource.RemoveAt(3);
                }
                else if (selItem == moveMenu)
                {
                    // Move last indexed item to index 3.
                    gallerySource.Move(gallerySource.Count - 1, 3);
                }
                //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Linear Sample Count[" + gallerySource.Count + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
            }
        }
Example #7
0
        public void DefaultTitleItemText()
        {
            tlog.Debug(tag, $"DefaultTitleItem START");

            var testingTarget = new DefaultTitleItem("Tizen.NUI.Components.DefaultTitleItem");

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <DefaultTitleItem>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Text = "test";
            Assert.AreEqual(testingTarget.Text, "test", "should be equal.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultTitleItem END (OK)");
        }
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            List <object> oldSel = new List <object>(ev.PreviousSelection);
            List <object> newSel = new List <object>(ev.CurrentSelection);

            foreach (object item in oldSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(newSel.Contains(item)))
                    {
                        galItem.Selected = false;
                        Tizen.Log.Debug("Unselected: {0}", galItem.ViewLabel);
                        selectedCount--;
                    }
                }
                else
                {
                    continue;
                }
            }
            foreach (object item in newSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(oldSel.Contains(item)))
                    {
                        galItem.Selected = true;
                        Tizen.Log.Debug("Selected: {0}", galItem.ViewLabel);
                        selectedCount++;
                    }
                }
                else
                {
                    continue;
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Grid Sample Count[" + groupSource.Count + "] Selected[" + selectedCount + "]";
            }
        }
Example #9
0
        public void DefaultTitleItemIcon()
        {
            tlog.Debug(tag, $"DefaultTitleItem START");

            var testingTarget = new DefaultTitleItem("Tizen.NUI.Components.DefaultTitleItem");

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <DefaultTitleItem>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Icon = new View()
            {
                Size = new Size(100, 100),
            };
            Assert.IsNotNull(testingTarget.Icon, "should be not null");

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultTitleItem END (OK)");
        }
Example #10
0
        public void CollectionViewFooter()
        {
            tlog.Debug(tag, $"CollectionViewFooter START");

            var model         = new TestModel();
            var testingTarget = new CollectionView(model);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <CollectionView>(testingTarget, "should be an instance of testing target class!");

            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text         = "test";
            testingTarget.Footer = myTitle;
            Assert.IsNotNull(testingTarget.Footer, "should be footer.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"CollectionViewFooter END (OK)");
        }
Example #11
0
        public CollectionViewTest9()
        {
            InitializeComponent();
            BindingContext = new GroupTestSourceModel(5, 5);

            ColView.ItemTemplate = new DataTemplate(() =>
            {
                var item = new DefaultLinearItem()
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                item.Label.SetBinding(TextLabel.TextProperty, "Name");

                var icon = new View()
                {
                    WidthSpecification  = 60,
                    HeightSpecification = 60
                };
                icon.SetBinding(BackgroundColorProperty, "BgColor");
                item.Icon = icon;

                var check = new CheckBox()
                {
                    WidthSpecification  = 60,
                    HeightSpecification = 60,
                };
                check.SetBinding(Button.IsSelectedProperty, "IsSelected");
                check.Clicked += OnCheckClicked;
                item.Extra     = check;

                return(item);
            });
            ColView.GroupHeaderTemplate = new DataTemplate(() =>
            {
                var header = new DefaultTitleItem()
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                header.Label.SetBinding(TextLabel.TextProperty, "GroupName");

                return(header);
            });
        }
Example #12
0
        public void DefaultTitleItemConstructorWithItemStyle()
        {
            tlog.Debug(tag, $"DefaultTitleItem START");

            var style = new DefaultTitleItemStyle()
            {
                SizeHeight      = 60,
                Padding         = new Extents(64, 64, 12, 12),
                Margin          = new Extents(0, 0, 0, 0),
                BackgroundColor = new Selector <Color>()
                {
                    Normal = new Color("#EEEEF1"),
                },
                Label = new TextLabelStyle()
                {
                    PixelSize            = 28,
                    Ellipsis             = true,
                    TextColor            = new Color("#001447"),
                    ThemeChangeSensitive = false
                },
                Icon = new ViewStyle()
                {
                    Margin = new Extents(40, 0, 0, 0)
                },
                Seperator = new ViewStyle()
                {
                    Margin          = new Extents(0, 0, 0, 0),
                    BackgroundColor = new Color(0, 0, 0, 0),
                },
            };
            var testingTarget = new DefaultTitleItem(style);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <DefaultTitleItem>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultTitleItem END (OK)");
        }
Example #13
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 SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            List <object> oldSel = new List <object>(ev.PreviousSelection);
            List <object> newSel = new List <object>(ev.CurrentSelection);

            foreach (object item in oldSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(newSel.Contains(item)))
                    {
                        galItem.Selected = false;
                        // Tizen.Log.Debug("Unselected: {0}", galItem.ViewLabel);
                    }
                }
                else if (item is Album selAlbum)
                {
                    if (!(newSel.Contains(selAlbum)))
                    {
                        selAlbum.Selected = false;
                        // Tizen.Log.Debug("Unselected Group: {0}", selAlbum.Title);
                        if (selAlbum == insertDeleteGroup)
                        {
                            albumSource.RemoveAt(2);
                        }
                    }
                }
            }
            foreach (object item in newSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(oldSel.Contains(item)))
                    {
                        galItem.Selected = true;
                        // Tizen.Log.Debug("Selected: {0}", galItem.ViewLabel);

                        if (galItem == insertMenu)
                        {
                            // Insert new item to index 3.
                            Random rand = new Random();
                            int    idx  = rand.Next(1000);
                            albumSource[2].Insert(3, new Gallery(idx, "Inserted Item"));
                        }
                        else if (galItem == deleteMenu)
                        {
                            // Remove item in index 3.
                            albumSource[2].RemoveAt(0);
                        }
                        else if (galItem == moveMenu)
                        {
                            // Move last indexed item to index 3.
                            albumSource[2].Move(albumSource[2].Count - 1, 0);
                        }
                    }
                }
                else if (item is Album selAlbum)
                {
                    if (!(oldSel.Contains(selAlbum)))
                    {
                        selAlbum.Selected = true;
                        // Tizen.Log.Debug("Selected Group: {0}", selAlbum.Title);
                        if (selAlbum == insertDeleteGroup)
                        {
                            Random rand        = new Random();
                            int    groupIdx    = rand.Next(1000);
                            Album  insertAlbum = new Album(groupIdx, "Inserted group", new DateTime(1999, 12, 31));
                            int    idx         = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 1"));
                            idx = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 2"));
                            idx = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 3"));
                            albumSource.Insert(2, insertAlbum);
                        }
                        else if (selAlbum == moveGroup)
                        {
                            albumSource.Move(albumSource.Count - 1, 2);
                        }
                    }
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Grid Sample Count[" + albumSource.Count + "] Selected[" + newSel.Count + "]";
            }
        }
Example #15
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);
        }
Example #16
0
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            //Tizen.Log.Debug("NUI", "LSH :: SelectionEvt called");

            //SingleSelection Only have 1 or nil object in the list.
            foreach (object item in ev.PreviousSelection)
            {
                if (item == null)
                {
                    break;
                }
                if (item is Gallery unselItem)
                {
                    unselItem.Selected = false;
                    selectedItem       = null;
                    //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
                }
                else if (item is Album selAlbum)
                {
                    selectedItem      = selAlbum.Title;
                    selAlbum.Selected = false;
                    if (selAlbum == insertDeleteGroup)
                    {
                        albumSource.RemoveAt(2);
                    }
                }
            }
            foreach (object item in ev.CurrentSelection)
            {
                if (item == null)
                {
                    break;
                }
                if (item is Gallery selItem)
                {
                    selItem.Selected = true;
                    selectedItem     = selItem.Name;
                    //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);

                    // Check test menu options.
                    if (selItem == insertMenu)
                    {
                        // Insert new item to index 3.
                        Random rand = new Random();
                        int    idx  = rand.Next(1000);
                        albumSource[2].Insert(0, new Gallery(idx, "Inserted Item"));
                    }
                    else if (selItem == deleteMenu)
                    {
                        // Remove item in index 3.
                        albumSource[2].RemoveAt(0);
                    }
                    else if (selItem == moveMenu)
                    {
                        // Move last indexed item to index 3.
                        albumSource[2].Move(albumSource[2].Count - 1, 0);
                    }
                }
                else if (item is Album selAlbum)
                {
                    selectedItem      = selAlbum.Title;
                    selAlbum.Selected = true;
                    if (selAlbum == insertDeleteGroup)
                    {
                        Random rand        = new Random();
                        int    groupIdx    = rand.Next(1000);
                        Album  insertAlbum = new Album(groupIdx, "Inserted group", new DateTime(1999, 12, 31));
                        int    idx         = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 1"));
                        idx = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 2"));
                        idx = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 3"));
                        albumSource.Insert(2, insertAlbum);
                    }
                    else if (selAlbum == moveGroup)
                    {
                        albumSource.Move(albumSource.Count - 1, 2);
                    }
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Linear Sample Count[" + albumSource.Count + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
            }
        }
        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);
        }
Example #18
0
        /// Modify this method for adding other examples.
        public DefaultTitleItemExample() : base()
        {
            Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n");

            WidthSpecification  = LayoutParamPolicies.MatchParent;
            HeightSpecification = LayoutParamPolicies.MatchParent;
            // Navigator bar title is added here.
            AppBar = new AppBar()
            {
                Title = "DefaultTitleItemExample Style",
            };

            // Example root content view.
            // you can decorate, add children on this view.
            var rootContent = new ScrollableBase()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                HideScrollbar       = false,
                Layout = new LinearLayout()
                {
                    LinearOrientation   = LinearLayout.Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    CellPadding         = new Size2D(10, 20),
                },
            };

            var item = new DefaultTitleItem()
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = "Title Item",
            };

            rootContent.Add(item);

            var path = Tizen.Applications.Application.Current.DirectoryInfo.Resource;

            var arrowStyle = new ButtonStyle()
            {
                IsSelectable            = true,
                Size                    = new Size(40, 40),
                ItemHorizontalAlignment = HorizontalAlignment.Center,
                ItemVerticalAlignment   = VerticalAlignment.Center,
                Icon                    = new ImageViewStyle()
                {
                    ResourceUrl = new Selector <string>()
                    {
                        Normal   = path + "/icon/icon_arrow_down.svg",
                        Pressed  = path + "/icon/icon_arrow_up.svg",
                        Selected = path + "/icon/icon_arrow_up.svg",
                    }
                }
            };

            var itemWithArrow = new DefaultTitleItem()
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = "Title Item With Arrow",
                EnableControlStatePropagation = true,
                Icon = new Button(arrowStyle)
                {
                    EnableControlStatePropagation = true,
                },
                IsSelectable = true,
            };

            rootContent.Add(itemWithArrow);

            Content = rootContent;
        }
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            List <object> oldSel = new List <object>(ev.PreviousSelection);
            List <object> newSel = new List <object>(ev.CurrentSelection);

            foreach (object item in oldSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(newSel.Contains(item)))
                    {
                        galItem.Selected = false;
                        Tizen.Log.Debug("Unselected: {0}", galItem.ViewLabel);
                    }
                }
                else
                {
                    continue;
                }
            }
            foreach (object item in newSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(oldSel.Contains(item)))
                    {
                        galItem.Selected = true;
                        Tizen.Log.Debug("Selected: {0}", galItem.ViewLabel);

                        // Check test menu options.
                        if (galItem == insertMenu)
                        {
                            // Insert new item to index 3.
                            Random rand = new Random();
                            int    idx  = rand.Next(1000);
                            gallerySource.Insert(3, new Gallery(idx, "Inserted Item"));
                        }
                        else if (galItem == deleteMenu)
                        {
                            // Remove item in index 3.
                            gallerySource.RemoveAt(3);
                        }
                        else if (galItem == moveMenu)
                        {
                            // Move last indexed item to index 3.
                            gallerySource.Move(gallerySource.Count - 1, 3);
                        }
                    }
                }
                else
                {
                    continue;
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Grid Sample Count[" + gallerySource.Count + "] Selected[" + newSel.Count + "]";
            }
        }