/// <summary>
        /// To initialize page info.
        /// </summary>
        void InitializePageInfo()
        {
            var logicalChildren = (Element as IElementController).LogicalChildren;
            int pageIndex       = 0;

            foreach (Page child in logicalChildren)
            {
                var toolbarItem = _tpage.Append(null, null);

                /// To Set a backgroundcolor for every toolbar item
                toolbarItem.SetPartColor("bg", Element.BarBackgroundColor.ToNative());

                _pageInfo.Add(toolbarItem, new PageInfo {
                    Index = pageIndex++, Page = child
                });

                var content = Platform.GetOrCreateRenderer(child).NativeView;
                content.SetAlignment(-1, -1);
                content.SetWeight(1, 1);
                content.MinimumWidth = App.ScreenWidth;
                content.Show();
                _box.PackEnd(content);

                if (Element.CurrentPage == child)
                {
                    toolbarItem.IsSelected = true;
                    ShowCurrentPage(_pageInfo[toolbarItem]);
                }
            }
        }
예제 #2
0
        void FillToolbarItems()
        {
            var logicalChildren = (Element as IElementController).LogicalChildren;

            foreach (Page child in logicalChildren)
            {
                var childRenderer = Platform.GetRenderer(child);
                if (childRenderer != null)
                {
                    childRenderer.NativeView.Hide();
                }

                EToolbarItem toolbarItem = _tpage.Append(child.Title, string.IsNullOrEmpty(child.Icon) ? null : ResourcePath.GetPath(child.Icon));
                toolbarItem.SetPartColor("bg", Element.BarBackgroundColor.ToNative());

                _itemToItemPage.Add(toolbarItem, child);
                if (Element.CurrentPage == child)
                {
                    toolbarItem.IsSelected = true;
                    OnCurrentPageChanged(null, null);
                }

                child.PropertyChanged += OnPageTitleChanged;
            }
        }
예제 #3
0
        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,
                BackgroundColor = Color.Aqua,
            };

            outterBox.Show();

            Toolbar toolbar = new Toolbar(window)
            {
                AlignmentX = -1,
                WeightX    = 1,
            };

            var rnd = new Random();

            toolbar.BackgroundColor = Color.FromRgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
            toolbar.Show();
            outterBox.PackEnd(toolbar);

            toolbar.Selected += (s, e) =>
            {
                e.Item.DeletePartColor("bg");
            };

            Label lb = new Label(window)
            {
                Text = "Please, click an item for delete part color",
            };

            lb.Show();
            outterBox.PackEnd(lb);

            for (int i = 0; i < 5; i++)
            {
                ToolbarItem item    = toolbar.Append(string.Format("{0} home", i), "home");
                Color       bgColor = Color.FromRgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
                item.SetPartColor("bg", bgColor);

                item.Clicked += (s, e) =>
                {
                    lb.Text = (s as ToolbarItem).Text + " clicked";
                };
            }


            conformant.SetContent(outterBox);
        }
예제 #4
0
        void InsertToolbarItem(ShellSection section)
        {
            if (_toolbarItemList.Count < 5)
            {
                EToolbarItem item = null;
                if (_moreToolbarItem == null)
                {
                    item = _toolbar.Append(section.Title, GetIconPath(section.Icon));
                }
                else
                {
                    item = _toolbar.InsertBefore(_moreToolbarItem, section.Title, GetIconPath(section.Icon));
                }

                if (item != null)
                {
                    item.SetPartColor("bg", _backgroudColor);
                    item.SetPartColor("underline", EColor.Transparent);

                    _toolbarItemList.AddLast(item);
                    _itemToSection.Add(item, section);
                    _sectionToitem.Add(section, item);
                }
            }
            else if (_moreToolbarItem == null && _toolbarItemList.Count == 5)
            {
                var last        = _toolbarItemList.Last() as EToolbarItem;
                var lastSection = _itemToSection[last];

                _toolbarItemList.RemoveLast();
                _itemToSection.Remove(last);
                _sectionToitem.Remove(lastSection);
                last.Delete();

                CreateMoreToolbarItem();

                _more.AddItem(lastSection);
                _more.AddItem(section);
            }
            else
            {
                _more.AddItem(section);
            }
        }
예제 #5
0
        EToolbarItem InsertToolbarItem(ShellContent content)
        {
            EToolbarItem item = _toolbar.Append(content.Title, null);

            item.SetPartColor("bg", _backgroundColor);

            _toolbarItemList.AddLast(item);
            _itemToContent.Add(item, content);
            _contentToItem.Add(content, item);

            return(item);
        }
