Exemple #1
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;
        }
Exemple #2
0
        private void Initialize()
        {
            window           = GetDefaultWindow();
            window.Title     = "NUI Style Guide";
            window.KeyEvent += OnKeyEvent;

            FocusableExtension.EnableAutoFocusable();

            navigator         = window.GetDefaultNavigator();
            navigator.Popped += (object obj, PoppedEventArgs ev) =>
            {
                Page top = navigator.Peek();
                FocusableExtension.SetFocusOnPage(top);
            };
        }
Exemple #3
0
        private void RunSample(string name)
        {
            IExample example = typeof(Program).Assembly?.CreateInstance(name) as IExample;


            Console.WriteLine($"@@@ typeof(Program).Assembly={typeof(Program).Assembly}, name={name}");

            if (example != null)
            {
                example.Activate();
                if (example is Page examplePage)
                {
                    examplePage.Focusable = true;
                    navigator.Push(examplePage);
                    FocusableExtension.SetFocusOnPage(examplePage);
                }
            }
            else
            {
                Console.WriteLine($"@@@ examle is null!");
            }
        }
Exemple #4
0
        private void SetMainPage()
        {
            var appBar = new AppBar()
            {
                Title = "NUI Style Guide",
                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";
            moreButton.EnableFocus();
            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 ControlMenuViewModel().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;
                    item.EnableFocus();
                    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,
            };
            page.Focusable = true;

            navigator.Push(page);
            FocusableExtension.SetFocusOnPage(page);
        }