Пример #1
0
        EvasObject GetContent(object data, string part)
        {
            ShellSection section = data as ShellSection;

            var box = new EBox(Forms.NativeParent);

            box.Show();

            EImage icon = null;

            if (section.Icon != null)
            {
                icon = new EImage(Forms.NativeParent);
                icon.Show();
                box.PackEnd(icon);
                _ = icon.LoadFromImageSourceAsync(section.Icon);
            }

            var title = new Native.Label(Forms.NativeParent)
            {
                Text     = section.Title,
                FontSize = Forms.ConvertToEflFontPoint(14),
                HorizontalTextAlignment = Native.TextAlignment.Start,
                VerticalTextAlignment   = Native.TextAlignment.Center,
            };

            title.Show();
            box.PackEnd(title);
            int iconPadding = Forms.ConvertToScaledPixel(this.GetIconPadding());
            int iconSize    = Forms.ConvertToScaledPixel(this.GetIconSize());
            int cellHeight  = iconPadding * 2 + iconSize;

            box.SetLayoutCallback(() =>
            {
                var bound      = box.Geometry;
                int leftMargin = iconPadding;

                if (icon != null)
                {
                    var iconBound    = bound;
                    iconBound.X     += iconPadding;
                    iconBound.Y     += iconPadding;
                    iconBound.Width  = iconSize;
                    iconBound.Height = iconSize;
                    icon.Geometry    = iconBound;
                    leftMargin       = (2 * iconPadding + iconSize);
                }

                bound.X       += leftMargin;
                bound.Width   -= leftMargin;
                title.Geometry = bound;
            });

            box.MinimumHeight = cellHeight;
            return(box);
        }
Пример #2
0
        public CollectionView(EvasObject parent) : base(parent)
        {
            SetLayoutCallback(OnLayout);
            Scroller = CreateScroller(parent);
            Scroller.Show();
            PackEnd(Scroller);
            Scroller.Scrolled += OnScrolled;

            _innerLayout = new EBox(parent);
            _innerLayout.SetLayoutCallback(OnInnerLayout);
            _innerLayout.Show();
            Scroller.SetContent(_innerLayout);
        }
