Ejemplo n.º 1
0
        protected override void InsertItem(ListItem item, int index)
        {
            item.Changed += ItemOnChanged;

            Widget widget = null;

            if (!item.IsSeparator)
            {
                widget = new ListButton(ListBoxStyle.ListItemStyle, this)
                {
                    Text                = item.Text,
                    TextColor           = item.Color ?? ListBoxStyle.ListItemStyle.LabelStyle.TextColor,
                    Tag                 = item,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Image               = item.Image,
                    ImageTextSpacing    = item.ImageTextSpacing
                };

                ((Button)widget).Click += ButtonOnClick;
            }
            else
            {
                widget = new HorizontalSeparator(ListBoxStyle.SeparatorStyle);
            }

            InternalChild.RowsProportions.Insert(index, new Proportion(ProportionType.Auto));
            InternalChild.Widgets.Insert(index, widget);

            item.Widget = widget;

            UpdateGridPositions();
        }
Ejemplo n.º 2
0
        protected override void InsertItem(ListItem item, int index)
        {
            item.Changed += ItemOnChanged;

            Widget widget = null;

            if (!item.IsSeparator)
            {
                widget = new ListButton(ListBoxStyle.ListItemStyle, this)
                {
                    Text                = item.Text,
                    TextColor           = item.Color ?? ListBoxStyle.ListItemStyle.LabelStyle.TextColor,
                    Tag                 = item,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Image               = item.Image,
                    ImageTextSpacing    = item.ImageTextSpacing
                };

                ((ImageTextButton)widget).Click += ButtonOnClick;
            }
            else
            {
                var separator = new HorizontalSeparator(null);
                separator.ApplySeparatorStyle(ListBoxStyle.SeparatorStyle);
                widget = separator;
            }

            _box.Widgets.Insert(index, widget);

            item.Widget = widget;
        }
Ejemplo n.º 3
0
        private void InsertItem(ListItem item, int index)
        {
            item.Changed += ItemOnChanged;

            Widget widget = null;

            if (!item.IsSeparator)
            {
                widget = new Button(ListBoxStyle.ListItemStyle)
                {
                    Text                = item.Text,
                    TextColor           = item.Color ?? ListBoxStyle.ListItemStyle.LabelStyle.TextColor,
                    Tag                 = item,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Image               = item.Image,
                    ImageTextSpacing    = item.ImageTextSpacing,
                    Toggleable          = true
                };

                ((Button)widget).Down += ButtonOnDown;
            }
            else
            {
                widget = new HorizontalSeparator(ListBoxStyle.SeparatorStyle);
            }

            RowsProportions.Insert(index, new Proportion(ProportionType.Auto));
            Widgets.Insert(index, widget);

            item.Widget = widget;

            UpdateGridPositions();
        }
Ejemplo n.º 4
0
        private void InsertItem(IMenuItem iMenuItem, int index)
        {
            var    menuItem = iMenuItem as MenuItem;
            Widget widget;

            if (menuItem != null)
            {
                menuItem.Changed += MenuItemOnChanged;
                var menuItemButton = new MenuItemButton(this, MenuItemStyle)
                {
                    Text = menuItem.Text,
                    Tag  = menuItem
                };

                if (menuItem.Color.HasValue)
                {
                    menuItemButton.TextColor = menuItem.Color.Value;
                }

                menuItemButton.MouseEntered += MouseOnEntered;
                menuItemButton.MouseLeft    += MouseOnLeft;
                menuItemButton.SubMenu.Items = menuItem.Items;
                menuItemButton.Toggleable    = menuItem.Items.Count > 0;

                if (menuItemButton.Toggleable)
                {
                    menuItemButton.PressedChanged += ButtonOnPressedChanged;
                }
                else
                {
                    menuItemButton.Click += ButtonOnClick;
                }

                widget = menuItemButton;
            }
            else
            {
                if (Orientation == Orientation.Horizontal)
                {
                    widget = new VerticalSeparator(SeparatorStyle);
                }
                else
                {
                    widget = new HorizontalSeparator(SeparatorStyle);
                }
            }

            iMenuItem.Menu   = this;
            iMenuItem.Widget = widget;

            AddItem(widget, index);
            UpdateGridPositions();
        }
Ejemplo n.º 5
0
        private void InsertItem(IMenuItem item, int index)
        {
            item.Menu = this;

            var menuItem = item as MenuItem;

            if (menuItem != null)
            {
                menuItem.Changed += MenuItemOnChanged;

                if (Orientation == Orientation.Horizontal)
                {
                    menuItem.Label.ApplyLabelStyle(MenuStyle.LabelStyle);
                }
                else
                {
                    menuItem.ImageWidget.ApplyPressableImageStyle(MenuStyle.ImageStyle);
                    menuItem.Label.ApplyLabelStyle(MenuStyle.LabelStyle);
                    menuItem.Shortcut.ApplyLabelStyle(MenuStyle.ShortcutStyle);
                }

                // Add only label, as other widgets(image and shortcut) would be optionally added by SetMenuItem
                InternalChild.Widgets.Add(menuItem.Label);
                SetMenuItem((MenuItem)item);
            }
            else
            {
                SeparatorWidget separator;
                if (Orientation == Orientation.Horizontal)
                {
                    separator = new VerticalSeparator(null);
                }
                else
                {
                    separator = new HorizontalSeparator(null);
                }

                separator.ApplySeparatorStyle(MenuStyle.SeparatorStyle);

                InternalChild.Widgets.Add(separator);

                ((MenuSeparator)item).Separator = separator;
            }
        }