public async Task DefaultLinearItemExtraNull()
        {
            tlog.Debug(tag, $"DefaultLinearItem START");

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

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

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

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

            Assert.IsNotNull(testingTarget.Extra, "should be not null");
            testingTarget.Extra.Size           = new Size(100, 100);
            testingTarget.Extra.AddedToWindow += onAddedToWindow;

            Window.Instance.Add(testingTarget.Extra);

            var result = await tcs.Task;

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

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultLinearItem END (OK)");
        }
Exemple #2
0
        public void Init()
        {
            tlog.Info(tag, "Init() is called!");

            testDataTemplate = 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);
            });
        }
Exemple #3
0
        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)");
        }
Exemple #4
0
        /// Modify this method for adding other examples.
        public ScrollableBaseExample() : base()
        {
            Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n");

            // Navigator bar title is added here.
            AppBar = new AppBar()
            {
                Title = "ScrollableBase Default Style",
            };

            directionMenu = new List <DirectionOption>();
            directionMenu.Add(new DirectionOption("Vertical"));
            directionMenu.Add(new DirectionOption("Horizontal"));

            // Example root content view.
            // you can decorate, add children on this view.
            // ScrollableBase need two different style guide.
            // so here we adding new CollectionView for 2-depth option.
            var directionListView = new CollectionView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                ItemsSource         = directionMenu,
                ItemsLayouter       = new LinearLayouter(),
                ItemTemplate        = new DataTemplate(() =>
                {
                    DefaultLinearItem item = new DefaultLinearItem()
                    {
                        WidthSpecification = LayoutParamPolicies.MatchParent,
                    };
                    item.Label.SetBinding(TextLabel.TextProperty, "Direction");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                    item.EnableFocus();
                    return(item);
                }),
                ScrollingDirection = ScrollableBase.Direction.Vertical,
                SelectionMode      = ItemSelectionMode.SingleAlways,
            };

            directionListView.SelectionChanged += (object colView, SelectionChangedEventArgs ev) =>
            {
                if (ev.CurrentSelection.Count == 0)
                {
                    return;
                }
                if (ev.CurrentSelection[0] is DirectionOption directionItem)
                {
                    Log.Info(this.GetType().Name, $"{directionItem.Direction} will be activated!\n");
                    Page scrollDirPage = new ScrollableBaseDirectionExample(directionItem.Direction);
                    window = NUIApplication.GetDefaultWindow();
                    window.GetDefaultNavigator().Push(scrollDirPage);
                    FocusableExtension.SetFocusOnPage(scrollDirPage);
                }
                directionListView.SelectedItem = null;
            };

            Content = directionListView;
        }
        public void DefaultLinearItemConstructorWithStyle()
        {
            tlog.Debug(tag, $"DefaultLinearItem START");

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

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

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultLinearItem END (OK)");
        }
        public void DefaultLinearSubText()
        {
            tlog.Debug(tag, $"DefaultLinearItem START");

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

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

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

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultLinearItem END (OK)");
        }
        public CollectionViewObservableTestPage()
        {
            InitializeComponent();

            // Empty Source
            source = new ObservableCollection <TestItem>();
            ColView.ItemsSource  = source;
            ColView.ItemTemplate = new DataTemplate(() =>
            {
                var item = new DefaultLinearItem()
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                item.Label.SetBinding(TextLabel.TextProperty, "Name");

                return(item);
            });
        }
        public void DefaultLinearItemExtra()
        {
            tlog.Debug(tag, $"DefaultLinearItem START");

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

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

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

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultLinearItem END (OK)");
        }
Exemple #9
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);
            });
        }
        DefaultLinearItem CreateItem(string text, string subText = null, bool icon = false, bool extra = false)
        {
            var item = new DefaultLinearItem()
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = text,
            };

            if (subText != null)
            {
                item.SubText = subText;
            }
            if (icon)
            {
                item.Icon = new CheckBox();
            }
            if (extra)
            {
                item.Extra = new RadioButton();
            }
            return(item);
        }
Exemple #11
0
        public void DefaultLinearItemConstructorWithItemStyle()
        {
            tlog.Debug(tag, $"DefaultLinearItem START");

            var style = new DefaultLinearItemStyle()
            {
                SizeHeight = 108,
                Padding    = new Extents(64, 64, 18, 17),
                Margin     = new Extents(0, 0, 0, 0),
                Icon       = new ViewStyle()
                {
                    Margin = new Extents(0, 32, 0, 0)
                },
            };
            var testingTarget = new DefaultLinearItem(style);

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

            testingTarget.Dispose();
            tlog.Debug(tag, $"DefaultLinearItem END (OK)");
        }
        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);
        }
Exemple #13
0
        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 ScrollableBase
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical
                }
            };

            foreach (var item in tests)
            {
                var itemView = new DefaultLinearItem();

                itemView.Focusable      = true;
                itemView.BindingContext = item;
                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);
                collectionview.Add(itemView);
            }

            // NUI bug - on target NUI CollectionView was crashed

            /*
             * 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);
             *
             *      var itemView = new DefaultLinearItem();
             *
             *      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);
        }
        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();
                    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 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  = 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);
        }
Exemple #15
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);
        }