Esempio n. 1
0
        void UpdateMenuIcon()
        {
            string file = _hasBackButton ? _backIcon : _menuIcon;
            var    path = Assembly.GetExecutingAssembly().GetManifestResourceStream(file);

            _menu.Load(path);
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        void Initialize(EvasObject parent)
        {
            _menu = new GenList(parent)
            {
                BackgroundColor = EColor.Transparent,
                Style           = "solid/default",
            };

            _menu.ItemSelected += (s, e) =>
            {
                MenuItemSelected?.Invoke(this, e);
            };

            _menu.Show();
            PackEnd(_menu);

            _defaultClass = new GenItemClass("double_label")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return(((Item)obj).Title);
                    }
                    else
                    {
                        return(null);
                    }
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon")
                    {
                        var icon = ((Item)obj).Icon;

                        if (icon != null)
                        {
                            var image = new ElmSharp.Image(parent)
                            {
                                MinimumWidth  = Forms.ConvertToScaledPixel(24),
                                MinimumHeight = Forms.ConvertToScaledPixel(24)
                            };
                            var result = image.Load(ResourcePath.GetPath(icon));
                            return(image);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }
Esempio n. 4
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;
        }
Esempio n. 5
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);
     }
 }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
    }