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 CollectionViewTest1() { InitializeComponent(); BindingContext = new TestSourceModel(); var RadioGroup = new RadioButtonGroup(); RadioGroup.Add(ShowBar); RadioGroup.Add(HideBar); ColView.ItemTemplate = new DataTemplate(() => { var item = new RecyclerViewItem() { HeightSpecification = LayoutParamPolicies.MatchParent, WidthSpecification = 200, }; item.SetBinding(View.BackgroundColorProperty, "BgColor"); var label = new TextLabel() { ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, "Index"); item.Add(label); return(item); }); }
public CollectionViewTest3Page() { InitializeComponent(); BindingContext = new TestSourceModel(); var winSize = NUIApplication.GetDefaultWindow().WindowSize; var itemSize = (winSize.Width / 2); ColView.ItemTemplate = new DataTemplate(() => { var item = new RecyclerViewItem() { WidthSpecification = itemSize, HeightSpecification = 200, }; item.SetBinding(View.BackgroundColorProperty, "BgColor"); var label = new TextLabel() { ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, "Index"); item.Add(label); return(item); }); }
public void RecyclerViewItemTemplate() { tlog.Debug(tag, $"RecyclerViewItem START"); var testingTarget = new RecyclerViewItem("Tizen.NUI.Components.RecyclerViewItem"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); testingTarget.Template = 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; } return(item); }); Assert.IsNotNull(testingTarget.Template, "should not be null."); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public void RecyclerViewItemOnKey() { tlog.Debug(tag, $"RecyclerViewItem START"); var testingTarget = new RecyclerViewItem("Tizen.NUI.Components.RecyclerViewItem"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); var key = new Key() { State = Key.StateType.Up, KeyPressedName = "Return" }; Assert.IsFalse(testingTarget.OnKey(key), "should not be processed."); key = new Key() { State = Key.StateType.Down, KeyPressedName = "Return" }; Assert.IsFalse(testingTarget.OnKey(key), "should not be processed."); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public CollectionViewTest7() { InitializeComponent(); BindingContext = new TestSourceModel(40); ColView.ItemTemplate = new DataTemplate(() => { var item = new RecyclerViewItem() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 100, }; item.SetBinding(View.BackgroundColorProperty, "BgColor"); var label = new TextLabel() { ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, "Index"); item.Add(label); return(item); }); // Currently ScrollableBase only support Scrolling and ScrollOutOfBound event. ColView.Scrolling += OnScrolling; }
void HeaderBtnClicked(object sender, ClickedEventArgs e) { headerClicked = !headerClicked; if (headerClicked) { var item = new RecyclerViewItem() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 100, BackgroundColor = Color.Grey, }; var label = new TextLabel() { PixelSize = 20, Text = clickedCount.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Begin, PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, PivotPoint = Position.PivotPointCenterLeft, }; item.Add(label); clickedCount++; ColView.Header = item; } else { ColView.Header = null; } }
public void GridLayouterNotifyItemInserted() { tlog.Debug(tag, $"GridLayouterNotifyItemInserted"); var view = new CollectionView(new List <string>() { "123", "456" }) { Header = new RecyclerViewItem(), Footer = new RecyclerViewItem(), IsGrouped = true, }; Assert.IsNotNull(view, "Should not be null"); view.GroupFooterTemplate = new DataTemplate(typeof(RecyclerViewItem)); view.GroupHeaderTemplate = new DataTemplate(typeof(RecyclerViewItem)); view.ItemTemplate = new DataTemplate(typeof(RecyclerViewItem)); var gridLayouter = new GridLayouter(); Assert.IsNotNull(gridLayouter, "Should not be null"); gridLayouter.Initialize(view); gridLayouter.RequestLayout(100.0f); var source = new CustomGroupItemSource(view) { Position = 1, }; gridLayouter.NotifyItemInserted(source, 0); source.Position = 4; gridLayouter.NotifyItemInserted(source, 0); gridLayouter.NotifyItemInserted(source, 1); var emptySource = new CustomEmptySource(); gridLayouter.NotifyItemInserted(emptySource, 1); var item = new RecyclerViewItem() { Size = new Size(200, 100), }; gridLayouter.NotifyItemSizeChanged(item); item.Dispose(); view.Dispose(); gridLayouter.Dispose(); source.Dispose(); emptySource.Dispose(); tlog.Debug(tag, $"GridLayouterNotifyItemInserted END (OK)"); }
public void RecyclerViewItemConstructorWithStyle() { tlog.Debug(tag, $"RecyclerViewItem START"); var testingTarget = new RecyclerViewItem("Tizen.NUI.Components.RecyclerViewItem"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public void RecyclerViewItemIndex() { tlog.Debug(tag, $"RecyclerViewItem START"); var testingTarget = new RecyclerViewItem("Tizen.NUI.Components.RecyclerViewItem"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); testingTarget.Index = 0; Assert.AreEqual(testingTarget.Index, 0, "should be equal to 0."); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public void RecyclerViewItemIsSelected() { tlog.Debug(tag, $"RecyclerViewItem START"); var testingTarget = new RecyclerViewItem("Tizen.NUI.Components.RecyclerViewItem"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); testingTarget.IsSelected = true; Assert.IsTrue(testingTarget.IsSelected, "should be selected."); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public void RecyclerViewItemConstructorWithItemStyle() { tlog.Debug(tag, $"RecyclerViewItem START"); var style = new RecyclerViewItemStyle() { BackgroundColor = new Selector <Color>() { Normal = new Color(1, 1, 1, 1), Pressed = new Color(0.85f, 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), }, }; var testingTarget = new RecyclerViewItem(style); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <RecyclerViewItem>(testingTarget, "should be an instance of testing target class!"); testingTarget.Dispose(); tlog.Debug(tag, $"RecyclerViewItem END (OK)"); }
public void LinearLayouterNotifyItemSizeChanged() { tlog.Debug(tag, $"LinearLayouterNotifyItemSizeChanged"); var view = new CollectionView(new List <string>() { "123" }) { Header = new RecyclerViewItem(), IsGrouped = false, }; Assert.IsNotNull(view, "Should not be null"); view.GroupHeaderTemplate = new DataTemplate(typeof(RecyclerViewItem)); view.ItemTemplate = new DataTemplate(typeof(RecyclerViewItem)); var emptySource = new CustomEmptySource(); var linearLayouter = new LinearLayouter(); Assert.IsNotNull(linearLayouter, "Should not be null"); linearLayouter.Initialize(view); var item = new RecyclerViewItem() { Size = new Size(200, 100), }; //linearLayouter.NotifyItemSizeChanged(item); item.Dispose(); view.Dispose(); linearLayouter.Dispose(); tlog.Debug(tag, $"LinearLayouterNotifyItemSizeChanged END (OK)"); }
public CollectionViewTest8Page() { InitializeComponent(); BindingContext = new TestSourceModel(40); var customStyle = new RecyclerViewItemStyle() { BackgroundColor = new Selector <Color>() { Normal = Color.White, Pressed = Color.Red, Selected = Color.Blue, Disabled = Color.Grey, }, }; ColView.ItemTemplate = new DataTemplate(() => { var item = new RecyclerViewItem(customStyle) { WidthSpecification = 100, HeightSpecification = LayoutParamPolicies.MatchParent, }; var label = new TextLabel() { ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, "Index"); item.Add(label); return(item); }); }
View CreateListPage(IEnumerable <TestCaseBase> tests) { var layout = new View { HeightResizePolicy = ResizePolicyType.FillToParent, WidthResizePolicy = ResizePolicyType.FillToParent, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, } }; EventHandler <ClickedEventArgs> clicked = (object sender, ClickedEventArgs args) => { var testCase = ((sender as View).BindingContext as TestCaseBase); RunTC(testCase); }; var collectionview = new CollectionView { SelectionMode = ItemSelectionMode.None, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, ItemsLayouter = new LinearLayouter(), ScrollingDirection = ScrollableBase.Direction.Vertical, ItemsSource = tests, ItemTemplate = new DataTemplate(() => { var itemView = new RecyclerViewItem { Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Center }, WidthResizePolicy = ResizePolicyType.FillToParent, SizeHeight = 100, }; var border = new BorderVisual { Opacity = 0.8f, CornerRadius = 0, BorderSize = 1, Color = Color.Black, AntiAliasing = true, }; itemView.AddVisual("border", border); itemView.Clicked += clicked; var label = new TextLabel { VerticalAlignment = VerticalAlignment.Center, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, new Binding("TestName")); itemView.Add(label); return(itemView); //var itemView = new DefaultLinearItem //{ // WidthResizePolicy = ResizePolicyType.FillToParent, //}; //itemView.Clicked += clicked; //itemView.Label.PixelSize = 30; //itemView.Label.SetBinding(TextLabel.TextProperty, new Binding("TestName")); //return itemView; }) }; layout.Add(collectionview); return(layout); }