예제 #1
0
        public void UpdateDrawerIcon(ImageSource source)
        {
            if (source == null)
            {
                _drawerIcon.LoadFromImageSourceAsync(ImageSource.FromResource(DefaultIcon, GetType().Assembly));
            }
            else
            {
                _drawerIconBox.UnPack(_drawerIcon);
                _drawerIcon.Unrealize();

                _drawerIcon = new EImage(this)
                {
                    AlignmentY = -1,
                    AlignmentX = -1,
                    WeightX    = 1,
                    WeightY    = 1
                };
                _drawerIcon.Show();
                _drawerIconBox.PackEnd(_drawerIcon);

                if (source is FileImageSource fsource)
                {
                    _drawerIcon.Load(fsource.ToAbsPath());
                }
                else
                {
                    _drawerIcon.LoadFromImageSourceAsync(source);
                }
            }
        }
예제 #2
0
        public ShellNavBar(IFlyoutController flyoutController) : base(System.Maui.Maui.NativeParent)
        {
            _flyoutController = flyoutController;

            _menuButton          = new EButton(System.Maui.Maui.NativeParent);
            _menuButton.Clicked += OnMenuClicked;
            _menu = new EImage(System.Maui.Maui.NativeParent);
            UpdateMenuIcon();
            _menu.Show();
            _menuButton.Show();

            _menuButton.SetPartContent("icon", _menu);

            _title = new Native.Label(System.Maui.Maui.NativeParent)
            {
                FontSize = Device.Idiom == TargetIdiom.TV ? 60 : 23,
                VerticalTextAlignment = Native.TextAlignment.Center,
                TextColor             = _backgroudColor,
                FontAttributes        = FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
            LayoutUpdated += OnLayoutUpdated;
        }
예제 #3
0
        public ShellNavBar() : base(Forms.NativeParent)
        {
            SetLayoutCallback(OnLayout);

            _menuButton          = new EButton(Forms.NativeParent);
            _menuButton.Clicked += OnMenuClicked;
            _menuIcon            = new EImage(Forms.NativeParent);
            UpdateMenuIcon();
            _menuIcon.Show();
            _menuButton.Show();

            _menuButton.SetIconPart(_menuIcon);

            _title = new Native.Label(Forms.NativeParent)
            {
                FontSize = this.GetDefaultTitleFontSize(),
                VerticalTextAlignment = Native.TextAlignment.Center,
                TextColor             = _titleColor,
                FontAttributes        = FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
        }
예제 #4
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);
        }
