private void UpdateIndexItem() { _index.Style = IndexStyle.Circle; _items.Clear(); var indexCount = Element.Children.Count; if (indexCount > ItemMaxCount) { indexCount = ItemMaxCount; } for (int i = 0; i < indexCount; i++) { var item = _index.Append(null); item.Style = getItemStyle(indexCount, i); _items.Add(item); } _index.Update(0); var selectIndex = _pageIndex; if (selectIndex >= ItemMaxCount) { selectIndex = ItemMaxCount - 1; } _items[selectIndex].Select(true); }
void UpdateIndexItem() { _index.SetStyledIndex(); _items.Clear(); var indexCount = Element.Children.Count; if (indexCount > ItemMaxCount) { indexCount = ItemMaxCount; } for (int i = 0; i < indexCount; i++) { var item = _index.Append(i.ToString()); if (Device.Idiom == TargetIdiom.Watch) { item.SetIndexItemStyle(indexCount, i, EvenMiddleItem, OddMiddleItem); } _items.Add(item); } _index.Update(0); OnSelect(_pageIndex); }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); Box outterBox = new Box(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, IsHorizontal = false, }; outterBox.Show(); Scroller scroller = new Scroller(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, ScrollBlock = ScrollBlock.Vertical, HorizontalPageScrollLimit = 1, }; scroller.SetPageSize(1.0, 1.0); scroller.Show(); Box box = new Box(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, IsHorizontal = true, }; box.Show(); scroller.SetContent(box); Index index = new Index(window) { IsHorizontal = true, Style = "pagecontrol", AlignmentX = -1, WeightX = 1, MinimumHeight = 100, }; index.Show(); var rnd = new Random(); for (int i = 0; i < 10; i++) { int r = rnd.Next(255); int g = rnd.Next(255); int b = rnd.Next(255); Color color = Color.FromRgb(r, g, b); Rectangle colorBox = new Rectangle(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, Color = color, MinimumWidth = window.ScreenSize.Width, }; colorBox.Show(); Console.WriteLine("Height = {0}", colorBox.Geometry.Height); box.PackEnd(colorBox); var item = index.Append(string.Format("{0}", i)); item.Selected += (s, e) => { scroller.ScrollTo(_indexTable[(IndexItem)s], 0, true); }; _indexTable[item] = i; } conformant.SetContent(outterBox); outterBox.PackEnd(scroller); Box buttonBox = new Box(window) { IsHorizontal = true, AlignmentX = -1, AlignmentY = 0, }; buttonBox.Show(); Button prev = new Button(window) { AlignmentX = -1, WeightX = 1, Text = "Prev" }; Button next = new Button(window) { AlignmentX = -1, WeightX = 1, Text = "next" }; prev.Clicked += (s, e) => { scroller.ScrollTo(scroller.HorizontalPageIndex > 0 ? scroller.HorizontalPageIndex - 1 : 0, scroller.VerticalPageIndex, true); }; next.Clicked += (s, e) => { scroller.ScrollTo(scroller.HorizontalPageIndex + 1, scroller.VerticalPageIndex, true); }; prev.Show(); next.Show(); buttonBox.PackEnd(prev); buttonBox.PackEnd(next); outterBox.PackEnd(buttonBox); outterBox.PackEnd(index); scroller.DragStart += Scroller_DragStart; scroller.DragStop += Scroller_DragStop; }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); Box box = new Box(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, IsHorizontal = true, }; box.Show(); GenList list = new GenList(window) { Homogeneous = false, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; list.Show(); Index index = new Index(window) { IsHorizontal = false, AlignmentY = -1, WeightY = 1, MinimumWidth = 100, AutoHide = false, Style = "fastscroll" }; index.Show(); GenItemClass groupClass = new GenItemClass("group_index") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; GenListItem[] groups = new GenListItem[10]; for (int i = 0; i < 10; i++) { groups[i] = list.Append(groupClass, string.Format("{0}", i), GenListItemType.Group); var indexitem = index.Append(string.Format("{0}", i)); indexitem.Selected += (s, e) => { Console.WriteLine("Index selected : {0}", ((IndexItem)s).Text); list.ScrollTo(_indexTable[(IndexItem)s], ScrollToPosition.In, true); }; _indexTable[indexitem] = groups[i]; } GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int j = 0; j < 10; j++) { for (int i = 0; i < 20; i++) { list.Append(defaultClass, string.Format("{0} Item", i), GenListItemType.Normal, groups[j]); } } list.ItemSelected += List_ItemSelected; index.Update(0); box.PackEnd(list); box.PackEnd(index); box.SetLayoutCallback(() => { list.Geometry = box.Geometry; index.Geometry = box.Geometry; }); conformant.SetContent(box); }
/// <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); }