Пример #3
0
        public TVShellSectionRenderer(ShellSection section)
        {
            ShellSection = section;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;

            _mainLayout = new EBox(Forms.NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(Forms.NativeParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateSectionItems();
            UpdateCurrentItem(ShellSection.CurrentItem);
        }
Пример #4
0
        public CollectionView(EvasObject parent) : base(parent)
        {
            AllowFocus(true);
            SetLayoutCallback(OnLayout);
            Scroller = CreateScroller(parent);
            Scroller.Show();
            PackEnd(Scroller);
            Scroller.Scrolled       += OnScrolled;
            _scrollAnimationStop     = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation);
            _scrollAnimationStop.On += OnScrollStopped;

            _innerLayout = new EBox(parent);
            _innerLayout.SetLayoutCallback(OnInnerLayout);
            _innerLayout.Show();
            Scroller.SetContent(_innerLayout);
        }
Пример #5
0
        public ShellSectionRenderer(ShellSection section)
        {
            ShellSection = section;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;

            _mainLayout = new EBox(Forms.NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(Forms.NativeParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateTabsItem();
            UpdateCurrentItem(ShellSection.CurrentItem);

            ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
            (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage);
        }
Пример #6
0
        private void Initialize()
        {
            _outterLayout = new ElmSharp.Layout(TForms.NativeParent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };
            _outterLayout.Show();
            _outterLayout.SetTheme("layout", "application", "default");

            _index = new Index(_outterLayout)
            {
                IsHorizontal = true,
                AutoHide     = false,
            };
            _index.Show();
            _outterLayout.SetPartContent("elm.swallow.content", _index);

            _scroller = new Scroller(_outterLayout);
            _scroller.PageScrolled += OnPageScrolled;

            // Disables the visibility of the scrollbar in both directions:
            _scroller.HorizontalScrollBarVisiblePolicy = ElmSharp.ScrollBarVisiblePolicy.Invisible;
            _scroller.VerticalScrollBarVisiblePolicy   = ElmSharp.ScrollBarVisiblePolicy.Invisible;
            // Sets the limit of scroll to one page maximum:
            _scroller.HorizontalPageScrollLimit = 1;
            _scroller.SetPageSize(1.0, 1.0);
            _scroller.SetAlignment(-1, -1);
            _scroller.SetWeight(1.0, 1.0);
            _scroller.Show();

            _innerContainer = new Box(_outterLayout);
            _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
            _innerContainer.SetAlignment(-1, -1);
            _innerContainer.SetWeight(1.0, 1.0);
            _innerContainer.Show();
            _scroller.SetContent(_innerContainer);

            _outterLayout.SetPartContent("elm.swallow.bg", _scroller);
        }
Пример #7
0
        public TVShellSectionHandler(ShellSection section, IMauiContext context)
        {
            ShellSection = section;
            MauiContext  = context;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            if (ShellSection.Items is INotifyCollectionChanged collection)
            {
                collection.CollectionChanged += OnShellSectionCollectionChanged;
            }

            _mainLayout = new EBox(PlatformParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(PlatformParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateSectionItems();
            UpdateCurrentItem(ShellSection.CurrentItem);
        }
Пример #8
0
        public ShellSectionHandler(ShellSection section, IMauiContext context)
        {
            ShellSection = section;
            MauiContext  = context;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            if (ShellSection.Items is INotifyCollectionChanged collection)
            {
                collection.CollectionChanged += OnShellSectionCollectionChanged;
            }

            _mainLayout = new EBox(PlatformParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(PlatformParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateTabsItem();
            UpdateCurrentItem(ShellSection.CurrentItem);

            ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
            (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage);
        }
Пример #9
0
        public ShellItemView(ShellItem item, IMauiContext context)
        {
            ShellItem   = item;
            MauiContext = context;

            //Initialize();
            _mainLayout = new EBox(NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);
            _mainLayout.Show();
            _contentHolder = new EBox(NativeParent);
            _contentHolder.Show();
            _mainLayout.PackEnd(_contentHolder);

            ShellItem.PropertyChanged += OnShellItemPropertyChanged;
            if (ShellItem.Items is INotifyCollectionChanged notifyCollectionChanged)
            {
                notifyCollectionChanged.CollectionChanged += OnShellItemsCollectionChanged;
            }
            ShellController.AddAppearanceObserver(this, ShellItem);

            UpdateTabsItems();
            UpdateCurrentItem(ShellItem.CurrentItem);
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the CarouselView class.
        /// </summary>
#pragma warning disable CS8618
        public CollectionView(EvasObject parent) : base(parent)
#pragma warning restore CS8618
        {
            AllowFocus(true);
            SetLayoutCallback(OnLayout);
            Scroller = new EScroller(parent);
            Scroller.Show();
            PackEnd(Scroller);
            Scroller.Scrolled += OnScrolled;

            _scrollAnimationStart     = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StartScrollAnimation);
            _scrollAnimationStart.On += OnScrollStarted;

            _scrollAnimationStop     = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation);
            _scrollAnimationStop.On += OnScrollStopped;

            Scroller.DragStart += OnDragStart;
            Scroller.KeyDown   += OnKeyDown;

            _innerLayout = new EBox(parent);
            _innerLayout.SetLayoutCallback(OnInnerLayout);
            _innerLayout.Show();
            Scroller.SetContent(_innerLayout);
        }
Пример #11
0
        protected override void OnElementChanged(ElementChangedEventArgs <CarouselPage> e)
        {
            if (NativeView == null)
            {
                _outterLayout = new Box(Forms.NativeParent)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _outterLayout.Show();

                _scroller = new Scroller(Forms.NativeParent)
                {
                    HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
                    VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible,
                    HorizontalPageScrollLimit        = 1,
                    HorizontalRelativePageSize       = 1.0,
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _scroller.PageScrolled += OnPageScrolled;
                _scroller.Show();

                _innerContainer = new Box(Forms.NativeParent)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
                _innerContainer.Show();
                _scroller.SetContent(_innerContainer);

                _index = new Index(Forms.NativeParent)
                {
                    IsHorizontal = true,
                    AutoHide     = false,
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                };
                _index.Changed += OnIndexChanged;
                _index.Show();

                _outterLayout.SetLayoutCallback(OnOutterLayoutUpdate);
                _outterLayout.PackEnd(_scroller);
                _outterLayout.PackEnd(_index);

                SetNativeView(_outterLayout);
            }

            if (e.OldElement != null)
            {
                e.OldElement.CurrentPageChanged -= OnCurrentPageChanged;
                e.OldElement.PagesChanged       -= OnPagesChanged;
                _isInitalized = false;
            }

            if (e.NewElement != null)
            {
                Element.CurrentPageChanged += OnCurrentPageChanged;
                Element.PagesChanged       += OnPagesChanged;
            }

            base.OnElementChanged(e);
        }
Пример #12
0
 /// <summary>
 /// Constructor of PaddingBox class
 /// </summary>
 /// <param name="parent">EvasObject</param>
 public PaddingBox(EvasObject parent) : base(parent)
 {
     _box.SetLayoutCallback(OnLayout);
 }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tizen.UIExtensions.ElmSharp.TVNavigationDrawer"/> class.
        /// </summary>
        /// <param name="parent"></param>
        public TVNavigationDrawer(EvasObject parent) : base(parent)
        {
            SetLayoutCallback(OnLayout);

            _drawerBox = new EBox(parent);
            _drawerBox.Show();
            PackEnd(_drawerBox);

            _mainBox = new EBox(parent);
            _mainBox.SetLayoutCallback(OnMainBoxLayout);
            _mainBox.Show();
            PackEnd(_mainBox);

            _focusControlArea = new Button(parent)
            {
                Color           = EColor.Transparent,
                BackgroundColor = EColor.Transparent
            };
            _focusControlArea.SetEffectColor(EColor.Transparent);
            _focusControlArea.Show();
            _mainBox.PackEnd(_focusControlArea);

            _behavior = Common.DrawerBehavior.Drawer;

            _drawerBox.KeyUp += (s, e) =>
            {
                if (e.KeyName == "Return" || e.KeyName == "Right")
                {
                    IsOpen = false;
                }
            };

            _mainBox.KeyUp += (s, e) =>
            {
                if (e.KeyName == "Left")
                {
                    if (_focusControlArea.IsFocused)
                    {
                        IsOpen = true;
                    }
                }
                else
                {
                    // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
                    if (_behavior == DrawerBehavior.Locked)
                    {
                        _drawerBox.AllowTreeFocus = true;
                    }
                }
            };

            _mainBox.KeyDown += (s, e) =>
            {
                if (e.KeyName != "Left")
                {
                    // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
                    if (_behavior == DrawerBehavior.Locked)
                    {
                        _drawerBox.AllowTreeFocus = false;
                    }
                }
            };

            UpdateFocusPolicy();
        }