예제 #5
0
        void Initialize()
        {
            AlignmentX = -1;
            AlignmentY = -1;
            WeightX    = 1;
            WeightY    = 1;

            _contentBox = new Box(_mainLayout);
            _contentBox.Show();
            _mainLayout.PackEnd(_contentBox);

            _drawerBox = new Box(_mainLayout);
            _drawerBox.Show();
            _mainLayout.PackEnd(_drawerBox);

            _drawerContentBox = new Box(_drawerBox);
            _drawerBox.PackEnd(_drawerContentBox);

            _drawerIconBox = new Box(_drawerBox);
            _drawerBox.PackEnd(_drawerIconBox);

            _drawerIcon = new EImage(this)
            {
                AlignmentY = -1,
                AlignmentX = -1,
                WeightX    = 1,
                WeightY    = 1
            };
            _drawerIcon.Show();
            using (var stream = GetType().Assembly.GetManifestResourceStream(DefaultIcon))
            {
                _drawerIcon.Load(stream);
            }

            _drawerIconBox.PackEnd(_drawerIcon);

            _contentGesture = new GestureLayer(_contentBox);
            _contentGesture.Attach(_contentBox);
            _contentGesture.SetMomentumCallback(GestureLayer.GestureState.Start, OnContentDragStarted);
            _contentGesture.SetMomentumCallback(GestureLayer.GestureState.End, OnContentDragEnded);
            _contentGesture.SetMomentumCallback(GestureLayer.GestureState.Abort, OnContentDragEnded);

            _drawerGesture = new GestureLayer(_drawerIconBox);
            _drawerGesture.Attach(_drawerIconBox);

            _drawerGesture.SetMomentumCallback(GestureLayer.GestureState.Move, OnDrawerDragged);
            _drawerGesture.SetMomentumCallback(GestureLayer.GestureState.End, OnDrawerDragEnded);
            _drawerGesture.SetMomentumCallback(GestureLayer.GestureState.Abort, OnDrawerDragEnded);

            _mainLayout.SetLayoutCallback(OnLayout);
            _drawerBox.SetLayoutCallback(OnDrawerContentLayout);
            _contentBox.SetLayoutCallback(OnContentLayout);

            RotaryEventManager.Rotated += OnRotateEventReceived;
        }
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text = Element.ActionButton.Text?.Replace("&", "&")
                                     .Replace("<", "&lt;")
                                     .Replace(">", "&gt;")
                                     .Replace(Environment.NewLine, "<br>");

                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (!Element.ActionButton.IconImageSource.IsNullOrEmpty())
                {
                    var imageSource = Element.ActionButton.IconImageSource as FileImageSource;
                    var path        = ResourcePath.GetPath(imageSource);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
                else
                {
                    _actionButton.SetPartContent("elm.swallow.content", null);
                }

                _actionButton.BackgroundColor = Element.ActionButton.BackgroundColor.ToNative();
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
예제 #7
0
 void UpdateActionButtonIcon(ImageSource source)
 {
     if (source is FileImageSource filesource)
     {
         var path        = ResourcePath.GetPath(filesource);
         var buttonImage = new ElmSharp.Image(_actionButton);
         buttonImage.Load(path);
         buttonImage.Show();
         _actionButton.SetPartContent("elm.swallow.content", buttonImage);
     }
     else
     {
         _actionButton.SetPartContent("elm.swallow.content", null);
     }
 }
예제 #8
0
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (!Element.ActionButton.IconImageSource.IsNullOrEmpty())
                {
                    var imageSource = Element.ActionButton.IconImageSource as FileImageSource;
                    var path        = ResourcePath.GetPath(imageSource);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }

                if (Element.ActionButton.BackgroundColor != Xamarin.Forms.Color.Default)
                {
                    _actionButton.BackgroundColor = Element.ActionButton.BackgroundColor.ToNative();
                }
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
예제 #9
0
        public GraphicPopUpRenderer()
        {
            Console.WriteLine("GraphicPopUpRenderer()  GetHashCode:" + this.GetHashCode());
            _popUp = new Popup(Forms.NativeParent)
            {
                Style       = "toast/circle",
                Orientation = PopupOrientation.Center,
                AllowEvents = true,
            };
            var path  = ResourcePath.GetPath("tw_ic_popup_btn_check.png");
            var image = new ElmSharp.Image(_popUp);

            image.LoadAsync(path);
            image.Show();
            _popUp.SetPartContent("toast,icon", image);
            _popUp.BackButtonPressed += BackButtonPressedHandler;
            _popUp.TimedOut          += TimedOutHandler;
            _popUp.Dismissed         += _popUp_Dismissed;
        }
예제 #10
0
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (Element.ActionButton.Icon != null)
                {
                    var path        = ResourcePath.GetPath(Element.ActionButton.Icon);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
        void UpdateActionButton(bool initialize)
        {
            if (initialize && Element.ActionButton == null)
            {
                return;
            }

            if (Element.ActionButton != null)
            {
                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (Element.ActionButton.Icon != null)
                {
                    var path        = ResourcePath.GetPath(Element.ActionButton.Icon);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
            }
        }
예제 #12
0
        public ElmSharp.EvasObject GetContent(object data, string part)
        {
            var minimumHeight = PageHeight > 800 ? 96 : 76;

            if (part == "elm.swallow.content")
            {
                DataSource2  itemSource = (DataSource2)data;
                ElmSharp.Box mainBox    = new ElmSharp.Box(Forms.NativeParent);
                mainBox.BackgroundColor = Xamarin.Forms.Color.LightYellow.ToNative();
                mainBox.MinimumHeight   = minimumHeight;
                mainBox.IsHorizontal    = false;
                mainBox.SetAlignment(-1, -1);
                mainBox.Show();

                ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
                contentBox.MinimumHeight = minimumHeight;
                contentBox.IsHorizontal  = true;
                contentBox.SetAlignment(-1, -1);
                contentBox.Show();

                ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
                left.IsHorizontal = false;
                left.Show();
                left.SetWeight(4.0, 1);
                left.SetAlignment(-1, -1);
                contentBox.PackEnd(left);

                ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleName);
                titleName.Show();
                titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {itemSource.Name}</span>";
                titleName.MinimumWidth = 250;
                titleName.SetAlignment(-1, -1);

                ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleCategory);
                titleCategory.Show();
                titleCategory.Text = $"<span align=center font_size=24 color=#008000>{itemSource.Category}</span>";
                titleCategory.SetAlignment(-1, -1);

                ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
                right.Show();
                right.MinimumWidth  = 96;
                right.MinimumHeight = minimumHeight;
                right.SetWeight(1, 1);
                right.SetAlignment(-1, 0);

                ElmSharp.Image image;

                if (itemSource.ImageFilename != "")
                {
                    image = new ElmSharp.Image(right);
                    image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + itemSource.ImageFilename + ".jpg");
                    image.SetAlignment(0.5, 0.5);
                    image.MinimumHeight = minimumHeight;
                    image.MinimumWidth  = minimumHeight;
                    image.Show();
                    right.PackEnd(image);
                }

                ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
                rec.MinimumHeight = 1;
                rec.MinimumWidth  = 400;
                rec.AlignmentX    = -1;
                rec.Color         = ElmSharp.Color.Gray;
                rec.Show();

                contentBox.PackEnd(right);

                mainBox.PackEnd(contentBox);
                mainBox.PackEnd(rec);

                return(mainBox);
            }
            return(null);
        }
