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("<", "<") .Replace(">", ">") .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; } } }
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); } }
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; } } }
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; }
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; } } }
public ShellNavBar() : base(Forms.NativeParent) { SetLayoutCallback(OnLayout); _menuButton = new EButton(Forms.NativeParent); _menuButton.Clicked += OnMenuClicked; _menuIcon = new EImage(Forms.NativeParent); UpdateMenuIcon(); _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); }
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); } } }
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); }
/// <summary> /// Initialize ThumbnailIndex View /// </summary> private void Initialize() { Console.WriteLine("Initialize"); _isFirstItem = true; _pbox = new PaddingBox(Forms.NativeParent) { Padding = new Thickness { Left = 0, Right = 0, Top = 22, Bottom = 0 }, HeaderSize = new ElmSharp.Size(200, 19), HeaderGap = 38 }; _pbox.Show(); _index = new ElmSharp.Index(_pbox) { Style = "thumbnail", AutoHide = false, IsHorizontal = true, AlignmentX = 0.5, AlignmentY = 0.5, }; _index.Show(); _pbox.Header = _index; //index.Geometry = new Rect(0, 22, 200, 19); _scroller = new ElmSharp.Scroller(_pbox) { HorizontalLoop = false, VerticalLoop = false, HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, HorizontalPageScrollLimit = 1, VerticalPageScrollLimit = 0, }; _scroller.PageScrolled += (s, e) => { Console.WriteLine($" _scroller PageScrolled"); var pageIndex = _scroller.HorizontalPageIndex; _items[pageIndex].Select(true); }; _scroller.Show(); _pbox.Content = _scroller; //_scroller.Geometry = new Rect(0, 79, 360, 281); var box = new ElmSharp.Box(_scroller) { IsHorizontal = true, AlignmentX = 0.5, AlignmentY = 0.5, }; _scroller.SetContent(box); box.Show(); // Create Rectangle for layout center align in Box var padder = new ElmSharp.Rectangle(box); box.PackEnd(padder); _items.Clear(); // Initialize ThumbnailItems foreach (var item in Element.ThumbnailItems) { // create layout var page = new ElmSharp.Layout(box) { WeightX = 1.0, WeightY = 1.0, AlignmentX = -1.0, AlignmentY = 0.5 }; page.SetTheme("layout", "body_thumbnail", "default"); page.Show(); // set icon var img = new ElmSharp.Image(page); var icon = item.Image; Console.WriteLine($"item.Image File:{icon.File}"); img.LoadAsync(ResourcePath.GetPath(icon.File)); page.SetPartContent("elm.icon", img); var indexItem = _index.Append(null); _items.Add(indexItem); // first item case if (_isFirstItem) { Console.WriteLine($"_isFirstItem is true"); page.Resized += (s, e) => { var g = _scroller.Geometry; var pg = page.Geometry; padder.MinimumWidth = (g.Width - pg.Width) / 2; padder.MinimumHeight = g.Height / 2; _scroller.SetPageSize(pg.Width, pg.Height); }; indexItem.Select(true); } _isFirstItem = false; box.PackEnd(page); } box.PackEnd(padder); _index.Update(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); } }