예제 #6
0
        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,
                BackgroundColor = Color.Aqua,
            };

            outterBox.Show();

            Toolbar toolbar = new Toolbar(window)
            {
                AlignmentX      = -1,
                WeightX         = 1,
                ShrinkMode      = ToolbarShrinkMode.Scroll,
                IconLookupOrder = ToolbarIconLookupOrder.ThemeFreedesktop,
            };

            toolbar.Show();
            outterBox.PackEnd(toolbar);

            toolbar.Append("FirstItem", "home");
            toolbar.Append("LastItem", "home");
            ToolbarItem result = toolbar.InsertAfter(toolbar.FirstItem, "Result", "");

            Button bt1 = new Button(window)
            {
                Text         = "Change IconSize",
                MinimumWidth = 400
            };

            bt1.Clicked += (s, e) =>
            {
                if (toolbar.IconSize < 50)
                {
                    toolbar.IconSize = 100;
                }
                else
                {
                    toolbar.IconSize = 32;
                }
                result.Text = string.Format("IconSize{0}", toolbar.IconSize.ToString());
            };
            bt1.Show();
            outterBox.PackEnd(bt1);

            Button bt2 = new Button(window)
            {
                Text         = "Find FirstItem",
                MinimumWidth = 400
            };

            bt2.Clicked += (s, e) =>
            {
                ToolbarItem item1 = toolbar.FirstItem;
                ToolbarItem item2 = toolbar.FindItemByLabel("FirstItem");
                if (item1 == null || item2 == null || item1 != item2)
                {
                    result.Text = "FAIL";
                }
                else
                {
                    result.Text = "PASS";
                }
            };
            bt2.Show();
            outterBox.PackEnd(bt2);

            Button bt3 = new Button(window)
            {
                Text         = "Find LastItem",
                MinimumWidth = 400
            };

            bt3.Clicked += (s, e) =>
            {
                ToolbarItem item1 = toolbar.LastItem;
                ToolbarItem item2 = toolbar.FindItemByLabel("LastItem");
                if (item1 == null || item2 == null || item1 != item2)
                {
                    result.Text = "FAIL";
                }
                else
                {
                    result.Text = "PASS";
                }
            };
            bt3.Show();
            outterBox.PackEnd(bt3);

            Button bt4 = new Button(window)
            {
                Text         = "Get ItemsCount",
                MinimumWidth = 400
            };

            bt4.Clicked += (s, e) =>
            {
                result.Text = toolbar.ItemsCount.ToString();
            };
            bt4.Show();
            outterBox.PackEnd(bt4);

            Button bt5 = new Button(window)
            {
                Text         = "Change IconLookupOrder",
                MinimumWidth = 400
            };

            bt5.Clicked += (s, e) =>
            {
                toolbar.IconLookupOrder = (ToolbarIconLookupOrder)(((int)toolbar.IconLookupOrder + 1) % 4);
                result.Text             = toolbar.IconLookupOrder.ToString();
            };
            bt5.Show();
            outterBox.PackEnd(bt5);

            conformant.SetContent(outterBox);
        }
예제 #7
0
        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();

            Toolbar toolbar = new Toolbar(window)
            {
                AlignmentX = -1,
                WeightX    = 1,
                ShrinkMode = ToolbarShrinkMode.Scroll
            };

            toolbar.Show();
            outterBox.PackEnd(toolbar);


            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);

            var rnd = new Random();

            for (int i = 0; i < 5; 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();
                box.PackEnd(colorBox);
                ToolbarItem item = toolbar.Append(string.Format("{0} Item", i), "home");
                _itemTable[item]     = i;
                _reverseItemTable[i] = item;
                item.Selected       += (s, e) =>
                {
                    scroller.ScrollTo(_itemTable[(ToolbarItem)s], 0, true);
                };
            }
            scroller.Scrolled += (s, e) =>
            {
                if (scroller.HorizontalPageIndex != currentItemIndex)
                {
                    currentItemIndex = scroller.HorizontalPageIndex;
                    _reverseItemTable[currentItemIndex].IsSelected = true;
                }
            };
            conformant.SetContent(outterBox);
            outterBox.PackEnd(scroller);
        }
예제 #8
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box outerBox = new Box(window)
            {
                AlignmentX      = -1,
                AlignmentY      = -1,
                WeightX         = 1,
                WeightY         = 1,
                IsHorizontal    = false,
                BackgroundColor = Color.Aqua,
            };

            outerBox.Show();

            Toolbar toolbar = new Toolbar(window)
            {
                AlignmentX = -1,
                WeightX    = 1,
            };

            toolbar.Show();
            outerBox.PackEnd(toolbar);

            List <ToolbarItem> items = new List <ToolbarItem>();

            items.Add(toolbar.Append(string.Format("{0} home", items.Count), "home"));

            Button bt = new Button(window)
            {
                Text         = "Add ToolbarItem",
                MinimumWidth = 400
            };

            bt.Clicked += (s, e) =>
            {
                items.Add(toolbar.Append(string.Format("{0} home", items.Count), "home"));
            };

            Button removebt = new Button(window)
            {
                Text         = "Remove first ToolbarItem",
                MinimumWidth = 400
            };

            removebt.Clicked += (s, e) =>
            {
                foreach (var cur in items)
                {
                    items.Remove(cur);
                    cur.Delete();
                    return;
                }
            };

            bt.Show();
            removebt.Show();
            outerBox.PackEnd(bt);
            outerBox.PackEnd(removebt);
            conformant.SetContent(outerBox);
        }