예제 #13
0
        void InitializeComponent()
        {
            _outterBox.SetLayoutCallback(OnLayout);

            _surfaceLayout = new ELayout(this);
            _surfaceLayout.Show();
            _surface = new CircleSurface(_surfaceLayout);

            _naviMenu = new CircleGenList(this, _surface)
            {
                Homogeneous     = true,
                BackgroundColor = ElmSharp.Color.Gray
            };
            _naviMenu.Show();

            _draggedUpCallback     = new SmartEvent(_naviMenu, "drag,start,up");
            _draggedUpCallback.On += (s, e) =>
            {
                if (_footer.TrackObject.IsVisible)
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeBottom));
                }
                else
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Up));
                }
            };

            _draggedDownCallback     = new SmartEvent(_naviMenu, "drag,start,down");
            _draggedDownCallback.On += (s, e) =>
            {
                if (_header.TrackObject.IsVisible)
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeTop));
                }
                else
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Down));
                }
            };

            _outterBox.PackEnd(_naviMenu);
            _outterBox.PackEnd(_surfaceLayout);

            _surfaceLayout.StackAbove(_naviMenu);

            _defaultClass = new GenItemClass("1icon_1text")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return((obj as Item).Text);
                    }
                    return(null);
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon" && obj is Item menuItem && !string.IsNullOrEmpty(menuItem.Icon))
                    {
                        var icon = new ElmSharp.Image(Xamarin.Forms.Forms.NativeParent)
                        {
                            AlignmentX    = -1,
                            AlignmentY    = -1,
                            WeightX       = 1.0,
                            WeightY       = 1.0,
                            MinimumWidth  = _dafaultIconSize,
                            MinimumHeight = _dafaultIconSize,
                        };
                        icon.Show();
                        icon.Load(menuItem.Icon);
                        return(icon);
                    }
                    return(null);
                }
            };

            _naviMenu.ItemSelected += OnItemSelected;
        }

        void OnItemSelected(object sender, GenListItemEventArgs e)
        {
            ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs((e.Item.Data as Item).Source, -1));
        }

        void OnLayout()
        {
            _surfaceLayout.Geometry = Geometry;
            _naviMenu.Geometry      = Geometry;
        }

        bool IsUpdated(List <List <Element> > items)
        {
            if (_itemCache == null)
            {
                return(true);
            }

            if (_itemCache.Count != items.Count)
            {
                return(true);
            }

            for (int i = 0; i < items.Count; i++)
            {
                if (_itemCache[i].Count != items[i].Count)
                {
                    return(true);
                }

                for (int j = 0; j < items[i].Count; j++)
                {
                    if (_itemCache[i][j] != items[i][j])
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
    }